Reorganize python tests.

Merge batch_others and batch_pg_regress. The original idea was to
split all the python tests into multiple "batches" and run each batch
in parallel as a separate CI job. However, the batch_pg_regress batch
was pretty short compared to all the tests in batch_others. We could
split batch_others into multiple batches, but it actually seems better
to just treat them as one big pool of tests and use pytest's handle
the parallelism on its own. If we need to split them across multiple
nodes in the future, we could use pytest-shard or something else,
instead of managing the batches ourselves.

Merge test_neon_regress.py, test_pg_regress.py and test_isolation.py
into one file, test_pg_regress.py. Seems more clear to group all
pg_regress-based tests into one file, now that they would all be in
the same directory.
This commit is contained in:
Heikki Linnakangas
2022-08-30 18:25:38 +03:00
parent 96a50e99cf
commit 3aca717f3d
72 changed files with 201 additions and 216 deletions

11
test_runner/sql_regress/.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
# Local binaries
/pg_regress
# Generated subdirectories
/tmp_check/
/results/
/log/
# Note: regression.* are only left behind on a failure; that's why they're not ignored
#/regression.diffs
#/regression.out

View File

@@ -0,0 +1,13 @@
Simple tests that only need a PostgreSQL connection to run.
These are run by the regress/test_pg_regress.py test, which uses
the PostgreSQL pg_regress utility.
To add a new SQL test:
- add sql script to run to neon_regress/sql/testname.sql
- add expected output to neon_regress/expected/testname.out
- add testname to parallel_schedule
That's it.
For more complex tests see PostgreSQL regression tests in src/test/regress.
These work basically the same.

View File

@@ -0,0 +1,9 @@
/constraints.out
/copy.out
/create_function_1.out
/create_function_2.out
/largeobject.out
/largeobject_1.out
/misc.out
/security_label.out
/tablespace.out

View File

@@ -0,0 +1,34 @@
BEGIN;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
CREATE TABLE cursor (a int);
INSERT INTO cursor VALUES (1);
DECLARE c1 NO SCROLL CURSOR FOR SELECT * FROM cursor FOR UPDATE;
UPDATE cursor SET a = 2;
FETCH ALL FROM c1;
a
---
(0 rows)
COMMIT;
DROP TABLE cursor;
create table to_be_evicted(x bigint);
begin;
insert into to_be_evicted values (1);
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
select sum(x) from to_be_evicted;
sum
-------------
25937424601
(1 row)
end;
drop table to_be_evicted;

View File

@@ -0,0 +1,15 @@
create or replace procedure do_commits() as $$
declare
xid xid8;
i integer;
begin
for i in 1..1000000 loop
xid = txid_current();
commit;
if (pg_xact_status(xid) <> 'committed') then
raise exception 'CLOG corruption';
end if;
end loop;
end;
$$ language plpgsql;
call do_commits();

View File

@@ -0,0 +1,45 @@
--
-- Test that when a relation is truncated by VACUUM, the next smgrnblocks()
-- query to get the relation's size returns the new size.
-- (This isn't related to the TRUNCATE command, which works differently,
-- by creating a new relation file)
--
CREATE TABLE truncatetest (i int);
INSERT INTO truncatetest SELECT g FROM generate_series(1, 10000) g;
-- Remove all the rows, and run VACUUM to remove the dead tuples and
-- truncate the physical relation to 0 blocks.
DELETE FROM truncatetest;
VACUUM truncatetest;
-- Check that a SeqScan sees correct relation size (which is now 0)
SELECT * FROM truncatetest;
i
---
(0 rows)
DROP TABLE truncatetest;
--
-- Test that the FSM is truncated along with the table.
--
-- Create a test table and delete and vacuum away most of the rows.
-- This leaves the FSM full of pages with plenty of space
create table tt(i int);
insert into tt select g from generate_series(1, 100000) g;
delete from tt where i%100 != 0 and i > 10000;
vacuum freeze tt;
-- Delete the rest of the rows, and vacuum again. This truncates the
-- heap to 0 blocks, and should also truncate the FSM.
delete from tt;
vacuum tt;
-- This can be used to look at the FSM directly, if the 'pg_freespace' contrib module
-- is installed
--SELECT blkno, avail from generate_series(1, 450) blkno, pg_freespace('tt'::regclass, blkno) AS avail;
-- Insert a row again. It should go on block #0. If the FSM was not truncated,
-- the insertion would find a higher-numbered block in the FSM and use that instead.
insert into tt values (0);
select ctid, * from tt;
ctid | i
-------+---
(0,1) | 0
(1 row)
drop table tt;

View File

@@ -0,0 +1,304 @@
create table foo(a int primary key, b int, c int);
insert into foo values (generate_series(1,10000), generate_series(1,10000), generate_series(1,10000));
create index concurrently on foo(b);
create index concurrently on foo(c);
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
vacuum full foo;
\d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
b | integer | | |
c | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (a)
"foo_b_idx" btree (b)
"foo_c_idx" btree (c)
drop table foo;

View File

@@ -0,0 +1,10 @@
# ----------
# Like in PostgreSQL src/test/regress/parallel_schedule, we put no
# more than twenty tests in any one parallel group; this limits the
# number of connections needed to run the tests.
# ----------
test: neon-cid
test: neon-rel-truncate
test: neon-clog
test: neon-vacuum-full

View File

@@ -0,0 +1,8 @@
/constraints.sql
/copy.sql
/create_function_1.sql
/create_function_2.sql
/largeobject.sql
/misc.sql
/security_label.sql
/tablespace.sql

View File

@@ -0,0 +1,26 @@
BEGIN;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
CREATE TABLE cursor (a int);
INSERT INTO cursor VALUES (1);
DECLARE c1 NO SCROLL CURSOR FOR SELECT * FROM cursor FOR UPDATE;
UPDATE cursor SET a = 2;
FETCH ALL FROM c1;
COMMIT;
DROP TABLE cursor;
create table to_be_evicted(x bigint);
begin;
insert into to_be_evicted values (1);
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
insert into to_be_evicted select x*10 from to_be_evicted;
select sum(x) from to_be_evicted;
end;
drop table to_be_evicted;

View File

@@ -0,0 +1,16 @@
create or replace procedure do_commits() as $$
declare
xid xid8;
i integer;
begin
for i in 1..1000000 loop
xid = txid_current();
commit;
if (pg_xact_status(xid) <> 'committed') then
raise exception 'CLOG corruption';
end if;
end loop;
end;
$$ language plpgsql;
call do_commits();

View File

@@ -0,0 +1,46 @@
--
-- Test that when a relation is truncated by VACUUM, the next smgrnblocks()
-- query to get the relation's size returns the new size.
-- (This isn't related to the TRUNCATE command, which works differently,
-- by creating a new relation file)
--
CREATE TABLE truncatetest (i int);
INSERT INTO truncatetest SELECT g FROM generate_series(1, 10000) g;
-- Remove all the rows, and run VACUUM to remove the dead tuples and
-- truncate the physical relation to 0 blocks.
DELETE FROM truncatetest;
VACUUM truncatetest;
-- Check that a SeqScan sees correct relation size (which is now 0)
SELECT * FROM truncatetest;
DROP TABLE truncatetest;
--
-- Test that the FSM is truncated along with the table.
--
-- Create a test table and delete and vacuum away most of the rows.
-- This leaves the FSM full of pages with plenty of space
create table tt(i int);
insert into tt select g from generate_series(1, 100000) g;
delete from tt where i%100 != 0 and i > 10000;
vacuum freeze tt;
-- Delete the rest of the rows, and vacuum again. This truncates the
-- heap to 0 blocks, and should also truncate the FSM.
delete from tt;
vacuum tt;
-- This can be used to look at the FSM directly, if the 'pg_freespace' contrib module
-- is installed
--SELECT blkno, avail from generate_series(1, 450) blkno, pg_freespace('tt'::regclass, blkno) AS avail;
-- Insert a row again. It should go on block #0. If the FSM was not truncated,
-- the insertion would find a higher-numbered block in the FSM and use that instead.
insert into tt values (0);
select ctid, * from tt;
drop table tt;

View File

@@ -0,0 +1,51 @@
create table foo(a int primary key, b int, c int);
insert into foo values (generate_series(1,10000), generate_series(1,10000), generate_series(1,10000));
create index concurrently on foo(b);
create index concurrently on foo(c);
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
vacuum full foo;
\d foo
drop table foo;