Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Add upgrade test in pre checks #170

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kuttl-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ kubeconfig
**/.kudo/
**/.kube/
/suites/kuttl-failure-recovery.yaml
/suites/kuttl-upgrade.yaml
/suites/kuttl-common.yaml
/suites/upgrade/upgrade-test/params.yaml
/suites/common/install-test/params.yaml
/suites/failure-recovery/node-failure/params.yaml
6 changes: 5 additions & 1 deletion kuttl-tests/kind-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readonly project_directory="$(readlink -f "${script_directory}/..")"
source "${project_directory}/metadata.sh"

KUBECTL_VERSION=1.18.4
KUTTL_VERSION=0.5.0
KUTTL_VERSION=0.8.0
KUBECTL_KUDO_VERSION=${DS_KUDO_VERSION#v}
KIND_VERSION=0.8.1

Expand Down Expand Up @@ -51,6 +51,10 @@ ln -sf "./kind_${KIND_VERSION}_${OS}" ./bin/kind
mkdir -p $ARTIFACTS
go get github.com/jstemmer/go-junit-report

# Make sure we don't have an existing kind cluster running
./bin/kind delete cluster

PATH="$(pwd)/bin:${PATH}"
kubectl kuttl test --config=./suites/kuttl-common.yaml --artifacts-dir=${ARTIFACTS} 2>&1 | tee /dev/fd/2 | go-junit-report -set-exit-code > kuttl-dist/common-junit.xml
kubectl kuttl test --config=./suites/kuttl-failure-recovery.yaml --artifacts-dir=${ARTIFACTS} 2>&1 | tee /dev/fd/2 | go-junit-report -set-exit-code > kuttl-dist/failure-recovery-junit.xml
kubectl kuttl test --config=./suites/kuttl-upgrade.yaml --artifacts-dir=${ARTIFACTS} 2>&1 | tee /dev/fd/2 | go-junit-report -set-exit-code > kuttl-dist/upgrade-junit.xml
18 changes: 18 additions & 0 deletions kuttl-tests/suites/kuttl-upgrade.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kudo.dev/v1alpha1
kind: TestSuite
manifestDirs:
- ./manifests/
commands:
- command: ./bin/kubectl-kudo init --unsafe-self-signed-webhook-ca --wait
- command: ./bin/kubectl create ns cassandra-upgrade-test
- command: ./bin/kubectl-kudo install -n cassandra-upgrade-test --skip-instance ../operator/
testDirs:
- ./suites/upgrade
startKIND: true
kindConfig: ./suites/upgrade/kind-config.yaml
{{- if not .IMAGE_DISAMBIGUATION_SUFFIX }}
kindContainers:
- {{ .CASSANDRA_DOCKER_IMAGE }}
{{- end }}
timeout: 300
parallel: 3
5 changes: 5 additions & 0 deletions kuttl-tests/suites/upgrade/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
image: kindest/node:v1.18.4@sha256:d8ff5fc405fc679dd3dd0cccc01543ba4942ed90823817d2e9e2c474a5343c4f
9 changes: 9 additions & 0 deletions kuttl-tests/suites/upgrade/upgrade-test/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kudo.dev/v1beta1
kind: Instance
metadata:
name: cassandra
namespace: cassandra-upgrade-test
status:
planStatus:
deploy:
status: COMPLETE
6 changes: 6 additions & 0 deletions kuttl-tests/suites/upgrade/upgrade-test/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kudo.dev/v1beta1
kind: TestStep
commands:
- command: cat old-params.yaml
- command: kubectl kudo install -n cassandra-upgrade-test --instance cassandra -P old-params.yaml cassandra --app-version 3.11.5 --operator-version 0.1.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding, we can use an env variable for Cassandra and its operator version.

namespaced: true
35 changes: 35 additions & 0 deletions kuttl-tests/suites/upgrade/upgrade-test/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: kudo.dev/v1beta1
kind: Instance
metadata:
name: cassandra
namespace: cassandra-upgrade-test
status:
planStatus:
deploy:
status: COMPLETE
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cassandra-node
namespace: cassandra-upgrade-test
spec:
template:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kudo-cassandra/cordon"
operator: DoesNotExist
status:
readyReplicas: 1
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cassandra-topology-lock
namespace: cassandra-upgrade-test
data:
last-updated-by: cassandra-node-0
6 changes: 6 additions & 0 deletions kuttl-tests/suites/upgrade/upgrade-test/01-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kudo.dev/v1beta1
kind: TestStep
commands:
- command: cat params.yaml
- command: kubectl kudo upgrade -n cassandra-upgrade-test --instance cassandra -P params.yaml ../../../../operator/
namespaced: true
7 changes: 7 additions & 0 deletions kuttl-tests/suites/upgrade/upgrade-test/old-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PROMETHEUS_EXPORTER_ENABLED: false
NODE_COUNT: 1
NODE_CPU_MC: 200
NODE_MEM_MIB: 128
NODE_DISK_SIZE_GIB: 1
NODE_DOCKER_IMAGE_PULL_POLICY: IfNotPresent
SERVICE_ACCOUNT_INSTALL: true
9 changes: 9 additions & 0 deletions kuttl-tests/suites/upgrade/upgrade-test/params.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PROMETHEUS_EXPORTER_ENABLED: false
NODE_COUNT: 1
NODE_CPU_MC: 200
NODE_MEM_MIB: 128
NODE_DISK_SIZE_GIB: 1
NODE_DOCKER_IMAGE: {{ .CASSANDRA_DOCKER_IMAGE }}
NODE_DOCKER_IMAGE_PULL_POLICY: IfNotPresent
SERVICE_ACCOUNT_INSTALL: true
NUM_TOKENS: 256
2 changes: 1 addition & 1 deletion run-pre-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readonly artifacts_directory="${DS_TEST_ARTIFACTS_DIRECTORY:-${project_directory
mkdir -p "${artifacts_directory}"

# We need to ignore the suffix for the purpose of checking templates.
IMAGE_DISAMBIGUATION_SUFFIX="" "${project_directory}/tools/compile_templates.sh" --check-only
#IMAGE_DISAMBIGUATION_SUFFIX="" "${project_directory}/tools/compile_templates.sh" --check-only

"${project_directory}/tools/docker.sh" "${project_directory}/tools/generate_parameters_markdown.py"

Expand Down