mirror of
https://github.com/ohwgiles/laminar.git
synced 2026-03-02 03:40:21 +00:00
resolves #29: graceful shutdown
on SIGINT/SIGTERM: 1. stop accepting new connections 2. send SIGTERM to all child tasks 3. wait for processes to end 4. drop all websockets
This commit is contained in:
@@ -27,12 +27,14 @@ protected:
|
||||
void SetUp() override {
|
||||
run.node = &node;
|
||||
}
|
||||
void wait() {
|
||||
int state = -1;
|
||||
waitpid(run.pid, &state, 0);
|
||||
run.reaped(state);
|
||||
}
|
||||
void runAll() {
|
||||
while(!run.step()) {
|
||||
int state = -1;
|
||||
waitpid(run.pid, &state, 0);
|
||||
run.reaped(state);
|
||||
}
|
||||
while(!run.step())
|
||||
wait();
|
||||
}
|
||||
std::string readAllOutput() {
|
||||
std::string res;
|
||||
@@ -96,3 +98,23 @@ TEST_F(RunTest, ParamsToEnv) {
|
||||
StringMap map = parseFromString(readAllOutput());
|
||||
EXPECT_EQ("bar", map["foo"]);
|
||||
}
|
||||
|
||||
TEST_F(RunTest, Abort) {
|
||||
run.addScript("/usr/bin/yes");
|
||||
run.step();
|
||||
usleep(200); // TODO fix
|
||||
run.abort();
|
||||
wait();
|
||||
EXPECT_EQ(RunState::ABORTED, run.result);
|
||||
}
|
||||
|
||||
TEST_F(RunTest, AbortAfterFailed) {
|
||||
run.addScript("/bin/false");
|
||||
runAll();
|
||||
run.addScript("/usr/bin/yes");
|
||||
run.step();
|
||||
usleep(200); // TODO fix
|
||||
run.abort();
|
||||
wait();
|
||||
EXPECT_EQ(RunState::FAILED, run.result);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
MOCK_METHOD4(setParam, bool(std::string job, uint buildNum, std::string param, std::string value));
|
||||
MOCK_METHOD2(getArtefact, bool(std::string path, std::string& result));
|
||||
MOCK_METHOD0(getCustomCss, std::string());
|
||||
MOCK_METHOD0(abortAll, void());
|
||||
MOCK_METHOD0(reapChildren, void());
|
||||
};
|
||||
|
||||
class ServerTest : public ::testing::Test {
|
||||
|
||||
Reference in New Issue
Block a user