Skip to content

Commit

Permalink
init gh actions e2e workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Mar 14, 2023
1 parent 407c762 commit c5c61fe
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .mk/e2e.mk
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include .mk/lint.mk
include .mk/e2e.mk

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
21 changes: 21 additions & 0 deletions tests/e2e/kind-bridge.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c5c61fe

Please sign in to comment.