diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..c49ec6b --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,38 @@ +"on": + workflow_dispatch: + inputs: + kne_ref: + description: "openconfig/kne reference (tag, commit, branch)" + type: string + default: v0.24.4 + kind_version: + description: "KinD version" + type: string + required: true + default: v0.17.0 + +jobs: + e2e: + name: End-to-end test + runs-on: ubuntu-latest + + steps: + - name: Set env vars + run: | + echo "KNE_REF=${{ inputs.kne_ref }}" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GOVER }} + + - name: set up kind cluster + uses: engineerd/setup-kind@v0.5.0 + with: + version: ${{ inputs.kind_version }} + + - uses: actions/checkout@v3 + # - uses: fregante/setup-git-user@v1 + + - name: Publish structs + run: make install-srl-controller diff --git a/.mk/e2e.mk b/.mk/e2e.mk new file mode 100644 index 0000000..a725de4 --- /dev/null +++ b/.mk/e2e.mk @@ -0,0 +1,36 @@ +# KNE_REF is a git reference to use for KNE. It can be a branch, tag, or commit hash. +KNE_REF ?= dee1995a7ec0f446b159a35fad201df9185ee75d +KNE_REPO := https://github.com/openconfig/kne.git +KNE_TEMP_DIR := /tmp/.srlcontroller-tests/kne +KNE_TEST_DEPLOYMENT_FILE := ${KNE_TEMP_DIR}/deploy/kne/kind-bridge-no-controllers.yaml +KIND_CLUSTER_NAME ?= srl-test + +.PHONY: install-kne +install-kne: ## Install KNE + rm -rf ${KNE_TEMP_DIR} && \ + mkdir -p ${KNE_TEMP_DIR} && \ + git clone ${KNE_REPO} ${KNE_TEMP_DIR} && \ + cd ${KNE_TEMP_DIR} && git checkout ${KNE_REF} && \ + make install + +.PHONY: kne-test-deployment-cfg-file +kne-test-deployment-cfg-file: ## Create a KNE test deployment config file without controllers section + sed -n '/controllers:/q;p' < ${KNE_TEMP_DIR}/deploy/kne/kind-bridge.yaml > ${KNE_TEST_DEPLOYMENT_FILE} + sed -i 's/name: kne/name: ${KIND_CLUSTER_NAME}/g' ${KNE_TEST_DEPLOYMENT_FILE} + +.PHONY: deploy-kne +deploy-kne: ## Deploy KNE kind cluster + kind delete cluster --name=${KIND_CLUSTER_NAME} && \ + cd ${KNE_TEMP_DIR} && kne deploy ${KNE_TEST_DEPLOYMENT_FILE} + +.PHONY: temp-docker-build +temp-docker-build: ## Built controller container using the image and tag specified in the manager's manifest + image="$(shell docker run -i --rm mikefarah/yq '.images[0].newName' < config/manager/kustomization.yaml)" tag="$(shell docker run -i --rm mikefarah/yq '.images[0].newTag' < config/manager/kustomization.yaml)" && \ + docker build -t $$image:$$tag . && \ + kind load docker-image $$image:$$tag --name ${KIND_CLUSTER_NAME} + +.PHONY: install-srl-controller +install-srl-controller: install-kne kne-test-deployment-cfg-file deploy-kne temp-docker-build ## Install srl-controller from current working dir + kubectl apply -k config/default + @echo "wait for controller manager to be ready" + kubectl -n srlinux-controller wait --for=condition=Available deployment.apps/srlinux-controller-controller-manager diff --git a/Makefile b/Makefile index 9d554db..386704a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ include .mk/lint.mk +include .mk/e2e.mk # Image URL to use all building/pushing image targets IMG ?= controller:latest diff --git a/README.md b/README.md index 7bca329..6e4c864 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To install the latest version of this controller on a cluster referenced in `~/. # latest version kubectl apply -k https://github.com/srl-labs/srl-controller/config/default -# specific version +# specific version (using git reference, e.g. tag or commit) kubectl apply -k https://github.com/srl-labs/srl-controller/config/default?ref=v0.3.1 ``` diff --git a/tests/e2e/kind-bridge.yml b/tests/e2e/kind-bridge.yml new file mode 100644 index 0000000..2b0239f --- /dev/null +++ b/tests/e2e/kind-bridge.yml @@ -0,0 +1,21 @@ +# copied from https://github.com/openconfig/kne/blob/main/deploy/kne/kind-bridge.yaml +# with controllers removed +cluster: + kind: Kind + spec: + name: kne + recycle: True + version: v0.17.0 + image: kindest/node:v1.26.0 + config: ../../kind/kind-no-cni.yaml + additionalManifests: + - ../../manifests/kind/kind-bridge.yaml +ingress: + kind: MetalLB + spec: + manifest: ../../manifests/metallb/manifest.yaml + ip_count: 100 +cni: + kind: Meshnet + spec: + manifest: ../../manifests/meshnet/grpc/manifest.yaml