-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new unauthenticated
/_ready
HTTP endpoint (#2592)
This PR adds a new _ready route, that allow orchestrators that uses probes to detect if the Kuzzle server is ready to accept incoming requests (node started, up and running and not overloaded) This specific implementation allow this route to not be part of the right system of Kuzzle. So that orchestrator can use this route to detect if Kuzzle is alive.
- Loading branch information
1 parent
c33f0dc
commit 52d54fa
Showing
4 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import rp from "request-promise"; | ||
|
||
test("Check _ready result", async () => { | ||
const response = rp.get({ | ||
uri: "http://localhost:17510/_ready", | ||
}); | ||
|
||
await expect(response).resolves.not.toThrow(); // Should return 200 | ||
}); | ||
|
||
test("Check _ready during node startup", async () => { | ||
await rp.get({ | ||
uri: "http://localhost:17510/tests/simulate-outage?type=nodeNotStarted", | ||
}); | ||
|
||
const response = rp.get({ | ||
uri: "http://localhost:17510/_ready", | ||
}); | ||
|
||
await expect(response).rejects; // Should return 503 | ||
|
||
await rp.get({ | ||
uri: "http://localhost:17510/tests/clear-outage", | ||
}); | ||
}); | ||
|
||
test("Check _ready during node overload", async () => { | ||
await rp.get({ | ||
uri: "http://localhost:17510/tests/simulate-outage?type=overload", | ||
}); | ||
|
||
const response = rp.get({ | ||
uri: "http://localhost:17510/_ready", | ||
}); | ||
|
||
await expect(response).rejects; // Should return 503 | ||
|
||
await rp.get({ | ||
uri: "http://localhost:17510/tests/clear-outage", | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters