8000 Add TAP testcase for pg-1401. by Naeem-Akhter · Pull Request #9 · Naeem-Akhter/percona-postgres · GitHub
[go: up one dir, main page]

Skip to content

Add TAP testcase for pg-1401. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: TDE_REL_17_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions contrib/pg_tde/t/expected/pg_1401.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
CREATE EXTENSION IF NOT EXISTS pg_tde;
SELECT pg_tde_add_global_key_provider_file('file-keyring-pg-1401','/tmp/pg_tde_test_pg1401.per');
pg_tde_add_global_key_provider_file
-------------------------------------
-1
(1 row)

SELECT pg_tde_set_key_using_global_key_provider('server-key', 'file-keyring-pg-1401');
pg_tde_set_key_using_global_key_provider
------------------------------------------

(1 row)

CREATE TABLE t1 (id SERIAL PRIMARY KEY,name VARCHAR(100),t2_id INT) using tde_heap;
INSERT INTO t1(name) VALUES ('John'),('Mark');
SELECT * FROM t1;
id | name | t2_id
----+------+-------
1 | John |
2 | Mark |
(2 rows)

ALTER TABLE t1 SET ACCESS METHOD heap;
SELECT * FROM t1;
id | name | t2_id
----+------+-------
1 | John |
2 | Mark |
(2 rows)

-- Update postgresql.conf, remove pg_tde from shared_preload_libraries
-- server restart
SELECT * FROM t1;
id | name | t2_id
----+------+-------
1 | John |
2 | Mark |
(2 rows)

DROP TABLE t1;
DROP EXTENSION pg_tde;
39 changes: 39 additions & 0 deletions contrib/pg_tde/t/expected/pg_1480.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CREATE DATABASE testdb;
CREATE EXTENSION IF NOT EXISTS pg_tde;
CREATE EXTENSION IF NOT EXISTS pg_tde;
SELECT pg_tde_add_global_key_provider_file('global_keyring','/tmp/pg_tde_test_pg1480.per');
pg_tde_add_global_key_provider_file
-------------------------------------
-1
(1 row)

SELECT pg_tde_set_default_key_using_global_key_provider('principal_key_of_testdb', 'global_keyring');
pg_tde_set_default_key_using_global_key_provider
--------------------------------------------------

(1 row)

CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR) USING tde_heap;
INSERT INTO t1 VALUES(101, 'James Bond');
SELECT pg_tde_set_default_key_using_global_key_provider('principal_key_of_testdb2', 'global_keyring');
pg_tde_set_default_key_using_global_key_provider
--------------------------------------------------

(1 row)

SELECT * FROM t1;
a | b
-----+------------
101 | James Bond
(1 row)

-- server restart
SELECT * FROM t1;
a | b
-----+------------
101 | James Bond
(1 row)

DROP TABLE t1;
DROP EXTENSION pg_tde;
DROP EXTENSION pg_tde;
73 changes: 73 additions & 0 deletions contrib/pg_tde/t/pg_1401.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/perl

use strict;
use warnings;
use File::Basename;
use Test::More;
use lib 't';
use pgtde;

PGTDE::setup_files_dir(basename($0));

my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
$node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_tde'");
$node->start;

PGTDE::psql($node, 'postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;');

PGTDE::psql($node, 'postgres',
"SELECT pg_tde_add_global_key_provider_file('file-keyring-pg-1401','/tmp/pg_tde_test_pg1401.per');"
);

PGTDE::psql($node, 'postgres',
"SELECT pg_tde_set_key_using_global_key_provider('server-key', 'file-keyring-pg-1401');"
);

PGTDE::psql($node, 'postgres',
'CREATE TABLE t1 (id SERIAL PRIMARY KEY,name VARCHAR(100),t2_id INT) using tde_heap;'
);

PGTDE::psql($node, 'postgres',
"INSERT INTO t1(name) VALUES ('John'),('Mark');"
);

#Query the table
PGTDE::psql($node, 'postgres',
"SELECT * FROM t1;"
);

#Change table access method to heap
PGTDE::psql($node, 'postgres',
"ALTER TABLE t1 SET ACCESS METHOD heap;"
);

#Query the table
PGTDE::psql($node, 'postgres',
"SELECT * FROM t1;"
);

PGTDE::append_to_result_file("-- Update postgresql.conf, remove pg_tde from shared_preload_libraries");
$node->adjust_conf('postgresql.conf', "shared_preload_libraries', ''");

PGTDE::append_to_result_file("-- server restart");
$node->restart;

#Query the table
PGTDE::psql($node, 'postgres',
"SELECT * FROM t1;"
);

PGTDE::psql($node, 'postgres', 'DROP TABLE t1;');
PGTDE::psql($node, 'postgres', 'DROP EXTENSION pg_tde;');

$node->stop;

# Compare the expected and out file
my $compare = PGTDE->compare_results();

is($compare, 0,
"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."
);

done_testing();
Loading
Loading
0