|
21 | 21 |
|
22 | 22 | psql_or_bail(2, "SELECT spock.node_drop('n2')"); |
23 | 23 | psql_or_bail(3, "SELECT spock.node_drop('n3')"); |
24 | | -psql_or_bail(1, "CREATE EXTENSION snowflake"); |
25 | | -psql_or_bail(1, "CREATE EXTENSION lolor"); |
26 | 24 | psql_or_bail(1, "CREATE EXTENSION amcheck"); |
27 | 25 | psql_or_bail(2, "CREATE EXTENSION dblink"); |
28 | 26 | psql_or_bail(3, "CREATE EXTENSION dblink"); |
|
31 | 29 | psql_or_bail(1, "CREATE TABLE test(x serial PRIMARY KEY)"); |
32 | 30 | psql_or_bail(1, "INSERT INTO test DEFAULT VALUES"); |
33 | 31 |
|
34 | | -print STDERR "All supporting stuff has been installed\n"; |
| 32 | +print STDERR "All supporting stuff has been installed successfully\n"; |
35 | 33 |
|
36 | | -print STDERR "Call Z0DAN: n2 => n1"; |
| 34 | +# ############################################################################## |
| 35 | +# |
| 36 | +# Basic check that Z0DAN correctly add node to the single-node cluster |
| 37 | +# |
| 38 | +# ############################################################################## |
| 39 | + |
| 40 | +print STDERR "Call Z0DAN: n2 => n1\n"; |
37 | 41 | psql_or_bail(2, " |
38 | 42 | CALL spock.add_node( |
39 | 43 | src_node_name := 'n1', |
|
49 | 53 |
|
50 | 54 | psql_or_bail(1, "SELECT spock.sub_disable('sub_n1_n2')"); |
51 | 55 |
|
52 | | -print STDERR "Call Z0DAN: n3 => n2\n"; |
| 56 | +# ############################################################################## |
| 57 | +# |
| 58 | +# Z0DAN reject node addition if some subscriptions are disabled |
| 59 | +# |
| 60 | +# ############################################################################## |
53 | 61 |
|
| 62 | +print STDERR "Call Z0DAN: n3 => n2\n"; |
54 | 63 | scalar_query(3, " |
55 | 64 | CALL spock.add_node( |
56 | 65 | src_node_name := 'n2', |
|
63 | 72 | print STDERR "Z0DAN should fail because of a disabled subscription\n"; |
64 | 73 |
|
65 | 74 | psql_or_bail(1, "SELECT spock.sub_enable('sub_n1_n2')"); |
66 | | -scalar_query(3, " |
| 75 | +psql_or_bail(3, " |
67 | 76 | CALL spock.add_node( |
68 | 77 | src_node_name := 'n2', |
69 | 78 | src_dsn := 'host=$host dbname=$dbname port=$node_ports->[1] user=$db_user password=$db_password', |
|
77 | 86 | ok($result eq '1', "Check state of the test table on N3 after the attachment"); |
78 | 87 | print STDERR "Z0DAN should add N3 to the cluster\n"; |
79 | 88 |
|
| 89 | +# ############################################################################## |
| 90 | +# |
| 91 | +# Test that Z0DAN correctly doesn't add node to the cluster if something happens |
| 92 | +# during the SYNC process. |
| 93 | +# |
| 94 | +# ############################################################################## |
| 95 | + |
| 96 | +# Remove node from the cluster and data leftovers. |
| 97 | +psql_or_bail(3, "\\i ../../samples/Z0DAN/zodremove.sql"); |
| 98 | +psql_or_bail(3, "CALL spock.remove_node(target_node_name := 'n3', |
| 99 | + target_node_dsn := 'host=$host dbname=$dbname port=$node_ports->[2] user=$db_user password=$db_password', |
| 100 | + verbose_mode := true)"); |
| 101 | +psql_or_bail(3, "DROP TABLE test"); |
| 102 | + |
| 103 | +psql_or_bail(1, "CREATE FUNCTION fake_fn() RETURNS integer LANGUAGE sql AS \$\$ SELECT 1\$\$"); |
| 104 | +psql_or_bail(3, "CREATE FUNCTION fake_fn() RETURNS integer LANGUAGE sql AS \$\$ SELECT 1\$\$"); |
| 105 | +scalar_query(3, " |
| 106 | + CALL spock.add_node( |
| 107 | + src_node_name := 'n2', |
| 108 | + src_dsn := 'host=$host dbname=$dbname port=$node_ports->[1] user=$db_user password=$db_password', |
| 109 | + new_node_name := 'n3', new_node_dsn := 'host=$host dbname=$dbname port=$node_ports->[2] user=$db_user password=$db_password', |
| 110 | + verb := true)"); |
| 111 | + |
| 112 | +# TODO: |
| 113 | +# It seems that add_node keeps remnants after unsuccessful execution. It is |
| 114 | +# happened because we have commited some intermediate results before. |
| 115 | +# It would be better to keep remote transaction opened until the end of the |
| 116 | +# operation or just remove these remnants at the end pretending to be a |
| 117 | +# distributed transaction. |
| 118 | +# |
| 119 | +# $result = scalar_query(3, "SELECT count(*) FROM spock.local_node"); |
| 120 | +# ok($result eq '0', "N3 is not in the cluster"); |
| 121 | + |
80 | 122 | # Clean up |
81 | 123 | destroy_cluster('Destroy test cluster'); |
82 | 124 | done_testing(); |
0 commit comments