Skip to content

Commit

Permalink
Basic presubmit (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 authored Oct 28, 2022
1 parent a8c00aa commit 2ac420a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cloudbuild/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lemming CI

## Presubmit

Any PR triggers the presubmit job. The presubmit creates GCE VM, sets up KNE instance, and runs tests in integration_tests folder.

See [remote-builder](https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/remote-builder) for details on the remote builder.
13 changes: 13 additions & 0 deletions cloudbuild/presubmit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -xe

export PATH=${PATH}:/usr/local/go/bin
gopath=$(go env GOPATH)
export PATH=${PATH}:$gopath/bin

cd /tmp/workspace
kne deploy ~/kne-internal/deploy/kne/kind-bridge.yaml
make deploy itest
make clean
make deploy2 itest2
17 changes: 17 additions & 0 deletions cloudbuild/presubmit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
steps:
- id: remote_builder_test
name: gcr.io/$PROJECT_ID/remote-builder
env:
- USERNAME=user
- SSH_ARGS=--internal-ip --ssh-key-expire-after=1d
- INSTANCE_NAME=kne-presubmit-$BUILD_ID
- INSTANCE_ARGS=--network cloudbuild-workers --image-project gep-kne --image-family kne --machine-type n2-standard-16 --preemptible
- ZONE=us-central1-a
- REMOTE_WORKSPACE=/tmp/workspace
- COMMAND=source /tmp/workspace/cloudbuild/presubmit.sh 2>&1

timeout: 1800s

options:
pool:
name: 'projects/openconfig-lemming/locations/us-central1/workerPools/lemming-workerpool'
9 changes: 6 additions & 3 deletions integration_tests/traffic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func waitOTGARPEntry(t *testing.T) {
// testTraffic generates traffic flow from source network to
// destination network via srcEndPoint to dstEndPoint and checks for
// packet loss and returns loss percentage as float.
func testTraffic(t *testing.T, ate *ondatra.ATEDevice, top gosnappi.Config, srcEndPoint, dstEndPoint Attributes) float32 {
func testTraffic(t *testing.T, ate *ondatra.ATEDevice, top gosnappi.Config, srcEndPoint, dstEndPoint Attributes, dur time.Duration) float32 {
otg := ate.OTG()
gwIP := gatewayMap[srcEndPoint].IPv4
waitOTGARPEntry(t)
Expand All @@ -201,7 +201,7 @@ func testTraffic(t *testing.T, ate *ondatra.ATEDevice, top gosnappi.Config, srcE
otg.PushConfig(t, top)

otg.StartTraffic(t)
time.Sleep(15 * time.Second)
time.Sleep(dur)
t.Logf("Stop traffic")
otg.StopTraffic(t)

Expand Down Expand Up @@ -360,7 +360,10 @@ func TestIPv4Entry(t *testing.T) {
chk.HasResult(t, c.Results(t), wantResult, chk.IgnoreOperationID())
}

loss := testTraffic(t, ate, ateTop, atePort1, atePort2)
// Send some traffic to make sure neighbor cache is warmed up on the dut.
testTraffic(t, ate, ateTop, atePort1, atePort2, 1*time.Second)

loss := testTraffic(t, ate, ateTop, atePort1, atePort2, 15*time.Second)
if loss > 1 {
t.Errorf("Loss: got %g, want <= 1", loss)
}
Expand Down
2 changes: 2 additions & 0 deletions kne/topo.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "ixia-c"
nodes: {
name: "otg"
type: IXIA_TG
vendor: KEYSIGHT
version: "0.0.1-9999"
services: {
key: 40051
Expand All @@ -21,6 +22,7 @@ nodes: {
nodes: {
name: "lemming"
type: LEMMING
vendor: OPENCONFIG
config: {
args: "--target=lemming"
args: "--enable_dataplane"
Expand Down
2 changes: 2 additions & 0 deletions kne/twodut_topo.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "twodut"
nodes: {
name: "lemming"
type: LEMMING
vendor: OPENCONFIG
config: {
args: "--target=lemming"
args: "--enable_dataplane"
Expand All @@ -13,6 +14,7 @@ nodes: {
nodes: {
name: "lemming2"
type: LEMMING
vendor: OPENCONFIG
config: {
args: "--target=lemming2"
args: "--enable_dataplane"
Expand Down

0 comments on commit 2ac420a

Please sign in to comment.