From 2ac420a7a70e41ce2b8c3dd2ca913b19a37c5a28 Mon Sep 17 00:00:00 2001 From: Daniel Grau Date: Fri, 28 Oct 2022 16:01:30 -0700 Subject: [PATCH] Basic presubmit (#88) --- cloudbuild/README.md | 7 +++++++ cloudbuild/presubmit.sh | 13 +++++++++++++ cloudbuild/presubmit.yaml | 17 +++++++++++++++++ integration_tests/traffic_test.go | 9 ++++++--- kne/topo.pb.txt | 2 ++ kne/twodut_topo.pb.txt | 2 ++ 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 cloudbuild/README.md create mode 100755 cloudbuild/presubmit.sh create mode 100644 cloudbuild/presubmit.yaml diff --git a/cloudbuild/README.md b/cloudbuild/README.md new file mode 100644 index 00000000..070d0168 --- /dev/null +++ b/cloudbuild/README.md @@ -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. \ No newline at end of file diff --git a/cloudbuild/presubmit.sh b/cloudbuild/presubmit.sh new file mode 100755 index 00000000..b513c89b --- /dev/null +++ b/cloudbuild/presubmit.sh @@ -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 \ No newline at end of file diff --git a/cloudbuild/presubmit.yaml b/cloudbuild/presubmit.yaml new file mode 100644 index 00000000..2e7a82e9 --- /dev/null +++ b/cloudbuild/presubmit.yaml @@ -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' \ No newline at end of file diff --git a/integration_tests/traffic_test.go b/integration_tests/traffic_test.go index f6ad754e..e2a48d5e 100644 --- a/integration_tests/traffic_test.go +++ b/integration_tests/traffic_test.go @@ -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) @@ -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) @@ -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) } diff --git a/kne/topo.pb.txt b/kne/topo.pb.txt index c7dd665a..01a2baf1 100644 --- a/kne/topo.pb.txt +++ b/kne/topo.pb.txt @@ -2,6 +2,7 @@ name: "ixia-c" nodes: { name: "otg" type: IXIA_TG + vendor: KEYSIGHT version: "0.0.1-9999" services: { key: 40051 @@ -21,6 +22,7 @@ nodes: { nodes: { name: "lemming" type: LEMMING + vendor: OPENCONFIG config: { args: "--target=lemming" args: "--enable_dataplane" diff --git a/kne/twodut_topo.pb.txt b/kne/twodut_topo.pb.txt index d4030cff..49e7c7a0 100644 --- a/kne/twodut_topo.pb.txt +++ b/kne/twodut_topo.pb.txt @@ -2,6 +2,7 @@ name: "twodut" nodes: { name: "lemming" type: LEMMING + vendor: OPENCONFIG config: { args: "--target=lemming" args: "--enable_dataplane" @@ -13,6 +14,7 @@ nodes: { nodes: { name: "lemming2" type: LEMMING + vendor: OPENCONFIG config: { args: "--target=lemming2" args: "--enable_dataplane"