@@ -336,107 +336,151 @@ func VerifyUpdateDataPlaneHealth(t *testing.T) {
336336 t .Helper ()
337337
338338 client := resty .New ()
339+
339340 client .SetRetryCount (RetryCount ).SetRetryWaitTime (RetryWaitTime ).SetRetryMaxWaitTime (RetryMaxWaitTime )
341+
340342 client .AddRetryCondition (
343+
341344 func (r * resty.Response , err error ) bool {
342345 return r .StatusCode () == http .StatusNotFound
343346 },
344347 )
345348
346349 url := fmt .Sprintf ("http://%s/api/v1/health" , MockManagementPlaneAPIAddress )
350+
347351 resp , err := client .R ().EnableTrace ().Get (url )
352+
348353 require .NoError (t , err )
354+
349355 assert .Equal (t , http .StatusOK , resp .StatusCode ())
350356
351357 responseData := resp .Body ()
358+
352359 t .Logf ("Response: %s" , string (responseData ))
360+
353361 assert .True (t , json .Valid (responseData ))
354362
355363 pb := protojson.UnmarshalOptions {DiscardUnknown : true }
356364
357365 updateDataPlaneHealthRequest := mpi.UpdateDataPlaneHealthRequest {}
366+
358367 unmarshalErr := pb .Unmarshal (responseData , & updateDataPlaneHealthRequest )
368+
359369 require .NoError (t , unmarshalErr )
360370
361371 t .Logf ("UpdateDataPlaneHealthRequest: %v" , & updateDataPlaneHealthRequest )
362372
363373 assert .NotNil (t , & updateDataPlaneHealthRequest )
364374
365375 // Verify message metadata
376+
366377 messageMeta := updateDataPlaneHealthRequest .GetMessageMeta ()
378+
367379 assert .NotEmpty (t , messageMeta .GetCorrelationId ())
380+
368381 assert .NotEmpty (t , messageMeta .GetMessageId ())
382+
369383 assert .NotEmpty (t , messageMeta .GetTimestamp ())
370384
371385 healths := updateDataPlaneHealthRequest .GetInstanceHealths ()
386+
372387 assert .Len (t , healths , 1 )
373388
374389 // Verify health metadata
390+
375391 assert .NotEmpty (t , healths [0 ].GetInstanceId ())
392+
376393 assert .Equal (t , mpi .InstanceHealth_INSTANCE_HEALTH_STATUS_HEALTHY , healths [0 ].GetInstanceHealthStatus ())
377394}
378395
379396func VerifyUpdateDataPlaneStatus (t * testing.T ) {
380397 t .Helper ()
381398
382399 client := resty .New ()
400+
383401 client .SetRetryCount (statusRetryCount ).SetRetryWaitTime (retryWait ).SetRetryMaxWaitTime (retryMaxWait )
384402
385403 url := fmt .Sprintf ("http://%s/api/v1/status" , MockManagementPlaneAPIAddress )
404+
386405 resp , err := client .R ().EnableTrace ().Get (url )
387406
388407 require .NoError (t , err )
408+
389409 assert .Equal (t , http .StatusOK , resp .StatusCode ())
390410
391411 updateDataPlaneStatusRequest := mpi.UpdateDataPlaneStatusRequest {}
392412
393413 responseData := resp .Body ()
414+
394415 t .Logf ("Response: %s" , string (responseData ))
416+
395417 assert .True (t , json .Valid (responseData ))
396418
397419 pb := protojson.UnmarshalOptions {DiscardUnknown : true }
420+
398421 unmarshalErr := pb .Unmarshal (responseData , & updateDataPlaneStatusRequest )
422+
399423 require .NoError (t , unmarshalErr )
400424
401425 t .Logf ("UpdateDataPlaneStatusRequest: %v" , & updateDataPlaneStatusRequest )
402426
403427 assert .NotNil (t , & updateDataPlaneStatusRequest )
404428
405429 // Verify message metadata
430+
406431 messageMeta := updateDataPlaneStatusRequest .GetMessageMeta ()
432+
407433 assert .NotEmpty (t , messageMeta .GetCorrelationId ())
434+
408435 assert .NotEmpty (t , messageMeta .GetMessageId ())
436+
409437 assert .NotEmpty (t , messageMeta .GetTimestamp ())
410438
411439 instances := updateDataPlaneStatusRequest .GetResource ().GetInstances ()
440+
412441 sort .Slice (instances , func (i , j int ) bool {
413442 return instances [i ].GetInstanceMeta ().GetInstanceType () < instances [j ].GetInstanceMeta ().GetInstanceType ()
414443 })
444+
415445 assert .Len (t , instances , instanceLen )
416446
417447 // Verify agent instance metadata
448+
418449 assert .NotEmpty (t , instances [0 ].GetInstanceMeta ().GetInstanceId ())
450+
419451 assert .Equal (t , mpi .InstanceMeta_INSTANCE_TYPE_AGENT , instances [0 ].GetInstanceMeta ().GetInstanceType ())
452+
420453 assert .NotEmpty (t , instances [0 ].GetInstanceMeta ().GetVersion ())
421454
422455 // Verify agent instance configuration
456+
423457 assert .Empty (t , instances [0 ].GetInstanceConfig ().GetActions ())
458+
424459 assert .NotEmpty (t , instances [0 ].GetInstanceRuntime ().GetProcessId ())
460+
425461 assert .Equal (t , "/usr/bin/nginx-agent" , instances [0 ].GetInstanceRuntime ().GetBinaryPath ())
462+
426463 assert .Equal (t , "/etc/nginx-agent/nginx-agent.conf" , instances [0 ].GetInstanceRuntime ().GetConfigPath ())
427464
428465 // Verify NGINX instance metadata
466+
429467 assert .NotEmpty (t , instances [1 ].GetInstanceMeta ().GetInstanceId ())
468+
430469 if os .Getenv ("IMAGE_PATH" ) == "/nginx-plus/agent" {
431470 assert .Equal (t , mpi .InstanceMeta_INSTANCE_TYPE_NGINX_PLUS , instances [1 ].GetInstanceMeta ().GetInstanceType ())
432471 } else {
433472 assert .Equal (t , mpi .InstanceMeta_INSTANCE_TYPE_NGINX , instances [1 ].GetInstanceMeta ().GetInstanceType ())
434473 }
474+
435475 assert .NotEmpty (t , instances [1 ].GetInstanceMeta ().GetVersion ())
436476
437477 // Verify NGINX instance configuration
478+
438479 assert .Empty (t , instances [1 ].GetInstanceConfig ().GetActions ())
480+
439481 assert .NotEmpty (t , instances [1 ].GetInstanceRuntime ().GetProcessId ())
482+
440483 assert .Equal (t , "/usr/sbin/nginx" , instances [1 ].GetInstanceRuntime ().GetBinaryPath ())
484+
441485 assert .Equal (t , "/etc/nginx/nginx.conf" , instances [1 ].GetInstanceRuntime ().GetConfigPath ())
442486}
0 commit comments