Guard optional values in publication tests
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (postgres) (push) Failing after 4m53s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 7m7s
Foundation / checks (tsan) (push) Canceled after 7m8s

This commit is contained in:
dingo
2026-10-11 20:02:42 -04:00
parent 8322f9c855
commit 0ff24a97e6
2 changed files with 34 additions and 17 deletions
+2
View File
@@ -7020,3 +7020,5 @@ CI run #308 passed client, deploy, ECS, network and TSan, including the X11 life
CI run #309 passed the client, deploy, ECS, network and TSan jobs, and the regular 68-test suite in the main checks job. PostgreSQL's full build then rejected 16 unchecked `std::optional` accesses in `tests/cellular_publication_tests.cpp` under warnings-as-errors. The affected test reads now use `optional::value()` after their existing checks, with committed snapshots stored once where repeated reads were previously unchecked. PostgreSQL tools and server-image/Harbor publication did not start.
CI run #310 passed client, deploy, ECS and network. The main checks stopped at the formatting gate because three new `CellularBatch::header` initializers were not laid out exactly as clang-format 19 expects. The test source is now formatted with clang-format 19.1.5 and passes its local dry-run check. PostgreSQL analysis was still building when this formatting correction was prepared, so run #310 does not yet validate the optional-access fixes; Harbor publication did not start.
CI run #311 passed client, deploy, ECS, network and TSan, and compiled the PostgreSQL test target. The PostgreSQL analysis build then still reported 17 unchecked accesses: clang-tidy does not treat the `CHECK(...)` macro or `optional::value()` by itself as proof of engagement. The test now uses a helper with an explicit `has_value()` guard before dereferencing those optionals. This version awaits CI validation; PostgreSQL tools and Harbor publication did not start.
+32 -17
View File
@@ -6,6 +6,7 @@
#include "evo/server/cellular_region_host.hpp"
#include <cstdlib>
#include <optional>
#include <source_location>
#include <stdexcept>
@@ -19,6 +20,11 @@ void check(bool value, std::source_location at = std::source_location::current()
throw std::runtime_error("cellular publication test line " + std::to_string(at.line()));
}
#define CHECK(...) check(static_cast<bool>(__VA_ARGS__))
template <typename T> const T& checked_value(const std::optional<T>& value) {
if (!value.has_value())
throw std::runtime_error("cellular publication test expected an optional value");
return *value;
}
std::string env(const char* name) {
const auto* value = std::getenv(name);
if (!value)
@@ -98,11 +104,13 @@ void cellular_birth_publication_is_durable() {
CHECK(host->step().ready);
const auto authority = host->authority();
CHECK(authority);
const auto& authority_value = checked_value(authority);
const auto committed = host->committed();
CHECK(committed);
const auto& committed_value = checked_value(committed);
const auto account = filled<16>(0x47);
const auto control =
claim_account_control(*runtime, key, authority.value(), account, 1, 1, 20'000ms, 5s);
claim_account_control(*runtime, key, authority_value, account, 1, 1, 20'000ms, 5s);
CHECK(control);
const auto requested = host->create_primitive_life(account, control->generation, 7);
CHECK(requested.result == evo::network::PrimitiveLifeResult::pending &&
@@ -112,10 +120,11 @@ void cellular_birth_publication_is_durable() {
const auto reservation = host->queued_births().front();
CellularBatch batch;
const auto predecessor_digest = sha256(committed.value().manifest);
const auto predecessor_digest = sha256(committed_value.manifest);
CHECK(predecessor_digest);
batch.header = {
key.world, key.region, 1, committed.value().head.commit, predecessor_digest.value(), 0, 1};
key.world, key.region, 1, committed_value.head.commit, checked_value(predecessor_digest),
0, 1};
CellularTickIntents tick;
tick.births.push_back(reservation);
batch.ticks.push_back(tick);
@@ -129,12 +138,12 @@ void cellular_birth_publication_is_durable() {
CHECK(host_outcome.result == evo::network::PrimitiveLifeResult::born &&
host_outcome.life_identity == reservation.identity && host_outcome.commit_sequence == 1);
const auto outcome =
query_primitive_life(*runtime, key, authority.value(), account, control->generation, 7, 5s);
query_primitive_life(*runtime, key, authority_value, account, control->generation, 7, 5s);
CHECK(outcome && outcome.value().has_value());
const auto& outcome_value = outcome.value().value();
const auto& outcome_value = checked_value(outcome.value());
CHECK(outcome_value.published.has_value());
CHECK(outcome_value.published.value().identity == reservation.identity &&
outcome_value.published.value().born == 1);
const auto& published_value = checked_value(outcome_value.published);
CHECK(published_value.identity == reservation.identity && published_value.born == 1);
host->drain();
host.reset();
@@ -211,15 +220,17 @@ void cellular_profile_migration_is_durable_and_recovers_without_a_tick() {
CHECK(host->step().ready);
const auto authority = host->authority();
CHECK(authority);
const auto& authority_value = checked_value(authority);
const auto predecessor = host->committed();
CHECK(predecessor);
CHECK(predecessor.value().head.sequence == 0);
const auto& predecessor_value = checked_value(predecessor);
CHECK(predecessor_value.head.sequence == 0);
CellularBatch batch;
const auto predecessor_digest = sha256(predecessor.value().manifest);
const auto predecessor_digest = sha256(predecessor_value.manifest);
CHECK(predecessor_digest);
batch.header = {
key.world, key.region, 1, predecessor.value().head.commit, predecessor_digest.value(),
key.world, key.region, 1, predecessor_value.head.commit, checked_value(predecessor_digest),
0, 1};
batch.ticks.resize(1);
for (const auto& life : host->state()->lives())
@@ -227,13 +238,13 @@ void cellular_profile_migration_is_durable_and_recovers_without_a_tick() {
const auto published = host->publish(batch);
CHECK(published && published->committed.head.sequence == 1);
auto migrated =
migrate_cellular_profile_to_v2(*owner, **migration_objects, authority.value(),
migrate_cellular_profile_to_v2(*owner, **migration_objects, authority_value,
published->committed, filled<16>(0x51), build, 5s);
CHECK(migrated && migrated->head.sequence == 2 && migrated->head.end_tick == 1);
CHECK(
retry_cellular_profile_migration(*owner, {key, filled<16>(0x51), migrated->manifest}, 5s));
auto revision_migrated = migrate_cellular_profile_to_v3(
*owner, **migration_objects, authority.value(), *migrated, filled<16>(0x52), build, 5s);
*owner, **migration_objects, authority_value, *migrated, filled<16>(0x52), build, 5s);
CHECK(revision_migrated && revision_migrated->head.sequence == 3 &&
revision_migrated->head.end_tick == 1);
CHECK(retry_cellular_profile_migration(
@@ -254,8 +265,9 @@ void cellular_profile_migration_is_durable_and_recovers_without_a_tick() {
auto restarted = std::move(*restarted_made);
const auto restarted_committed = restarted->committed();
CHECK(restarted_committed);
CHECK(restarted->step().ready && restarted_committed.value().head.sequence == 3 &&
restarted_committed.value().head.end_tick == 1 && restarted->state()->tick() == 1 &&
const auto& restarted_committed_value = checked_value(restarted_committed);
CHECK(restarted->step().ready && restarted_committed_value.head.sequence == 3 &&
restarted_committed_value.head.end_tick == 1 && restarted->state()->tick() == 1 &&
restarted->state()->format_version() == cellular_lives_revision_format &&
restarted->state()->snapshot() == *target_payload);
restarted->drain();
@@ -359,11 +371,13 @@ void run_cellular_publication_tests() {
CHECK(host->step().ready);
const auto committed = host->committed();
CHECK(committed);
const auto& committed_value = checked_value(committed);
CellularBatch batch;
const auto predecessor_digest = sha256(committed.value().manifest);
const auto predecessor_digest = sha256(committed_value.manifest);
CHECK(predecessor_digest);
batch.header = {
key.world, key.region, 1, committed.value().head.commit, predecessor_digest.value(), 0, 2};
key.world, key.region, 1, committed_value.head.commit, checked_value(predecessor_digest),
0, 2};
batch.ticks.resize(2);
for (auto& tick : batch.ticks)
tick.lives.push_back({(*opening)->lives()[0].identity.life, {}});
@@ -391,8 +405,9 @@ void run_cellular_publication_tests() {
auto restarted = std::move(*made_restarted);
const auto restarted_committed = restarted->committed();
CHECK(restarted_committed);
const auto& restarted_committed_value = checked_value(restarted_committed);
CHECK(restarted->step().ready && restarted->state()->tick() == 2 &&
restarted->state()->snapshot() == (**replay).snapshot() &&
restarted_committed.value().head.sequence == 1);
restarted_committed_value.head.sequence == 1);
restarted->drain();
}