This is an automated email from the ASF dual-hosted git repository. dklco pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git
commit 9c76f213161016005aeaef179ae91f2306202822 Author: Dan Klco <k...@adobe.com> AuthorDate: Wed Sep 27 00:01:24 2023 -0400 Minor - improving the startup detection --- feature/src/main/features/healthcheck.json | 39 ++++++++++++++++++-------- it/cypress/ready.js | 45 ++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/feature/src/main/features/healthcheck.json b/feature/src/main/features/healthcheck.json index 9e300493..80b35644 100644 --- a/feature/src/main/features/healthcheck.json +++ b/feature/src/main/features/healthcheck.json @@ -26,11 +26,6 @@ "registerHealthyMarkerService":true, "registerUnhealthyMarkerService":true }, - "org.apache.felix.hc.generalchecks.BundlesStartedCheck":{ - "hc.tags":[ - "bundles" - ] - }, "org.apache.felix.hc.generalchecks.CpuCheck":{ "hc.tags":[ "cpu", @@ -47,12 +42,6 @@ "." ] }, - "org.apache.felix.hc.generalchecks.FrameworkStartCheck":{ - "hc.tags":[ - "systemalive" - ], - "targetStartLevel:Integer":30 - }, "org.apache.felix.hc.generalchecks.MemoryCheck":{ "hc.tags":[ "memory", @@ -63,7 +52,8 @@ }, "org.apache.felix.hc.generalchecks.ServicesCheck":{ "hc.tags":[ - "systemalive" + "systemalive", + "systemready" ], "services.list":[ "org.apache.sling.jcr.api.SlingRepository", @@ -73,6 +63,31 @@ "javax.script.ScriptEngineManager" ] }, + "org.apache.felix.hc.generalchecks.DsComponentsCheck~systemready": { + "hc.name":"DS Components Ready Check", + "hc.tags":[ + "systemalive", + "systemready" + ], + "components.list":[ + "org.apache.sling.cms.core.internal.servlets.CMSPageServlet", + "org.apache.sling.cms.core.internal.filters.CMSSecurityFilter" + ] + }, + "org.apache.felix.hc.generalchecks.BundlesStartedCheck~systemready": { + "hc.name":"All bundles are up", + "hc.tags":[ + "systemalive", + "systemready" + ] + }, + "org.apache.felix.hc.generalchecks.FrameworkStartCheck": { + "hc.tags":[ + "systemalive", + "systemready" + ], + "targetStartLevel:Integer":30 + }, "org.apache.felix.hc.generalchecks.ThreadUsageCheck":{ "hc.tags":[ "threads", diff --git a/it/cypress/ready.js b/it/cypress/ready.js index 8ffae2b8..dfc55a85 100644 --- a/it/cypress/ready.js +++ b/it/cypress/ready.js @@ -19,26 +19,53 @@ const fetch = require("node-fetch-commonjs"); const url = process.env.CYPRESS_BASE_URL; +const auth = Buffer.from("admin:admin").toString("base64"); async function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); } + +async function checkSystemReady() { + const res = await fetch(`${url}/system/health?tags=systemalive&format=txt`, { + headers: { Authorization: `Basic ${auth}` }, + }); + return res.ok; +} + +async function checkLoginContent() { + const res = await fetch(`${url}/system/sling/login`); + if (res.ok) { + const body = await res.text(); + if (body.indexOf("Welcome to Apache Sling CMS") !== -1) { + return true; + } + } + return false; +} + +async function checkHomeStatus() { + const res = await fetch(`${url}/`); + return res.status === 403; +} + async function main() { console.log(`Waiting for Sling to start on: ${url}`); - for (let i = 0; i < 120; i++) { + for (let i = 0; i < 240; i++) { try { - const res = await fetch(`${url}/system/sling/form/login`); + const systemReadyOk = await checkSystemReady(); + const homeStatusOk = await checkHomeStatus(); + const loginContentOk = await checkLoginContent(); - if (res.ok) { - const body = await res.text(); - if (body.indexOf("Welcome to Apache Sling CMS") !== -1) { - console.log(`Sling started on: ${url}`); - return; - } + if (systemReadyOk && homeStatusOk && loginContentOk) { + console.log(`Sling started on: ${url}`); + await sleep(2000); + return; } - } catch (e) {} + } catch (e) { + console.warn("Caught error checking status", e); + } await sleep(5000); } console.log("Sling failed to start in the allotted time, failing...");