-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
greg-dennis
committed
Oct 13, 2023
1 parent
3b5b8db
commit a588a91
Showing
5 changed files
with
120 additions
and
14 deletions.
There are no files selected for viewing
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,6 @@ | ||
# Replay-1.0: Record/replay presession test | ||
|
||
## Summary | ||
|
||
This is an example record/replay test. | ||
At this time, no vendor is expected to run this test. |
7 changes: 7 additions & 0 deletions
7
feature/experimental/replay/tests/presession_test/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: "44bc3e16-ee02-42c7-8122-6f066a41a488" | ||
plan_id: "Replay-1.0" | ||
description: "Record/replay presession test" | ||
testbed: TESTBED_DUT_ |
89 changes: 89 additions & 0 deletions
89
feature/experimental/replay/tests/presession_test/presession_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,89 @@ | ||
// 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 presession_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 = "grpclog.pb" | ||
t.Logf("Parsing log file: %v", logFile) | ||
rec, err := replayer.Parse(logFile) | ||
if err != nil { | ||
t.Fatalf("Parse(): cannot parse log file: %v", err) | ||
} | ||
|
||
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, err := replayer.Replay(ctx, rec, clients) | ||
if err != nil { | ||
t.Fatalf("Replay(): got error replaying record: %v", err) | ||
} | ||
|
||
// 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 := results.GRIBIDiff(rec); 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) | ||
} | ||
} |
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