1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
use strict;
use warnings;
use Cwd;
use Config;
use TestLib;
use Test::More tests => 1;
my $dataDirRoot="~/DATA/pgxl/nodes/";
$ENV{'PGXC_CTL_HOME'} = '/tmp/pgxc_ctl';
my $PGXC_CTL_HOME=$ENV{'PGXC_CTL_HOME'};
#delete related dirs for cleanup
system("rm -rf $dataDirRoot");
system("rm -rf $PGXC_CTL_HOME");
my $DEFAULT_DB="postgres";
my $TEST_DB="testdb";
my $COORD1_PORT=30001;
system_or_bail 'pgxc_ctl', 'prepare', 'minimal' ;
system_or_bail 'pgxc_ctl', 'init', 'all' ;
system_or_bail 'pgxc_ctl', 'monitor', 'all' ;
system_or_bail 'psql', '-p', "$COORD1_PORT", "$DEFAULT_DB",'-c', "CREATE DATABASE testdb;";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "CREATE TABLE ana1(col1 int, col2 text default 'ana1');";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "insert into ana1 select generate_series(1, 10000);";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "CREATE TABLE ana2(col1 int, col2 text default 'ana2');";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "insert into ana2 select generate_series(1, 10000);";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "CREATE TABLE ana3(col1 int, col2 text default 'ana3');";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "insert into ana3 select generate_series(1, 10000);";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "CREATE TABLE ana4(col1 int, col2 text default 'ana4');";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "insert into ana4 select generate_series(1, 10000);";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "CREATE TABLE ana5(col1 int, col2 text default 'ana5');";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "insert into ana5 select generate_series(1, 10000);";
# 30 jobs of anaylze running in parallel
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
system("psql -p 30001 testdb -f t/analyze_verbose.sql --echo-all --set AUTOCOMMIT=off &");
command_ok([ 'psql', '-p', "$COORD1_PORT", "$TEST_DB", '-c', "analyze verbose;" ], 'analyze verbose ');
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "select pg_sleep(5);";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "DROP TABLE ana1;";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "DROP TABLE ana2;";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "DROP TABLE ana3;";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "DROP TABLE ana4;";
system_or_bail 'psql', '-p', "$COORD1_PORT", "$TEST_DB",'-c', "DROP TABLE ana5;";
#add cleanup
system_or_bail 'pgxc_ctl', 'clean', 'all' ;
#delete related dirs for cleanup
system("rm -rf $dataDirRoot");
system("rm -rf $PGXC_CTL_HOME");
|