feat(admin): live tuning revisions adopted at recorded ticks (schema 66)
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m47s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m42s
Foundation / image (push) Successful in 5m55s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m47s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m42s
Foundation / image (push) Successful in 5m55s
ADR-0182 section 13. The admin portal's Tuning page edits the world's rules-13 tuning (the Git revamp file format); the admin API checks it, stores an append-only revision and queues an adopt_tuning admin command (kind 7: revision and rules digest) for every region of the world. - Lifecycle: adopt_tuning replaces the region's rules after births when a resolver names the rules for that revision and digest; the safety revision cannot change live. At most one adoption per batch. - Host: fetches the revision text, rebuilds and digests the rules before appending the command; publication and recovery name the rules from the successor state, checked against the recorded digest. - Schema 66: tuning_revisions, admin_set_tuning_v1, load_tuning_revision_v1 (runtime), admin_tuning_revisions_v1, admin_tuning_text_v1. - OpsServer: optional bounded request bodies (Content-Length, 413). - Region view: rules_sha256, so the portal shows each region's revision. - Portal: Tuning page; baseline from the mounted cellular-revamp.tuning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1587,6 +1587,56 @@ void run_starting_wildlife_publication_tests() {
|
||||
CHECK(!publish_cellular_batch(*runtime, **objects, *lease, head, again, **again_state,
|
||||
identity(11), build, 5s));
|
||||
runtime = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||
|
||||
// ADR-0182 (schema 66): a tuning revision's adoption publishes, binds and recovers; the
|
||||
// publisher and recovery name its rules from the successor state, checked by digest.
|
||||
auto tuned_rules = recovered->state->revamp_rules();
|
||||
auto& upkeep = tuned_rules.body.essential_upkeep_per_thousand;
|
||||
upkeep = upkeep == 100 ? 101 : 100;
|
||||
CHECK(evo::server::cellular_revamp_valid(tuned_rules) &&
|
||||
tuned_rules != recovered->state->revamp_rules());
|
||||
const auto tuned_digest = checked_value(
|
||||
evo::persistence::sha256(evo::server::encode_cellular_revamp_rules(tuned_rules)));
|
||||
std::string tuned_hex;
|
||||
for (const auto byte : tuned_digest) {
|
||||
constexpr std::string_view digits = "0123456789abcdef";
|
||||
tuned_hex.push_back(digits[byte >> 4U]);
|
||||
tuned_hex.push_back(digits[byte & 0x0FU]);
|
||||
}
|
||||
const auto revision_rows = owner->query(
|
||||
"SELECT evolution.admin_set_tuning_v1($1, 'not parsed by publication', "
|
||||
"decode($2, 'hex'), ARRAY[$3::bigint], 'ops', 'test')",
|
||||
std::array{std::to_string(key.world), tuned_hex, std::to_string(key.region)}, 5s);
|
||||
CHECK(revision_rows && revision_rows->size() == 1);
|
||||
const auto tuning_revision = std::stoull(revision_rows.value().at(0).at(0).value_or(""));
|
||||
const auto queued_adoption = runtime->query(
|
||||
"SELECT command_id FROM evolution.load_pending_admin_commands_v1($1, $2) WHERE kind = 7",
|
||||
std::array{std::to_string(key.world), std::to_string(key.region)}, 5s);
|
||||
CHECK(queued_adoption && queued_adoption->size() == 1);
|
||||
const auto adoption = evo::server::cellular_adopt_tuning_command(
|
||||
std::stoull(queued_adoption.value().at(0).at(0).value_or("")), tuning_revision,
|
||||
tuned_digest);
|
||||
auto adopt_batch = admin_batch({adoption});
|
||||
adopt_batch.header = {key.world, key.region, 1, head.head.commit, head.head.digest, 3, 4};
|
||||
adopt_batch.ticks.front().lives = checked_value(wildlife_intents(*recovered->state, 4));
|
||||
auto adopted = evo::fixture::restore(*recovered->state);
|
||||
CHECK(adopted->advance_tick(adopt_batch.ticks.front().lives));
|
||||
std::vector<evo::server::CellularAdminResult> adopt_results;
|
||||
auto adopted_state =
|
||||
adopted->admin_candidate(std::vector{adoption}, &adopt_results,
|
||||
[&](std::uint64_t, const std::array<std::uint8_t, 32>&) {
|
||||
return std::optional{tuned_rules};
|
||||
});
|
||||
CHECK(adopted_state && adopt_results.size() == 1 && adopt_results.front().applied);
|
||||
const auto adopted_bytes = (*adopted_state)->snapshot();
|
||||
auto adopted_publish = publish_cellular_batch(*runtime, **objects, *lease, head, adopt_batch,
|
||||
**adopted_state, identity(12), build, 5s);
|
||||
CHECK(adopted_publish);
|
||||
head = adopted_publish->committed;
|
||||
CHECK(pending() == 0);
|
||||
recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s);
|
||||
CHECK(recovered && recovered->state->snapshot() == adopted_bytes &&
|
||||
recovered->state->revamp_rules() == tuned_rules);
|
||||
CHECK(release_region_lease(*runtime, key, *lease, 5s));
|
||||
std::puts("starting wildlife publication and replacement-owner replay passed");
|
||||
}
|
||||
|
||||
@@ -968,6 +968,97 @@ void admin_commands_apply_and_replay() {
|
||||
require(!decode_cellular_batch(mangled), "a trace 4 with commands decoded");
|
||||
}
|
||||
|
||||
// ADR-0182 tuning amendments: adopt_tuning swaps the rules at a recorded tick; whoever applies
|
||||
// or replays it must name the rules for its revision and digest, and the safety revision stays.
|
||||
void tuning_is_adopted_and_replayed() {
|
||||
auto live = revamp_region();
|
||||
const auto base = restore(*live);
|
||||
const auto& before = live->revamp_rules();
|
||||
auto changed = before;
|
||||
changed.drip_interval_ticks += 7;
|
||||
changed.drip_bubble_pj *= 2;
|
||||
changed.body.essential_upkeep_per_thousand = 200;
|
||||
require(cellular_revamp_valid(changed) &&
|
||||
encode_cellular_revamp_rules(changed) != encode_cellular_revamp_rules(before),
|
||||
"the changed rules are not distinct valid rules");
|
||||
std::array<std::uint8_t, 32> digest{};
|
||||
for (std::size_t i = 0; i < digest.size(); ++i)
|
||||
digest.at(i) = static_cast<std::uint8_t>(i * 7 + 1);
|
||||
const auto adopt = cellular_adopt_tuning_command(1, 5, digest);
|
||||
require(cellular_admin_command_valid(adopt) && cellular_admin_digest(adopt) == digest &&
|
||||
adopt.target == 5,
|
||||
"the adoption command does not carry its revision and digest");
|
||||
auto zero = cellular_adopt_tuning_command(1, 5, {});
|
||||
auto counted = adopt;
|
||||
counted.count = 1;
|
||||
auto other = adopt;
|
||||
other.amount.matter[3].value = 1;
|
||||
for (const auto& bad : {zero, counted, other})
|
||||
require(!cellular_admin_command_valid(bad), "an invalid adoption was accepted");
|
||||
const CellularTuningResolver resolver =
|
||||
[&](std::uint64_t revision,
|
||||
const std::array<std::uint8_t, 32>& named) -> std::optional<CellularRevampRules> {
|
||||
if (revision != 5 || named != digest)
|
||||
return std::nullopt;
|
||||
return changed;
|
||||
};
|
||||
|
||||
const auto intents = swim(*live, {});
|
||||
checked(live->advance_tick(intents), "tick before the adoption");
|
||||
const std::vector commands{adopt};
|
||||
// Nobody can name the rules: an error, not a refusal (replay would diverge).
|
||||
require(!live->admin_candidate(commands), "an unnamed revision was applied or refused");
|
||||
std::vector<CellularAdminResult> results;
|
||||
auto after = checked(live->admin_candidate(commands, &results, resolver), "adoption applies");
|
||||
require(results.size() == 1 && results.front().applied && after->revamp_rules() == changed,
|
||||
"the rules were not adopted");
|
||||
require(restore(*after)->snapshot() == after->snapshot(), "adopted rules do not restore");
|
||||
// The safety revision is a law of the opening: such a revision is refused, nothing changes.
|
||||
auto unsafe = changed;
|
||||
unsafe.safety_version = before.safety_version + 1;
|
||||
std::vector<CellularAdminResult> refused;
|
||||
const auto kept =
|
||||
checked(live->admin_candidate(commands, &refused,
|
||||
[&](std::uint64_t, const std::array<std::uint8_t, 32>&) {
|
||||
return std::optional{unsafe};
|
||||
}),
|
||||
"an unsafe adoption is a refusal");
|
||||
require(refused.size() == 1 && !refused.front().applied && kept->revamp_rules() == before,
|
||||
"a safety revision change was adopted");
|
||||
|
||||
// Trace 5 replays the adoption with the same resolver, and the successor state names it.
|
||||
CellularBatch batch;
|
||||
batch.format_version = cellular_batch_admin_format;
|
||||
batch.header = {base->world(), base->region(), base->frame(), {}, {}, base->tick(), 0};
|
||||
batch.header.predecessor.fill(1);
|
||||
batch.header.predecessor_digest.fill(2);
|
||||
batch.ticks.push_back({intents, {}, {}, commands});
|
||||
batch.header.end_tick = base->tick() + 1;
|
||||
const auto decoded =
|
||||
checked(decode_cellular_batch(checked(encode_cellular_batch(batch), "encodes")), "decodes");
|
||||
std::vector<CellularMutationOutcome> outcomes;
|
||||
std::vector<CellularAdminResult> replayed_results;
|
||||
require(!replay_cellular_batch(*base, decoded, outcomes, replayed_results),
|
||||
"an adoption replayed without its rules");
|
||||
const auto replayed =
|
||||
checked(replay_cellular_batch(*base, decoded, outcomes, replayed_results, resolver),
|
||||
"the adoption replays");
|
||||
require(replayed->snapshot() == after->snapshot(), "the adoption replay diverged");
|
||||
const auto encoded = encode_cellular_revamp_rules(changed);
|
||||
const auto successor = cellular_successor_tuning(
|
||||
*replayed, [&](std::span<const std::uint8_t> bytes, const std::array<std::uint8_t, 32>& d) {
|
||||
return d == digest && std::ranges::equal(bytes, encoded);
|
||||
});
|
||||
const auto from_successor =
|
||||
checked(replay_cellular_batch(*base, decoded, outcomes, replayed_results, successor),
|
||||
"the successor names the adopted rules");
|
||||
require(from_successor->snapshot() == after->snapshot(), "the successor's rules diverged");
|
||||
// One adoption per batch: its successor can name only one set of rules.
|
||||
auto twice = batch;
|
||||
twice.ticks.front().admin.push_back(cellular_adopt_tuning_command(2, 6, digest));
|
||||
require(!encode_cellular_batch(twice), "two adoptions shared a batch");
|
||||
}
|
||||
|
||||
// The safety revision preserves all five channels, follows both control choices,
|
||||
// separates eligible predator/prey siblings and replays their actual motion exactly.
|
||||
void safety_split(bool become) {
|
||||
@@ -1127,6 +1218,7 @@ void safe_bud_provision(bool become) {
|
||||
|
||||
int main() try {
|
||||
admin_commands_apply_and_replay();
|
||||
tuning_is_adopted_and_replayed();
|
||||
safety_split(false);
|
||||
safety_split(true);
|
||||
safe_bud_provision(false);
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <source_location>
|
||||
@@ -630,6 +633,121 @@ void admin_api_tests(const Realm& realm) {
|
||||
CHECK(post("/api/regions/1/schedules?kind=add_bubbles&count=4&interval=60&energy=1&id=999999")
|
||||
.status == 400);
|
||||
|
||||
// Tuning revisions (schema 66): a request body in the Git revamp file format, checked,
|
||||
// stored with the admin's identity and queued as an adopt_tuning command per region.
|
||||
{
|
||||
const auto file = [](std::string_view name) {
|
||||
std::ifstream in{env("EVO_SOURCE_ROOT") + "/deploy/kubernetes/region/dev/tuning/" +
|
||||
std::string(name),
|
||||
std::ios::binary};
|
||||
return std::string{std::istreambuf_iterator<char>{in}, {}};
|
||||
};
|
||||
const auto baseline = file("cellular-revamp.tuning");
|
||||
CHECK(!baseline.empty());
|
||||
server::admin::AdminConfig config;
|
||||
config.world = 9831;
|
||||
config.view_regions = {1};
|
||||
config.baseline_tuning = baseline;
|
||||
AdminApi tuned{config,
|
||||
*TokenVerifier::from_jwks(realm.jwks("sig-1"), admin_rules),
|
||||
[] { return connect_as(env("EVO_PG_ADMIN_USER")); },
|
||||
[](std::uint64_t) { return std::optional<std::string>{}; },
|
||||
{}};
|
||||
const auto send = [&](std::string_view target, std::string_view body) {
|
||||
return tuned.handle({"POST", target, admin, body}, now, t0);
|
||||
};
|
||||
const auto read = [&](std::string_view target) {
|
||||
return tuned.handle({"GET", target, admin}, now, t0);
|
||||
};
|
||||
const auto none = must(JsonValue::parse(read("/api/tuning").body));
|
||||
const auto digest =
|
||||
std::string(must(none.member("baseline")->member("rules_sha256")->string()));
|
||||
CHECK(none.member("newest")->kind() == JsonValue::Kind::null &&
|
||||
none.member("revisions")->array()->empty() &&
|
||||
none.member("baseline")->member("text")->string() == baseline &&
|
||||
digest.size() == 64 && none.member("regions")->array()->at(0).string() == "1");
|
||||
|
||||
// Bodies go to /api/tuning only; check=1 stores nothing.
|
||||
CHECK(tuned
|
||||
.handle({"POST", "/api/regions/1/commands?kind=add_pool&energy=1", admin, "x"},
|
||||
now, t0)
|
||||
.status == 400);
|
||||
const auto checked = must(JsonValue::parse(send("/api/tuning?check=1", baseline).body));
|
||||
CHECK(checked.member("valid")->boolean() == true &&
|
||||
checked.member("rules_sha256")->string() == digest &&
|
||||
checked.member("safety_version")->integer() == 0);
|
||||
// Problems name the kind, line and key; the safety revision cannot change live.
|
||||
const auto lines = std::ranges::count(baseline, '\n');
|
||||
const auto unknown = must(
|
||||
JsonValue::parse(send("/api/tuning?check=1", baseline + "no.such_key = 1\n").body));
|
||||
CHECK(unknown.member("error")->string() == "invalid_tuning" &&
|
||||
unknown.member("kind")->string() == "unknown_key" &&
|
||||
unknown.member("key")->string() == "no.such_key" &&
|
||||
unknown.member("line")->integer() == lines + 1);
|
||||
CHECK(send("/api/tuning", "").status == 400 &&
|
||||
send("/api/tuning", "a = \x01").status == 400);
|
||||
const auto unsafe = must(JsonValue::parse(
|
||||
send("/api/tuning?check=1", file("cellular-reproduction-safety.tuning")).body));
|
||||
CHECK(unsafe.member("error")->string() == "safety_version_changed" &&
|
||||
unsafe.member("expected")->integer() == 0);
|
||||
CHECK(
|
||||
must(JsonValue::parse(read("/api/tuning").body)).member("revisions")->array()->empty());
|
||||
|
||||
// A slower drip: stored, listed, and queued for region 1 with its digest.
|
||||
auto changed = baseline;
|
||||
const auto at = changed.find("spent.drip_interval_ticks = 20");
|
||||
CHECK(at != std::string::npos);
|
||||
changed.replace(at, 30, "spent.drip_interval_ticks = 40");
|
||||
const auto stored =
|
||||
must(JsonValue::parse(send("/api/tuning?reason=slower+drip", changed).body));
|
||||
const auto revision = std::string(must(stored.member("revision")->string()));
|
||||
const auto changed_digest = std::string(must(stored.member("rules_sha256")->string()));
|
||||
CHECK(changed_digest != digest && stored.member("regions")->integer() == 1);
|
||||
const auto listed_tuning = must(JsonValue::parse(read("/api/tuning").body));
|
||||
const auto& entry = listed_tuning.member("revisions")->array()->at(0);
|
||||
CHECK(listed_tuning.member("newest")->member("revision")->string() == revision &&
|
||||
listed_tuning.member("newest")->member("text")->string() == changed &&
|
||||
entry.member("rules_sha256")->string() == changed_digest &&
|
||||
entry.member("reason")->string() == "slower drip" &&
|
||||
entry.member("author")->string() == "ops@example.test (ops)" &&
|
||||
entry.member("regions")->integer() == 1 && entry.member("adopted")->integer() == 0);
|
||||
CHECK(
|
||||
must(JsonValue::parse(read("/api/tuning/" + revision).body)).member("text")->string() ==
|
||||
changed);
|
||||
CHECK(read("/api/tuning/999999").status == 404 && read("/api/tuning/0").status == 404 &&
|
||||
read("/api/tuning/x").status == 404);
|
||||
std::uint64_t first_word = 0;
|
||||
for (std::size_t b = 0; b < 8; ++b)
|
||||
first_word |= std::stoull(changed_digest.substr(b * 2, 2), nullptr, 16) << (8 * b);
|
||||
auto reader = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||
const auto adoption =
|
||||
reader->query("SELECT cell_count, target, energy, other FROM "
|
||||
"evolution.load_pending_admin_commands_v1(9831, 1) WHERE kind = 7",
|
||||
{}, 5s);
|
||||
CHECK(adoption && adoption->size() == 1 && (*adoption)[0][0] == "0" &&
|
||||
(*adoption)[0][1] == revision && (*adoption)[0][2] == std::to_string(first_word) &&
|
||||
(*adoption)[0][3] == "0");
|
||||
const auto text = reader->query(
|
||||
"SELECT text, encode(rules_sha256, 'hex') FROM evolution.load_tuning_revision_v1(9831, "
|
||||
"$1::bigint)",
|
||||
std::array{revision}, 5s);
|
||||
CHECK(text && text->size() == 1 && (*text)[0][0] == changed &&
|
||||
(*text)[0][1] == changed_digest);
|
||||
// Only the admin stores revisions, rows never change, and kind 7 is never queued by hand.
|
||||
CHECK(!reader->query("SELECT evolution.admin_set_tuning_v1(9831, 'x', "
|
||||
"decode(repeat('ab', 32), 'hex'), '{1}', 'x', '')",
|
||||
{}, 5s));
|
||||
reader = connect_as(env("PGUSER"));
|
||||
CHECK(!reader->query("UPDATE evolution.tuning_revisions SET reason = 'x'", {}, 5s));
|
||||
CHECK(post("/api/regions/1/commands?kind=adopt_tuning&target=1").status == 400);
|
||||
CHECK(post("/api/regions/1/schedules?kind=adopt_tuning&count=1&interval=60").status == 400);
|
||||
// An unknown region (3 has no lease) refuses the whole revision.
|
||||
CHECK(api.handle({"POST", "/api/tuning", admin, changed}, now, t0).status == 400);
|
||||
CHECK(
|
||||
must(JsonValue::parse(read("/api/tuning").body)).member("revisions")->array()->size() ==
|
||||
1);
|
||||
}
|
||||
|
||||
// Accounts (schema 64): control claims recorded alice's sessions; a ban refuses grants
|
||||
// and is listed with its reason; lifting it restores them; an admin logout succeeds.
|
||||
CHECK(alice->member("sessions")->integer().value_or(0) >= 1 &&
|
||||
|
||||
@@ -231,6 +231,7 @@ void upgrade_across_migration_and_barrier() {
|
||||
" -v migration_sha_63=$(s 0063_admin_commands.sql)"
|
||||
" -v migration_sha_64=$(s 0064_account_admin.sql)"
|
||||
" -v migration_sha_65=$(s 0065_admin_schedules.sql)"
|
||||
" -v migration_sha_66=$(s 0066_tuning_revisions.sql)"
|
||||
" -v runtime_role=evo_runtime_test -f migrations/apply.sql"
|
||||
" > /dev/null 2>&1") != 0);
|
||||
CHECK(history(*owner_db) == "1,2,3,4,5,6,7");
|
||||
@@ -248,7 +249,7 @@ void upgrade_across_migration_and_barrier() {
|
||||
"tools/migrate-postgres.sh\" > /dev/null") == 0);
|
||||
CHECK(history(*owner_db) == "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,"
|
||||
"25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,"
|
||||
"47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65");
|
||||
"47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66");
|
||||
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
|
||||
"c.confrelid = 'evolution.region_commits'::regclass)::text "
|
||||
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
|
||||
|
||||
@@ -229,6 +229,63 @@ void accept_work_is_bounded_per_serve() {
|
||||
::close(fd);
|
||||
}
|
||||
|
||||
// ADR-0182: API request bodies only when asked for, complete (Content-Length, possibly over
|
||||
// several reads), bounded (413) and nothing else: no chunking, no body on GET, no extra bytes.
|
||||
void api_bodies_are_bounded_and_complete() {
|
||||
using evo::server::OpsServer;
|
||||
for (const std::size_t limit : {std::size_t{0}, std::size_t{64}}) {
|
||||
auto made = OpsServer::listen("127.0.0.1:0");
|
||||
CHECK(made);
|
||||
auto& ops = **made;
|
||||
std::atomic<bool> stop{false};
|
||||
std::thread serving([&] {
|
||||
while (!stop.load()) {
|
||||
ops.serve_api(
|
||||
[](const evo::server::ApiRequest& r) {
|
||||
return evo::server::OpsResponse{200, std::string(r.method) + ":" +
|
||||
std::string(r.body)};
|
||||
},
|
||||
limit);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
});
|
||||
const auto port = ops.port();
|
||||
const auto post = [&](const std::string& headers, const std::string& body) {
|
||||
std::string request = "POST /x HTTP/1.1\r\n";
|
||||
request.append(headers).append("\r\n").append(body);
|
||||
return http_exchange(port, request);
|
||||
};
|
||||
CHECK(post("", "").body == "POST:");
|
||||
CHECK(post("Content-Length: 0\r\n", "").body == "POST:");
|
||||
const auto hello = post("Content-Length: 5\r\n", "hello");
|
||||
CHECK(limit == 0 ? hello.status == 400 : hello.status == 200 && hello.body == "POST:hello");
|
||||
if (limit > 0) {
|
||||
// A body arriving after the headers, in a later read.
|
||||
const int fd = connect_local(port);
|
||||
const std::string first = "POST /x HTTP/1.1\r\nContent-Length: 5\r\n\r\nhe";
|
||||
CHECK(::send(fd, first.data(), first.size(), MSG_NOSIGNAL) ==
|
||||
static_cast<ssize_t>(first.size()));
|
||||
std::this_thread::sleep_for(50ms);
|
||||
CHECK(::send(fd, "llo", 3, MSG_NOSIGNAL) == 3);
|
||||
std::string raw;
|
||||
char chunk[512];
|
||||
for (ssize_t n = 0; (n = ::recv(fd, chunk, sizeof chunk, 0)) > 0;)
|
||||
raw.append(chunk, static_cast<std::size_t>(n));
|
||||
::close(fd);
|
||||
CHECK(raw.starts_with("HTTP/1.1 200") && raw.ends_with("\r\n\r\nPOST:hello"));
|
||||
}
|
||||
CHECK(post("Content-Length: 65\r\n", std::string(65, 'a')).status ==
|
||||
(limit == 0 ? 400 : 413));
|
||||
CHECK(post("Transfer-Encoding: chunked\r\n", "5\r\nhello\r\n0\r\n\r\n").status == 400);
|
||||
CHECK(post("Content-Length: 2\r\n", "hixx").status == 400);
|
||||
CHECK(post("Content-Length: 2\r\nContent-Length: 2\r\n", "hi").status == 400);
|
||||
CHECK(post("Content-Length: two\r\n", "hi").status == 400);
|
||||
CHECK(http_exchange(port, "GET /x HTTP/1.1\r\nContent-Length: 2\r\n\r\nhi").status == 400);
|
||||
stop = true;
|
||||
serving.join();
|
||||
}
|
||||
}
|
||||
|
||||
// A real server under sustained connection churn keeps its lease and readiness.
|
||||
void connection_pressure_keeps_authority() {
|
||||
const auto r = provision(54, 0x0D);
|
||||
@@ -266,6 +323,7 @@ void connection_pressure_keeps_authority() {
|
||||
|
||||
void run_region_ops_tests() {
|
||||
accept_work_is_bounded_per_serve();
|
||||
api_bodies_are_bounded_and_complete();
|
||||
connection_pressure_keeps_authority();
|
||||
probes_follow_authority_and_stay_bounded();
|
||||
unavailable_database_is_live_not_ready();
|
||||
|
||||
Reference in New Issue
Block a user