Skip to content

Commit

Permalink
test: Create multi node kind cluster and use alpine images (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike authored Sep 17, 2024
1 parent 71cc64e commit 3167d2e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-dummy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: e2e-dummy
jobs:
e2e-dummy:
name: ${{ matrix.kind-k8s-version }}
runs-on: ubuntu-latest
runs-on: [self-hosted, ops]
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.22 AS builder
FROM golang:1.22-alpine AS builder

ARG RELEASE_VERSION=master
ARG RELEASE_COMMIT=none
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ endif
eval \$$($(GOBIN)/setup-envtest use -p env ${TEST_K8S_VERSION}); \
export USE_CERTMANAGER=false; \
export TEST_USE_EXISTING_CLUSTER=false; \
$(GINKGO) --label-filter=envtest -vv --no-color --procs 3 -output-dir=${PWD} -keep-separate-reports --junit-report=test-results-junit.xml --randomize-suites --randomize-all -timeout 10m ./... -covermode=count -coverprofile cover.out \
$(GINKGO) --label-filter=envtest -vv --no-color --procs 3 -output-dir=${PWD} -keep-separate-reports -race --junit-report=test-results-junit.xml --randomize-suites --randomize-all -timeout 10m ./... -covermode=count -coverprofile cover.out \
"

##@ Build
Expand Down
3 changes: 1 addition & 2 deletions hack/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PATH=$bin_dir/goinstall/bin:$bin_dir:/usr/local/go/bin:$PATH
GOBIN=$bin_dir

start_kind_cluster() {
$kind create cluster --name kind --image $kindest_node_image_multiplatform_amd64_arm64 --wait 300s
$kind create cluster --name kind --config hack/kind-config.yaml --image $kindest_node_image_multiplatform_amd64_arm64 --wait 300s

sleep 5

Expand All @@ -25,7 +25,6 @@ start_kind_cluster() {
exit 1
fi

$kubectl label node --overwrite --all topology.kubernetes.io/zone=az1
$kubectl patch clusterrolebinding cluster-admin --type='json' -p='[{"op": "add", "path": "/subjects/1", "value": {"kind": "ServiceAccount", "name": "default", "namespace": "default" } }]'
}

Expand Down
13 changes: 13 additions & 0 deletions hack/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
labels:
"topology.kubernetes.io/zone": "us-west-2a"
- role: worker
labels:
"topology.kubernetes.io/zone": "us-west-2b"
- role: worker
labels:
"topology.kubernetes.io/zone": "us-west-2c"
2 changes: 1 addition & 1 deletion hack/run-e2e-within-kind-test-pod-dummy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -x -o pipefail
source hack/functions.sh

# We skip the helpers package as those tests assumes the environment variable USE_CERT_MANAGER is not set.
USE_CERTMANAGER=true TEST_USE_EXISTING_CLUSTER=true DUMMY_LOGSCALE_IMAGE=true ginkgo --label-filter=dummy -timeout 1h -nodes=$GINKGO_NODES --no-color --skip-package helpers -race -v ./controllers/suite/... -covermode=count -coverprofile cover.out -progress | tee /proc/1/fd/1
USE_CERTMANAGER=true TEST_USE_EXISTING_CLUSTER=true DUMMY_LOGSCALE_IMAGE=true ginkgo --label-filter=dummy -timeout 1h -nodes=$GINKGO_NODES --no-color --skip-package helpers -v ./controllers/suite/... -covermode=count -coverprofile cover.out -progress | tee /proc/1/fd/1
2 changes: 1 addition & 1 deletion hack/run-e2e-within-kind-test-pod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -x -o pipefail
source hack/functions.sh

# We skip the helpers package as those tests assumes the environment variable USE_CERT_MANAGER is not set.
USE_CERTMANAGER=true TEST_USE_EXISTING_CLUSTER=true ginkgo --label-filter=real -timeout 120m -nodes=$GINKGO_NODES --no-color --skip-package helpers -race -v ./controllers/suite/... -covermode=count -coverprofile cover.out -progress | tee /proc/1/fd/1
USE_CERTMANAGER=true TEST_USE_EXISTING_CLUSTER=true ginkgo --label-filter=real -timeout 120m -nodes=$GINKGO_NODES --no-color --skip-package helpers -v ./controllers/suite/... -covermode=count -coverprofile cover.out -progress | tee /proc/1/fd/1
2 changes: 1 addition & 1 deletion images/helper/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 AS builder
FROM golang:1.22-alpine AS builder

ARG RELEASE_VERSION=master
ARG RELEASE_COMMIT=none
Expand Down
6 changes: 4 additions & 2 deletions images/logscale-dummy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM golang:1.22 AS builder
FROM golang:1.22-alpine AS builder

RUN apk add bash

WORKDIR /app/humio
COPY . /app/humio
RUN go run "$(go env GOROOT)/src/crypto/tls/generate_cert.go" -host dummy
RUN chmod a+r key.pem
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/humio/dummy /app/humio/*.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/humio/dummy /app/humio/*.go
7 changes: 5 additions & 2 deletions test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM golang:1.22.2
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.22.2-alpine

RUN apk add bash

# Create and populate /var/src with the source code for the humio-operator repository
RUN mkdir /var/src
COPY ./ /var/src
COPY --exclude=tmp --exclude=bin ./ /var/src
WORKDIR /var/src

RUN bash -c "rm -rf /var/src/tmp/*"
Expand Down

0 comments on commit 3167d2e

Please sign in to comment.