17
Automated self-testing and health check of live Sling instances Bertrand Delacrétaz Sling committer, ASF Member and (current) Director Senior Developer, Adobe CQ R&D team, Basel @bdelacretaz - grep.codeconsult.ch adaptTo() Berlin, September 2013 slides revision 2013-09-24

Automated self-testing and health check of live Sling instances

Embed Size (px)

DESCRIPTION

Slides of my talk at adaptTop 2013, "Automated self-testing and health check of live Sling instances". The use cases are similar to my previous presentation at CQCon, but the tool has been almost completely rewritten in the meantime. See http://sling.apache.org/documentation/bundles/sling-health-check-tool.html for more info on the Sling health check tools.

Citation preview

Page 1: Automated self-testing and health check of live Sling instances

Automated self-testing and health checkof live Sling instances

Bertrand DelacrétazSling committer, ASF Member and (current) DirectorSenior Developer, Adobe CQ R&D team, Basel@bdelacretaz - grep.codeconsult.chadaptTo() Berlin, September 2013slides revision 2013-09-24

Page 2: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

How can you trust your current (fragile?) combination of OSGi bundles and configs?

It needs live TESTING.

2

picture: anitapeppers on morgue!le.com

Page 3: Automated self-testing and health check of live Sling instances

what do we mean by

Health Checks?

Page 4: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

HealthCheck APIs

4

public interface HealthCheck { Result execute();}

public class Result { public boolean isOk() ... public Status getStatus() ... public Iterator<ResultLog.Entry> iterator() ...}

HealthCheckOSGi services

Service props:name, MBean, tags

Page 5: Automated self-testing and health check of live Sling instances

Webconsole, JMX

Page 6: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Webconsole plugin/system/console/healthcheck

6

Page 7: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Health Check MBeans

7

Service propsname, MBean, tags

Page 8: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Health Checks as JMX processors

8

MBean

MBean

MBean

HC

HC

HC

using expressions likejmx.attribute('java.lang:type=ClassLoading', 'LoadedClassCount') > 10 && jmx.attribute('java.lang:type=Runtime', 'ManagementSpecVersion') > 1

Page 9: Automated self-testing and health check of live Sling instances

Use cases

Page 10: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Use cases

10

System status Configuration

Self-testPerformance

All bundles up?Initial content ready?Disk space ok?External services ok?Load within bounds? (for jobs)

Requests per second ok?Request duration ok?Free memory ok?Replication queues ok?

Security checklist ok?Default accounts disabled?Demo content removed?

Startup smoke tests?Keep history of results?

Page 11: Automated self-testing and health check of live Sling instances

what do you get

Out of the box?

Page 12: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Out of the box - core

12

JmxAttributeHealthCheck

ScriptableHealthCheck

CompositeHealthCheck

Single JMX attributes

Script(let)s in any languageusing BindingValuesProviders

Run other Health Checksbased on their tags

Page 13: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Out of the box - support bundle

13

SlingRequestStatusHC

DefaultLoginsHealthCheck

Is my resource there?Including its scripts?

admin:admin -> fail?

current HC bundles:org.apache.sling.hc.coreorg.apache.sling.hc.supportorg.apache.sling.hc.webconsoleorg.apache.sling.hc.jmxorg.apache.sling.hc.samples

Page 14: Automated self-testing and health check of live Sling instances

how do you write

Your own Health Checks?

Page 15: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

Custom Health Checks

15

@Component(...policy=ConfigurationPolicy.REQUIRE, metatype=true)@Property(name=HealthCheck.NAME),@Property(name=HealthCheck.TAGS,unbounded=PropertyUnbounded.ARRAY),@Property(name=HealthCheck.MBEAN_NAME)@Service(value=HealthCheck.class)public class MyHealthCheck { public Result execute() { FormattingResultLog f = new FormattingResultLog(); ... if(badThings) f.warn(“Something happened with {}”, foo); return new Result(f); }}

Execute “quickly”, cache...

Page 16: Automated self-testing and health check of live Sling instances

Sling health check tools - adaptTo() 2013 - Bertrand Delacretaz

That’s it - have fun!

16

JmxAttributeHealthCheck

ScriptableHealthCheck

CompositeHealthCheck

SlingRequestStatusHC

DefaultLoginsHealthCheck

@Service(value=HealthCheck.class)public class MyHealthCheck { ....generate a Result quickly}

Docs at sling.apache.org : bundles : health check.Discuss on the Sling dev list.

I’m @bdelacretaz - thanks!

JMX processors

Webconsole

Page 17: Automated self-testing and health check of live Sling instances

APACHE SLING & FRIENDS TECH MEETUPBERLIN, 23-25 SEPTEMBER 2013