Skip to content

Commit

Permalink
Add CI job for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuvesz committed Jul 18, 2023
1 parent 34071dc commit bc3d735
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/actions/kind-create/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Setup kind cluster"
description: "Creates a kind cluster to be used elsewhere"
inputs: # adding these parameters to make this reusable later on
kind_cluster_name:
description: "The kind cluster name to use"
required: true
default: "e2e-kind"
kind_k8s_version:
description: 'The k8s version to use'
required: true
default: 'v1.24.15'
kind_config:
description: 'Path to the kind config to use'
required: true
default: 'tests/e2e/platforms/kind/kind_config.yaml'
outputs:
kubeconfig:
description: 'Path of the resulting kubeconfig'
value: ${{ steps.check-kind-cluster.outputs.kubeconfig }}

runs:
using: "composite"

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: engineerd/[email protected]
with:
name: ${{ inputs.kind_cluster_name }}
version: v0.20.0
image: kindest/node:${{ inputs.kind_k8s_version }}
config: ${{ inputs.kind_config }}

- name: Check kind cluster and extract kubeconfig
id: check-kind-cluster
run: |
kubectl version
kubectl cluster-info
kubectl get pods -n kube-system
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}
mkdir tests/e2e/platforms/kind/${{ inputs.kind_k8s_version }}
kubeconfig_path=$(pwd)/tests/e2e/platforms/kind/${{ inputs.kind_k8s_version }}/kind.kconf
kind get kubeconfig --name ${{ inputs.kind_cluster_name }} > $kubeconfig_path
echo "kubeconfig=$(echo $kubeconfig_path)" >> $GITHUB_OUTPUT
shell: bash
32 changes: 32 additions & 0 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: e2e-test

on:
push:
branches:
- master
- add_kind_ci_execution
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Checkout code
uses: actions/checkout@v3

- name: Setup Kind cluster
id: setup-kind
uses: ./.github/actions/kind-create

- name: run tests
env:
KUBECONFIG: ${{ steps.setup-kind.outputs.kubeconfig }}
run: |
go get github.com/banzaicloud/koperator/tests/e2e
make test-e2e
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test-e2e:
-tags e2e \
--ginkgo.show-node-events \
--ginkgo.trace \
--ginkgo.v
--ginkgo.v

# Build manager binary
manager: generate fmt vet
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/platforms/kind/kind_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker

0 comments on commit bc3d735

Please sign in to comment.