Skip to content

Commit

Permalink
[pg15] test: clean up tests using sequential ybrowid
Browse files Browse the repository at this point in the history
Summary:
Sequential ybrowid generation makes previous workarounds no longer
necessary.  Update some tests to have less workarounds, enabling the
TEST_generate_ybrowid_sequentially where it can be useful.  In case of
TestPgRegressDml, split it up to TestPgRegressDml and TestPgRegressPgDml
so that pg ported tests are in one schedule with the flag enabled and yb
tests are in a different schedule.

- Remove ORDER BY where unnecessary
- Remove setting VERBOSITY terse because the ordering of cascade details
  is now fixed, even though it often does not match the upstream PG
  ordering due to system table updates that do not reallocate ybrowid.
  This reveals some other deficiencies of not dropping objects in
  yb_pg_alter_generic.

There are more tests that could be adjusted, but stop here for now.

Test Plan:
On Almalinux 8:

    #!/usr/bin/env bash
    set -eu
    ./yb_build.sh fastdebug --gcc11
    pg15_tests/run_tests.sh <<EOT
    JAVA	org.yb.pgsql.TestPgRegressDml
    JAVA	org.yb.pgsql.TestPgRegressPgDml
    JAVA	org.yb.pgsql.TestPgRegressPgMisc
    SHELL	test_pg_misc_independent
    EOT

Jenkins: rebase: pg15, test regex: TestPgRegress

Reviewers: aagrawal, fizaa, tfoucher

Reviewed By: tfoucher

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D36303
  • Loading branch information
jaki committed Jul 2, 2024
1 parent c6222f4 commit 4f17a04
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) YugaByte, Inc.
// Copyright (c) YugabyteDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -27,7 +27,7 @@ public int getTestMethodTimeoutSec() {
}

@Test
public void testPgRegressDml() throws Exception {
runPgRegressTest("yb_pg_dml_serial_schedule");
public void schedule() throws Exception {
runPgRegressTest("yb_dml_serial_schedule");
}
}
33 changes: 33 additions & 0 deletions java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRegressPgDml.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) YugabyteDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations
// under the License.
//
package org.yb.pgsql;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.yb.YBTestRunner;

/**
* Runs the pg_regress test suite on YB code.
*/
@RunWith(value=YBTestRunner.class)
public class TestPgRegressPgDml extends BasePgRegressTestSequentialYbrowid {
@Override
public int getTestMethodTimeoutSec() {
return 1800;
}

@Test
public void schedule() throws Exception {
runPgRegressTest("yb_pg_dml_serial_schedule");
}
}
48 changes: 43 additions & 5 deletions src/postgres/src/test/regress/expected/yb_pg_alter_generic.out
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ ERROR: current transaction is aborted, commands ignored until end of transactio
DROP OPERATOR FAMILY alt_opf5 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
DROP OPERATOR FAMILY alt_opf5 USING btree; -- YB: workaround for lack of transactional DDL
-- Should fail. Need rights to namespace for ALTER OPERATOR FAMILY .. ADD / DROP
BEGIN TRANSACTION;
CREATE ROLE regress_alter_generic_user6;
Expand Down Expand Up @@ -418,6 +419,8 @@ ERROR: btree comparison functions must return integer
DROP OPERATOR FAMILY alt_opf12 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
DROP FUNCTION fn_opf12 (int4, int2); -- YB: workaround for lack of transactional DDL
DROP OPERATOR FAMILY alt_opf12 USING btree; -- YB: workaround for lack of transactional DDL
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
Expand All @@ -427,6 +430,8 @@ ERROR: hash function 1 must return integer
DROP OPERATOR FAMILY alt_opf13 USING hash;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
DROP FUNCTION fn_opf13 (int4); -- YB: workaround for lack of transactional DDL
DROP OPERATOR FAMILY alt_opf13 USING hash; -- YB: workaround for lack of transactional DDL
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
Expand All @@ -436,6 +441,8 @@ ERROR: btree comparison functions must have two arguments
DROP OPERATOR FAMILY alt_opf14 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
DROP FUNCTION fn_opf14 (int4); -- YB: workaround for lack of transactional DDL
DROP OPERATOR FAMILY alt_opf14 USING btree; -- YB: workaround for lack of transactional DDL
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
Expand All @@ -445,6 +452,8 @@ ERROR: hash function 1 must have one argument
DROP OPERATOR FAMILY alt_opf15 USING hash;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
DROP FUNCTION fn_opf15 (int4, int2); -- YB: workaround for lack of transactional DDL
DROP OPERATOR FAMILY alt_opf15 USING hash; -- YB: workaround for lack of transactional DDL
-- Should fail. In gist throw an error when giving different data types for function argument
-- without defining left / right type in ALTER OPERATOR FAMILY ... ADD FUNCTION
CREATE OPERATOR FAMILY alt_opf16 USING gist;
Expand Down Expand Up @@ -699,12 +708,41 @@ NOTICE: drop cascades to server alt_fserv3
DROP LANGUAGE alt_lang2 CASCADE;
DROP LANGUAGE alt_lang3 CASCADE; -- YB: fails due to above commenting out
ERROR: language "alt_lang3" does not exist
\set VERBOSITY terse \\ -- YB: suppress cascade details
DROP SCHEMA alt_nsp1 CASCADE; -- YB: output numbers different due to above commenting out
NOTICE: drop cascades to 31 other objects
DROP SCHEMA alt_nsp2 CASCADE;
DROP SCHEMA alt_nsp1 CASCADE; -- YB: output different due to above commenting out
NOTICE: drop cascades to 22 other objects
DETAIL: drop cascades to function alt_agg2(integer)
drop cascades to function alt_agg3(integer)
drop cascades to function alt_agg4(integer)
drop cascades to function alt_func2(integer)
drop cascades to function alt_func3(integer)
drop cascades to function alt_func4(integer)
drop cascades to operator @+@(integer,integer)
drop cascades to operator @-@(integer,integer)
drop cascades to operator family alt_opc1 for access method hash
drop cascades to operator family alt_opc2 for access method hash
drop cascades to operator family alt_opf3 for access method hash
drop cascades to table alt_regress_1
drop cascades to text search configuration alt_ts_conf2
drop cascades to text search configuration alt_ts_conf3
drop cascades to text search configuration alt_ts_conf4
drop cascades to text search dictionary alt_ts_dict2
drop cascades to text search dictionary alt_ts_dict3
drop cascades to text search dictionary alt_ts_dict4
drop cascades to text search parser alt_ts_prs2
drop cascades to text search parser alt_ts_prs3
drop cascades to text search template alt_ts_temp2
drop cascades to text search template alt_ts_temp3
DROP SCHEMA alt_nsp2 CASCADE; -- YB: output different due to above commenting out
NOTICE: drop cascades to 7 other objects
DROP USER regress_alter_generic_user1; -- YB: fails likely due to above commenting out
DETAIL: drop cascades to function alt_nsp2.alt_func2(integer)
drop cascades to operator alt_nsp2.@-@(integer,integer)
drop cascades to operator family alt_nsp2.alt_opf2 for access method hash
drop cascades to text search configuration alt_nsp2.alt_ts_conf2
drop cascades to text search dictionary alt_nsp2.alt_ts_dict2
drop cascades to text search parser alt_nsp2.alt_ts_prs2
drop cascades to text search template alt_nsp2.alt_ts_temp2
DROP USER regress_alter_generic_user1; -- YB: fails due to above commenting out
ERROR: role "regress_alter_generic_user1" cannot be dropped because some objects depend on it
DETAIL: owner of language alt_lang1
DROP USER regress_alter_generic_user2;
DROP USER regress_alter_generic_user3;
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ SELECT functest_S_14();
2
(1 row)

\set VERBOSITY terse \\ -- YB: suppress cascade details because of ordering
DROP TABLE functest3 CASCADE;
NOTICE: drop cascades to 2 other objects
\set VERBOSITY default \\ -- YB
DETAIL: drop cascades to function functest_s_14()
drop cascades to view functestv3
-- information_schema tests
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
Expand Down Expand Up @@ -540,10 +540,10 @@ SELECT routine_name, table_name FROM information_schema.routine_table_usage

DROP FUNCTION functest_IS_4a CASCADE;
NOTICE: drop cascades to function functest_is_4b(integer)
\set VERBOSITY terse \\ -- YB: suppress cascade details because of ordering
DROP SEQUENCE functest1 CASCADE;
NOTICE: drop cascades to 2 other objects
\set VERBOSITY default \\ -- YB
DETAIL: drop cascades to function functest_is_5(integer)
drop cascades to function functest_is_6()
DROP TABLE functest2 CASCADE;
NOTICE: drop cascades to function functest_is_7()
-- overload
Expand Down Expand Up @@ -573,7 +573,7 @@ STABLE
AS '
SELECT * FROM functest3;
';
SELECT * FROM functest_sri1() ORDER BY functest_sri1; -- YB: add ordering
SELECT * FROM functest_sri1();
functest_sri1
---------------
1
Expand All @@ -594,7 +594,7 @@ STABLE
BEGIN ATOMIC
SELECT * FROM functest3;
END;
SELECT * FROM functest_sri2() ORDER BY functest_sri2; -- YB: add ordering
SELECT * FROM functest_sri2();
functest_sri2
---------------
1
Expand Down Expand Up @@ -653,7 +653,7 @@ SELECT voidtest4(39);

(1 row)

TABLE sometable ORDER BY f1; -- YB: add ordering
TABLE sometable;
f1
----
18
Expand Down Expand Up @@ -708,9 +708,37 @@ CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
AS 'a', 'b';
ERROR: only one AS item needed for language "sql"
-- Cleanup
\set VERBOSITY terse \\ -- YB: suppress cascade details because of ordering
DROP SCHEMA temp_func_test CASCADE;
NOTICE: drop cascades to 30 other objects
\set VERBOSITY default \\ -- YB
DETAIL: drop cascades to function double_append(anyarray,anyelement)
drop cascades to function functest_a_1(text,date)
drop cascades to function functest_a_2(text[])
drop cascades to function functest_a_3()
drop cascades to function functest_b_2(bigint)
drop cascades to function functest_b_2(integer)
drop cascades to function functest_b_3(integer)
drop cascades to function functest_b_4(integer)
drop cascades to function functest_c_1(integer)
drop cascades to function functest_c_2(integer)
drop cascades to function functest_c_3(integer)
drop cascades to function functest_e_1(integer)
drop cascades to function functest_e_2(integer)
drop cascades to function functest_f_1(integer)
drop cascades to function functest_f_2(integer)
drop cascades to function functest_f_3(integer)
drop cascades to function functest_f_4(integer)
drop cascades to function functest_s_1(text,date)
drop cascades to function functest_s_10(text,date)
drop cascades to function functest_s_13()
drop cascades to function functest_s_15(integer)
drop cascades to function functest_s_2(text[])
drop cascades to function functest_s_3()
drop cascades to function functest_s_3a()
drop cascades to function functest_sri1()
drop cascades to function voidtest1(integer)
drop cascades to function voidtest2(integer,integer)
drop cascades to function voidtest3(integer)
drop cascades to function voidtest4(integer)
drop cascades to function voidtest5(integer)
DROP USER regress_unpriv_user;
RESET search_path;
34 changes: 29 additions & 5 deletions src/postgres/src/test/regress/expected/yb_pg_create_type.out
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,25 @@ CREATE FUNCTION base_fn_out(base_type) RETURNS cstring AS 'boolout'
LANGUAGE internal IMMUTABLE STRICT;
NOTICE: argument type base_type is only a shell
CREATE TYPE base_type(INPUT = base_fn_in, OUTPUT = base_fn_out);
\set VERBOSITY terse \\ -- YB: suppress cascade details
DROP FUNCTION base_fn_in(cstring); -- error
ERROR: cannot drop function base_fn_in(cstring) because other objects depend on it
DETAIL: function base_fn_out(base_type) depends on type base_type
type base_type depends on function base_fn_in(cstring)
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP FUNCTION base_fn_out(base_type); -- error
ERROR: cannot drop function base_fn_out(base_type) because other objects depend on it
DETAIL: function base_fn_in(cstring) depends on type base_type
type base_type depends on function base_fn_out(base_type)
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TYPE base_type; -- error
ERROR: cannot drop type base_type because other objects depend on it
DETAIL: function base_fn_in(cstring) depends on type base_type
function base_fn_out(base_type) depends on type base_type
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TYPE base_type CASCADE;
NOTICE: drop cascades to 2 other objects
\set VERBOSITY default \\ -- YB: unsuppress cascade details
DETAIL: drop cascades to function base_fn_in(cstring)
drop cascades to function base_fn_out(base_type)
-- Check usage of typmod with a user-defined type
-- (we have borrowed numeric's typmod functions)
CREATE TEMP TABLE mytab (foo widget(42,13,7)); -- should fail
Expand Down Expand Up @@ -268,7 +277,7 @@ CREATE TABLE city (
INSERT INTO city VALUES
('Podunk', '(1,2),(3,4)', '100,127,1000'),
('Gotham', '(1000,34),(1100,334)', '123456,127,-1000,6789');
TABLE city ORDER BY name DESC; -- YB-added ordering
TABLE city;
name | location | budget
--------+----------------------+-----------------------
Podunk | (3,4),(1,2) | 100,127,1000,0
Expand Down Expand Up @@ -348,11 +357,26 @@ FROM pg_type WHERE typname = '_myvarchardom';
(1 row)

-- ensure dependencies are straight
\set VERBOSITY terse \\ -- YB: suppress cascade details
DROP FUNCTION myvarcharsend(myvarchar); -- fail
ERROR: cannot drop function myvarcharsend(myvarchar) because other objects depend on it
DETAIL: function myvarcharin(cstring,oid,integer) depends on type myvarchar
function myvarcharout(myvarchar) depends on type myvarchar
function myvarcharrecv(internal,oid,integer) depends on type myvarchar
type myvarchar depends on function myvarcharsend(myvarchar)
type myvarchardom depends on function myvarcharsend(myvarchar)
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TYPE myvarchar; -- fail
ERROR: cannot drop type myvarchar because other objects depend on it
DETAIL: function myvarcharin(cstring,oid,integer) depends on type myvarchar
function myvarcharout(myvarchar) depends on type myvarchar
function myvarcharrecv(internal,oid,integer) depends on type myvarchar
function myvarcharsend(myvarchar) depends on type myvarchar
type myvarchardom depends on type myvarchar
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TYPE myvarchar CASCADE;
NOTICE: drop cascades to 5 other objects
\set VERBOSITY default \\ -- YB: unsuppress cascade details
DETAIL: drop cascades to function myvarcharin(cstring,oid,integer)
drop cascades to function myvarcharout(myvarchar)
drop cascades to function myvarcharrecv(internal,oid,integer)
drop cascades to function myvarcharsend(myvarchar)
drop cascades to type myvarchardom
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ insert into cities values ('Las Vegas', 2.583E+5, 2174) on conflict do nothing;
-- Wrong "Sacramento", so do nothing:
-- insert into capitals values ('Sacramento', 50, 2267, 'NE') on conflict (name) do nothing;
-- select * from capitals;
with ybtmp as (delete from cities where name = 'Las Vegas' returning *)
insert into cities select * from ybtmp; -- YB: imitate PG ctid reallocation for the following update
insert into cities values ('Las Vegas', 5.83E+5, 2001) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude;
select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
select tableoid::regclass, * from cities;
tableoid | name | population | altitude
----------+---------------+------------+----------
cities | San Francisco | 724000 | 63
Expand All @@ -543,7 +545,7 @@ select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
-- select * from capitals;
-- Cities contains two instances of "Las Vegas", since unique constraints don't
-- work across inheritance:
select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
select tableoid::regclass, * from cities;
tableoid | name | population | altitude
----------+---------------+------------+----------
cities | San Francisco | 724000 | 63
Expand All @@ -553,7 +555,7 @@ select tableoid::regclass, * from cities order by altitude; -- YB: add ordering

-- This only affects "cities" version of "Las Vegas":
insert into cities values ('Las Vegas', 5.86E+5, 2223) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude;
select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
select tableoid::regclass, * from cities;
tableoid | name | population | altitude
----------+---------------+------------+----------
cities | San Francisco | 724000 | 63
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ insert into cities values ('Las Vegas', 2.583E+5, 2174) on conflict do nothing;
-- Wrong "Sacramento", so do nothing:
-- insert into capitals values ('Sacramento', 50, 2267, 'NE') on conflict (name) do nothing;
-- select * from capitals;
with ybtmp as (delete from cities where name = 'Las Vegas' returning *)
insert into cities select * from ybtmp; -- YB: imitate PG ctid reallocation for the following update
insert into cities values ('Las Vegas', 5.83E+5, 2001) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude;
select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
select tableoid::regclass, * from cities;
tableoid | name | population | altitude
----------+---------------+------------+----------
cities | San Francisco | 724000 | 63
Expand All @@ -543,7 +545,7 @@ select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
-- select * from capitals;
-- Cities contains two instances of "Las Vegas", since unique constraints don't
-- work across inheritance:
select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
select tableoid::regclass, * from cities;
tableoid | name | population | altitude
----------+---------------+------------+----------
cities | San Francisco | 724000 | 63
Expand All @@ -553,7 +555,7 @@ select tableoid::regclass, * from cities order by altitude; -- YB: add ordering

-- This only affects "cities" version of "Las Vegas":
insert into cities values ('Las Vegas', 5.86E+5, 2223) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude;
select tableoid::regclass, * from cities order by altitude; -- YB: add ordering
select tableoid::regclass, * from cities;
tableoid | name | population | altitude
----------+---------------+------------+----------
cities | San Francisco | 724000 | 63
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src/test/regress/expected/yb_pg_misc.out
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
-- joe and sally play basketball, and
-- everyone else does nothing.
--
SELECT p.name, name(p.hobbies) FROM ONLY person p ORDER BY 2 DESC, 1; -- YB: add ordering
SELECT p.name, name(p.hobbies) FROM ONLY person p;
name | name
-------+-------------
mike | posthacking
Expand Down Expand Up @@ -250,7 +250,7 @@ SELECT name(equipment_named_ambiguous_2a(text 'skywalking'));
guts
(1 row)

SELECT name(equipment_named_ambiguous_2b(text 'skywalking')) ORDER BY substr(name(equipment_named_ambiguous_2b(text 'skywalking')), 2, 1); -- YB: add ordering
SELECT name(equipment_named_ambiguous_2b(text 'skywalking'));
name
---------------
advil
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src/test/regress/expected/yb_pg_namespace.out
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ SELECT COUNT(*) FROM pg_class WHERE relnamespace =
INSERT INTO test_ns_schema_1.abc DEFAULT VALUES;
INSERT INTO test_ns_schema_1.abc DEFAULT VALUES;
INSERT INTO test_ns_schema_1.abc DEFAULT VALUES;
SELECT * FROM test_ns_schema_1.abc ORDER BY a; -- YB: add ordering
SELECT * FROM test_ns_schema_1.abc;
a | b
---+---
1 |
2 |
3 |
(3 rows)

SELECT * FROM test_ns_schema_1.abc_view ORDER BY a; -- YB: add ordering
SELECT * FROM test_ns_schema_1.abc_view;
a | b
---+---
2 |
Expand Down
Loading

0 comments on commit 4f17a04

Please sign in to comment.