Foundation / checks (client) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (checks) (push) Failing after 3m22s
Foundation / checks (postgres) (push) Failing after 3m11s
Foundation / checks (tsan) (push) Successful in 7m36s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
#include "evo/server/session_window.hpp"
|
|
#include <cassert>
|
|
#include <string>
|
|
|
|
using evo::server::SessionWindow;
|
|
|
|
int main() {
|
|
constexpr std::uint64_t now = 1'000;
|
|
|
|
auto opened = SessionWindow::open("dev-42:1200", now);
|
|
assert(opened.has_value());
|
|
assert(opened->activation_id() == "dev-42");
|
|
assert(opened->deadline_seconds() == 1200);
|
|
assert(opened->accepting(1'199));
|
|
assert(!opened->accepting(1'200));
|
|
assert(opened->closed());
|
|
|
|
// A restart re-reads the same absolute deadline; it does not get a new duration.
|
|
auto restarted = SessionWindow::open("dev-42:1200", 1'100);
|
|
assert(restarted.has_value());
|
|
assert(restarted->deadline_seconds() == 1200);
|
|
assert(!SessionWindow::open("dev-42:1200", 1'200).has_value());
|
|
assert(!SessionWindow::open("dev-42:1200", 1'201).has_value());
|
|
|
|
// Delayed application and clock movement cannot extend an expired window.
|
|
assert(!SessionWindow::open("dev-43:1200", 1'300).has_value());
|
|
assert(restarted->accepting(1'150));
|
|
assert(restarted->accepting(1'050));
|
|
assert(!restarted->accepting(1'200));
|
|
|
|
// Invalid activation/deadline forms and excessive windows fail closed.
|
|
assert(!SessionWindow::open(":1200", now).has_value());
|
|
assert(!SessionWindow::open("dev space:1200", now).has_value());
|
|
assert(!SessionWindow::open("dev-44:not-a-number", now).has_value());
|
|
assert(!SessionWindow::open("dev-45:3001", now).has_value());
|
|
|
|
auto close = SessionWindow::open("dev-46:1200", now);
|
|
assert(close.has_value());
|
|
close->close();
|
|
assert(!close->accepting(1'001));
|
|
return 0;
|
|
}
|