@@ -16,6 +16,11 @@ def pgcat_start():
16
16
os .system ("./target/debug/pgcat .circleci/pgcat.toml &" )
17
17
time .sleep (2 )
18
18
19
+ def pgcat_trust_start ():
20
+ pg_cat_send_signal (signal .SIGTERM )
21
+ os .system ("./target/debug/pgcat .circleci/pgcat_trust.toml &" )
22
+ time .sleep (2 )
23
+
19
24
20
25
def pg_cat_send_signal (signal : signal .Signals ):
21
26
try :
@@ -33,6 +38,28 @@ def pg_cat_send_signal(signal: signal.Signals):
33
38
raise Exception ("pgcat not closed after SIGTERM" )
34
39
35
40
41
+ def connect_db_trust (
42
+ autocommit : bool = True ,
43
+ admin : bool = False ,
44
+ ) -> Tuple [psycopg2 .extensions .connection , psycopg2 .extensions .cursor ]:
45
+
46
+ if admin :
47
+ user = "admin_user"
48
+ db = "pgcat"
49
+ else :
50
+ user = "sharding_user"
51
+ db = "sharded_db"
52
+
53
+ conn = psycopg2 .connect (
54
+ f"postgres://{ user } :@{ PGCAT_HOST } :{ PGCAT_PORT } /{ db } ?application_name=testing_pgcat" ,
55
+ connect_timeout = 2 ,
56
+ )
57
+ conn .autocommit = autocommit
58
+ cur = conn .cursor ()
59
+
60
+ return (conn , cur )
61
+
62
+
36
63
def connect_db (
37
64
autocommit : bool = True ,
38
65
admin : bool = False ,
@@ -62,6 +89,29 @@ def cleanup_conn(conn: psycopg2.extensions.connection, cur: psycopg2.extensions.
62
89
conn .close ()
63
90
64
91
92
+ def test_admin_trust_auth ():
93
+ conn , cur = connect_db_trust (admin = True )
94
+ cur .execute ("SHOW POOLS" )
95
+ res = cur .fetchall ()
96
+ print (res )
97
+ cleanup_conn (conn , cur )
98
+
99
+
100
+ def test_normal_trust_auth ():
101
+ conn , cur = connect_db_trust (autocommit = False )
102
+ cur .execute ("SELECT 1" )
103
+ res = cur .fetchall ()
104
+ print (res )
105
+ cleanup_conn (conn , cur )
106
+
107
+
108
+ def test_trust ():
109
+ pgcat_trust_start ()
110
+ test_admin_trust_auth ()
111
+ test_normal_trust_auth ()
112
+ pg_cat_send_signal (signal .SIGTERM )
113
+
114
+
65
115
def test_normal_db_access ():
66
116
pgcat_start ()
67
117
conn , cur = connect_db (autocommit = False )
@@ -71,6 +121,7 @@ def test_normal_db_access():
71
121
cleanup_conn (conn , cur )
72
122
73
123
124
+
74
125
def test_admin_db_access ():
75
126
conn , cur = connect_db (admin = True )
76
127
@@ -317,3 +368,5 @@ def test_shutdown_logic():
317
368
test_normal_db_access ()
318
369
test_admin_db_access ()
319
370
test_shutdown_logic ()
371
+
372
+ test_trust ()
0 commit comments