@@ -58,6 +58,7 @@ function SynchronousReplicationWithViewSuite () {
58
58
var cinfo ;
59
59
var ccinfo ;
60
60
var shards ;
61
+ var failedState = { leader : null , follower : null } ;
61
62
62
63
////////////////////////////////////////////////////////////////////////////////
63
64
/// @brief find out servers for the system collections
@@ -120,21 +121,23 @@ function SynchronousReplicationWithViewSuite () {
120
121
assertTrue ( pos >= 0 ) ;
121
122
assertTrue ( suspendExternal ( global . instanceInfo . arangods [ pos ] . pid ) ) ;
122
123
console . info ( "Have failed follower" , follower ) ;
124
+ failedState . follower = follower ;
123
125
}
124
126
125
127
////////////////////////////////////////////////////////////////////////////////
126
128
/// @brief heal the follower
127
129
////////////////////////////////////////////////////////////////////////////////
128
130
129
- function healFollower ( ) {
130
- var follower = cinfo . shards [ shards [ 0 ] ] [ 1 ] ;
131
+ function healFollower ( follower = null ) {
132
+ if ( follower == null ) follower = cinfo . shards [ shards [ 0 ] ] [ 1 ] ;
131
133
var endpoint = global . ArangoClusterInfo . getServerEndpoint ( follower ) ;
132
134
// Now look for instanceInfo:
133
135
var pos = _ . findIndex ( global . instanceInfo . arangods ,
134
136
x => x . endpoint === endpoint ) ;
135
137
assertTrue ( pos >= 0 ) ;
136
138
assertTrue ( continueExternal ( global . instanceInfo . arangods [ pos ] . pid ) ) ;
137
139
console . info ( "Have healed follower" , follower ) ;
140
+ if ( failedState . follower === follower ) failedState . follower = null ;
138
141
}
139
142
140
143
////////////////////////////////////////////////////////////////////////////////
@@ -150,22 +153,24 @@ function SynchronousReplicationWithViewSuite () {
150
153
assertTrue ( pos >= 0 ) ;
151
154
assertTrue ( suspendExternal ( global . instanceInfo . arangods [ pos ] . pid ) ) ;
152
155
console . info ( "Have failed leader" , leader ) ;
156
+ failedState . leader = leader ;
153
157
return leader ;
154
158
}
155
159
156
160
////////////////////////////////////////////////////////////////////////////////
157
161
/// @brief heal the follower
158
162
////////////////////////////////////////////////////////////////////////////////
159
163
160
- function healLeader ( ) {
161
- var leader = cinfo . shards [ shards [ 0 ] ] [ 0 ] ;
164
+ function healLeader ( leader ) {
165
+ if ( leader == null ) leader = cinfo . shards [ shards [ 0 ] ] [ 1 ] ;
162
166
var endpoint = global . ArangoClusterInfo . getServerEndpoint ( leader ) ;
163
167
// Now look for instanceInfo:
164
168
var pos = _ . findIndex ( global . instanceInfo . arangods ,
165
169
x => x . endpoint === endpoint ) ;
166
170
assertTrue ( pos >= 0 ) ;
167
171
assertTrue ( continueExternal ( global . instanceInfo . arangods [ pos ] . pid ) ) ;
168
172
console . info ( "Have healed leader" , leader ) ;
173
+ if ( failedState . leader === leader ) failedState . leader = null ;
169
174
}
170
175
171
176
////////////////////////////////////////////////////////////////////////////////
@@ -493,6 +498,8 @@ function SynchronousReplicationWithViewSuite () {
493
498
////////////////////////////////////////////////////////////////////////////////
494
499
495
500
tearDown : function ( ) {
501
+ if ( failedState . leader != null ) healLeader ( failedState . leader ) ;
502
+ if ( failedState . follower != null ) healFollower ( failedState . leader ) ;
496
503
db . _drop ( cn ) ;
497
504
viewOperations ( "drop" ) ;
498
505
//global.ArangoAgency.set('Target/FailedServers', {});
0 commit comments