From 9e56ebc87f9d95a0078a62ca444e90bfe60a5af9 Mon Sep 17 00:00:00 2001 From: Andreas Neumann Date: Tue, 25 Aug 2020 11:08:55 +0200 Subject: [PATCH] Expanded upgrade test (#1652) * Expanded upgrade test ** Install KUDO 0.11.1 ** Install a simple operator with a version 0.1.0 ** Upgrade KUDO current version ** Upgrade the operator to a version 0.2.0 ** Uninstall KUDO with kudo init --upgrade --dry-run --output yaml | kubectl delete -f - Signed-off-by: Andreas Neumann --- .gitignore | 1 + Makefile | 2 +- ...-install.yaml => 00-install-old-kudo.yaml} | 2 +- .../upgrade/upgrade-to-current/01-assert.yaml | 25 +++++++++++------- .../01-install-operator.yaml | 5 ++++ .../upgrade/upgrade-to-current/02-assert.yaml | 13 ++++++++++ .../{01-upgrade.yaml => 02-upgrade-kudo.yaml} | 2 +- .../upgrade/upgrade-to-current/03-assert.yaml | 22 ++++++++++++++++ .../03-upgrade-operator.yaml | 5 ++++ .../upgrade/upgrade-to-current/99-errors.yaml | 26 +++++++++++++++++++ .../upgrade-to-current/99-remove-kudo.yaml | 4 +++ .../upgrade-to-current/download-kudo.sh | 6 ++--- .../simple-op-0.1.0/operator.yaml | 24 +++++++++++++++++ .../simple-op-0.1.0/params.yaml | 5 ++++ .../simple-op-0.1.0/templates/deployment.yaml | 19 ++++++++++++++ .../simple-op-0.2.0/operator.yaml | 24 +++++++++++++++++ .../simple-op-0.2.0/params.yaml | 9 +++++++ .../simple-op-0.2.0/templates/deployment.yaml | 20 ++++++++++++++ 18 files changed, 198 insertions(+), 16 deletions(-) rename test/upgrade/upgrade-to-current/{00-install.yaml => 00-install-old-kudo.yaml} (74%) create mode 100644 test/upgrade/upgrade-to-current/01-install-operator.yaml create mode 100644 test/upgrade/upgrade-to-current/02-assert.yaml rename test/upgrade/upgrade-to-current/{01-upgrade.yaml => 02-upgrade-kudo.yaml} (83%) create mode 100644 test/upgrade/upgrade-to-current/03-assert.yaml create mode 100644 test/upgrade/upgrade-to-current/03-upgrade-operator.yaml create mode 100644 test/upgrade/upgrade-to-current/99-errors.yaml create mode 100644 test/upgrade/upgrade-to-current/99-remove-kudo.yaml create mode 100644 test/upgrade/upgrade-to-current/simple-op-0.1.0/operator.yaml create mode 100644 test/upgrade/upgrade-to-current/simple-op-0.1.0/params.yaml create mode 100644 test/upgrade/upgrade-to-current/simple-op-0.1.0/templates/deployment.yaml create mode 100644 test/upgrade/upgrade-to-current/simple-op-0.2.0/operator.yaml create mode 100644 test/upgrade/upgrade-to-current/simple-op-0.2.0/params.yaml create mode 100644 test/upgrade/upgrade-to-current/simple-op-0.2.0/templates/deployment.yaml diff --git a/.gitignore b/.gitignore index 7606f1ed2..2f9a969d0 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ tags [._]*.un~ kubeconfig .kube +/test/upgrade/upgrade-to-current/old-kudo diff --git a/Makefile b/Makefile index 7fdc2aa69..332d188c4 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ lint: ## Run golangci-lint ifneq (${GOLANGCI_LINT_VER}, "$(shell golangci-lint --version 2>/dev/null | cut -b 27-32)") ./hack/install-golangcilint.sh endif - golangci-lint --timeout 3m run + golangci-lint --timeout 3m run --allow-parallel-runners .PHONY: download download: diff --git a/test/upgrade/upgrade-to-current/00-install.yaml b/test/upgrade/upgrade-to-current/00-install-old-kudo.yaml similarity index 74% rename from test/upgrade/upgrade-to-current/00-install.yaml rename to test/upgrade/upgrade-to-current/00-install-old-kudo.yaml index a5813a6f6..db0ac4ce2 100644 --- a/test/upgrade/upgrade-to-current/00-install.yaml +++ b/test/upgrade/upgrade-to-current/00-install-old-kudo.yaml @@ -2,4 +2,4 @@ apiVersion: kudo.dev/v1beta1 kind: TestStep commands: - command: ./download-kudo.sh 0.11.1 - - command: ./kubectl-kudo init \ No newline at end of file + - command: ./old-kudo init \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/01-assert.yaml b/test/upgrade/upgrade-to-current/01-assert.yaml index 7c0ed7905..8ea0687be 100644 --- a/test/upgrade/upgrade-to-current/01-assert.yaml +++ b/test/upgrade/upgrade-to-current/01-assert.yaml @@ -1,13 +1,18 @@ +apiVersion: kudo.dev/v1beta1 +kind: Instance +metadata: + name: simple-op +spec: + operatorVersion: + name: simple-op-0.1.0 +status: + planStatus: + deploy: + status: COMPLETE +--- apiVersion: apps/v1 -kind: StatefulSet +kind: Deployment metadata: - labels: - app: kudo-manager - control-plane: controller-manager - name: kudo-controller-manager - namespace: kudo-system + name: nginx-deployment spec: - template: - spec: - containers: - - image: kudobuilder/controller:test \ No newline at end of file + replicas: 2 \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/01-install-operator.yaml b/test/upgrade/upgrade-to-current/01-install-operator.yaml new file mode 100644 index 000000000..9baa9b4d0 --- /dev/null +++ b/test/upgrade/upgrade-to-current/01-install-operator.yaml @@ -0,0 +1,5 @@ +apiVersion: kudo.dev/v1beta1 +kind: TestStep +commands: + - command: ./old-kudo install --instance simple-op ./simple-op-0.1.0 + namespaced: true \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/02-assert.yaml b/test/upgrade/upgrade-to-current/02-assert.yaml new file mode 100644 index 000000000..7c0ed7905 --- /dev/null +++ b/test/upgrade/upgrade-to-current/02-assert.yaml @@ -0,0 +1,13 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app: kudo-manager + control-plane: controller-manager + name: kudo-controller-manager + namespace: kudo-system +spec: + template: + spec: + containers: + - image: kudobuilder/controller:test \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/01-upgrade.yaml b/test/upgrade/upgrade-to-current/02-upgrade-kudo.yaml similarity index 83% rename from test/upgrade/upgrade-to-current/01-upgrade.yaml rename to test/upgrade/upgrade-to-current/02-upgrade-kudo.yaml index 20e7efa8a..818701433 100644 --- a/test/upgrade/upgrade-to-current/01-upgrade.yaml +++ b/test/upgrade/upgrade-to-current/02-upgrade-kudo.yaml @@ -1,4 +1,4 @@ apiVersion: kudo.dev/v1beta1 kind: TestStep commands: - - command: kubectl kudo init -v 4 --upgrade --kudo-image kudobuilder/controller:test --kudo-image-pull-policy IfNotPresent --unsafe-self-signed-webhook-ca \ No newline at end of file + - command: kubectl kudo init -v 4 --upgrade --kudo-image kudobuilder/controller:test --kudo-image-pull-policy IfNotPresent --unsafe-self-signed-webhook-ca --wait \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/03-assert.yaml b/test/upgrade/upgrade-to-current/03-assert.yaml new file mode 100644 index 000000000..8a4628714 --- /dev/null +++ b/test/upgrade/upgrade-to-current/03-assert.yaml @@ -0,0 +1,22 @@ +apiVersion: kudo.dev/v1beta1 +kind: Instance +metadata: + name: simple-op +spec: + operatorVersion: + name: simple-op-0.2.0 +status: + planStatus: + deploy: + status: COMPLETE +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 1 + template: + metadata: + labels: + fixedLabel: fixedvalue \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/03-upgrade-operator.yaml b/test/upgrade/upgrade-to-current/03-upgrade-operator.yaml new file mode 100644 index 000000000..77e1041de --- /dev/null +++ b/test/upgrade/upgrade-to-current/03-upgrade-operator.yaml @@ -0,0 +1,5 @@ +apiVersion: kudo.dev/v1beta1 +kind: TestStep +commands: + - command: kubectl kudo upgrade ./simple-op-0.2.0 --instance simple-op -p replicas=1 -p unchangeable=fixedvalue + namespaced: true \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/99-errors.yaml b/test/upgrade/upgrade-to-current/99-errors.yaml new file mode 100644 index 000000000..fe4051bb3 --- /dev/null +++ b/test/upgrade/upgrade-to-current/99-errors.yaml @@ -0,0 +1,26 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: instances.kudo.dev +spec: + group: kudo.dev + names: + kind: Instance +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: operators.kudo.dev +spec: + group: kudo.dev + names: + kind: Operator +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: operatorversions.kudo.dev +spec: + group: kudo.dev + names: + kind: OperatorVersion diff --git a/test/upgrade/upgrade-to-current/99-remove-kudo.yaml b/test/upgrade/upgrade-to-current/99-remove-kudo.yaml new file mode 100644 index 000000000..152cf9065 --- /dev/null +++ b/test/upgrade/upgrade-to-current/99-remove-kudo.yaml @@ -0,0 +1,4 @@ +apiVersion: kudo.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl kudo init --upgrade --kudo-image kudobuilder/controller:test --kudo-image-pull-policy IfNotPresent --unsafe-self-signed-webhook-ca --dry-run --output yaml | tee output.log | kubectl delete -f - \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/download-kudo.sh b/test/upgrade/upgrade-to-current/download-kudo.sh index ccb7681fc..c07a87c61 100755 --- a/test/upgrade/upgrade-to-current/download-kudo.sh +++ b/test/upgrade/upgrade-to-current/download-kudo.sh @@ -6,9 +6,9 @@ echo "Downloading KUDO v${PREV_KUDO_VERSION}" # Download previous KUDO version for upgrade testing if [[ "$(uname)" == "Darwin" ]]; then - curl -L https://github.com/kudobuilder/kudo/releases/download/v${PREV_KUDO_VERSION}/kubectl-kudo_${PREV_KUDO_VERSION}_darwin_x86_64 --output kubectl-kudo + curl -L https://github.com/kudobuilder/kudo/releases/download/v${PREV_KUDO_VERSION}/kubectl-kudo_${PREV_KUDO_VERSION}_darwin_x86_64 --output old-kudo elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then - curl -L https://github.com/kudobuilder/kudo/releases/download/v${PREV_KUDO_VERSION}/kubectl-kudo_${PREV_KUDO_VERSION}_linux_x86_64 --output kubectl-kudo + curl -L https://github.com/kudobuilder/kudo/releases/download/v${PREV_KUDO_VERSION}/kubectl-kudo_${PREV_KUDO_VERSION}_linux_x86_64 --output old-kudo fi -chmod +x kubectl-kudo \ No newline at end of file +chmod +x old-kudo \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/simple-op-0.1.0/operator.yaml b/test/upgrade/upgrade-to-current/simple-op-0.1.0/operator.yaml new file mode 100644 index 000000000..a051e02b6 --- /dev/null +++ b/test/upgrade/upgrade-to-current/simple-op-0.1.0/operator.yaml @@ -0,0 +1,24 @@ +apiVersion: kudo.dev/v1beta1 +name: "simple-op" +operatorVersion: "0.1.0" +kubernetesVersion: 1.13.0 +maintainers: + - name: Your name + email: +url: https://kudo.dev +tasks: + - name: app + kind: Apply + spec: + resources: + - deployment.yaml +plans: + deploy: + strategy: serial + phases: + - name: main + strategy: parallel + steps: + - name: everything + tasks: + - app \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/simple-op-0.1.0/params.yaml b/test/upgrade/upgrade-to-current/simple-op-0.1.0/params.yaml new file mode 100644 index 000000000..853be3213 --- /dev/null +++ b/test/upgrade/upgrade-to-current/simple-op-0.1.0/params.yaml @@ -0,0 +1,5 @@ +apiVersion: kudo.dev/v1beta1 +parameters: + - name: replicas + description: Number of replicas that should be run as part of the deployment + default: 2 \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/simple-op-0.1.0/templates/deployment.yaml b/test/upgrade/upgrade-to-current/simple-op-0.1.0/templates/deployment.yaml new file mode 100644 index 000000000..73b0ad025 --- /dev/null +++ b/test/upgrade/upgrade-to-current/simple-op-0.1.0/templates/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + selector: + matchLabels: + app: nginx + replicas: {{ .Params.replicas }} # tells deployment to run 2 pods matching the template + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.7.9 + ports: + - containerPort: 80 \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/simple-op-0.2.0/operator.yaml b/test/upgrade/upgrade-to-current/simple-op-0.2.0/operator.yaml new file mode 100644 index 000000000..0bbb85956 --- /dev/null +++ b/test/upgrade/upgrade-to-current/simple-op-0.2.0/operator.yaml @@ -0,0 +1,24 @@ +apiVersion: kudo.dev/v1beta1 +name: "simple-op" +operatorVersion: "0.2.0" +kubernetesVersion: 1.15.0 +maintainers: + - name: Your name + email: +url: https://kudo.dev +tasks: + - name: app + kind: Apply + spec: + resources: + - deployment.yaml +plans: + deploy: + strategy: serial + phases: + - name: main + strategy: parallel + steps: + - name: everything + tasks: + - app \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/simple-op-0.2.0/params.yaml b/test/upgrade/upgrade-to-current/simple-op-0.2.0/params.yaml new file mode 100644 index 000000000..fc30c92e8 --- /dev/null +++ b/test/upgrade/upgrade-to-current/simple-op-0.2.0/params.yaml @@ -0,0 +1,9 @@ +apiVersion: kudo.dev/v1beta1 +parameters: + - name: replicas + description: Number of replicas that should be run as part of the deployment + default: 2 + - name: unchangeable + description: An unchangeable parameter + required: true + immutable: true \ No newline at end of file diff --git a/test/upgrade/upgrade-to-current/simple-op-0.2.0/templates/deployment.yaml b/test/upgrade/upgrade-to-current/simple-op-0.2.0/templates/deployment.yaml new file mode 100644 index 000000000..de9fb3dd1 --- /dev/null +++ b/test/upgrade/upgrade-to-current/simple-op-0.2.0/templates/deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + selector: + matchLabels: + app: nginx + replicas: {{ .Params.replicas }} # tells deployment to run 2 pods matching the template + template: + metadata: + labels: + app: nginx + fixedLabel: {{ .Params.unchangeable }} + spec: + containers: + - name: nginx + image: nginx:1.7.9 + ports: + - containerPort: 80 \ No newline at end of file