bobcat
bobcat copied to clipboard
PoC: Use systemready to make sure that you can run aem tests
There is a new part of felix https://github.com/apache/felix/tree/trunk/systemready that will be part of AEM 6.5 and can be installed now. We could check if small module could be written to use it to check if instance is running and running tests make sens. Could be used in testing after fresh build to make sure that tests has instance ready for them
What should be done:
- does it run on 6.4
- how it api is responding
- new module to call it and translate result for bobcat (ideas needed)
As Felix System Ready is obsolete and superseded by Apache Felix Health Checks there a following configuration required for AEM project in case one want use it.
- Need to install 3 felix packages - not installed by default on AEM 6.4 and 6.5.
- org.apache.felix.healthcheck.api
- org.apache.felix.healthcheck.core
- org.apache.felix.healthcheck.generalchecks
It can be installed automaticly by GAP. Need to add following instruction to build file of your project:
aem {
tasks {
...
satisfy {
packages {
group("org.apache.felix.healthcheck.api") { url("https://www.apache.org/dist/felix/org.apache.felix.healthcheck.api-2.0.0.jar") }
group("org.apache.felix.healthcheck.core") { url("https://www.apache.org/dist/felix/org.apache.felix.healthcheck.core-2.0.2.jar") }
group("org.apache.felix.healthcheck.generalchecks") { url("https://www.apache.org/dist/felix/org.apache.felix.healthcheck.generalchecks-2.0.0.jar") }
}
}
}
}
- Define configuration for Health Check Servlet Example file: org.apache.felix.hc.core.impl.servlet.HealthCheckExecutorServlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
servletPath="/system/health"/>
It will expose endpoint /system/health for healthcheck
- As there are many AEM parts which can be monitored by Apache Felix Health Checks lets assume that for bobcat puposes one need to check whether some required bundles are running. Lets define configuration for Bundle Started Health Check which is available out of the box
File: org.apache.felix.hc.generalchecks.BundlesStartedCheck.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
includesRegex="com.company.aem.example"
hc.tags="myapplication"
useCriticalForInactive="true"/>
It defines tag myapplication and check wheter bundles for pattern com.company.aem.example are up and running. By this configuration we force CRITICAL result once any of bundle is inactive
After this configuration is installed one can call http://localhost:4502/system/health/myapplication.json and if there defined bundle is inactive the answer can look like below:
{
"overallResult": "CRITICAL",
"results": [
{
"name": "Bundles Started",
"status": "CRITICAL",
"timeInMs": 0,
"finishedAt": "2019-04-29T13:41:16.070",
"tags": [
"myapplication"
],
"messages": [
{
"status": "CRITICAL",
"message": "Inactive bundle 581 com.company.aem.example: RESOLVED"
},
{
"status": "OK",
"message": "Found 1 inactive of 1 bundles for pattern com.company.aem.example"
}
]
}
]
}