Skip to content

Commit c4d1d10

Browse files
author
Tim Middleton
authored
Add additional kind tests (#131)
* Add additional kind test * Fix workflow * More test updates * More test updates * More test updates * More test updates * more updates * Tweak github actions * further script updates * Fixup perms of docker file * refine docker image * Add iterations parameter to script * Final updates * Update version in Makefile
1 parent 5e76d97 commit c4d1d10

File tree

14 files changed

+790
-5
lines changed

14 files changed

+790
-5
lines changed

.github/workflows/build-kind.yaml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Copyright 2025 Oracle Corporation and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at
3+
# https://oss.oracle.com/licenses/upl.
4+
5+
# ---------------------------------------------------------------------------
6+
# Coherence Go Client GitHub Actions - Kind Tests
7+
# ---------------------------------------------------------------------------
8+
name: CI Kind Tests
9+
10+
on:
11+
push:
12+
branches:
13+
- '*'
14+
workflow_dispatch:
15+
inputs:
16+
go-version:
17+
description: "Go version (comma-separated for matrix)"
18+
required: false
19+
default: "1.23.x,1.24.x"
20+
max-iterations:
21+
description: "Maximum number of iterations"
22+
required: false
23+
default: "10"
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
go-version:
34+
- 1.24.x
35+
36+
# Checkout the source, we need a depth of zero to fetch all of the history otherwise
37+
# the copyright check cannot work out the date of the files from Git.
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Cache Go Modules
44+
# if: github.event_name == 'workflow_dispatch'
45+
uses: actions/cache@v4
46+
with:
47+
path: ~/go/pkg/mod
48+
key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }}
49+
restore-keys: |
50+
${{ runner.os }}-go-mods-
51+
52+
- name: Set up Go
53+
# if: github.event_name == 'workflow_dispatch'
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: '${{ matrix.go-version }}'
57+
58+
- name: Create Kind Cluster
59+
# if: github.event_name == 'workflow_dispatch'
60+
shell: bash
61+
run: |
62+
make kind
63+
make create-namespace deploy-operator
64+
make deploy-coherence
65+
make build-go-client
66+
make load-schools
67+
mkdir -p build/_output/test-logs
68+
69+
- name: Run Tests
70+
# if: github.event_name == 'workflow_dispatch'
71+
shell: bash
72+
env:
73+
MAX_ITERATIONS: ${{ github.event.inputs.max-iterations }}
74+
run: |
75+
export MAX_ITERATIONS
76+
NAMESPACE=coherence-perf
77+
kubectl exec -it -n $NAMESPACE perf-cluster-0 -c coherence -- /coherence-operator/utils/cohctl get caches -o wide
78+
make deploy-test-schools
79+
JOB_NAME=perf-go-client
80+
echo "Waiting for pod from job $JOB_NAME to start running..."
81+
for i in {1..30}; do
82+
POD=$(kubectl get pods -n "$NAMESPACE" -l job-name="$JOB_NAME" -o jsonpath='{.items[0].metadata.name}')
83+
STATUS=$(kubectl get pod "$POD" -n "$NAMESPACE" -o jsonpath='{.status.phase}')
84+
echo "Pod: $POD, Status: $STATUS"
85+
if [[ "$STATUS" == "Running" ]]; then
86+
echo "Pod is running"
87+
break
88+
elif [[ "$STATUS" == "Pending" || "$STATUS" == "ContainerCreating" ]]; then
89+
sleep 2
90+
else
91+
echo "Pod entered unexpected state: $STATUS"
92+
kubectl describe pod "$POD" -n "$NAMESPACE"
93+
exit 1
94+
fi
95+
done
96+
# Put the tail into the background
97+
POD=$(kubectl get pods -n $NAMESPACE | grep perf-go-client | awk '{print $1}')
98+
kubectl logs $POD -n $NAMESPACE -f > build/_output/test-logs/perf-go-client.log 2>&1 &
99+
TAIL_PID=$!
100+
# port forward the http port
101+
echo "Pod: $POD"
102+
kubectl port-forward -n $NAMESPACE pod/${POD} 8080:8080 > build/_output/test-logs/port-forward.log 2>&1 &
103+
PORT_FORWARD_PID=$!
104+
echo "Sleep 10..."
105+
sleep 10
106+
# run curl requests
107+
while : ; do curl -s -v http://127.0.0.1:8080/api/schools?q=[1-2] | jq length || true ; sleep 0.5; done > build/_output/test-logs/curl.log 2>&1 &
108+
CURL_PID=$!
109+
# Start the rolling restart
110+
./scripts/kind/roll-cluster.sh | tee build/_output/test-logs/rolling-restart.log
111+
kill -9 $CURL_PID || true
112+
sleep 5 && kill -9 $PORT_FORWARD_PID || true
113+
kill -9 $TAIL_PID || true
114+
115+
- name: Shutdown
116+
# if: github.event_name == 'workflow_dispatch'
117+
shell: bash
118+
run: |
119+
make kind-stop
120+
121+
- uses: actions/upload-artifact@v4
122+
if: failure()
123+
with:
124+
name: test-output-${{ matrix.go-version }}-failure-logs
125+
path: build/_output/test-logs
126+
127+
- uses: actions/upload-artifact@v4
128+
with:
129+
name: test-output-${{ matrix.go-version }}-test-logs
130+
path: build/_output/test-logs
131+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ certs/
4141
release/
4242
etc/
4343
coherence/coherence.test
44+
runner

Makefile

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# ----------------------------------------------------------------------------------------------------------------------
99

1010
# This is the version of the coherence-go-client
11-
VERSION ?=2.3.0-rc1
11+
VERSION ?=2.3.0-rc2
1212
CURRDIR := $(shell pwd)
1313
USER_ID := $(shell echo "`id -u`:`id -g`")
1414

@@ -178,6 +178,7 @@ copyright: getcopyright ## Check copyright headers
178178
-X proto/ \
179179
-X /Dockerfile \
180180
-X .Dockerfile \
181+
-X runner \
181182
-X go.sum \
182183
-X HEADER.txt \
183184
-X .iml \
@@ -277,6 +278,111 @@ show-docs: ## Show the Documentation
277278
trivy-scan: gettrivy ## Scan the CLI using trivy
278279
$(TOOLS_BIN)/trivy fs --cache-dir ${TRIVY_CACHE} --exit-code 1 --skip-dirs "./java" .
279280

281+
# ======================================================================================================================
282+
# Targets related to running KinD clusters for testing
283+
# ======================================================================================================================
284+
##@ KinD
285+
286+
KIND_CLUSTER ?= go-client
287+
KIND_IMAGE ?= "kindest/node:v1.33.0@sha256:91e9ed777db80279c22d1d1068c091b899b2078506e4a0f797fbf6e397c0b0b2"
288+
KIND_SCRIPTS := ./scripts/kind
289+
NAMESPACE ?= coherence-perf
290+
OPERATOR_VERSION ?= v3.5.0
291+
COHERENCE_IMAGE ?= ghcr.io/oracle/coherence-ce:14.1.2-0-2-java17
292+
INITIAL_HEAP ?= 1g
293+
GO_CLIENT_ARCH ?= amd64
294+
GO_IMAGE ?= perf-go-client:1.0.0
295+
296+
# ----------------------------------------------------------------------------------------------------------------------
297+
# Start a Kind cluster
298+
# ----------------------------------------------------------------------------------------------------------------------
299+
.PHONY: kind
300+
kind: ## Run a default KinD cluster
301+
kind create cluster --name $(KIND_CLUSTER) --wait 10m --config $(KIND_SCRIPTS)/kind-config.yaml --image $(KIND_IMAGE)
302+
$(KIND_SCRIPTS)/kind-label-node.sh
303+
304+
# ----------------------------------------------------------------------------------------------------------------------
305+
# Stop and delete the Kind cluster
306+
# ----------------------------------------------------------------------------------------------------------------------
307+
.PHONY: kind-stop
308+
kind-stop: ## Stop and delete the KinD cluster
309+
kind delete cluster --name $(KIND_CLUSTER)
310+
311+
# ----------------------------------------------------------------------------------------------------------------------
312+
# Deploy Coherence Operator
313+
# ----------------------------------------------------------------------------------------------------------------------
314+
.PHONY: deploy-operator
315+
deploy-operator: ## Deploy the Coherence Operator
316+
kubectl apply -f https://github.com/oracle/coherence-operator/releases/download/$(OPERATOR_VERSION)/coherence-operator.yaml
317+
kubectl -n coherence wait --timeout=300s --for condition=available deployment/coherence-operator-controller-manager
318+
319+
# ----------------------------------------------------------------------------------------------------------------------
320+
# UnDeploy Coherence Operator
321+
# ----------------------------------------------------------------------------------------------------------------------
322+
.PHONY: undeploy-operator
323+
undeploy-operator: ## UnDeploy the Coherence Operator
324+
kubectl delete -f https://github.com/oracle/coherence-operator/releases/download/$(OPERATOR_VERSION)/coherence-operator.yaml || true
325+
326+
# ----------------------------------------------------------------------------------------------------------------------
327+
# Deploy Coherence Cluster
328+
# ----------------------------------------------------------------------------------------------------------------------
329+
.PHONY: deploy-coherence
330+
deploy-coherence: ## Deploy the Coherence Cluster
331+
envsubst < $(KIND_SCRIPTS)/coherence-cluster.yaml | kubectl apply -n $(NAMESPACE) -f -
332+
sleep 5
333+
kubectl -n $(NAMESPACE) wait --timeout=300s --for condition=Ready coherence/perf-cluster
334+
335+
#-----------------------------------------------------------------------------------------------------------------------
336+
# Deploy Coherence Cluster
337+
# ----------------------------------------------------------------------------------------------------------------------
338+
.PHONY: build-go-client
339+
build-go-client: ## Make Go Client
340+
cd test/e2e/kind && CGO_ENABLED=0 GOOS=linux GOARCH=$(GO_CLIENT_ARCH) GO111MODULE=on go build -trimpath -o runner . && docker build --no-cache -t $(GO_IMAGE) .
341+
kind --name $(KIND_CLUSTER) load docker-image $(GO_IMAGE)
342+
343+
#-----------------------------------------------------------------------------------------------------------------------
344+
# Load Schools Data
345+
# ----------------------------------------------------------------------------------------------------------------------
346+
.PHONY: load-schools
347+
load-schools: ## Load Schools
348+
kubectl -n $(NAMESPACE) apply -f $(KIND_SCRIPTS)/load-schools.yaml
349+
kubectl wait -n $(NAMESPACE) --timeout=1200s --for condition=Complete job/go-perf-load-schools
350+
kubectl -n $(NAMESPACE) delete -f $(KIND_SCRIPTS)/load-schools.yaml || true
351+
352+
#-----------------------------------------------------------------------------------------------------------------------
353+
# Test Schools
354+
# ----------------------------------------------------------------------------------------------------------------------
355+
.PHONY: deploy-test-schools
356+
deploy-test-schools: ## Deploy Test Schools
357+
kubectl -n $(NAMESPACE) apply -f $(KIND_SCRIPTS)/test-schools.yaml
358+
359+
#-----------------------------------------------------------------------------------------------------------------------
360+
# Stop Schools Test
361+
# ----------------------------------------------------------------------------------------------------------------------
362+
.PHONY: undeploy-test-schools
363+
undeploy-test-schools: ## Undeploy Test Schools
364+
kubectl -n $(NAMESPACE) delete -f $(KIND_SCRIPTS)/test-schools.yaml
365+
366+
# ----------------------------------------------------------------------------------------------------------------------
367+
# UnDeploy Coherence Cluster
368+
# ----------------------------------------------------------------------------------------------------------------------
369+
.PHONY: undeploy-coherence
370+
undeploy-coherence: ## UnDeploy the Coherence Cluster
371+
kubectl delete -n $(NAMESPACE) -f $(KIND_SCRIPTS)/coherence-cluster.yaml || true
372+
373+
# ----------------------------------------------------------------------------------------------------------------------
374+
# Create Perf namespace
375+
# ----------------------------------------------------------------------------------------------------------------------
376+
.PHONY: create-namespace
377+
create-namespace: ## Create the perf test namespace
378+
kubectl create namespace $(NAMESPACE)
379+
380+
# ----------------------------------------------------------------------------------------------------------------------
381+
# Delete Perf namespace
382+
# ----------------------------------------------------------------------------------------------------------------------
383+
.PHONY: delete-namespace
384+
delete-namespace: ## Create the perf test namespace
385+
kubectl delete namespace $(NAMESPACE) || true
280386

281387
# ======================================================================================================================
282388
# Test targets
@@ -344,7 +450,6 @@ test-v1-base: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coh
344450
test-examples: test-clean gotestsum $(BUILD_PROPS) ## Run examples tests with Coherence
345451
./scripts/run-test-examples.sh
346452

347-
348453
# ----------------------------------------------------------------------------------------------------------------------
349454
# Startup cluster members via docker compose
350455
# ----------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)