Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updating the previous test to actually produce + check the condition …

…described
  • Loading branch information...
commit fb2c2e325999015b104a3405557141e914ce196f 1 parent dbed2a3
Steve Singer ssinger authored

Showing 1 changed file with 45 additions and 12 deletions. Show diff stats Hide diff stats

  1. +45 12 clustertest/disorder/tests/RecreateSet.js
57 clustertest/disorder/tests/RecreateSet.js
@@ -38,10 +38,13 @@ RecreateSet.prototype.runTest = function() {
38 38 this.coordinator.join (load);
39 39
40 40 this.subscribeSet(1,1,1,[2]);
41   -
  41 + //Create + subscribe a second set to nodes 2 + 3.
  42 + this.createSecondSet(1);
  43 + this.subscribeSet(2,1,1,[2,3]);
  44 +
42 45 /**
43 46 * take a lock out on a table on db3 to prevent the subscribe
44   - * from finishing.
  47 + * from finishing (for set 1).
45 48 */
46 49 var conn = this.coordinator.createJdbcConnection('db3');
47 50 var stat = conn.createStatement();
@@ -54,22 +57,39 @@ RecreateSet.prototype.runTest = function() {
54 57 * slon for node 3 sees the list of tables on node 1.
55 58 */
56 59 java.lang.Thread.sleep(10*1000);
57   - //drop the set.
  60 +
  61 +
  62 + /**
  63 + * now we DROP set 2 and recreate it on node 2.
  64 + * The idea is that the CREATE SET from node 2
  65 + * will reach node 3 before the DROP SET from node 1.
  66 + * This is because the node 3 remote worker is busy
  67 + * due to the lock on set 1.
  68 + */
58 69 var slonikPreamble = this.getSlonikPreamble();
59   - var slonikScript = 'drop set (id=1, origin=1);\n'
60   - + 'wait for event(origin=1, confirmed=2,wait on=1);\n'
61   - + 'create set(id=1,origin=2);'
62   - + 'set add table(id=1,set id=1, fully qualified name=\'disorder.do_customer\', origin=2);';
  70 + var slonikScript = 'drop set (id=2, origin=1);\n'
  71 + + 'wait for event(origin=1, confirmed=2,wait on=1);\n';
  72 +
63 73 var slonik=this.coordinator.createSlonik('drop set 1',slonikPreamble,slonikScript);
64 74 slonik.run();
  75 +
  76 +
  77 +
65 78 this.coordinator.join(slonik);
66 79 this.testResults.assertCheck('drop set 1 worked',slonik.getReturnCode(),
67 80 0);
68   - java.lang.Thread.sleep(10*1000);
  81 + this.createSecondSet(2);
  82 + java.lang.Thread.sleep(60*1000);
69 83 conn.rollback();
70   - stat.close();
71   - conn.close();
72   - this.subscribeSet(1,2,2,[3]);
  84 +
  85 + this.subscribeSet(2,2,2,[3]);
  86 + // The subscribe on node 3 won't finish with that lock
  87 + // due to internal slon mutexes. We just need
  88 + // to make sure the remoteWorkerThread_2 on
  89 + // node 3 gets ahead of remoteWorkerThread_1 on
  90 + // node 3.
  91 + //java.lang.Thread.sleep(60*1000);
  92 +
73 93 this.coordinator.join(subscribeArray[0]);
74 94
75 95 //verify things.
@@ -79,7 +99,20 @@ RecreateSet.prototype.runTest = function() {
79 99 slonArray[idx].stop();
80 100 this.coordinator.join(slonArray[idx]);
81 101 }
82   -
  102 + var rs = stat.executeQuery("select set_origin from _" +
  103 + this.getClusterName()+ ".sl_set where"
  104 + + " set_id=2");
  105 + if(rs.next()) {
  106 + this.testResults.assertCheck('set 2 has node 2 as origin',
  107 + rs.getInt(1),2);
  108 + }
  109 + else {
  110 + this.testResults.assertCheck('set 2 is missing from node 3',
  111 + true,false);
  112 + }
  113 + rs.close();
  114 + stat.close();
  115 + conn.close();
83 116
84 117 }
85 118

0 comments on commit fb2c2e3

Please sign in to comment.
Something went wrong with that request. Please try again.