Skip to content

Commit

Permalink
gNMI-1.14 enhancements (#2929)
Browse files Browse the repository at this point in the history
* gNMI-1.14 fix
seperate metadata check to be more consistent with the procedure
explained in README.md
"This code is a Contribution to the OpenConfig Feature Profiles project (“Work”) made under the Google Software Grant and Corporate Contributor License Agreement (“CLA”) and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia’s intellectual property are granted for any other purpose. This code is provided on an “as is” basis without any warranties of any kind."

* remove stale comment
“This code is a Contribution to the OpenConfig Feature Profiles project (“Work”) made under the Google Software Grant and Corporate Contributor License Agreement (“CLA”) and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia’s intellectual property are granted for any other purpose. This code is provided on an “as is” basis without any warranties of any kind.”
  • Loading branch information
MarcCharlebois authored May 13, 2024
1 parent c9114a6 commit 11c85e8
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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)
}

0 comments on commit 11c85e8

Please sign in to comment.