forked from openconfig/featureprofiles
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental replay test to reproduce "couldn't diff the command …
…trees" error (openconfig#2329) * Add test to reproduce 'couldn't diff the command trees' error * Update relpayer to latest version
- Loading branch information
Showing
6 changed files
with
128 additions
and
36 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
feature/experimental/replay/tests/diff_command_trees/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Replay-1.1: Record/replay diff command trees test | ||
|
||
## Summary | ||
|
||
This is an example record/replay test. It is meant to reproduce a "couldn't | ||
diff the command trees" error when applying certain gNMI config on Arista | ||
devices. | ||
|
||
At this time, no vendor is expected to run this test. |
83 changes: 83 additions & 0 deletions
83
feature/experimental/replay/tests/diff_command_trees/diff_command_trees_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2023 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package diff_command_trees_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/openconfig/featureprofiles/internal/fptest" | ||
gpb "github.com/openconfig/gribi/v1/proto/service" | ||
"github.com/openconfig/ondatra" | ||
"github.com/openconfig/replayer" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
fptest.RunTests(m) | ||
} | ||
|
||
func TestReplay(t *testing.T) { | ||
const logFile = "https://github.com/openconfig/featureprofiles/raw/main/feature/experimental/replay/tests/diff_command_trees/grpclog.pb" | ||
t.Logf("Parsing log file: %v", logFile) | ||
rec := replayer.ParseURL(t, logFile) | ||
|
||
dut := ondatra.DUT(t, "dut") | ||
portMap := map[string]string{} | ||
intfs, err := rec.Interfaces() | ||
if err != nil { | ||
t.Fatalf("Interfaces(): cannot get interfaces: %v", err) | ||
} | ||
|
||
// This test only needs Port-Channel4, so remap only those ports to the dut's reserved ports. | ||
available := dut.Ports() | ||
t.Logf("PortChannel4: %v", intfs["Port-Channel4"]) | ||
for _, member := range intfs["Port-Channel4"] { | ||
if len(available) == 0 { | ||
t.Fatalf("Ports(): not enough ports to satisfy Port-Channel4 remapping, members: %v", intfs["Port-Channel4"]) | ||
} | ||
portMap[member.Name] = available[0].Name() | ||
available = available[1:] | ||
} | ||
|
||
if err := rec.SetInterfaceMap(portMap); err != nil { | ||
t.Fatalf("Transform(%v): cannot transform log: %v", portMap, err) | ||
} | ||
|
||
t.Logf("Creating gRPC clients to dut") | ||
clients := &replayer.Clients{ | ||
GNMI: dut.RawAPIs().GNMI(t), | ||
GRIBI: dut.RawAPIs().GRIBI(t), | ||
} | ||
|
||
t.Logf("Replaying parsed log to device %v", dut.Name()) | ||
ctx := context.Background() | ||
results := replayer.Replay(ctx, t, rec, clients) | ||
|
||
// Validate that all gRIBI requests were programmed successfully. | ||
for _, result := range results.GRIBI() { | ||
if result.OperationID > 0 && result.ProgrammingResult != gpb.AFTResult_FIB_PROGRAMMED && result.ProgrammingResult != gpb.AFTResult_RIB_PROGRAMMED { | ||
t.Errorf("Replay(): gRIBI Result failed: %v", result) | ||
} | ||
} | ||
|
||
// Validate that resulting gRIBI state matches the recorded one. | ||
if diff := replayer.GRIBIDiff(rec, results); diff != "" { | ||
t.Errorf("Replay(): unexpected diff in final gRIBI state (-want,+got): %v", diff) | ||
} | ||
|
||
for i, result := range results.GNMI() { | ||
t.Logf("Result [%v]: %v", i, result) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
feature/experimental/replay/tests/diff_command_trees/grpclog.pb
Git LFS file not shown
7 changes: 7 additions & 0 deletions
7
feature/experimental/replay/tests/diff_command_trees/metadata.textproto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto | ||
# proto-message: Metadata | ||
|
||
uuid: "2cba9ffc-173d-49c2-8c02-f141561e339f" | ||
plan_id: "Replay-1.1" | ||
description: "Record/replay diff command trees test" | ||
testbed: TESTBED_DUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters