Skip to content

Commit bf29ec1

Browse files
authored
Merge branch 'main' into gcodeflux-patch-4
2 parents 90ae71d + a309477 commit bf29ec1

File tree

68 files changed

+7417
-893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+7417
-893
lines changed

.gemini/config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See reference at https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github#config.yaml-schema
2+
have_fun: false
3+
memory_config:
4+
disabled: false
5+
code_review:
6+
disable: false
7+
comment_severity_threshold: MEDIUM
8+
max_review_comments: -1
9+
pull_request_opened:
10+
help: false
11+
summary: true
12+
code_review: true
13+
include_drafts: true
14+
ignore_patterns: []

.gemini/styleguide.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
### **1. General Coding & Contribution Guidelines**
2+
3+
**Source:** `CONTRIBUTING.md`
4+
5+
* **License Requirement:** All code must be Apache 2.0 licensed, and authors
6+
must sign the Google CLA.
7+
* **Go Code Style:**
8+
9+
* Follow
10+
[Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments),
11+
[Effective Go](https://go.dev/doc/effective_go), and
12+
[Google Go Style Guide](https://google.github.io/styleguide/go/) for
13+
writing readable Go code with a consistent look and feel.
14+
15+
* Tests should follow
16+
[Testing on the Toilet](https://testing.googleblog.com/) best practices.
17+
18+
* Use
19+
[Table Driven Tests](https://github.com/golang/go/wiki/TableDrivenTests),
20+
but **do not** run test cases in parallel.
21+
22+
* **Directory Structure:**
23+
24+
* Directory names must **not** contain hyphens (`-`).
25+
* Tests must be nested under `tests/` or `otg_tests/` directories.
26+
* Organization format:
27+
`feature/<featurename>/[<sub-feature>/]<tests|otg_tests|kne_tests>/<test_name>/<test_name>.go`.
28+
29+
* **Code Should Follow The Test README:**
30+
31+
* The test `README.md` should be structured following the
32+
[test plan template]([url]\(https://github.com/openconfig/featureprofiles/blob/main/doc/test-requirements-template.md\)).
33+
34+
* Each step in the test plan procedure should correspond to a comment or
35+
`t.Log`in the code. Steps not covered by code should have a TODO comment
36+
in the test code.
37+
38+
* In the PR, please mention any corrections made to the test README for
39+
errors that were discovered when implementing the code.
40+
41+
* **File Types:**
42+
43+
* Source code, text-formatted protos, and device configs must **not** be
44+
executable.
45+
* Only scripts (Shell, Python, Perl) may be executable.
46+
47+
* **Test Structure:**
48+
49+
* Test code must follow the steps documented in the test `README.md`.
50+
* Environment setup code should be placed in a function named
51+
setupEnvironment and called from TestMain
52+
* Use `t.Run` for subtests so output clearly reflects passed/failed steps.
53+
* **Avoid `time.Sleep`**: Use `gnmi.Watch` with `.Await` for waiting on
54+
conditions.
55+
56+
* **Enums:**
57+
58+
* Do not use numerical enum values (e.g., `6`). Use the ygot-generated
59+
constants (e.g., `telemetry.PacketMatchTypes_IP_PROTOCOL_IP_TCP`).
60+
61+
* **Network Assignments:**
62+
63+
* **IPv4:** Use RFC 5737 blocks (`192.0.2.0/24`, `198.51.100.0/24`,
64+
`203.0.113.0/24`) or `100.64.0.0/10`, `198.18.0.0/15`.
65+
* **IPv6:** Use RFC 3849 (`2001:DB8::/32`), sub-divided for control/data
66+
planes.
67+
* **ASNs:** Use RFC 5398 (`64496-64511` or `65536-65551`).
68+
* **Do not use:** `1.1.1.1`, `8.8.8.8`, or common local private ranges
69+
like `192.168.0.0/16`.
70+
71+
### **2. Deviation Guidelines**
72+
73+
**Source:** `internal/deviations/README.md`
74+
75+
* **When to use:** Use deviations to allow alternate OC paths or CLI commands
76+
to achieve the *same* operational intent. Do not use them to skip validation
77+
or change the intent of the test.
78+
* **Implementation Steps:**
79+
1. Define the deviation in `proto/metadata.proto`.
80+
2. Generate Go code using `make proto/metadata_go_proto/metadata.pb.go`.
81+
3. Add an accessor function in `internal/deviations/deviations.go`. This
82+
must accept `*ondatra.DUTDevice`.
83+
5. Add a comment to the accessor function containing a URL link to an
84+
issue tracker which tracks removal of the deviation. The format should
85+
be `https://issuetracker.google.com/issues/xxxxx`. If the issue is not
86+
tracked at Google, another URL could be used.
87+
7. Enable the deviation in the test's `metadata.textproto` file.
88+
89+
* **Usage in Tests:** Access deviations via `deviations.DeviationName(dut)`.
90+
91+
92+
### **3. Configuration Plugins (`cfgplugins`) Guidelines**
93+
94+
**Source:** `internal/cfgplugins/README.md`
95+
96+
* **Purpose:** Use `cfgplugins` to generate reusable configuration snippets
97+
for the DUT.
98+
* **Implementation:**
99+
* Functions should align with the `/feature` folder structure.
100+
* Use a struct to pass configuration parameters.
101+
* **Function Signature:** Must be `(t *testing.T, dut *ondatra.DUTDevice,
102+
sb *gnmi.SetBatch, cfg MyConfigStruct) *gnmi.SetBatch`.
103+
* **Workflow:**
104+
* The plugin appends config to the `*gnmi.SetBatch` object.
105+
* The **calling test code** is responsible for executing `batch.Set(t,
106+
dut)` to apply the config.
107+
* **Deviations:** Deviations that affect configuration generation should be
108+
implemented *inside* the `cfgplugins` function, not in the test file.
109+

.github/workflows/go.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ on:
66
pull_request:
77
schedule:
88
- cron: "0 0 * * *"
9-
109
jobs:
1110
build:
1211
runs-on: ubuntu-latest
1312
steps:
1413
- uses: actions/checkout@v4
14+
# Go & staticcheck build cache require a lot of disk space. Reclaim extra
15+
# space for the container by removing unnecessary tooling.
16+
- name: Free additional disk space
17+
run: |
18+
sudo rm -rf /usr/share/dotnet
19+
sudo rm -rf /usr/local/lib/android
20+
sudo rm -rf /opt/hostedtoolcache/CodeQL
1521
- name: Set up Go
1622
uses: actions/setup-go@v5
1723
with:
@@ -23,6 +29,10 @@ jobs:
2329
~/go/pkg/mod
2430
~/.cache/go-build
2531
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
32+
- name: Move cache
33+
run: |
34+
sudo mv "${HOME}/.cache" /mnt/cache
35+
ln -s /mnt/cache "${HOME}/.cache"
2636
# Dependency for Go module github.com/google/gopacket
2737
- name: Install libpcap-dev
2838
run: sudo apt-get -y install libpcap-dev
@@ -31,8 +41,15 @@ jobs:
3141

3242
test:
3343
runs-on: ubuntu-latest
34-
steps:
44+
steps:
3545
- uses: actions/checkout@v4
46+
# Go & staticcheck build cache require a lot of disk space. Reclaim extra
47+
# space for the container by removing unnecessary tooling.
48+
- name: Free additional disk space
49+
run: |
50+
sudo rm -rf /usr/share/dotnet
51+
sudo rm -rf /usr/local/lib/android
52+
sudo rm -rf /opt/hostedtoolcache/CodeQL
3653
- name: Set up Go
3754
uses: actions/setup-go@v5
3855
with:
@@ -44,6 +61,10 @@ jobs:
4461
~/go/pkg/mod
4562
~/.cache/go-build
4663
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
64+
- name: Move cache
65+
run: |
66+
sudo mv "${HOME}/.cache" /mnt/cache
67+
ln -s /mnt/cache "${HOME}/.cache"
4768
# Dependency for Go module github.com/google/gopacket
4869
- name: Install libpcap-dev
4970
run: sudo apt-get -y install libpcap-dev
@@ -59,19 +80,15 @@ jobs:
5980
runs-on: ubuntu-latest
6081
steps:
6182
- uses: actions/checkout@v4
62-
- name: Set up Go
63-
uses: actions/setup-go@v5
64-
with:
65-
go-version-file: 'go.mod'
66-
# Go & staticcheck build cache require a lot of disk space. Reclaim extra
67-
# space for the container by removing unnecessary tooling.
6883
- name: Free additional disk space
6984
run: |
7085
sudo rm -rf /usr/share/dotnet
7186
sudo rm -rf /usr/local/lib/android
7287
sudo rm -rf /opt/hostedtoolcache/CodeQL
73-
sudo mv "${HOME}/.cache" /mnt/cache
74-
ln -s /mnt/cache "${HOME}/.cache"
88+
- name: Set up Go
89+
uses: actions/setup-go@v5
90+
with:
91+
go-version-file: 'go.mod'
7592
- name: Cache
7693
uses: actions/cache@v4
7794
with:
@@ -80,6 +97,10 @@ jobs:
8097
~/.cache/go-build
8198
~/.cache/staticcheck
8299
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
100+
- name: Move cache
101+
run: |
102+
sudo mv "${HOME}/.cache" /mnt/cache
103+
ln -s /mnt/cache "${HOME}/.cache"
83104
# Dependency for Go module github.com/google/gopacket
84105
- name: Install libpcap-dev
85106
run: sudo apt-get -y install libpcap-dev

0 commit comments

Comments
 (0)