payment tests
Some checks failed
Deploy / build-deploy (push) Failing after 4m58s

This commit is contained in:
Jorijn van der Graaf 2026-08-20 01:36:42 +02:00
commit 45992c4f91
10 changed files with 670 additions and 13 deletions

View file

@ -22,6 +22,7 @@ module;
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <unistd.h>
export module Catcrafts.E2eHarness;
@ -187,6 +188,24 @@ public:
std::format("--orders={}", orders_.string()),
};
for (const std::string& a : options.extraArgs) argv.push_back(a);
// A stale server from an aborted run squatting on this port would
// answer the readiness probe while OUR child dies on a failed bind —
// every request then hits the wrong server and the suite fails on
// assertions that cannot make sense (an order that "vanishes" from
// the ledger). The pdeathsig in Spawn stops the leak from happening
// again; this stops anything already leaked (or anything else on the
// port) from being mistaken for the server under test.
try {
(void)Get("/api/healthz");
std::println(std::cerr,
"e2e: something is already listening on port {} — a stale "
"catcrafts-server from an aborted run? Find it with "
"`pgrep -af catcrafts-server`, kill it, and re-run.",
port_);
std::exit(1);
} catch (...) {
// Nothing answered: the port is ours to take.
}
Spawn(argv);
WaitUntilUp();
}
@ -297,6 +316,12 @@ private:
pid_ = ::fork();
if (pid_ == 0) {
// Die WITH the suite. A suite killed hard — Ctrl+C, a runner
// timeout, a crash that skips destructors — must not leave this
// child alive holding the port: the leaked server answers the
// next run's probes and every assertion after that lies.
::prctl(PR_SET_PDEATHSIG, SIGKILL);
if (::getppid() == 1) ::_exit(127); // parent died before prctl took
const int fd = ::open(log_.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd >= 0) {
::dup2(fd, 1);