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


Published on

Slides of my CQCon 2013 "Automated self-testing and health check of CQ instances", see and

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

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

  1. 1. CQ5HealthCheckAutomated self-testingand health checkof live CQ instancesBertrand DelacrétazSenior R&D Developer, Adobe Basel@bdelacretaz, grep.codeconsult.chCQCon, Basel, June 2013slides revision 2013-06-19
  2. 2. CQ5HealthCheck Bertrand Delacrétaz, Adobe Baselpicture: anitapeppers on morguefile.comThemoreconfigurable,themorebreakable....letstestitlive!Agile softwareneedsTESTING
  3. 3. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselApache Sling Health CheckWebconsole pluginRules configured in contentTagged rulesWebconsole and servletsRuleBuilder OSGi servicesApacheSlingmodule,runsinCQ5.5andlaterMuppet
  4. 4. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselJSON output selectors map to tagsno news (log) is good news!Rule uses a Logger to complainrule 1rule 2
  5. 5. rules
  6. 6. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselRule defined in content$ curl -u admin:adminhttp://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 ruleand verify that its output is <= 3The rules engine executes a tree of such definitions, optionally taking tags into account.
  7. 7. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselHTTP rule execution$ curl -u admin:adminhttp://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 treesno news (log) is good news!
  8. 8. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselRule scripts$ curl -u admin:adminhttp://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_PASSEDCurrently executable only from asling/healthcheck/rules container resource.#theskyisthelimit
  9. 9. outof thebox
  10. 10. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselOut of the box rulesas of revision 1490454JMXbeans,service=RequestProcessorRequestsCount < use @TestReference for services) activeOSGiinactivebundlesosgi:inactive.bundles.count < 3Sling defaultlogins failsling:loginfailsadmin#adminpicture:mconnorsonmorguefile.comSlingscripts/apps/hc/demo/somescript.espBYOR!
  11. 11. extensibili t y
  12. 12. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselRule evaluates a SystemAttribute
  13. 13. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselRuleBuilder service builds Rulescheck namespacemap ruleName toSystemAttributebuild Ruletest:constant:5 = 5namespace:ruleName:qualifier expr
  14. 14. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselDefaultEvaluator expressionscan use custom Evaluator as well“Some string”< 5> 5<= 5>= 5between 5 and 12public interface Evaluator {void evaluate(SystemAttribute a,String expression,Logger logger);}
  15. 15. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselExtensibility summaryImplement a SystemAttributegetValue(Logger)Register a RuleBuilder servicecheck namesbuild SystemAttribute + RuleThat’s it.(optionally supply custom Evaluator)
  16. 16. similarideas
  17. 17. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselJoerg Hoh’s cq5-healthcheck = = com.adobe.granite.replication:type=agent,id="publish" = QueueNumEntries.warn.>.100mbean.providerHint = Warn Queue lengthMBean attribute valueranges or customStatusProvider servicesCQ:Page for statusBased on OSGi configs:
  18. 18. CQ5HealthCheck Bertrand Delacrétaz, Adobe BaselDavide Giannella’s sanitycheckAdobe Internal github for now: dgiannel/sanitycheckServlets as sanitycheck services.CQ page componentsfor options, forms.Checks remote CQinstances via HTTP.CQ pages to assemblesanity check pages.
  19. 19. future
  20. 20. CQ5HealthCheckFuture?Implement CQ security checklist rulesExecute rules via JMX?Scheduling of rules execution + reportingScheduling and time-based range checks, samplingperiods (thx Radu Cotescu)Whatareyourusecases?Execute rules tagged “startup” at startupand report or lock instance if WARN.’m @bdelacretaz - thanks for attending!<YOUR IDEA HERE> or on the Apache Sling mailing lists