@@ -76,34 +76,34 @@ func secureStarterEndpoint(portOffset int) string {
76
76
// testCluster runs a series of tests to verify a good cluster.
77
77
func testCluster (t * testing.T , starterEndpoint string , isSecure bool ) client.API {
78
78
c := NewStarterClient (t , starterEndpoint )
79
- testProcesses (t , c , "cluster" , starterEndpoint , isSecure , false , false , 0 )
79
+ testProcesses (t , c , "cluster" , starterEndpoint , isSecure , false , false , 0 , 0 )
80
80
return c
81
81
}
82
82
83
83
// testClusterWithSync runs a series of tests to verify a good cluster with synchronization enabled.
84
84
func testClusterWithSync (t * testing.T , starterEndpoint string , isSecure bool ) client.API {
85
85
c := NewStarterClient (t , starterEndpoint )
86
- testProcesses (t , c , "cluster" , starterEndpoint , isSecure , false , true , time .Minute * 2 )
86
+ testProcesses (t , c , "cluster" , starterEndpoint , isSecure , false , true , 0 , time .Minute * 2 )
87
87
return c
88
88
}
89
89
90
90
// testSingle runs a series of tests to verify a good single server.
91
91
func testSingle (t * testing.T , starterEndpoint string , isSecure bool ) client.API {
92
92
c := NewStarterClient (t , starterEndpoint )
93
- testProcesses (t , c , "single" , starterEndpoint , isSecure , false , false , 0 )
93
+ testProcesses (t , c , "single" , starterEndpoint , isSecure , false , false , 0 , 0 )
94
94
return c
95
95
}
96
96
97
97
// testResilientSingle runs a series of tests to verify good resilientsingle servers.
98
98
func testResilientSingle (t * testing.T , starterEndpoint string , isSecure bool , expectAgencyOnly bool ) client.API {
99
99
c := NewStarterClient (t , starterEndpoint )
100
- testProcesses (t , c , "resilientsingle" , starterEndpoint , isSecure , expectAgencyOnly , false , time .Second * 30 )
100
+ testProcesses (t , c , "resilientsingle" , starterEndpoint , isSecure , expectAgencyOnly , false , time .Second * 30 , time . Second * 30 )
101
101
return c
102
102
}
103
103
104
104
// testProcesses runs a series of tests to verify a good series of database servers.
105
105
func testProcesses (t * testing.T , c client.API , mode , starterEndpoint string , isSecure bool ,
106
- expectAgencyOnly bool , syncEnabled bool , reachableTimeout time.Duration ) {
106
+ expectAgencyOnly bool , syncEnabled bool , singleTimeout , reachableTimeout time.Duration ) {
107
107
ctx := context .Background ()
108
108
109
109
// Fetch version
@@ -171,20 +171,32 @@ func testProcesses(t *testing.T, c client.API, mode, starterEndpoint string, isS
171
171
}
172
172
173
173
// Check single
174
- if sp , ok := processes .ServerByType (client .ServerTypeSingle ); ok {
175
- if sp .IsSecure != isSecure {
176
- t .Errorf ("Invalid IsSecure on single. Expected %v, got %v" , isSecure , sp .IsSecure )
177
- }
178
- if mode == "cluster" || expectAgencyOnly {
179
- t .Errorf ("Found single, not allowed in cluster mode" )
180
- } else {
181
- if isVerbose {
182
- t .Logf ("Found single at %s:%d" , sp .IP , sp .Port )
174
+ {
175
+ deadline := time .Now ().Add (singleTimeout )
176
+ for {
177
+ if sp , ok := processes .ServerByType (client .ServerTypeSingle ); ok {
178
+ if sp .IsSecure != isSecure {
179
+ t .Errorf ("Invalid IsSecure on single. Expected %v, got %v" , isSecure , sp .IsSecure )
180
+ }
181
+ if mode == "cluster" || expectAgencyOnly {
182
+ t .Errorf ("Found single, not allowed in cluster mode" )
183
+ } else {
184
+ if isVerbose {
185
+ t .Logf ("Found single at %s:%d" , sp .IP , sp .Port )
186
+ }
187
+ testArangodReachable (t , sp , reachableTimeout )
188
+ }
189
+ } else if (mode == "single" || mode == "resilientsingle" ) && ! expectAgencyOnly {
190
+ if time .Now ().Before (deadline ) {
191
+ // For activefailover not all starters have to be ready when we're called,
192
+ // so we allow for some time to pass until we call it a failure.
193
+ time .Sleep (time .Second )
194
+ continue
195
+ }
196
+ t .Errorf ("No single found in %s" , starterEndpoint )
183
197
}
184
- testArangodReachable ( t , sp , reachableTimeout )
198
+ break
185
199
}
186
- } else if (mode == "single" || mode == "resilientsingle" ) && ! expectAgencyOnly {
187
- t .Errorf ("No single found in %s" , starterEndpoint )
188
200
}
189
201
190
202
// Check syncmaster
0 commit comments