Skip to content

Commit

Permalink
PG-979: Run SQL tests with both tde_heap and tde_heap_basic
Browse files Browse the repository at this point in the history
  • Loading branch information
dutow committed Oct 2, 2024
1 parent ae29fd7 commit 93f24e3
Show file tree
Hide file tree
Showing 69 changed files with 4,016 additions and 2,403 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ __pycache__
/Makefile
/autom4te.cache
/configure~
t/results
26 changes: 13 additions & 13 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ EXTENSION = pg_tde
DATA = pg_tde--1.0.sql

REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_tde/pg_tde.conf
REGRESS = toast_decrypt \
toast_extended_storage \
move_large_tuples \
non_sorted_off_compact \
update_compare_indexes \
pg_tde_is_encrypted \
test_issue_153_fix \
multi_insert \
trigger_on_view \
change_access_method \
insert_update_delete \
keyprovider_dependency \
vault_v2_test
REGRESS = toast_decrypt_basic \
toast_extended_storage_basic \
move_large_tuples_basic \
non_sorted_off_compact_basic \
update_compare_indexes_basic \
pg_tde_is_encrypted_basic \
test_issue_153_fix_basic \
multi_insert_basic \
trigger_on_view_basic \
change_access_method_basic \
insert_update_delete_basic \
keyprovider_dependency_basic \
vault_v2_test_basic
TAP_TESTS = 1

OBJS = src/encryption/enc_tde.o \
Expand Down
10 changes: 6 additions & 4 deletions expected/change_access_method.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
\set tde_am tde_heap
\i sql/change_access_method.inc
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');
pg_tde_add_key_provider_file
Expand All @@ -11,13 +13,13 @@ SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault');
t
(1 row)

CREATE TABLE country_table (
CREATE TABLE country_table (
country_id serial primary key,
country_name text unique not null,
continent text not null
) using tde_heap_basic;
) using :tde_am;

INSERT INTO country_table (country_name, continent)
INSERT INTO country_table (country_name, continent)
VALUES ('Japan', 'Asia'),
('UK', 'Europe'),
('USA', 'North America');
Expand Down Expand Up @@ -60,7 +62,7 @@ SELECT pg_tde_is_encrypted('country_table');
(1 row)

-- Change it back to encrypted
ALTER TABLE country_table SET access method tde_heap_basic;
ALTER TABLE country_table SET access method :tde_am;
INSERT INTO country_table (country_name, continent)
VALUES ('China', 'Asia'),
('Brazil', 'South America'),
Expand Down
91 changes: 91 additions & 0 deletions expected/change_access_method_basic.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
\set tde_am tde_heap_basic
\i sql/change_access_method.inc
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');
pg_tde_add_key_provider_file
------------------------------
1
(1 row)

SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault');
pg_tde_set_principal_key
--------------------------
t
(1 row)

CREATE TABLE country_table (
country_id serial primary key,
country_name text unique not null,
continent text not null
) using :tde_am;

INSERT INTO country_table (country_name, continent)
VALUES ('Japan', 'Asia'),
('UK', 'Europe'),
('USA', 'North America');
SELECT * FROM country_table;
country_id | country_name | continent
------------+--------------+---------------
1 | Japan | Asia
2 | UK | Europe
3 | USA | North America
(3 rows)

SELECT pg_tde_is_encrypted('country_table');
pg_tde_is_encrypted
---------------------
t
(1 row)

-- Try changing the encrypted table to an unencrypted table
ALTER TABLE country_table SET access method heap;
-- Insert some more data
INSERT INTO country_table (country_name, continent)
VALUES ('France', 'Europe'),
('Germany', 'Europe'),
('Canada', 'North America');
SELECT * FROM country_table;
country_id | country_name | continent
------------+--------------+---------------
1 | Japan | Asia
2 | UK | Europe
3 | USA | North America
4 | France | Europe
5 | Germany | Europe
6 | Canada | North America
(6 rows)

SELECT pg_tde_is_encrypted('country_table');
pg_tde_is_encrypted
---------------------
f
(1 row)

-- Change it back to encrypted
ALTER TABLE country_table SET access method :tde_am;
INSERT INTO country_table (country_name, continent)
VALUES ('China', 'Asia'),
('Brazil', 'South America'),
('Australia', 'Oceania');
SELECT * FROM country_table;
country_id | country_name | continent
------------+--------------+---------------
1 | Japan | Asia
2 | UK | Europe
3 | USA | North America
4 | France | Europe
5 | Germany | Europe
6 | Canada | North America
7 | China | Asia
8 | Brazil | South America
9 | Australia | Oceania
(9 rows)

SELECT pg_tde_is_encrypted('country_table');
pg_tde_is_encrypted
---------------------
t
(1 row)

DROP TABLE country_table;
DROP EXTENSION pg_tde;
4 changes: 3 additions & 1 deletion expected/insert_update_delete.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
\set tde_am tde_heap
\i sql/insert_update_delete.inc
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');
pg_tde_add_key_provider_file
Expand All @@ -16,7 +18,7 @@ CREATE TABLE albums (
artist VARCHAR(256),
title TEXT NOT NULL,
released DATE NOT NULL
) USING tde_heap_basic;
) USING :tde_am;
INSERT INTO albums (artist, title, released) VALUES
('Graindelavoix', 'Jisquin The Undead', '2021-06-12'),
('Graindelavoix', 'Tenebrae Responsoria - Carlo Gesualdo', '2019-08-06'),
Expand Down
96 changes: 96 additions & 0 deletions expected/insert_update_delete_basic.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
\set tde_am tde_heap_basic
\i sql/insert_update_delete.inc
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');
pg_tde_add_key_provider_file
------------------------------
1
(1 row)

SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault');
pg_tde_set_principal_key
--------------------------
t
(1 row)

CREATE TABLE albums (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
artist VARCHAR(256),
title TEXT NOT NULL,
released DATE NOT NULL
) USING :tde_am;
INSERT INTO albums (artist, title, released) VALUES
('Graindelavoix', 'Jisquin The Undead', '2021-06-12'),
('Graindelavoix', 'Tenebrae Responsoria - Carlo Gesualdo', '2019-08-06'),
('Graindelavoix', 'Cypriot Vespers', '2015-12-20'),
('John Coltrane', 'Blue Train', '1957-09-15'),
('V/A Analog Africa', 'Space Echo - The Mystery Behind the Cosmic Sound of Cabo Verde Finally Revealed', '2016-05-27'),
('Incapacitants', 'As Loud As Possible', '2022-09-15'),
('Chris Corsano & Bill Orcutt', 'Made Out Of Sound', '2021-03-26'),
('Jürg Frey (Quatuor Bozzini / Konus Quartett)', 'Continuit​é​, fragilit​é​, r​é​sonance', '2023-04-01'),
('clipping.', 'Visions of Bodies Being Burned', '2020-10-23'),
('clipping.', 'There Existed an Addiction to Blood', '2019-10-19'),
('Autechre', 'elseq 1–5', '2016-05-19'),
('Decapitated', 'Winds of Creation', '2000-04-17'),
('Ulthar', 'Anthronomicon', '2023-02-17'),
('Τζίμης Πανούσης', 'Κάγκελα Παντού', '1986-01-01'),
('Воплі Відоплясова', 'Музіка', '1997-01-01');
SELECT * FROM albums;
id | artist | title | released
----+----------------------------------------------+---------------------------------------------------------------------------------+------------
1 | Graindelavoix | Jisquin The Undead | 06-12-2021
2 | Graindelavoix | Tenebrae Responsoria - Carlo Gesualdo | 08-06-2019
3 | Graindelavoix | Cypriot Vespers | 12-20-2015
4 | John Coltrane | Blue Train | 09-15-1957
5 | V/A Analog Africa | Space Echo - The Mystery Behind the Cosmic Sound of Cabo Verde Finally Revealed | 05-27-2016
6 | Incapacitants | As Loud As Possible | 09-15-2022
7 | Chris Corsano & Bill Orcutt | Made Out Of Sound | 03-26-2021
8 | Jürg Frey (Quatuor Bozzini / Konus Quartett) | Continuit​é​, fragilit​é​, r​é​sonance | 04-01-2023
9 | clipping. | Visions of Bodies Being Burned | 10-23-2020
10 | clipping. | There Existed an Addiction to Blood | 10-19-2019
11 | Autechre | elseq 1–5 | 05-19-2016
12 | Decapitated | Winds of Creation | 04-17-2000
13 | Ulthar | Anthronomicon | 02-17-2023
14 | Τζίμης Πανούσης | Κάγκελα Παντού | 01-01-1986
15 | Воплі Відоплясова | Музіка | 01-01-1997
(15 rows)

DELETE FROM albums WHERE id % 4 = 0;
SELECT * FROM albums;
id | artist | title | released
----+-----------------------------+---------------------------------------------------------------------------------+------------
1 | Graindelavoix | Jisquin The Undead | 06-12-2021
2 | Graindelavoix | Tenebrae Responsoria - Carlo Gesualdo | 08-06-2019
3 | Graindelavoix | Cypriot Vespers | 12-20-2015
5 | V/A Analog Africa | Space Echo - The Mystery Behind the Cosmic Sound of Cabo Verde Finally Revealed | 05-27-2016
6 | Incapacitants | As Loud As Possible | 09-15-2022
7 | Chris Corsano & Bill Orcutt | Made Out Of Sound | 03-26-2021
9 | clipping. | Visions of Bodies Being Burned | 10-23-2020
10 | clipping. | There Existed an Addiction to Blood | 10-19-2019
11 | Autechre | elseq 1–5 | 05-19-2016
13 | Ulthar | Anthronomicon | 02-17-2023
14 | Τζίμης Πανούσης | Κάγκελα Παντού | 01-01-1986
15 | Воплі Відоплясова | Музіка | 01-01-1997
(12 rows)

UPDATE albums SET title='Jisquin The Undead: Laments, Deplorations and Dances of Death', released='2021-10-01' WHERE id=1;
UPDATE albums SET released='2020-04-01' WHERE id=2;
SELECT * FROM albums;
id | artist | title | released
----+-----------------------------+---------------------------------------------------------------------------------+------------
3 | Graindelavoix | Cypriot Vespers | 12-20-2015
5 | V/A Analog Africa | Space Echo - The Mystery Behind the Cosmic Sound of Cabo Verde Finally Revealed | 05-27-2016
6 | Incapacitants | As Loud As Possible | 09-15-2022
7 | Chris Corsano & Bill Orcutt | Made Out Of Sound | 03-26-2021
9 | clipping. | Visions of Bodies Being Burned | 10-23-2020
10 | clipping. | There Existed an Addiction to Blood | 10-19-2019
11 | Autechre | elseq 1–5 | 05-19-2016
13 | Ulthar | Anthronomicon | 02-17-2023
14 | Τζίμης Πανούσης | Κάγκελα Παντού | 01-01-1986
15 | Воплі Відоплясова | Музіка | 01-01-1997
1 | Graindelavoix | Jisquin The Undead: Laments, Deplorations and Dances of Death | 10-01-2021
2 | Graindelavoix | Tenebrae Responsoria - Carlo Gesualdo | 04-01-2020
(12 rows)

DROP TABLE albums;
DROP EXTENSION pg_tde;
2 changes: 2 additions & 0 deletions expected/keyprovider_dependency.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
\set tde_am tde_heap
\i sql/keyprovider_dependency.inc
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('mk-file','/tmp/pg_tde_test_keyring.per');
pg_tde_add_key_provider_file
Expand Down
36 changes: 36 additions & 0 deletions expected/keyprovider_dependency_basic.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
\set tde_am tde_heap_basic
\i sql/keyprovider_dependency.inc
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('mk-file','/tmp/pg_tde_test_keyring.per');
pg_tde_add_key_provider_file
------------------------------
1
(1 row)

SELECT pg_tde_add_key_provider_file('free-file','/tmp/pg_tde_test_keyring_2.per');
pg_tde_add_key_provider_file
------------------------------
2
(1 row)

SELECT pg_tde_add_key_provider_vault_v2('V2-vault','vault-token','percona.com/vault-v2/percona','/mount/dev','ca-cert-auth');
pg_tde_add_key_provider_vault_v2
----------------------------------
3
(1 row)

SELECT * FROM pg_tde_list_all_key_providers();
id | provider_name | provider_type | options
----+---------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------
1 | mk-file | file | {"type" : "file", "path" : "/tmp/pg_tde_test_keyring.per"}
2 | free-file | file | {"type" : "file", "path" : "/tmp/pg_tde_test_keyring_2.per"}
3 | V2-vault | vault-v2 | {"type" : "vault-v2", "url" : "percona.com/vault-v2/percona", "token" : "vault-token", "mountPath" : "/mount/dev", "caPath" : "ca-cert-auth"}
(3 rows)

SELECT pg_tde_set_principal_key('test-db-principal-key','mk-file');
pg_tde_set_principal_key
--------------------------
t
(1 row)

DROP EXTENSION pg_tde;
4 changes: 3 additions & 1 deletion expected/move_large_tuples.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
\set tde_am tde_heap
\i sql/move_large_tuples.inc
-- test pg_tde_move_encrypted_data()
CREATE EXTENSION pg_tde;
SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');
Expand All @@ -16,7 +18,7 @@ CREATE TABLE sbtest2(
id SERIAL,
k TEXT STORAGE PLAIN,
PRIMARY KEY (id)
) USING tde_heap_basic;
) USING :tde_am;
INSERT INTO sbtest2(k) VALUES(repeat('a', 2500));
INSERT INTO sbtest2(k) VALUES(repeat('b', 2500));
INSERT INTO sbtest2(k) VALUES(repeat('c', 2500));
Expand Down
Loading

0 comments on commit 93f24e3

Please sign in to comment.