![Page 1: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/1.jpg)
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-17
![Page 2: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/2.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/3.jpg)
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
![Page 4: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/4.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/5.jpg)
rules
![Page 6: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/6.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/7.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/8.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/9.jpg)
outof the
box
![Page 10: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/10.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/11.jpg)
extensibili t y
![Page 12: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/12.jpg)
CQ5Health Check Bertrand Delacrétaz, Adobe Basel
Rule evaluates a SystemA#ribute
![Page 13: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/13.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/14.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/15.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/16.jpg)
similarideas
![Page 17: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/17.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/18.jpg)
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: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/19.jpg)
future
![Page 20: Auto-testing production CQ instances with Muppet](https://reader034.vdocument.in/reader034/viewer/2022051817/547bcf35b4795963098b4e69/html5/thumbnails/20.jpg)
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