20
CQ5 Health Check Automated self-testing and health check of live CQ instances Bertrand Delacrétaz Senior R&D Developer, Adobe Basel @bdelacretaz, grep.codeconsult.ch CQCon, Basel, June 2013 slides revision 2013-06-19

Automated self-testing and health check of CQ and Sling instances

Embed Size (px)

DESCRIPTION

Slides of my CQCon 2013 "Automated self-testing and health check of CQ instances", see http://www.cqcon.eu/2013/en/speakers/bertrand-delacretaz.html and http://sling.apache.org/documentation/bundles/sling-health-check-tool.html

Citation preview

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

CQ5Health Check

Automated self-testing and health checkof live CQ instances

Bertrand DelacrétazSenior R&D Developer, Adobe Basel@bdelacretaz, grep.codeconsult.chCQCon, Basel, June 2013slides revision 2013-06-19

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

picture: anitapeppers on morgue!le.com

The more configurable, the

more breakable....let's

test it live!

Agile so!wareneedsTESTING

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Apache Sling Health CheckWebconsole plugin

Rules con!gured in content

Tagged rules

Webconsole and servlets

RuleBuilder OSGi services

Apache Sling

module, runs in

CQ 5.5 and later

Muppet

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

JSON outputselectors map to tags

no news (log) is good news!

Rule uses a Logger to complain

rule 1

rule 2

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

rules

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Rule de!ned in content$ curl -u admin:admin http://localhost:4502/apps/hc/demo/inactive-bundles.tidy.json{ "sling:resourceType": "sling/healthcheck/rules", "namespace": "osgi", "ruleName": "inactive.bundles.count", "expression": "<= 3", "tags": [ "bundles", "osgi", "sling" ], "jcr:primaryType": "nt:unstructured"}

Execute the osgi:inactive.bundles.count rule and verify that its output is <= 3"e rules engine executes a tree of such de!nitions, optionally taking tags into account.

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

HTTP rule execution$ curl -u admin:admin http://localhost:4502/apps/hc/demo/inactive-bundles.healthcheck.json{ "results": [{ "rule": "Rule: InactiveBundlesCount <= 3", "info": [{ "sling.resource.path": "/apps/hc/demo/inactive-bundles" } ], "tags": [ "sling", "bundles", "osgi" ] } ]}

Rule path with .healthcheck selectorWorks with single rules or trees

no news (log) is good news!

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Rule scripts$ curl -u admin:admin http://localhost:4502/apps/hc/demo/script-that-passes.esp

# A rule script must output only TEST_PASSED, # comments like this one and white space. # Anything else is considered failure #(as with the Sling testing tools)TEST_PASSED

Currently executable only from a sling/healthcheck/rules container resource.

#theskyisthelimit

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

outof the

box

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Out of the box rulesas of revision 1490454

JMXbeans a#ributes

jmxbeans:org.apache.sling:type=engine,service=RequestProcessorRequestsCount < 20

JUnittests

junit:org.apache.sling.hc.demo.tests.ResourcesExistTest(can use @TestReference for services)

OSGibundlestate

osgi:bundle.stateorg.apache.sling.startup!lter.disabler= active

OSGiinactivebundles

osgi:inactive.bundles.count < 3

Sling defaultlogins fail

sling:loginfailsadmin#admin

pict

ure:

mco

nnor

s on

mor

gue!

le.c

om

Slingscripts

/apps/hc/demo/somescript.esp

BYOR!

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

extensibili t y

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Rule evaluates a SystemA#ribute

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

RuleBuilder service builds Rules

check namespace

map ruleName to SystemA"ribute

build Rule

test:constant:5 = 5namespace:ruleName:qualifier expr

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

DefaultEvaluator expressionscan use custom Evaluator as well

“Some string”< 5> 5<= 5>= 5between 5 and 12

public interface Evaluator { void evaluate( SystemA"ribute a, String expression, Logger logger);}

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Extensibility summary

Implement a SystemA"ributegetValue(Logger)

Register a RuleBuilder servicecheck namesbuild SystemA"ribute + Rule

#at’s it.(optionally supply custom Evaluator)

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

similarideas

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

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Joerg Hoh’s cq5-healthcheck

h#ps://github.com/joerghoh/cq5-healthcheck

PID = de.joerghoh.cq5.healthcheck.MBeanStatusProvider.b9cb0c91-972b mbean.name = com.adobe.granite.replication:type=agent,id="publish" mbean.property = QueueNumEntries.warn.>.100 mbean.providerHint = Warn Queue length

MBean a#ribute value ranges or custom StatusProvider services

CQ:Page for status

Based on OSGi con!gs:

Page 18: Automated self-testing and health check of CQ and Sling instances

CQ5Health Check Bertrand Delacrétaz, Adobe Basel

Davide Giannella’s sanitycheck

Adobe Internal github for now: dgiannel/sanitycheck

Servlets as sanity check services.

CQ page components for options, forms.

Checks remote CQ instances via HTTP.

CQ pages to assemble sanity check pages.

Page 19: Automated self-testing and health check of CQ and Sling instances

future

Page 20: Automated self-testing and health check of CQ and Sling instances

CQ5Health Check

Future?Implement CQ security checklist rules

Execute rules via JMX?

Scheduling of rules execution + reportingScheduling and time-based range checks, sampling periods (thx Radu Cotescu)

What are your

use cases?

Execute rules tagged “startup” at startup and report or lock instance if WARN.

h#p://sling.apache.org/documentation/bundles/sling-health-check-tool.htmlI’m @bdelacretaz - thanks for a#ending!

<YOUR IDEA HERE> or on the Apache Sling mailing lists