Publish cellular births with durable control
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 43s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (postgres) (push) Failing after 52s
Foundation / checks (tsan) (push) Failing after 32s
Foundation / checks (network) (push) Failing after 3m4s
Foundation / checks (client) (push) Failing after 4m24s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 43s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (postgres) (push) Failing after 52s
Foundation / checks (tsan) (push) Failing after 32s
Foundation / checks (network) (push) Failing after 3m4s
Foundation / checks (client) (push) Failing after 4m24s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// Profile-4 publication and recovery against the migration-backed PostgreSQL adapter.
|
||||
#include "evo/persistence/checkpoint_store.hpp"
|
||||
#include "evo/persistence/account_control_store.hpp"
|
||||
#include "evo/persistence/life_reservation_store.hpp"
|
||||
#include "evo/persistence/sha256.hpp"
|
||||
#include "evo/server/cellular_region_host.hpp"
|
||||
|
||||
@@ -45,7 +47,90 @@ std::string hex(std::span<const std::uint8_t> bytes) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void cellular_birth_publication_is_durable() {
|
||||
using namespace evo::biology;
|
||||
constexpr RegionKey key{9758, 1};
|
||||
auto owner = connect_as(env("PGUSER"));
|
||||
auto runtime = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||
const auto build = filled<32>(0xD9);
|
||||
CHECK(owner->query("INSERT INTO evolution.retained_builds(build_identity) VALUES "
|
||||
"(decode(repeat('d9',32),'hex')) ON CONFLICT DO NOTHING",
|
||||
{}, 5s));
|
||||
auto endowed = primitive_endowment();
|
||||
CHECK(endowed);
|
||||
auto funding = endowed->body;
|
||||
funding.energy.value = endowed->reserve.energy.value + endowed->construction.value;
|
||||
auto primitive = PrimitiveLives::create({key.world, key.region, 1, 17, funding, {{0, 0}}});
|
||||
CHECK(primitive);
|
||||
auto habitat = CellularHabitat::create({key.world, key.region, 1, 1'000, 1'000, {}});
|
||||
CHECK(habitat);
|
||||
auto opening = CellularLives::create(**primitive, std::move(*habitat),
|
||||
{{1'000, 1'000}, 0, 293'150});
|
||||
CHECK(opening && (*opening)->lives().empty());
|
||||
auto objects = FilesystemObjectStore::open(env("PGHOST"), key, max_cellular_lives_bytes);
|
||||
CHECK(objects);
|
||||
const auto genesis = provision_cellular_region(*owner, **objects, key, 1, **opening,
|
||||
filled<16>(0x30), build, 5s);
|
||||
CHECK(genesis);
|
||||
CHECK(owner->query("INSERT INTO evolution.life_allocators VALUES(9758,1000)", {}, 5s));
|
||||
const auto connect = [&]() -> std::expected<std::unique_ptr<Postgres>, PgFailure> {
|
||||
return Postgres::connect({env("PGHOST"), {}, env("PGPORT"), env("PGDATABASE"),
|
||||
env("EVO_PG_RUNTIME_USER"), {}, {}}, 5s);
|
||||
};
|
||||
CellularHostConfig config{key, 1, {}, build, {build}};
|
||||
auto made = CellularRegionHost::create(config, connect, std::move(*objects));
|
||||
CHECK(made);
|
||||
auto host = std::move(*made);
|
||||
CHECK(host->step().ready);
|
||||
const auto authority = host->authority();
|
||||
CHECK(authority);
|
||||
const auto account = filled<16>(0x47);
|
||||
const auto control = claim_account_control(*runtime, key, *authority, account, 1, 1,
|
||||
20'000ms, 5s);
|
||||
CHECK(control);
|
||||
const auto reservation = reserve_primitive_life(*runtime, key, *authority, account,
|
||||
control->generation, 7, 1, 5s);
|
||||
CHECK(reservation && reservation->refusal == LifeRefusal::none &&
|
||||
reservation->region == key.region);
|
||||
|
||||
CellularBatch batch;
|
||||
const auto predecessor_digest = sha256(host->committed()->manifest);
|
||||
CHECK(predecessor_digest);
|
||||
batch.header = {key.world, key.region, 1, host->committed()->head.commit,
|
||||
*predecessor_digest, 0, 1};
|
||||
CellularTickIntents tick;
|
||||
tick.births.push_back({account, 7, control->generation, reservation->identity});
|
||||
batch.ticks.push_back(tick);
|
||||
auto candidate = replay_cellular_batch(*host->state(), batch);
|
||||
CHECK(candidate && (*candidate)->lives().size() == 1 &&
|
||||
(*candidate)->lives()[0].identity.life == reservation->identity);
|
||||
auto published = host->publish(batch);
|
||||
CHECK(published && published->committed.head.sequence == 1 &&
|
||||
host->state()->snapshot() == (*candidate)->snapshot());
|
||||
const auto outcome = query_primitive_life(*runtime, key, *authority, account,
|
||||
control->generation, 7, 5s);
|
||||
CHECK(outcome && outcome->has_value() && (*outcome)->published &&
|
||||
(*outcome)->published->identity == reservation->identity &&
|
||||
(*outcome)->published->born == 1);
|
||||
host->drain();
|
||||
host.reset();
|
||||
|
||||
auto restarted_objects = FilesystemObjectStore::open(env("PGHOST"), key,
|
||||
max_cellular_lives_bytes);
|
||||
CHECK(restarted_objects);
|
||||
auto restarted_made = CellularRegionHost::create(config, connect,
|
||||
std::move(*restarted_objects));
|
||||
CHECK(restarted_made);
|
||||
auto restarted = std::move(*restarted_made);
|
||||
CHECK(restarted->step().ready && restarted->state()->tick() == 1 &&
|
||||
restarted->state()->snapshot() == (*candidate)->snapshot());
|
||||
restarted->drain();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void run_cellular_publication_tests() {
|
||||
cellular_birth_publication_is_durable();
|
||||
auto owner = connect_as(env("PGUSER"));
|
||||
const auto build = filled<32>(0xD9);
|
||||
CHECK(owner->query("INSERT INTO evolution.retained_builds(build_identity) VALUES "
|
||||
|
||||
@@ -186,10 +186,10 @@ void runtime_cannot_bypass_the_guard() {
|
||||
void cellular_publisher_adapter_rejects_malformed_requests() {
|
||||
auto db = runtime();
|
||||
const std::vector<std::uint8_t> empty;
|
||||
auto published = publish_cellular_checkpoint(*db, empty, empty, empty, 5s);
|
||||
auto published = publish_cellular_checkpoint(*db, empty, empty, empty, empty, 5s);
|
||||
CHECK(failed(published, LeaseStoreError::invalid));
|
||||
auto resolved = resolve_cellular_region_commit(*db, {1, 999}, id(0xC1), empty, empty, empty,
|
||||
5s);
|
||||
empty, 5s);
|
||||
CHECK(failed(resolved, LeaseStoreError::invalid));
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,7 @@ void upgrade_across_migration_and_barrier() {
|
||||
" -v migration_sha_20=$(s 0020_cellular_publication.sql)"
|
||||
" -v migration_sha_21=$(s 0021_cellular_trace_and_recovery.sql)"
|
||||
" -v migration_sha_22=$(s 0022_cellular_birth_trace_bound.sql)"
|
||||
" -v migration_sha_23=$(s 0023_cellular_birth_publication.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");
|
||||
@@ -204,7 +205,7 @@ void upgrade_across_migration_and_barrier() {
|
||||
" EVO_PG_RUNTIME_ROLE=evo_runtime_test bash \"$EVO_SOURCE_ROOT/"
|
||||
"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");
|
||||
"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23");
|
||||
CHECK(scalar(*owner_db, "SELECT count(*) FROM information_schema.columns WHERE "
|
||||
"table_schema = 'evolution' AND table_name = 'region_actions' AND "
|
||||
"column_name IN ('input_bytes', 'result')") == "2");
|
||||
@@ -223,12 +224,24 @@ void upgrade_across_migration_and_barrier() {
|
||||
"'0100000000000000' || '0100000000000000' || repeat('00', 16), 'hex'), "
|
||||
"0, 1)::text") == "1");
|
||||
CHECK(scalar(*owner_db,
|
||||
"SELECT (to_regprocedure('evolution.publish_cellular_checkpoint(bytea,bytea,bytea)') "
|
||||
"SELECT (to_regprocedure('evolution.publish_cellular_checkpoint(bytea,bytea,bytea,bytea)') "
|
||||
"IS NOT NULL)::text") == "true");
|
||||
CHECK(scalar(*owner_db,
|
||||
"SELECT has_function_privilege('evo_runtime_login', "
|
||||
"'evolution.publish_cellular_checkpoint(bytea,bytea,bytea)', 'EXECUTE')::text") ==
|
||||
"'evolution.publish_cellular_checkpoint(bytea,bytea,bytea,bytea)', 'EXECUTE')::text") ==
|
||||
"true");
|
||||
CHECK(scalar(*owner_db,
|
||||
"SELECT has_function_privilege('evo_runtime_login', "
|
||||
"'evolution.publish_cellular_checkpoint(bytea,bytea,bytea)', 'EXECUTE')::text") ==
|
||||
"false");
|
||||
CHECK(scalar(*owner_db,
|
||||
"SELECT (to_regprocedure('evolution.load_cellular_publication_births("
|
||||
"evolution.u64,evolution.u64,uuid,evolution.u64,uuid)') IS NOT NULL)::text") ==
|
||||
"true");
|
||||
CHECK(scalar(*owner_db,
|
||||
"SELECT has_function_privilege('evo_runtime_login', "
|
||||
"'evolution.resolve_cellular_region_commit(evolution.u64,evolution.u64,uuid,"
|
||||
"bytea,bytea,bytea,bytea)', 'EXECUTE')::text") == "true");
|
||||
CHECK(scalar(*owner_db,
|
||||
"SELECT has_table_privilege('evo_runtime_login', "
|
||||
"'evolution.cellular_publications', 'INSERT')::text") == "false");
|
||||
|
||||
Reference in New Issue
Block a user