From: Steve Singer Date: Tue, 25 Apr 2017 12:16:19 +0000 (-0400) Subject: failover unit test improvements X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=1585f5a793980ed3150d1cbfe20c0d23aa870ad3;p=slony1-engine.git failover unit test improvements --- diff --git a/clustertest/disorder/tests/BasicTest.js b/clustertest/disorder/tests/BasicTest.js index 7abb6080..ee41110e 100644 --- a/clustertest/disorder/tests/BasicTest.js +++ b/clustertest/disorder/tests/BasicTest.js @@ -810,4 +810,31 @@ BasicTest.prototype.updateReviewTable=function(node_id,text) { stat.close(); connection.close(); } - this.coordinator.log('updating review table on ' + node_id + " - complete");} \ No newline at end of file + this.coordinator.log('updating review table on ' + node_id + " - complete"); +} + +BasicTest.prototype.unsubscribe=function(node,set) +{ + var slonikPreamble = this.getSlonikPreamble(); + var slonikScript = 'echo \'BasicTest.prototype.unsubscribe\';\n'; + slonikScript += 'UNSUBSCRIBE SET(id=' + set + ',receiver=' + node +');\n'; + var slonik=this.coordinator.createSlonik('unsubscribe',slonikPreamble,slonikScript); + slonik.run(); + this.coordinator.join(slonik); + this.testResults.assertCheck('unsubscribe passes',slonik.getReturnCode(),0); + +} + +BasicTest.prototype.resubscribe=function(origin,provider,receiver) +{ + var slonikPreamble = this.getSlonikPreamble(); + var slonikScript = 'echo \'BasicTest.prototype.resubscribe\';\n'; + var slonikScript = 'resubscribe node(origin=' + origin + ',provider=' + +provider + ',receiver=' + receiver+');\n'; + + var slonik=this.coordinator.createSlonik('unsubscribe',slonikPreamble,slonikScript); + slonik.run(); + this.coordinator.join(slonik); + this.testResults.assertCheck('resubscribe passes',slonik.getReturnCode(),0); + +} diff --git a/clustertest/disorder/tests/FailNodeTest.js b/clustertest/disorder/tests/FailNodeTest.js index c3936c02..6b67eab6 100644 --- a/clustertest/disorder/tests/FailNodeTest.js +++ b/clustertest/disorder/tests/FailNodeTest.js @@ -292,7 +292,6 @@ FailNodeTest.prototype.reAddNode = function(node_id,origin,provider) { var slonik=this.coordinator.createSlonik('re-add node',slonikPreamble,slonikScript); slonik.run(); this.coordinator.join(slonik); - slonikScript = 'store node(id=' + node_id + ',event node=' + provider+');\n' + 'store path(server=' + node_id + ',client=' + provider + ',conninfo=@CONNINFO' + node_id+');\n' diff --git a/clustertest/disorder/tests/MultinodeCascadeFailover.js b/clustertest/disorder/tests/MultinodeCascadeFailover.js index 8d1599e8..4c7d1572 100644 --- a/clustertest/disorder/tests/MultinodeCascadeFailover.js +++ b/clustertest/disorder/tests/MultinodeCascadeFailover.js @@ -25,6 +25,8 @@ MultinodeCascadeFailover.prototype.runTest = function() { this.prepareDb(['db6']); this.setupReplication(); + + this.addCompletePaths(); /** * Start the slons. @@ -49,17 +51,19 @@ MultinodeCascadeFailover.prototype.runTest = function() { * 5 6 */ this.subscribeSet(1,1, 1, [ 2, 3,4 ]); - this.subscribeSet(1,1, 3, [ 5, 6 ]); + this.subscribeSet(1,1, 3, [5, 6 ]); this.slonikSync(1,1); + for(var j=1; j<100;j++) { var load = this.generateLoad(); java.lang.Thread.sleep(10*1000); this.slonikSync(1,1); - //stop slon 3, to make sure + //stop slon 1, to make sure //3 and 5,6 aren't ahead of 2 //If that happens nodes 5 might get unsubscribed // - this.slonArray[3-1].stop(); - this.coordinator.join(this.slonArray[3-1]); + this.slonArray[0].stop(); + this.coordinator.join(this.slonArray[0]); + java.lang.Thread.sleep(20*1000); this.failover(1,2,3,5); /** * At the end of this we should have @@ -79,13 +83,38 @@ MultinodeCascadeFailover.prototype.runTest = function() { this.compareDb('db2','db5'); this.compareDb('db2','db6'); this.compareDb('db2','db4'); + + if(this.testResults.getFailureCount() > 0) { + exit(-1); + } + this.dropTwoNodes(1,3,2); + this.reAddNode(1,2,2); + this.reAddNode(3,2,2); + this.slonikSync(1,2); + this.addCompletePaths(); + this.moveSet(1,2,1); + this.resubscribe(1,1,3); + this.resubscribe(1,3,4); + this.resubscribe(1,3,2); + this.resubscribe(1,3,5); + this.resubscribe(1,3,6); + this.currentOrigin='db1'; + }//j + this.unsubscribe(3,1); + load=this.generateLoad(); + java.lang.Thread.sleep(1000*10); + load.stop(); + this.coordinator.join(load); + this.slonikSync(1,2); + //should fail. + this.failover(2,3,5,1); + + + for ( var idx = 1; idx <= this.getNodeCount(); idx++) { this.slonArray[idx - 1].stop(); this.coordinator.join(this.slonArray[idx - 1]); } - this.dropDb(['db6']); - - } MultinodeCascadeFailover.prototype.failover=function(originA,backupA,originB,backupB) diff --git a/clustertest/disorder/tests/MultinodeFailover.js b/clustertest/disorder/tests/MultinodeFailover.js index ae94a26d..5f470b92 100644 --- a/clustertest/disorder/tests/MultinodeFailover.js +++ b/clustertest/disorder/tests/MultinodeFailover.js @@ -141,14 +141,11 @@ MultinodeFailover.prototype.runTest = function() { this.moveSet(1,1,2); this.dropNode(5,1); this.nodeCount=4; - var resubscribeSlonik = 'resubscribe node(origin=2,provider=2,receiver=1);\n' - + 'resubscribe node(origin=2,provider=2,receiver=3);\n' - + 'resubscribe node(origin=2,provider=3,receiver=4);\n'; - var slonikPreamble = this.getSlonikPreamble(); - var slonik=this.coordinator.createSlonik('failover',slonikPreamble,resubscribeSlonik); - slonik.run(); - this.coordinator.join(slonik); - this.testResults.assertCheck('failover passes',slonik.getReturnCode(),0); + this.resubscribe(2,2,1); + this.resubscribe(2,2,3); + this.resubscribe(2,3,4); + + this.currentOrigin='db2'; load=this.generateLoad(); java.lang.Thread.sleep(1000);