Skip to content

Commit

Permalink
update presubmit (#340)
Browse files Browse the repository at this point in the history
* update presubmit

* update go mod and fmt

* expand test

* fix lint

* fix linter

* add missing cluster delete

* fix vm name overlap

* fix path resolution

* fix bad indentation

* remove interactive mode

* remove interactive mode for cp

* address comments

* fix failure in kubeadm cluster

* add sudo back for kubeadm

* add unlicensed ixia option

* increase boot disk size to avoid space issues

* use separate dep cfg

* fix filepath

* enable nested virt

* fix test path

* fix flags

* revert timeout

* use ondatra 1.9

* update srl model

* remove p4rt from xrd test
  • Loading branch information
alexmasi authored Mar 24, 2023
1 parent e196aa6 commit bed949c
Show file tree
Hide file tree
Showing 22 changed files with 1,644 additions and 396 deletions.
3 changes: 3 additions & 0 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ issues:
- linters:
- revive
text: "var-naming: don't use leading k"
- linters:
- staticcheck
text: "SA1019:"
linters:
disable-all: true
enable:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
go-version: 1.20.x
- run: |
# shellcheck disable=2046
go test -v -coverprofile=profile.cov $(go list ./... | grep -v /cloudbuild/) # ignore cloudbuild tests
go test -v -coverprofile=profile.cov $(go list ./... | grep -v /cloudbuild) # ignore cloudbuild tests
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ all: docker
## Run unit tests
## Ignore all tests under the cloudbuild/ tree as these targets are end-to-end
test:
go test `go list ./... | grep -v /cloudbuild/`
go test `go list ./... | grep -v /cloudbuild`

## Targets below are for integration testing only

Expand Down
116 changes: 116 additions & 0 deletions cloudbuild/kne_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash
# Copyright 2023 Google LLC
#
# 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
#
# https://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.

set -xe

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

# Replace exisiting kne repo with new version
rm -r "$HOME/kne"
cp -r /tmp/workspace "$HOME/kne"

# Rebuild the kne cli
pushd "$HOME/kne/kne_cli"
go build -o kne
cli="$HOME/kne/kne_cli/kne"
popd

# Deploy a kind cluster
pushd "$HOME"
$cli deploy kne/deploy/kne/kind-bridge.yaml

kubectl get pods -A

# Redeploy the same cluster
$cli deploy kne/deploy/kne/kind-bridge.yaml

kubectl get pods -A

# Cleanup the kind cluster
kind delete cluster --name kne

# Create a kind cluster with GAR access and image loading
cat >/tmp/dep-cfg.yaml << EOF
cluster:
kind: Kind
spec:
name: kne
recycle: True
version: v0.17.0
image: 'kindest/node:v1.26.0'
googleArtifactRegistries:
- us-west1-docker.pkg.dev
containerImages:
'us-west1-docker.pkg.dev/kne-external/kne/networkop/init-wait:ga': 'networkop/init-wait:latest'
config: ${HOME}/kne/kind/kind-no-cni.yaml
additionalManifests:
- ${HOME}/kne/manifests/kind/kind-bridge.yaml
ingress:
kind: MetalLB
spec:
manifest: ${HOME}/kne/manifests/metallb/manifest.yaml
ip_count: 100
cni:
kind: Meshnet
spec:
manifest: ${HOME}/kne/manifests/meshnet/grpc/manifest.yaml
EOF

$cli deploy /tmp/dep-cfg.yaml

kubectl get pods -A

# Check for existence of preloaded image
if ! docker exec kne-control-plane crictl images | grep "docker.io/networkop/init-wait"; then
echo "Unable to find preloaded image in cluster"
exit 1
fi

# Cleanup the kind cluster
kind delete cluster --name kne

# Create a kubeadm single node cluster
sudo kubeadm init --cri-socket unix:///var/run/cri-dockerd.sock --pod-network-cidr 10.244.0.0/16
mkdir -p "$HOME"/.kube
sudo cp /etc/kubernetes/admin.conf "$HOME"/.kube/config
sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config
kubectl taint nodes --all node-role.kubernetes.io/control-plane- # allows pods to be scheduled on control plane node
kubectl apply -f "$HOME"/flannel/Documentation/kube-flannel.yml
docker network create multinode

# Deploy an external cluster
$cli deploy kne/deploy/kne/external-multinode.yaml

kubectl get pods -A

# Create a simple lemming topology
$cli create kne/examples/openconfig/lemming.pb.txt

kubectl get pods -A

kubectl get services -A

# Use the KNE cli to interact with the topology
$cli show kne/examples/openconfig/lemming.pb.txt

$cli topology service kne/examples/openconfig/lemming.pb.txt

# Delete the topology

$cli delete kne/examples/openconfig/lemming.pb.txt

popd
20 changes: 16 additions & 4 deletions cloudbuild/presubmit.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
steps:
- id: remote_builder_test
- id: kne_test
name: gcr.io/$PROJECT_ID/remote-builder
waitFor: ["-"]
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
- INSTANCE_NAME=kne-presubmit-kne-$BUILD_ID
- INSTANCE_ARGS=--network cloudbuild-workers --image-project gep-kne --image-family kne --machine-type e2-standard-4 --boot-disk-size 100GB --preemptible
- ZONE=us-central1-a
- REMOTE_WORKSPACE=/tmp/workspace
- COMMAND=source /tmp/workspace/cloudbuild/presubmit.sh 2>&1
- COMMAND=source /tmp/workspace/cloudbuild/kne_test.sh 2>&1
- id: vendors_test
name: gcr.io/$PROJECT_ID/remote-builder
waitFor: ["-"]
env:
- USERNAME=user
- SSH_ARGS=--internal-ip --ssh-key-expire-after=1d
- INSTANCE_NAME=kne-presubmit-vendors-$BUILD_ID
- INSTANCE_ARGS=--network cloudbuild-workers --image-project gep-kne --image-family kne --machine-type n2-standard-16 --boot-disk-size 100GB --enable-nested-virtualization --preemptible
- ZONE=us-central1-a
- REMOTE_WORKSPACE=/tmp/workspace
- COMMAND=source /tmp/workspace/cloudbuild/vendors_test.sh 2>&1

timeout: 1800s

Expand Down
132 changes: 0 additions & 132 deletions cloudbuild/presubmit/presubmit_test.go

This file was deleted.

Loading

0 comments on commit bed949c

Please sign in to comment.