Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit389a262

Browse files
authored
Add proper routine with users over --config-auth (#67)
Windows requires sspi user authentification. We needuse some specific configurations for tests so that testswork the same on different types of systems, including Windows.
1 parentadea69f commit389a262

File tree

1 file changed

+104
-40
lines changed

1 file changed

+104
-40
lines changed

‎t/001_bad_progress_bar.pl‎

Lines changed: 104 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,8 @@
1313
# 2) extracting the state of the process itself
1414

1515
my$node;
16-
my$dbh_status;
17-
my$pid_status;
18-
19-
subbad_pid
20-
{
21-
note('Extracting from bad pid');
22-
my$stderr;
23-
$node->psql('postgres','SELECT * from pg_progress_bar(-1)',stderr=> \$stderr);
24-
is ($stderr,'psql:<stdin>:1: ERROR: backend with pid=-1 not found',"appealing to a bad pid for pg_progress_bar");
25-
$node->psql('postgres','SELECT * from pg_progress_bar(-1)_visual',stderr=> \$stderr);
26-
is ($stderr,'psql:<stdin>:1: ERROR: backend with pid=-1 not found',"appealing to a bad pid for pg_progress_bar_visual");
27-
}
28-
29-
subself_status
30-
{
31-
note('Extracting your own status');
32-
$dbh_status->do('SELECT * from pg_progress_bar(' .$pid_status .')');
33-
is($dbh_status->errstr,'ERROR: attempt to extract state of current process',"extracting the state of the process itself for pg_progress_bar");
34-
$dbh_status->do('SELECT * from pg_progress_bar_visual(' .$pid_status .')');
35-
is($dbh_status->errstr,'ERROR: attempt to extract state of current process',"extracting the state of the process itself for pg_progress_bar_visual");
36-
}
37-
38-
# start backend for function pg_progress_bar
3916

17+
# modules depend on the PostgreSQL version
4018
my$pg_15_modules;
4119

4220
BEGIN
@@ -68,11 +46,95 @@ BEGIN
6846
$node = PostgresNode->get_new_node("master");
6947
}
7048

71-
$node->init;
49+
# start backend for function pg_progress_bar
50+
my$dbh_status;
51+
my$pid_status;
52+
53+
# this code exists only because of problems
54+
# with authentification in Windows
55+
#
56+
# in a friendlier system it would be enough to do:
57+
#
58+
# $node->init;
59+
# $node->start;
60+
# $node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_query_state'");
61+
# $node->restart;
62+
# $node->psql('postgres', 'CREATE EXTENSION pg_query_state;');
63+
#
64+
# but now we will carefully configure the work
65+
# for specific users and databases
66+
# -----------------------------------------------------------
67+
$ENV{LC_ALL} ='C';
68+
$ENV{PGCLIENTENCODING} ='LATIN1';
69+
70+
my$dbname1 ='regression_bad_progress_bar';
71+
my$username1 =$dbname1;
72+
my$src_bootstrap_super ='regress_postgres';
73+
74+
$node->init(
75+
extra=> [
76+
'--username'=>$src_bootstrap_super,
77+
'--locale'=>'C',
78+
'--encoding'=>'LATIN1',
79+
]);
80+
81+
# update pg_hba.conf and pg_ident.conf
82+
# for sppi-authentification in Windows
83+
$node->run_log(
84+
[
85+
$ENV{PG_REGRESS},
86+
'--config-auth'=>$node->data_dir,
87+
'--user'=>$src_bootstrap_super,
88+
'--create-role'=>"$username1",
89+
]);
90+
7291
$node->start;
92+
93+
# create test user and test database
94+
$node->run_log(
95+
['createdb','--username'=>$src_bootstrap_super,$dbname1 ]);
96+
$node->run_log(
97+
[
98+
'createuser',
99+
'--username'=>$src_bootstrap_super,
100+
'--superuser',
101+
$username1,
102+
]);
103+
73104
$node->append_conf('postgresql.conf',"shared_preload_libraries = 'pg_query_state'");
74105
$node->restart;
75-
$node->psql('postgres','CREATE EXTENSION pg_query_state;');
106+
107+
# now we are ready to create extension pg_query_state
108+
# we perform this and following actions under the
109+
# created test user and on the test database
110+
$node->psql($dbname1,'CREATE EXTENSION pg_query_state;',
111+
extra_params=> ['-U',$username1]);
112+
# -----------------------------------------------------------
113+
114+
subbad_pid
115+
{
116+
note('Extracting from bad pid');
117+
my$stderr;
118+
$node->psql($dbname1,'SELECT * from pg_progress_bar(-1)',
119+
stderr=> \$stderr,extra_params=> ['-U',$username1]);
120+
is ($stderr,'psql:<stdin>:1: ERROR: backend with pid=-1 not found',
121+
"appealing to a bad pid for pg_progress_bar");
122+
$node->psql($dbname1,'SELECT * from pg_progress_bar(-1)_visual',
123+
stderr=> \$stderr,extra_params=> ['-U',$username1]);
124+
is ($stderr,'psql:<stdin>:1: ERROR: backend with pid=-1 not found',
125+
"appealing to a bad pid for pg_progress_bar_visual");
126+
}
127+
128+
subself_status
129+
{
130+
note('Extracting your own status');
131+
$dbh_status->do('SELECT * from pg_progress_bar(' .$pid_status .')');
132+
is($dbh_status->errstr,'ERROR: attempt to extract state of current process',
133+
"extracting the state of the process itself for pg_progress_bar");
134+
$dbh_status->do('SELECT * from pg_progress_bar_visual(' .$pid_status .')');
135+
is($dbh_status->errstr,'ERROR: attempt to extract state of current process',
136+
"extracting the state of the process itself for pg_progress_bar_visual");
137+
}
76138

77139
# 2 tests for 1 case
78140
bad_pid();
@@ -81,34 +143,36 @@ BEGIN
81143

82144
my$dbdpg_rc =eval
83145
{
84-
require DBI;
85-
require DBD::Pg;
86-
1;
146+
require DBI;
147+
require DBD::Pg;
148+
1;
87149
};
88150

89151
$dbdpg_rc = 0unlessdefined$dbdpg_rc;
90152

91153
if ($dbdpg_rc != 1)
92154
{
93-
diag('DBI and DBD::Pg are not available, skip 2/4 tests');
155+
diag('DBI and DBD::Pg are not available, skip 2/4 tests');
94156
}
95157

96158
SKIP: {
97-
skip"DBI and DBD::Pg are not available", 2if ($dbdpg_rc != 1);
159+
skip"DBI and DBD::Pg are not available", 2if ($dbdpg_rc != 1);
160+
161+
DBD::Pg->import(':async');
98162

99-
DBD::Pg->import(':async');
100-
$dbh_status = DBI->connect('DBI:Pg:' .$node->connstr('postgres'));
101-
if ( !defined$dbh_status )
102-
{
103-
die"Cannot connect to database for dbh with pg_progress_bar\n";
104-
}
163+
# connect to test database under the test user
164+
$dbh_status = DBI->connect('DBI:Pg:' .$node->connstr() ." user=$username1" ." dbname=$dbname1");
165+
if ( !defined$dbh_status )
166+
{
167+
die"Cannot connect to database for dbh with pg_progress_bar\n";
168+
}
105169

106-
$pid_status =$dbh_status->{pg_pid};
170+
$pid_status =$dbh_status->{pg_pid};
107171

108-
# 2 tests for 2 case
109-
self_status();
172+
# 2 tests for 2 case
173+
self_status();
110174

111-
$dbh_status->disconnect;
175+
$dbh_status->disconnect;
112176
}
113177

114178
$node->stop('fast');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp