|
43 | 43 |
|
44 | 44 | sleep(5); # Wait until failure of node will be detected
|
45 | 45 |
|
46 |
| -my $ret = $cluster->psql(0, 'postgres', "insert into t values(4, 40);"); |
| 46 | +diag("inserting 2 on node 1"); |
| 47 | +my $ret = $cluster->psql(0, 'postgres', "insert into t values(2, 20);"); # this transaciton may fail |
47 | 48 | diag "tx1 status = $ret";
|
48 | 49 |
|
49 |
| -diag("inserting 2"); |
50 |
| -my $ret = $cluster->psql(0, 'postgres', "insert into t values(2, 20);"); |
| 50 | +diag("inserting 3 on node 2"); |
| 51 | +my $ret = $cluster->psql(1, 'postgres', "insert into t values(3, 30);"); # this transaciton may fail |
| 52 | +diag "tx2 status = $ret"; |
| 53 | + |
| 54 | +diag("inserting 4 on node 1 (can fail)"); |
| 55 | +my $ret = $cluster->psql(0, 'postgres', "insert into t values(4, 40);"); |
| 56 | +diag "tx1 status = $ret"; |
| 57 | + |
| 58 | +diag("inserting 5 on node 2 (can fail)"); |
| 59 | +my $ret = $cluster->psql(1, 'postgres', "insert into t values(5, 50);"); |
51 | 60 | diag "tx2 status = $ret";
|
52 | 61 |
|
53 | 62 | diag("selecting");
|
54 |
| -$cluster->psql(1, 'postgres', "select v from t where k=2;", stdout => \$psql_out); |
| 63 | +$cluster->psql(1, 'postgres', "select v from t where k=4;", stdout => \$psql_out); |
55 | 64 | diag("selected");
|
56 |
| -is($psql_out, '20', "Check replication after node failure."); |
| 65 | +is($psql_out, '40', "Check replication after node failure."); |
57 | 66 |
|
58 | 67 | ###############################################################################
|
59 | 68 | # Work after node start
|
|
62 | 71 | diag("starting node 2");
|
63 | 72 | $cluster->{nodes}->[2]->start;
|
64 | 73 |
|
65 |
| -sleep(10); # Wait until recovery of node will be completed |
66 |
| - |
67 | 74 | $cluster->psql(0, 'postgres', "select mtm.poll_node(3);");
|
| 75 | +sleep(5); # Wait until recovery of node will be completed |
68 | 76 |
|
69 |
| -diag("inserting 3"); |
70 |
| -$cluster->psql(0, 'postgres', "insert into t values(3, 30);"); |
71 |
| -diag("inserting 4"); |
72 |
| -$cluster->psql(1, 'postgres', "insert into t values(4, 40);"); |
| 77 | +diag("inserting 6 on node 1 (can fail)"); |
| 78 | +$cluster->psql(0, 'postgres', "insert into t values(6, 60);"); |
| 79 | +diag("inserting 7 on node 2 (can fail)"); |
| 80 | +$cluster->psql(1, 'postgres', "insert into t values(7, 70);"); |
73 | 81 |
|
74 |
| -diag("selecting"); |
75 |
| -$cluster->psql(2, 'postgres', "select v from t where k=3;", stdout => \$psql_out); |
| 82 | +diag("inserting 8 on node 1"); |
| 83 | +$cluster->psql(0, 'postgres', "insert into t values(8, 80);"); |
| 84 | +diag("inserting 9 on node 2"); |
| 85 | +$cluster->psql(1, 'postgres', "insert into t values(9, 90);"); |
| 86 | + |
| 87 | +diag("selecting from node 3"); |
| 88 | +$cluster->psql(2, 'postgres', "select v from t where k=8;", stdout => \$psql_out); |
76 | 89 | diag("selected");
|
77 | 90 |
|
78 |
| -is($psql_out, '30', "Check replication after failed node recovery."); |
| 91 | +is($psql_out, '80', "Check replication after failed node recovery."); |
79 | 92 |
|
80 |
| -$cluster->psql(2, 'postgres', "select v from t where k=4;", stdout => \$psql_out); |
| 93 | +$cluster->psql(2, 'postgres', "select v from t where k=9;", stdout => \$psql_out); |
81 | 94 | diag("selected");
|
82 | 95 |
|
83 |
| -is($psql_out, '40', "Check replication after failed node recovery."); |
| 96 | +is($psql_out, '90', "Check replication after failed node recovery."); |
84 | 97 |
|
85 | 98 | $cluster->stop();
|
86 | 99 | 1;
|
0 commit comments