@@ -366,11 +366,7 @@ type curlOutput struct {
366
366
Errors []curlErrorEntry `json:"errors"`
367
367
}
368
368
369
- func verifyOutput (t * testing.T , bytes []byte , failureConfig * CurlFailureConfig ) {
370
- output := curlOutput {}
371
- require .NoError (t , json .Unmarshal (bytes , & output ),
372
- "unable to unmarshal the curl output" )
373
-
369
+ func verifyOutput (t * testing.T , output curlOutput , failureConfig * CurlFailureConfig ) {
374
370
if failureConfig .ShouldFail {
375
371
require .True (t , len (output .Errors ) > 0 , "no error entry found" )
376
372
if len (failureConfig .DgraphErrMsg ) > 0 {
@@ -387,21 +383,28 @@ func verifyOutput(t *testing.T, bytes []byte, failureConfig *CurlFailureConfig)
387
383
388
384
// VerifyCurlCmd executes the curl command with the given arguments and verifies
389
385
// the result against the expected output.
390
- func VerifyCurlCmd (t * testing.T , args []string ,
391
- failureConfig * CurlFailureConfig ) {
392
- queryCmd := exec .Command ("curl" , args ... )
393
-
394
- output , err := queryCmd .Output ()
395
- if len (failureConfig .CurlErrMsg ) > 0 {
396
- // the curl command should have returned an non-zero code
397
- require .Error (t , err , "the curl command should have failed" )
398
- if ee , ok := err .(* exec.ExitError ); ok {
399
- require .True (t , strings .Contains (string (ee .Stderr ), failureConfig .CurlErrMsg ),
400
- "the curl output does not contain the expected output" )
386
+ func VerifyCurlCmd (t * testing.T , args []string , failureConfig * CurlFailureConfig ) {
387
+ for {
388
+ queryCmd := exec .Command ("curl" , args ... )
389
+ output , err := queryCmd .Output ()
390
+ if len (failureConfig .CurlErrMsg ) > 0 {
391
+ // the curl command should have returned an non-zero code
392
+ require .Error (t , err , "the curl command should have failed" )
393
+ if ee , ok := err .(* exec.ExitError ); ok {
394
+ require .True (t , strings .Contains (string (ee .Stderr ), failureConfig .CurlErrMsg ),
395
+ "the curl output does not contain the expected output" )
396
+ }
397
+ } else {
398
+ require .NoError (t , err , "the curl command should have succeeded" )
399
+ co := curlOutput {}
400
+ require .NoError (t , json .Unmarshal (output , & co ),
401
+ "unable to unmarshal the curl output" )
402
+ if len (co .Errors ) > 0 && strings .Contains (co .Errors [0 ].Code , "schema is already being modified" ) {
403
+ time .Sleep (time .Second )
404
+ continue
405
+ }
406
+ verifyOutput (t , co , failureConfig )
401
407
}
402
- } else {
403
- require .NoError (t , err , "the curl command should have succeeded" )
404
- verifyOutput (t , output , failureConfig )
405
408
}
406
409
}
407
410
0 commit comments