~stub/slony-i/trunk

« back to all changes in this revision

Viewing changes to clustertest/disorder/tests/MultinodeCascadeFailover.js

  • Committer: Steve Singer
  • Date: 2017-04-10 13:40:41 UTC
  • Revision ID: git-v1:c27d3e623f8044c456597aacabe8edb39e76e4c9
Add unit test for multi-node failover (cascaded) issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
coordinator.includeFile('disorder/tests/FailNodeTest.js');
 
4
 
 
5
MultinodeCascadeFailover = function(coordinator, testResults) {
 
6
        Failover.call(this, coordinator, testResults);
 
7
        this.testDescription='Test the FAILOVER command.  This test will try FAILOVER'
 
8
                +' with multiple nodes failing and cascading';
 
9
        this.compareQueryList.push(['select i_id,comments from disorder.do_item_review order by i_id','i_id']);
 
10
        this.nodeCount=5;
 
11
}
 
12
MultinodeCascadeFailover.prototype = new Failover();
 
13
MultinodeCascadeFailover.prototype.constructor = MultinodeCascadeFailover;
 
14
 
 
15
/**
 
16
 * Returns the number of nodes used in the test.
 
17
 */
 
18
MultinodeCascadeFailover.prototype.getNodeCount = function() {
 
19
        return this.nodeCount;
 
20
}
 
21
 
 
22
MultinodeCascadeFailover.prototype.runTest = function() {
 
23
    this.coordinator.log("MultinodeCascadeFailover.prototype.runTest - begin");
 
24
        this.testResults.newGroup("Multinode Cascade Fail Over Test");
 
25
        this.prepareDb(['db6']);
 
26
        this.setupReplication();
 
27
 
 
28
        this.addCompletePaths();
 
29
        /**
 
30
         * Start the slons.
 
31
         */
 
32
        this.slonArray = [];
 
33
        for ( var idx = 1; idx <= this.getNodeCount(); idx++) {
 
34
                this.slonArray[idx - 1] = this.coordinator.createSlonLauncher('db' + idx);
 
35
                this.slonArray[idx - 1].run();
 
36
        }
 
37
        this.addCompletePaths();
 
38
        /**
 
39
         * Add some tables to replication.
 
40
         * 
 
41
         */
 
42
        this.addTables();
 
43
 
 
44
        /**
 
45
         * Subscribe the first node.
 
46
         *           1
 
47
         *       2   3   4
 
48
         *           |
 
49
         *       5      6
 
50
         */
 
51
        this.subscribeSet(1,1, 1, [ 2, 3,4 ]);
 
52
        this.subscribeSet(1,1, 3, [ 5, 6 ]);
 
53
        this.slonikSync(1,1);
 
54
        var load = this.generateLoad();
 
55
        java.lang.Thread.sleep(10*1000);
 
56
        this.slonikSync(1,1);
 
57
        //stop slon 3, to make sure
 
58
        //3 and 5,6 aren't ahead of 2
 
59
        //If that happens nodes 5 might get unsubscribed
 
60
        //
 
61
        this.slonArray[3-1].stop();
 
62
        this.coordinator.join(this.slonArray[3-1]);
 
63
        this.failover(1,2,3,5);
 
64
        /**
 
65
         * At the end of this we should have
 
66
         *   2-->5-->6
 
67
         *   |
 
68
         *   4
 
69
         */
 
70
        load.stop();
 
71
        this.coordinator.join(load);
 
72
        this.slonikSync(1,2);
 
73
        this.currentOrigin='db2';
 
74
        load=this.generateLoad();
 
75
        java.lang.Thread.sleep(1000*10);
 
76
        load.stop();    
 
77
        this.coordinator.join(load);
 
78
        this.slonikSync(1,2);
 
79
        this.compareDb('db2','db5');
 
80
        this.compareDb('db2','db6');
 
81
        this.compareDb('db2','db4');
 
82
        for ( var idx = 1; idx <= this.getNodeCount(); idx++) {
 
83
                this.slonArray[idx - 1].stop();
 
84
                this.coordinator.join(this.slonArray[idx - 1]);         
 
85
        }
 
86
        this.dropDb(['db6']);
 
87
 
 
88
        
 
89
}
 
90
 
 
91
MultinodeCascadeFailover.prototype.failover=function(originA,backupA,originB,backupB) 
 
92
{
 
93
        var slonikPreamble = this.getSlonikPreamble();
 
94
        var slonikScript = 'echo \'MultinodeCascadeFailover.prototype.failover\';\n';
 
95
        slonikScript += 'FAILOVER( node=(id='  + originA  + ',backup node=' + backupA +')'
 
96
        + ', node=(id=' + originB + ',backup node=' + backupB + '));\n';
 
97
        var slonik=this.coordinator.createSlonik('failover',slonikPreamble,slonikScript);
 
98
        slonik.run();
 
99
        this.coordinator.join(slonik);
 
100
        this.testResults.assertCheck('failover passes',slonik.getReturnCode(),0);       
 
101
 
 
102
}
 
103
 
 
104
        MultinodeCascadeFailover.prototype.dropTwoNodes=function(node1,node2,event_node)
 
105
{
 
106
        var slonikPreamble = this.getSlonikPreamble();
 
107
        var slonikScript = 'echo \'MultinodeCascadeFailover.prototype.dropTwoNodes\';\n';
 
108
        slonikScript+= 'drop node(id=\'' + node1 + ',' + node2 + '\',event node = ' + event_node + ');\nuninstall node(id='+node1+');\nuninstall node(id='+node2+');\n'
 
109
 
 
110
        var slonik=this.coordinator.createSlonik('drop node',slonikPreamble,slonikScript);
 
111
        slonik.run();
 
112
        this.coordinator.join(slonik);
 
113
        this.testResults.assertCheck('drop 2 nodes passes',slonik.getReturnCode(),0);   
 
114
 
 
115
}
 
116
 
 
117
MultinodeCascadeFailover.prototype.getNodeCount = function() {
 
118
        return 6;
 
119
}