diff --git a/feature/system/gnmi/metadata/tests/large_set_consistency_test/large_set_consistency_test.go b/feature/system/gnmi/metadata/tests/large_set_consistency_test/large_set_consistency_test.go index 2b0763f68b6..84b7e7af943 100644 --- a/feature/system/gnmi/metadata/tests/large_set_consistency_test/large_set_consistency_test.go +++ b/feature/system/gnmi/metadata/tests/large_set_consistency_test/large_set_consistency_test.go @@ -240,17 +240,21 @@ func getNotificationsUsingGNMIGet(t *testing.T, gnmiClient gpb.GNMIClient, dut * return getResponse.GetNotification() } -// checkMetadata checks protobuf-metadata -func checkMetadata(t *testing.T, gnmiClient gpb.GNMIClient, dut *ondatra.DUTDevice, done *atomic.Int64) { +func checkMetadata1(t *testing.T, gnmiClient gpb.GNMIClient, dut *ondatra.DUTDevice, done *atomic.Int64) { t.Helper() - got, getRespTimeStamp := extractMetadataAnnotation(t, gnmiClient, dut) - want := metadata1 - t.Logf("SetResp: %v, getResp: %v ", done.Load(), getRespTimeStamp) - if done.Load() > 0 && done.Load() < getRespTimeStamp { - want = metadata2 + t.Logf("getResp: %v ", getRespTimeStamp) + if got != want && done.Load() == 0 { + t.Errorf("extractMetadataAnnotation: got %v, want %v", got, want) } +} + +func checkMetadata2(t *testing.T, gnmiClient gpb.GNMIClient, dut *ondatra.DUTDevice) { + t.Helper() + got, getRespTimeStamp := extractMetadataAnnotation(t, gnmiClient, dut) + want := metadata2 + t.Logf("getResp: %v ", getRespTimeStamp) if got != want { t.Errorf("extractMetadataAnnotation: got %v, want %v", got, want) } @@ -280,7 +284,7 @@ func TestLargeSetConsistency(t *testing.T) { if _, err := gnmiClient.Set(context.Background(), gpbSetRequest); err != nil { t.Fatalf("gnmi.Set unexpected error: %v", err) } - checkMetadata(t, gnmiClient, dut, done) + checkMetadata1(t, gnmiClient, dut, done) var wg sync.WaitGroup ch := make(chan struct{}, 1) @@ -300,7 +304,6 @@ func TestLargeSetConsistency(t *testing.T) { done.Store(setResp.GetTimestamp()) }() - // sending 4 Get requests concurrently every 5 seconds. for i := 0; i < 4; i++ { wg.Add(1) go func(i int) { @@ -312,14 +315,14 @@ func TestLargeSetConsistency(t *testing.T) { return default: t.Logf("[%d - running] checking config protobuf-metadata", i) - checkMetadata(t, gnmiClient, dut, done) - time.Sleep(5 * time.Second) + time.Sleep(5 * time.Millisecond) + checkMetadata1(t, gnmiClient, dut, done) } } }(i) } wg.Wait() - - checkMetadata(t, gnmiClient, dut, done) + time.Sleep(5 * time.Second) + checkMetadata2(t, gnmiClient, dut) }