@@ -76,34 +76,34 @@ func secureStarterEndpoint(portOffset int) string {
7676// testCluster runs a series of tests to verify a good cluster.
7777func testCluster (t * testing.T , starterEndpoint string , isSecure bool ) client.API {
7878 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 )
8080 return c
8181}
8282
8383// testClusterWithSync runs a series of tests to verify a good cluster with synchronization enabled.
8484func testClusterWithSync (t * testing.T , starterEndpoint string , isSecure bool ) client.API {
8585 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 )
8787 return c
8888}
8989
9090// testSingle runs a series of tests to verify a good single server.
9191func testSingle (t * testing.T , starterEndpoint string , isSecure bool ) client.API {
9292 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 )
9494 return c
9595}
9696
9797// testResilientSingle runs a series of tests to verify good resilientsingle servers.
9898func testResilientSingle (t * testing.T , starterEndpoint string , isSecure bool , expectAgencyOnly bool ) client.API {
9999 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 )
101101 return c
102102}
103103
104104// testProcesses runs a series of tests to verify a good series of database servers.
105105func 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 ) {
107107 ctx := context .Background ()
108108
109109 // Fetch version
@@ -171,20 +171,32 @@ func testProcesses(t *testing.T, c client.API, mode, starterEndpoint string, isS
171171 }
172172
173173 // 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 )
183197 }
184- testArangodReachable ( t , sp , reachableTimeout )
198+ break
185199 }
186- } else if (mode == "single" || mode == "resilientsingle" ) && ! expectAgencyOnly {
187- t .Errorf ("No single found in %s" , starterEndpoint )
188200 }
189201
190202 // Check syncmaster
0 commit comments