Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental replay test to reproduce "couldn't diff the command trees" error #2329

Merged
merged 7 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pb filter=lfs diff=lfs merge=lfs -text
nhawke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Replay-1.0: Record/replay presession 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.
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)
}
}
Git LFS file not shown
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 diff command trees test"
testbed: TESTBED_DUT
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ require (
github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b
github.com/openconfig/goyang v1.4.3
github.com/openconfig/gribi v1.0.0
github.com/openconfig/gribigo v0.0.0-20231024221855-bb56d1759075
github.com/openconfig/gribigo v0.0.0-20231031140438-9a293da13ff9
github.com/openconfig/kne v0.1.14
github.com/openconfig/ondatra v0.4.0
github.com/openconfig/replayer v0.0.0-20231027154425-b7fb1391cb3c
github.com/openconfig/replayer v0.0.0-20231031192218-5462382820d4
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07
github.com/openconfig/ygnmi v0.9.0
github.com/openconfig/ygot v0.29.13
Expand All @@ -49,9 +49,9 @@ require (

require (
cloud.google.com/go v0.110.8 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute v1.23.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.2 // indirect
cloud.google.com/go/iam v1.1.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/aristanetworks/arista-ceoslab-operator/v2 v2.0.2 // indirect
Expand Down Expand Up @@ -135,17 +135,17 @@ require (
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.26.3 // indirect
k8s.io/apimachinery v0.26.3 // indirect
k8s.io/client-go v0.26.3 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdi
cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY=
cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78=
cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU=
cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM=
Expand Down Expand Up @@ -378,6 +379,7 @@ cloud.google.com/go/iam v1.1.0/go.mod h1:nxdHjaKfCr7fNYx/HJMM8LgiMugmveWlkatear5
cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU=
cloud.google.com/go/iam v1.1.2 h1:gacbrBdWcoVmGLozRuStX45YKvJtzIjJdAolzUs1sm4=
cloud.google.com/go/iam v1.1.2/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU=
cloud.google.com/go/iam v1.1.3/go.mod h1:3khUlaBXfPKKe7huYgEpDn6FtgRyMEqbkvBxrQyY5SE=
cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc=
cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A=
cloud.google.com/go/iap v1.6.0/go.mod h1:NSuvI9C/j7UdjGjIde7t7HBz+QTwBcapPE07+sSRcLk=
Expand Down Expand Up @@ -1164,6 +1166,8 @@ github.com/openconfig/gribigo v0.0.0-20231011232723-88c9b8d98d8a h1:GderYwmwEia1
github.com/openconfig/gribigo v0.0.0-20231011232723-88c9b8d98d8a/go.mod h1:Vb7wUYPIS4JujR46QjvKeaXB74G8rqXc2FSSKUiyzaU=
github.com/openconfig/gribigo v0.0.0-20231024221855-bb56d1759075 h1:tNrt1DaXoHi6iSSuMZgZXeRBhpHUOsyg75xdCY/z58U=
github.com/openconfig/gribigo v0.0.0-20231024221855-bb56d1759075/go.mod h1:T6A11G1rP6F7XiKX/CNoFDbDHP0Nk2RyvvFqf3uQtl4=
github.com/openconfig/gribigo v0.0.0-20231031140438-9a293da13ff9 h1:AXdc2tqHWnYr4GlzYcs50wpQ7NLv6YWckHlgOHZ2qgo=
github.com/openconfig/gribigo v0.0.0-20231031140438-9a293da13ff9/go.mod h1:Fue9aTSqtMM9AxH9p3wOEAPGec5uBRurxLmtcjTHhWg=
github.com/openconfig/grpctunnel v0.0.0-20220819142823-6f5422b8ca70 h1:t6SvvdfWCMlw0XPlsdxO8EgO+q/fXnTevDjdYREKFwU=
github.com/openconfig/grpctunnel v0.0.0-20220819142823-6f5422b8ca70/go.mod h1:OmTWe7RyZj2CIzIgy4ovEBzCLBJzRvWSZmn7u02U9gU=
github.com/openconfig/kne v0.1.14 h1:3xHy2bP+rr+2/2uFqliWXGjMPR7umO6mvFXh/TA2aJE=
Expand All @@ -1178,6 +1182,8 @@ github.com/openconfig/replayer v0.0.0-20231017143923-d23179322187 h1:BLLFxnn1kDF
github.com/openconfig/replayer v0.0.0-20231017143923-d23179322187/go.mod h1:IV6R35V5mbZbMdRjn1nIn+T//9s4vFPGhiRAgGSYqlQ=
github.com/openconfig/replayer v0.0.0-20231027154425-b7fb1391cb3c h1:MOmc5EWf8AWJFVsJGsOI3JVY1lR9MLJYpzIgDbNfmtY=
github.com/openconfig/replayer v0.0.0-20231027154425-b7fb1391cb3c/go.mod h1:qWxkJVt7w/SWhrTyxwAWGHUG1nT2hqDRtL74u5SuMh0=
github.com/openconfig/replayer v0.0.0-20231031192218-5462382820d4 h1:ohE/OcV38lEOt7IHOtFzjYVzzoCgMYp3sqJBKmVwuw0=
github.com/openconfig/replayer v0.0.0-20231031192218-5462382820d4/go.mod h1:qWxkJVt7w/SWhrTyxwAWGHUG1nT2hqDRtL74u5SuMh0=
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07 h1:X631iD/B0ximGFb5P9LY5wHju4SiedxUhc5UZEo7VSw=
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07/go.mod h1:bmpU0kIsCiXuncozViVuQx1HqolC3C94H7lD9KKmoTo=
github.com/openconfig/ygnmi v0.9.0 h1:u3NJNoJLJZu3c+93ZgKas65mggykNg6UT/cGEnQSTzU=
Expand Down Expand Up @@ -1971,6 +1977,8 @@ google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0=
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8=
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE=
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA=
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI=
google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8=
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig=
google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig=
Expand All @@ -1980,6 +1988,7 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130/go.
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU=
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0=
google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:SUBoKXbI1Efip18FClrQVGjWcyd0QZd8KkvdP34t7ww=
google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
Expand All @@ -1990,6 +1999,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130/go.
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down Expand Up @@ -2098,6 +2109,7 @@ k8s.io/client-go v0.26.3 h1:k1UY+KXfkxV2ScEL3gilKcF7761xkYsSD6BC9szIu8s=
k8s.io/client-go v0.26.3/go.mod h1:ZPNu9lm8/dbRIPAgteN30RSXea6vrCpFvq+MateTUuQ=
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg=
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY=
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 h1:xMMXJlJbsU8w3V5N2FLDQ8YgU8s1EoULdbQBcAeNJkY=
Expand Down
Loading