Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (postgres) (push) Failing after 34m51s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
98 lines
5.8 KiB
PL/PgSQL
98 lines
5.8 KiB
PL/PgSQL
-- Runs only in the isolated PostgreSQL test cluster (tools/ci/postgres-check.sh).
|
|
\set ON_ERROR_STOP on
|
|
INSERT INTO evolution.life_allocators VALUES (9750, 1);
|
|
INSERT INTO evolution.region_leases(world_id,region_id,frame_id) VALUES (9750,1,7),(9750,2,7);
|
|
INSERT INTO evolution.retained_builds(build_identity) VALUES (decode(repeat('d5',32),'hex'))
|
|
ON CONFLICT DO NOTHING;
|
|
SET ROLE evo_runtime_login;
|
|
SELECT * FROM evolution.acquire_region_lease(9750,1,60000,decode(repeat('d5',32),'hex')) \gset
|
|
SELECT * FROM evolution.claim_account_control(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',1,1,60000) \gset
|
|
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',:control_generation,10,1) \gset
|
|
SELECT 1 / ((:life_identity = 1 AND :life_region = 1 AND :rejection = 0)::int);
|
|
-- Successful allocation retry returns identical IDs, without another counter increment.
|
|
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',:control_generation,10,1) \gset
|
|
SELECT 1 / ((:life_identity = 1)::int);
|
|
-- Capture parameters for PL/pgSQL exception assertions without string interpolation.
|
|
SELECT set_config('test.holder', :'lease_holder', false),
|
|
set_config('test.epoch', :'lease_epoch', false);
|
|
DO $$ BEGIN
|
|
BEGIN
|
|
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
|
|
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',99,10,1);
|
|
RAISE EXCEPTION 'accepted stale control';
|
|
EXCEPTION WHEN SQLSTATE 'EVL02' THEN NULL; END;
|
|
BEGIN
|
|
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
|
|
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',1,10,2);
|
|
RAISE EXCEPTION 'accepted unknown rules';
|
|
EXCEPTION WHEN SQLSTATE '22023' THEN NULL; END;
|
|
BEGIN
|
|
PERFORM 1 FROM evolution.life_reservations;
|
|
RAISE EXCEPTION 'runtime can access reservations directly';
|
|
EXCEPTION WHEN insufficient_privilege THEN NULL; END;
|
|
END $$;
|
|
SELECT 1 / ((evolution.reject_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',1,10,1::smallint) = 1)::int);
|
|
-- First durable refusal is immutable, including across a different proposed reason.
|
|
SELECT 1 / ((evolution.reject_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',1,10,2::smallint) = 1)::int);
|
|
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',1,11,1) \gset
|
|
-- The conflicting request keeps its own allocated identity and immutable refusal.
|
|
SELECT 1 / ((:life_identity = 2 AND :rejection = 4)::int);
|
|
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',1,10,1) \gset
|
|
SELECT 1 / ((:life_identity = 1 AND :rejection = 1)::int);
|
|
RESET ROLE;
|
|
SELECT 1 / ((SELECT next_identity = 3 FROM evolution.life_allocators WHERE world_id=9750)::int);
|
|
UPDATE evolution.life_allocators SET next_identity=18446744073709551615 WHERE world_id=9750;
|
|
SET ROLE evo_runtime_login;
|
|
SELECT * FROM evolution.claim_account_control(9750,1,:'lease_holder',:lease_epoch,
|
|
'55555555-5555-5555-5555-555555555555',1,3,60000) \gset
|
|
DO $$ BEGIN
|
|
BEGIN
|
|
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
|
|
current_setting('test.epoch')::numeric,'55555555-5555-5555-5555-555555555555',1,1,1);
|
|
RAISE EXCEPTION 'wrapped exhausted allocator';
|
|
EXCEPTION WHEN SQLSTATE 'EVL05' THEN NULL; END;
|
|
END $$;
|
|
RESET ROLE;
|
|
SELECT 1 / ((SELECT count(*) = 2 FROM evolution.life_reservations WHERE world_id=9750)::int);
|
|
SELECT 1 / ((SELECT next_identity = 18446744073709551615 FROM evolution.life_allocators WHERE world_id=9750)::int);
|
|
UPDATE evolution.life_allocators SET next_identity=3 WHERE world_id=9750;
|
|
-- Deliberate transaction rollback: no allocation or reservation can survive alone.
|
|
BEGIN;
|
|
SET LOCAL ROLE evo_runtime_login;
|
|
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
|
|
'55555555-5555-5555-5555-555555555555',1,1,1);
|
|
ROLLBACK;
|
|
SELECT 1 / ((SELECT next_identity = 3 FROM evolution.life_allocators WHERE world_id=9750)::int);
|
|
SELECT 1 / ((SELECT count(*) = 2 FROM evolution.life_reservations WHERE world_id=9750)::int);
|
|
-- Expired region cannot reserve or resolve through its stale authority.
|
|
UPDATE evolution.region_leases SET expires_at=clock_timestamp()-interval '1 second'
|
|
WHERE world_id=9750 AND region_id=1;
|
|
SET ROLE evo_runtime_login;
|
|
DO $$ BEGIN
|
|
BEGIN
|
|
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
|
|
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',1,11,1);
|
|
RAISE EXCEPTION 'accepted expired region authority';
|
|
EXCEPTION WHEN SQLSTATE 'EVL02' THEN NULL; END;
|
|
END $$;
|
|
SELECT * FROM evolution.acquire_region_lease(9750,2,60000,decode(repeat('d5',32),'hex')) \gset
|
|
SELECT * FROM evolution.claim_account_control(9750,2,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',2,2,60000) \gset
|
|
-- A takeover may inspect the reservation while waiting; it grants no body/control
|
|
-- before the session layer's takeover wait. The original owner remains region 1.
|
|
SELECT * FROM evolution.reserve_primitive_life(9750,2,:'lease_holder',:lease_epoch,
|
|
'11111111-1111-1111-1111-111111111111',:control_generation,11,1) \gset
|
|
SELECT 1 / ((:life_identity = 2 AND :life_region = 1)::int);
|
|
RESET ROLE;
|
|
-- Restore tests must retain the allocator above every historical reservation.
|
|
SELECT 1 / ((SELECT count(*) = 2 FROM evolution.life_reservations WHERE world_id=9750)::int);
|
|
UPDATE evolution.region_leases SET expires_at=clock_timestamp()-interval '1 second'
|
|
WHERE world_id=9750;
|