Add health check gatekeeper for hub integration tests
Problem
Hub integration tests in extensions/cli/src/hubLoader.test.ts can fail spuriously when the Hub API experiences 5xx errors or outages. This creates noise in CI and makes it harder to identify real test failures.
Suggested Solution
Add a health check helper that runs before integration tests and gracefully skips them if the Hub API is unavailable:
describe("Real Hub Integration Tests", () => {
let hubAvailable = false;
beforeAll(async () => {
hubAvailable = await isHubAvailable();
if (!hubAvailable) {
console.warn("Hub API unavailable - skipping integration tests");
}
});
async function isHubAvailable(): Promise<boolean> {
try {
const response = await fetch(`${env.apiBase}health`, {
signal: AbortSignal.timeout(5000),
});
return response.ok;
} catch {
return false;
}
}
it("should load rule from real hub", async () => {
if (!hubAvailable) return;
// actual test
});
});
Benefits
- Prevents spurious CI failures from external service outages
- Makes tests more reliable without changing functionality
- Standard practice for integration testing
- Graceful degradation (logs warning, doesn't fail build)
Context
Discovered while working on PR #9314 - the hub integration tests failed with 5xx errors during an apparent service outage, blocking an unrelated PR.
Related Issues
- #8355 - Fix the CI pipeline tests once and for all to be able to actually make use of them (broader test stability issue that this addresses for hub integration tests)
This is a good idea but has not been a major issue as of late, and when the hub integration tests are failing because of a service outage, I think it's alright to wait till hub is up and rerun the tests rather than skipping.
This was a specific case I ran into when very first using the CI here. I've gotten a little more familiar with it since December. No big deal to me for you to close this now.