Skip to content

Commit

Permalink
clean up additional feature.textproto tools, fix static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dplore committed Nov 18, 2024
1 parent 735ea2a commit 78d6dad
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1,228 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/protobufs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Protobufs

on:
push:
branches: [ main ]
pull_request:
schedule:
- cron: "0 0 * * *"

jobs:
validate_protobufs:
name: Validate Protobufs
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.21'
- name: Checkout code
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Install protobuf
uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint protobufs
run: |
go install github.com/googleapis/api-linter/cmd/api-linter@latest
make protoimports
cd protobuf-import
find github.com/openconfig/featureprofiles/ -name \*.proto -exec api-linter --disable-rule all --enable-rule core {} \+
- name: Validate textprotos
run: |
go install github.com/bstoll/textproto-validator@latest
make protoimports
for i in `find . -name \*.textproto`; do
textproto-validator -I ./protobuf-import $i
done
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ GO_PROTOS:=proto/feature_go_proto/feature.pb.go proto/metadata_go_proto/metadata
.PHONY: all clean protos validate_paths protoimports
all: openconfig_public protos validate_paths

openconfig_public:
tools/clone_oc_public.sh openconfig_public

protos: $(GO_PROTOS)

protoimports:
Expand All @@ -39,11 +36,6 @@ protoimports:
go list -f '{{ .Dir }} protobuf-import/{{ .Path }}' -m github.com/openconfig/kne | xargs -L1 -- ln -s
ln -s $(ROOT_DIR) protobuf-import/github.com/openconfig/featureprofiles

proto/feature_go_proto/feature.pb.go: proto/feature.proto
mkdir -p proto/feature_go_proto
protoc --proto_path=proto --go_out=./ --go_opt=Mfeature.proto=proto/feature_go_proto feature.proto
goimports -w proto/feature_go_proto/feature.pb.go

proto/metadata_go_proto/metadata.pb.go: proto/metadata.proto protoimports
mkdir -p proto/metadata_go_proto
protoc -I='protobuf-import' --proto_path=proto --go_out=./ --go_opt=Mmetadata.proto=proto/metadata_go_proto metadata.proto
Expand Down
8 changes: 8 additions & 0 deletions internal/otg_helpers/otg_config_helpers/otgconfighelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type InterfaceProperties struct {

// ConfigureOtgNetworkInterface configures the network interface.
func ConfigureOtgNetworkInterface(t *testing.T, top gosnappi.Config, ate *ondatra.ATEDevice, a *Port) {
t.Helper()

if a.Islag {
ConfigureOtgLag(t, top, ate, a)
} else {
Expand All @@ -76,6 +78,8 @@ func ConfigureOtgNetworkInterface(t *testing.T, top gosnappi.Config, ate *ondatr

// ConfigureOtgLag configures the aggregate port.
func ConfigureOtgLag(t *testing.T, top gosnappi.Config, ate *ondatra.ATEDevice, a *Port) {
t.Helper()

agg := top.Lags().Add().SetName(a.Name)
agg.Protocol().Lacp().SetActorKey(1).SetActorSystemPriority(1).SetActorSystemId(a.AggMAC)
for index, portName := range a.MemberPorts {
Expand All @@ -87,13 +91,17 @@ func ConfigureOtgLag(t *testing.T, top gosnappi.Config, ate *ondatra.ATEDevice,

// ConfigureOtgLagMemberPort configures the member port in the LAG.
func ConfigureOtgLagMemberPort(agg gosnappi.Lag, portID string, a *Port, index int) {
t.Helper()

lagPort := agg.Ports().Add().SetPortName(portID)
lagPort.Ethernet().SetMac(a.AggMAC).SetName(a.Name + "-" + portID)
lagPort.Lacp().SetActorActivity("active").SetActorPortNumber(uint32(index) + 1).SetActorPortPriority(1).SetLacpduTimeout(0)
}

// ConfigureOtgInterface configures the Ethernet for the LAG or subinterface.
func ConfigureOtgInterface(t *testing.T, top gosnappi.Config, intf *InterfaceProperties, a *Port) {
t.Helper()

dev := top.Devices().Add().SetName(intf.Name + ".Dev")
eth := dev.Ethernets().Add().SetName(intf.Name + ".Eth").SetMac(intf.Mac)
if a.Islag {
Expand Down
109 changes: 0 additions & 109 deletions proto/feature.proto

This file was deleted.

Loading

0 comments on commit 78d6dad

Please sign in to comment.