diff --git a/.chainsaw.yaml b/.chainsaw.yaml new file mode 100755 index 000000000..211dbd60d --- /dev/null +++ b/.chainsaw.yaml @@ -0,0 +1,13 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Configuration +metadata: + creationTimestamp: null + name: configuration +spec: + timeouts: + assert: 3m0s + cleanup: 3m0s + delete: 3m0s + error: 3m0s + exec: 3m0s diff --git a/.gitignore b/.gitignore index 02300e75f..0afdec677 100644 --- a/.gitignore +++ b/.gitignore @@ -88,9 +88,5 @@ e2e-tests/conf/cloud-secret.yml # Kubernetes Generated files - skip generated files, except for vendored files !vendor/**/zz_generated.* -# Kuttl -kubeconfig -kind-logs-*/ - # Other gke_gcloud_auth_plugin_cache \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5adaf48eb..bc1621a0f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -163,11 +163,11 @@ Contributions to the source tree should follow the workflow described below: Run the command `make test`. 2. E2E tests - For e2e test we are using [kuttl](https://kuttl.dev/). To run a single test call: + For e2e test we are using [chainsaw](https://kyverno.github.io/chainsaw/). To run a single test call: - `kubectl kuttl test --config ./e2e-tests/kuttl.yaml --test ^/$` where the `` is the folder inside `e2e-tests/tests`. + `chainsaw test ./e2e-tests/tests/` where the `` is the folder inside `e2e-tests/tests`. - By default kuttl will delete created test namespace after test is finished, you can add `--skip-delete` flag in order to prevent deletion for potential troubleshooting. + By default chainsaw will delete created test namespace after test is finished, you can add `--skip-delete` flag in order to prevent deletion for potential troubleshooting. **Running the Operator locally** diff --git a/Makefile b/Makefile index 4c3e92a78..aa66e0f90 100644 --- a/Makefile +++ b/Makefile @@ -91,12 +91,12 @@ vet: ## Run go vet against code. test: manifests generate fmt vet envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out -kuttl-shfmt: +chainsaw-shfmt: shfmt -bn -ci -s -w e2e-tests/functions find e2e-tests/tests/ -type f -not -name '*-assert.yaml' -name '*.yaml' | xargs ./e2e-tests/format -e2e-test: kuttl-shfmt - ROOT_REPO=$(ROOT_REPO) kubectl kuttl test --config e2e-tests/kuttl.yaml +e2e-test: chainsaw-shfmt + ROOT_REPO=$(ROOT_REPO) chainsaw test ./e2e-tests/tests manifests: kustomize generate $(KUSTOMIZE) build config/crd/ > $(DEPLOYDIR)/crd.yaml diff --git a/e2e-tests/kuttl.yaml b/e2e-tests/kuttl.yaml deleted file mode 100644 index 9a06130c5..000000000 --- a/e2e-tests/kuttl.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestSuite -testDirs: -- e2e-tests/tests -timeout: 180 diff --git a/e2e-tests/tests/async-ignore-annotations/00-assert.yaml b/e2e-tests/tests/async-ignore-annotations/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/async-ignore-annotations/00-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/async-ignore-annotations/00-deploy-operator.yaml b/e2e-tests/tests/async-ignore-annotations/00-deploy-operator.yaml deleted file mode 100644 index 1aaca58be..000000000 --- a/e2e-tests/tests/async-ignore-annotations/00-deploy-operator.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_client diff --git a/e2e-tests/tests/async-ignore-annotations/01-assert.yaml b/e2e-tests/tests/async-ignore-annotations/01-assert.yaml index b91ac65f6..3c0407a3a 100644 --- a/e2e-tests/tests/async-ignore-annotations/01-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/01-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 600 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: async-ignore-annotations-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: async-ignore-annotations-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: async-ignore-annotations-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: async-ignore-annotations finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: async-ignore-annotations status: haproxy: ready: 3 diff --git a/e2e-tests/tests/async-ignore-annotations/01-create-cluster.yaml b/e2e-tests/tests/async-ignore-annotations/01-create-cluster.yaml deleted file mode 100644 index 7ae131ada..000000000 --- a/e2e-tests/tests/async-ignore-annotations/01-create-cluster.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.expose.enabled=true' - \ - | yq eval '.spec.mysql.expose.type="ClusterIP"' - \ - | yq eval '.spec.proxy.haproxy.expose.type="ClusterIP"' - \ - | yq eval '.spec.orchestrator.expose.type="ClusterIP"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/async-ignore-annotations/02-add-custom-annotations.yaml b/e2e-tests/tests/async-ignore-annotations/02-add-custom-annotations.yaml deleted file mode 100644 index 7bd25bad7..000000000 --- a/e2e-tests/tests/async-ignore-annotations/02-add-custom-annotations.yaml +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - mysql_svc=$(get_mysql_service async-ignore-annotations) - haproxy_svc=$(get_haproxy_svc async-ignore-annotations) - orc_svc=$(get_orc_svc async-ignore-annotations) - - kubectl get svc $mysql_svc-0 -o yaml -n "${NAMESPACE}" \ - | yq eval '.metadata.annotations += {"async-annotations-to-ignore-mysql": "true", "async-annotations-not-to-ignore-mysql": "true" }' - \ - | yq eval '.metadata.labels += {"async-labels-to-ignore-mysql": "true", "async-labels-not-to-ignore-mysql": "true"}' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - kubectl get svc $haproxy_svc -o yaml -n "${NAMESPACE}"\ - | yq eval '.metadata.annotations += {"async-annotations-to-ignore-haproxy": "true", "async-annotations-not-to-ignore-haproxy": "true" }' - \ - | yq eval '.metadata.labels += {"async-labels-to-ignore-haproxy": "true", "async-labels-not-to-ignore-haproxy": "true"}' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - kubectl get svc $orc_svc-0 -o yaml -n "${NAMESPACE}"\ - | yq eval '.metadata.annotations += {"async-annotations-to-ignore-orc": "true", "async-annotations-not-to-ignore-orc": "true" }' - \ - | yq eval '.metadata.labels += {"async-labels-to-ignore-orc": "true", "async-labels-not-to-ignore-orc": "true" }' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - timeout: 100 diff --git a/e2e-tests/tests/async-ignore-annotations/02-assert.yaml b/e2e-tests/tests/async-ignore-annotations/02-assert.yaml index ed3fbbcf9..7c38d2db6 100644 --- a/e2e-tests/tests/async-ignore-annotations/02-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/02-assert.yaml @@ -1,22 +1,18 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-not-to-ignore-mysql: "true" + async-annotations-to-ignore-mysql: "true" labels: - async-labels-to-ignore-mysql: "true" - async-labels-not-to-ignore-mysql: "true" app.kubernetes.io/component: mysql app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-not-to-ignore-mysql: "true" + async-labels-to-ignore-mysql: "true" percona.com/exposed: "true" - annotations: - async-annotations-to-ignore-mysql: "true" - async-annotations-not-to-ignore-mysql: "true" name: async-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -54,17 +50,17 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-not-to-ignore-haproxy: "true" + async-annotations-to-ignore-haproxy: "true" labels: - async-labels-to-ignore-haproxy: "true" - async-labels-not-to-ignore-haproxy: "true" app.kubernetes.io/component: haproxy app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server - annotations: - async-annotations-to-ignore-haproxy: "true" - async-annotations-not-to-ignore-haproxy: "true" + async-labels-not-to-ignore-haproxy: "true" + async-labels-to-ignore-haproxy: "true" name: async-ignore-annotations-haproxy ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -110,16 +106,16 @@ apiVersion: v1 kind: Service metadata: annotations: - async-annotations-to-ignore-orc: "true" async-annotations-not-to-ignore-orc: "true" + async-annotations-to-ignore-orc: "true" labels: app.kubernetes.io/component: orc app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server - async-labels-to-ignore-orc: "true" async-labels-not-to-ignore-orc: "true" + async-labels-to-ignore-orc: "true" percona.com/exposed: "true" name: async-ignore-annotations-orc-0 ownerReferences: diff --git a/e2e-tests/tests/async-ignore-annotations/03-add-annotations-to-ignore.yaml b/e2e-tests/tests/async-ignore-annotations/03-add-annotations-to-ignore.yaml deleted file mode 100644 index 6a6c5a438..000000000 --- a/e2e-tests/tests/async-ignore-annotations/03-add-annotations-to-ignore.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/ignoreAnnotations", "value": ["async-annotations-to-ignore-mysql","async-annotations-to-ignore-haproxy", "async-annotations-to-ignore-orc"] }]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/ignoreLabels", "value": ["async-labels-to-ignore-mysql","async-labels-to-ignore-haproxy","async-labels-to-ignore-orc" ] }]' - - timeout: 30 diff --git a/e2e-tests/tests/async-ignore-annotations/03-assert.yaml b/e2e-tests/tests/async-ignore-annotations/03-assert.yaml index 71e99f06d..829873306 100644 --- a/e2e-tests/tests/async-ignore-annotations/03-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/03-assert.yaml @@ -1,21 +1,16 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: name: async-ignore-annotations spec: ignoreAnnotations: - - async-annotations-to-ignore-mysql - - async-annotations-to-ignore-haproxy - - async-annotations-to-ignore-orc + - async-annotations-to-ignore-mysql + - async-annotations-to-ignore-haproxy + - async-annotations-to-ignore-orc ignoreLabels: - - async-labels-to-ignore-mysql - - async-labels-to-ignore-haproxy - - async-labels-to-ignore-orc - + - async-labels-to-ignore-mysql + - async-labels-to-ignore-haproxy + - async-labels-to-ignore-orc status: haproxy: ready: 3 diff --git a/e2e-tests/tests/async-ignore-annotations/04-add-annotations-to-service-via-cr.yaml b/e2e-tests/tests/async-ignore-annotations/04-add-annotations-to-service-via-cr.yaml deleted file mode 100644 index 81d53712f..000000000 --- a/e2e-tests/tests/async-ignore-annotations/04-add-annotations-to-service-via-cr.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": ClusterIP,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/proxy/haproxy/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/orchestrator/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' - - timeout: 30 diff --git a/e2e-tests/tests/async-ignore-annotations/04-assert.yaml b/e2e-tests/tests/async-ignore-annotations/04-assert.yaml index 2a1bd591b..9af7edf96 100644 --- a/e2e-tests/tests/async-ignore-annotations/04-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/04-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 20 ---- apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-to-ignore-mysql: "true" + service.beta.kubernetes.io/aws-load-balancer-backend: test-type + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: - async-labels-to-ignore-mysql: "true" app.kubernetes.io/component: mysql app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-to-ignore-mysql: "true" percona.com/exposed: "true" rack: rack-22 rack-test: rack-test-22 - annotations: - async-annotations-to-ignore-mysql: "true" - service.beta.kubernetes.io/aws-load-balancer-backend: test-type - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: async-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -58,19 +54,19 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-to-ignore-haproxy: "true" + service.beta.kubernetes.io/aws-load-balancer-backend: test-type + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: - async-labels-to-ignore-haproxy: "true" app.kubernetes.io/component: haproxy app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-to-ignore-haproxy: "true" rack: rack-22 rack-test: rack-test-22 - annotations: - async-annotations-to-ignore-haproxy: "true" - service.beta.kubernetes.io/aws-load-balancer-backend: test-type - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: async-ignore-annotations-haproxy ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/async-ignore-annotations/05-assert.yaml b/e2e-tests/tests/async-ignore-annotations/05-assert.yaml index 6fe806fd5..934041833 100644 --- a/e2e-tests/tests/async-ignore-annotations/05-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/05-assert.yaml @@ -1,22 +1,18 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 20 ---- apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-to-ignore-mysql: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: - async-labels-to-ignore-mysql: "true" app.kubernetes.io/component: mysql app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-to-ignore-mysql: "true" percona.com/exposed: "true" rack: rack-22 - annotations: - async-annotations-to-ignore-mysql: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: async-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -55,17 +51,17 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-to-ignore-haproxy: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: - async-labels-to-ignore-haproxy: "true" app.kubernetes.io/component: haproxy app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-to-ignore-haproxy: "true" rack: rack-22 - annotations: - async-annotations-to-ignore-haproxy: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: async-ignore-annotations-haproxy ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/async-ignore-annotations/05-delete-annotations.yaml b/e2e-tests/tests/async-ignore-annotations/05-delete-annotations.yaml deleted file mode 100644 index 5d2ddb7d2..000000000 --- a/e2e-tests/tests/async-ignore-annotations/05-delete-annotations.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": ClusterIP,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/proxy/haproxy/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/orchestrator/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' - - timeout: 30 diff --git a/e2e-tests/tests/async-ignore-annotations/06-assert.yaml b/e2e-tests/tests/async-ignore-annotations/06-assert.yaml index 93bb6aeaf..d4c2e81ac 100644 --- a/e2e-tests/tests/async-ignore-annotations/06-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/06-assert.yaml @@ -1,22 +1,18 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 20 ---- apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-to-ignore-mysql: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: - async-labels-to-ignore-mysql: "true" app.kubernetes.io/component: mysql app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-to-ignore-mysql: "true" percona.com/exposed: "true" rack: rack-22-test - annotations: - async-annotations-to-ignore-mysql: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: async-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -55,17 +51,17 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + async-annotations-to-ignore-haproxy: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: - async-labels-to-ignore-haproxy: "true" app.kubernetes.io/component: haproxy app.kubernetes.io/instance: async-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + async-labels-to-ignore-haproxy: "true" rack: rack-22-test - annotations: - async-annotations-to-ignore-haproxy: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: async-ignore-annotations-haproxy ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/async-ignore-annotations/06-update-annotation.yaml b/e2e-tests/tests/async-ignore-annotations/06-update-annotation.yaml deleted file mode 100644 index e4cdba18e..000000000 --- a/e2e-tests/tests/async-ignore-annotations/06-update-annotation.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": ClusterIP,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/proxy/haproxy/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/orchestrator/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' - - timeout: 30 diff --git a/e2e-tests/tests/async-ignore-annotations/07-assert.yaml b/e2e-tests/tests/async-ignore-annotations/07-assert.yaml index c244dc5ab..fd4cfb10a 100644 --- a/e2e-tests/tests/async-ignore-annotations/07-assert.yaml +++ b/e2e-tests/tests/async-ignore-annotations/07-assert.yaml @@ -1,10 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 20 ---- apiVersion: v1 kind: Service metadata: + annotations: + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: app.kubernetes.io/component: mysql app.kubernetes.io/instance: async-ignore-annotations @@ -13,8 +11,6 @@ metadata: app.kubernetes.io/part-of: percona-server percona.com/exposed: "true" rack: rack-22-test - annotations: - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: async-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -53,6 +49,8 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: app.kubernetes.io/component: haproxy app.kubernetes.io/instance: async-ignore-annotations @@ -60,8 +58,6 @@ metadata: app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server rack: rack-22-test - annotations: - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: async-ignore-annotations-haproxy ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -146,4 +142,3 @@ spec: rack: rack-22-test sessionAffinity: None type: ClusterIP - diff --git a/e2e-tests/tests/async-ignore-annotations/07-delete-custom-annotations-from-ignore.yaml b/e2e-tests/tests/async-ignore-annotations/07-delete-custom-annotations-from-ignore.yaml deleted file mode 100644 index 3b7415653..000000000 --- a/e2e-tests/tests/async-ignore-annotations/07-delete-custom-annotations-from-ignore.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/ignoreAnnotations", "value": [] }]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/ignoreLabels", "value": [] }]' - - timeout: 30 diff --git a/e2e-tests/tests/async-ignore-annotations/chainsaw-test.yaml b/e2e-tests/tests/async-ignore-annotations/chainsaw-test.yaml new file mode 100755 index 000000000..0fe9f0f26 --- /dev/null +++ b/e2e-tests/tests/async-ignore-annotations/chainsaw-test.yaml @@ -0,0 +1,169 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: async-ignore-annotations +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.expose.enabled=true' - \ + | yq eval '.spec.mysql.expose.type="ClusterIP"' - \ + | yq eval '.spec.proxy.haproxy.expose.type="ClusterIP"' - \ + | yq eval '.spec.orchestrator.expose.type="ClusterIP"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\nmysql_svc=$(get_mysql_service + async-ignore-annotations)\nhaproxy_svc=$(get_haproxy_svc async-ignore-annotations)\norc_svc=$(get_orc_svc + async-ignore-annotations)\n\nkubectl get svc $mysql_svc-0 -o yaml -n \"${NAMESPACE}\" + \\\n\t| yq eval '.metadata.annotations += {\"async-annotations-to-ignore-mysql\": + \"true\", \"async-annotations-not-to-ignore-mysql\": \"true\" }' - \\\n\t| + yq eval '.metadata.labels += {\"async-labels-to-ignore-mysql\": \"true\", + \"async-labels-not-to-ignore-mysql\": \"true\"}' - \\\n | kubectl -n \"${NAMESPACE}\" + apply -f -\n\nkubectl get svc $haproxy_svc -o yaml -n \"${NAMESPACE}\"\\\n + \ | yq eval '.metadata.annotations += {\"async-annotations-to-ignore-haproxy\": + \"true\", \"async-annotations-not-to-ignore-haproxy\": \"true\" }' - \\\n + \ | yq eval '.metadata.labels += {\"async-labels-to-ignore-haproxy\": \"true\", + \"async-labels-not-to-ignore-haproxy\": \"true\"}' - \\\n | kubectl -n + \"${NAMESPACE}\" apply -f -\n\nkubectl get svc $orc_svc-0 -o yaml -n \"${NAMESPACE}\"\\\n + \ | yq eval '.metadata.annotations += {\"async-annotations-to-ignore-orc\": + \"true\", \"async-annotations-not-to-ignore-orc\": \"true\" }' - \\\n | + yq eval '.metadata.labels += {\"async-labels-to-ignore-orc\": \"true\", + \"async-labels-not-to-ignore-orc\": \"true\" }' - \\\n | kubectl -n \"${NAMESPACE}\" + apply -f -" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/ignoreAnnotations", "value": ["async-annotations-to-ignore-mysql","async-annotations-to-ignore-haproxy", "async-annotations-to-ignore-orc"] }]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/ignoreLabels", "value": ["async-labels-to-ignore-mysql","async-labels-to-ignore-haproxy","async-labels-to-ignore-orc" ] }]' + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": ClusterIP,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/proxy/haproxy/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/orchestrator/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": ClusterIP,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/proxy/haproxy/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/orchestrator/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": ClusterIP,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/proxy/haproxy/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/orchestrator/expose", "value": {"type": ClusterIP ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/ignoreAnnotations", "value": [] }]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/ignoreLabels", "value": [] }]' + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/auto-config/00-assert.yaml b/e2e-tests/tests/auto-config/00-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/auto-config/00-assert.yaml +++ b/e2e-tests/tests/auto-config/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/auto-config/00-deploy-operator.yaml b/e2e-tests/tests/auto-config/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/auto-config/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/auto-config/01-assert.yaml b/e2e-tests/tests/auto-config/01-assert.yaml index dc8c73056..841432420 100644 --- a/e2e-tests/tests/auto-config/01-assert.yaml +++ b/e2e-tests/tests/auto-config/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -78,5 +74,5 @@ spec: name: backup-logs status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 diff --git a/e2e-tests/tests/auto-config/01-create-cluster.yaml b/e2e-tests/tests/auto-config/01-create-cluster.yaml deleted file mode 100644 index 888da9c74..000000000 --- a/e2e-tests/tests/auto-config/01-create-cluster.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/auto-config/02-assert.yaml b/e2e-tests/tests/auto-config/02-assert.yaml index 1168398bb..a0fc5495b 100644 --- a/e2e-tests/tests/auto-config/02-assert.yaml +++ b/e2e-tests/tests/auto-config/02-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 620 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/auto-config/02-remove-requests-add-limits.yaml b/e2e-tests/tests/auto-config/02-remove-requests-add-limits.yaml deleted file mode 100644 index c45cb89b2..000000000 --- a/e2e-tests/tests/auto-config/02-remove-requests-add-limits.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/resources", "value": {"limits": {"memory": "1024Mi"}}}]' diff --git a/e2e-tests/tests/auto-config/03-check-auto-tuning.yaml b/e2e-tests/tests/auto-config/03-check-auto-tuning.yaml deleted file mode 100644 index 370542d78..000000000 --- a/e2e-tests/tests/auto-config/03-check-auto-tuning.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - RAM_SIZE=1073741824 # 1024Mi - - check_auto_tuning ${RAM_SIZE} diff --git a/e2e-tests/tests/auto-config/04-assert.yaml b/e2e-tests/tests/auto-config/04-assert.yaml index 82df8d7ca..ee0687df4 100644 --- a/e2e-tests/tests/auto-config/04-assert.yaml +++ b/e2e-tests/tests/auto-config/04-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 620 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -19,6 +15,6 @@ spec: - name: pt-heartbeat status: observedGeneration: 3 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 diff --git a/e2e-tests/tests/auto-config/04-remove-limits-add-requests.yaml b/e2e-tests/tests/auto-config/04-remove-limits-add-requests.yaml deleted file mode 100644 index aebde093c..000000000 --- a/e2e-tests/tests/auto-config/04-remove-limits-add-requests.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/resources", "value": {"requests": {"memory": "4Gi"}}}]' diff --git a/e2e-tests/tests/auto-config/05-check-auto-tuning.yaml b/e2e-tests/tests/auto-config/05-check-auto-tuning.yaml deleted file mode 100644 index 5daef87ce..000000000 --- a/e2e-tests/tests/auto-config/05-check-auto-tuning.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - RAM_SIZE=4294967296 # 4Gi - - check_auto_tuning ${RAM_SIZE} diff --git a/e2e-tests/tests/auto-config/06-add-limits-change-requests.yaml b/e2e-tests/tests/auto-config/06-add-limits-change-requests.yaml deleted file mode 100644 index 821209a94..000000000 --- a/e2e-tests/tests/auto-config/06-add-limits-change-requests.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/resources", "value": {"requests": {"memory": "512M"}, "limits": {"memory": "1Gi"}}}]' diff --git a/e2e-tests/tests/auto-config/06-assert.yaml b/e2e-tests/tests/auto-config/06-assert.yaml index 7fdd81852..adb7ebd27 100644 --- a/e2e-tests/tests/auto-config/06-assert.yaml +++ b/e2e-tests/tests/auto-config/06-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 620 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -21,6 +17,6 @@ spec: - name: pt-heartbeat status: observedGeneration: 4 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 diff --git a/e2e-tests/tests/auto-config/07-check-auto-tuning.yaml b/e2e-tests/tests/auto-config/07-check-auto-tuning.yaml deleted file mode 100644 index bf384b559..000000000 --- a/e2e-tests/tests/auto-config/07-check-auto-tuning.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - RAM_SIZE=1073741824 # 1Gi - - check_auto_tuning ${RAM_SIZE} diff --git a/e2e-tests/tests/auto-config/08-add-custom-config.yaml b/e2e-tests/tests/auto-config/08-add-custom-config.yaml deleted file mode 100644 index 78824f328..000000000 --- a/e2e-tests/tests/auto-config/08-add-custom-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type merge \ - -p '{"spec": {"mysql": {"configuration": "innodb_buffer_pool_size=2147483648"}}}' diff --git a/e2e-tests/tests/auto-config/08-assert.yaml b/e2e-tests/tests/auto-config/08-assert.yaml index 4753e0d18..172bc866d 100644 --- a/e2e-tests/tests/auto-config/08-assert.yaml +++ b/e2e-tests/tests/auto-config/08-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 620 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,6 +5,6 @@ metadata: name: auto-config-mysql status: observedGeneration: 5 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 diff --git a/e2e-tests/tests/auto-config/09-check-auto-tuning.yaml b/e2e-tests/tests/auto-config/09-check-auto-tuning.yaml deleted file mode 100644 index 65bddd090..000000000 --- a/e2e-tests/tests/auto-config/09-check-auto-tuning.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - RAM_SIZE=1073741824 # 1Gi - CUSTOM_INNODB_SIZE=2147483648 - - check_auto_tuning ${RAM_SIZE} ${CUSTOM_INNODB_SIZE} diff --git a/e2e-tests/tests/auto-config/10-assert.yaml b/e2e-tests/tests/auto-config/10-assert.yaml index 8069a3917..47c814119 100644 --- a/e2e-tests/tests/auto-config/10-assert.yaml +++ b/e2e-tests/tests/auto-config/10-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 620 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,6 +5,6 @@ metadata: name: auto-config-mysql status: observedGeneration: 6 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 diff --git a/e2e-tests/tests/auto-config/10-change-cfg-template-params.yaml b/e2e-tests/tests/auto-config/10-change-cfg-template-params.yaml deleted file mode 100644 index b1d9cd713..000000000 --- a/e2e-tests/tests/auto-config/10-change-cfg-template-params.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type merge \ - -p '{"spec": {"mysql": {"configuration": "innodb_buffer_pool_size={{containerMemoryLimit * 2}}\nmax_connections=200"}}}' diff --git a/e2e-tests/tests/auto-config/11-check-auto-tuning.yaml b/e2e-tests/tests/auto-config/11-check-auto-tuning.yaml deleted file mode 100644 index 9214250ad..000000000 --- a/e2e-tests/tests/auto-config/11-check-auto-tuning.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - RAM_SIZE=1073741824 # 1Gi - CUSTOM_INNODB_SIZE=2147483648 - CUSTOM_CONNECTIONS=200 - - check_auto_tuning ${RAM_SIZE} ${CUSTOM_INNODB_SIZE} ${CUSTOM_CONNECTIONS} diff --git a/e2e-tests/tests/auto-config/chainsaw-test.yaml b/e2e-tests/tests/auto-config/chainsaw-test.yaml new file mode 100755 index 000000000..786404c50 --- /dev/null +++ b/e2e-tests/tests/auto-config/chainsaw-test.yaml @@ -0,0 +1,149 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: auto-config +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type json \\\n\t-p + '[{\"op\": \"replace\", \"path\": \"/spec/mysql/resources\", \"value\": + {\"limits\": {\"memory\": \"1024Mi\"}}}]'" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + RAM_SIZE=1073741824 # 1024Mi + + check_auto_tuning ${RAM_SIZE} + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type json \\\n\t-p + '[{\"op\": \"replace\", \"path\": \"/spec/mysql/resources\", \"value\": + {\"requests\": {\"memory\": \"4Gi\"}}}]'" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + RAM_SIZE=4294967296 # 4Gi + + check_auto_tuning ${RAM_SIZE} + - name: step-06 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type json \\\n\t-p + '[{\"op\": \"replace\", \"path\": \"/spec/mysql/resources\", \"value\": + {\"requests\": {\"memory\": \"512M\"}, \"limits\": {\"memory\": \"1Gi\"}}}]'" + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + RAM_SIZE=1073741824 # 1Gi + + check_auto_tuning ${RAM_SIZE} + - name: step-08 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type merge + \\\n\t-p '{\"spec\": {\"mysql\": {\"configuration\": \"innodb_buffer_pool_size=2147483648\"}}}'" + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + RAM_SIZE=1073741824 # 1Gi + CUSTOM_INNODB_SIZE=2147483648 + + check_auto_tuning ${RAM_SIZE} ${CUSTOM_INNODB_SIZE} + - name: step-10 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type merge + \\\n\t-p '{\"spec\": {\"mysql\": {\"configuration\": \"innodb_buffer_pool_size={{containerMemoryLimit + * 2}}\\nmax_connections=200\"}}}'" + - assert: + file: 10-assert.yaml + - name: step-11 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + RAM_SIZE=1073741824 # 1Gi + CUSTOM_INNODB_SIZE=2147483648 + CUSTOM_CONNECTIONS=200 + + check_auto_tuning ${RAM_SIZE} ${CUSTOM_INNODB_SIZE} ${CUSTOM_CONNECTIONS} + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/config-router/00-assert.yaml b/e2e-tests/tests/config-router/00-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/config-router/00-assert.yaml +++ b/e2e-tests/tests/config-router/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/config-router/00-deploy-operator.yaml b/e2e-tests/tests/config-router/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/config-router/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/config-router/01-assert.yaml b/e2e-tests/tests/config-router/01-assert.yaml index 93b8c3ceb..5583d342c 100644 --- a/e2e-tests/tests/config-router/01-assert.yaml +++ b/e2e-tests/tests/config-router/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -56,8 +52,8 @@ spec: optional: true - configMap: items: - - key: my.cnf - path: auto-config.cnf + - key: my.cnf + path: auto-config.cnf name: auto-config-router-mysql optional: true - secret: @@ -70,8 +66,8 @@ spec: name: backup-logs status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: Deployment @@ -82,4 +78,4 @@ status: observedGeneration: 1 readyReplicas: 3 replicas: 3 - updatedReplicas: 3 \ No newline at end of file + updatedReplicas: 3 diff --git a/e2e-tests/tests/config-router/01-create-cluster.yaml b/e2e-tests/tests/config-router/01-create-cluster.yaml deleted file mode 100644 index 9a366a342..000000000 --- a/e2e-tests/tests/config-router/01-create-cluster.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/config-router/02-assert.yaml b/e2e-tests/tests/config-router/02-assert.yaml index 519755442..26e0f3b60 100644 --- a/e2e-tests/tests/config-router/02-assert.yaml +++ b/e2e-tests/tests/config-router/02-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/config-router/02-config-through-cr.yaml b/e2e-tests/tests/config-router/02-config-through-cr.yaml deleted file mode 100644 index 850d3747d..000000000 --- a/e2e-tests/tests/config-router/02-config-through-cr.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type merge \ - -p '{"spec": {"proxy": {"router": {"configuration": "[default]\nlogging_folder=/tmp/router/log\n\n[logger]\nlevel=DEBUG\n"}}}}' diff --git a/e2e-tests/tests/config-router/03-assert.yaml b/e2e-tests/tests/config-router/03-assert.yaml index 63153a840..986094a9f 100644 --- a/e2e-tests/tests/config-router/03-assert.yaml +++ b/e2e-tests/tests/config-router/03-assert.yaml @@ -1,11 +1,4 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 60 ---- apiVersion: v1 -kind: ConfigMap -metadata: - name: config-router-router data: mysqlrouter.conf: | [default] @@ -13,3 +6,6 @@ data: [logger] level=DEBUG +kind: ConfigMap +metadata: + name: config-router-router diff --git a/e2e-tests/tests/config-router/03-check-config.yaml b/e2e-tests/tests/config-router/03-check-config.yaml deleted file mode 100644 index 5bf53dcac..000000000 --- a/e2e-tests/tests/config-router/03-check-config.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - pod=$(get_router_pods | head -n 1) - - echo "$pod" - - if ! kubectl -n "${NAMESPACE}" exec -it $pod -- bash -c 'cat /tmp/router/log/mysqlrouter.log' | grep -q 'DEBUG' ; then - echo "Failed to find necessary logs in $pod, expected logs in /tmp/router/log/mysqlrouter.log" - exit 1 - fi diff --git a/e2e-tests/tests/config-router/04-assert.yaml b/e2e-tests/tests/config-router/04-assert.yaml index 61cdbec4f..7103724db 100644 --- a/e2e-tests/tests/config-router/04-assert.yaml +++ b/e2e-tests/tests/config-router/04-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/config-router/04-remove-config.yaml b/e2e-tests/tests/config-router/04-remove-config.yaml deleted file mode 100644 index 16519deb5..000000000 --- a/e2e-tests/tests/config-router/04-remove-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type=merge \ - -p '{"spec": {"proxy": {"router": {"configuration": ""}}}}' diff --git a/e2e-tests/tests/config-router/05-assert.yaml b/e2e-tests/tests/config-router/05-assert.yaml index bfffecc3c..d5bf970a2 100644 --- a/e2e-tests/tests/config-router/05-assert.yaml +++ b/e2e-tests/tests/config-router/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: v1 kind: ConfigMap metadata: @@ -26,4 +22,4 @@ status: observedGeneration: 4 readyReplicas: 3 replicas: 3 - updatedReplicas: 3 \ No newline at end of file + updatedReplicas: 3 diff --git a/e2e-tests/tests/config-router/07-assert.yaml b/e2e-tests/tests/config-router/07-assert.yaml index 63153a840..986094a9f 100644 --- a/e2e-tests/tests/config-router/07-assert.yaml +++ b/e2e-tests/tests/config-router/07-assert.yaml @@ -1,11 +1,4 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 60 ---- apiVersion: v1 -kind: ConfigMap -metadata: - name: config-router-router data: mysqlrouter.conf: | [default] @@ -13,3 +6,6 @@ data: [logger] level=DEBUG +kind: ConfigMap +metadata: + name: config-router-router diff --git a/e2e-tests/tests/config-router/07-check-config.yaml b/e2e-tests/tests/config-router/07-check-config.yaml deleted file mode 100644 index 5bf53dcac..000000000 --- a/e2e-tests/tests/config-router/07-check-config.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - pod=$(get_router_pods | head -n 1) - - echo "$pod" - - if ! kubectl -n "${NAMESPACE}" exec -it $pod -- bash -c 'cat /tmp/router/log/mysqlrouter.log' | grep -q 'DEBUG' ; then - echo "Failed to find necessary logs in $pod, expected logs in /tmp/router/log/mysqlrouter.log" - exit 1 - fi diff --git a/e2e-tests/tests/config-router/chainsaw-test.yaml b/e2e-tests/tests/config-router/chainsaw-test.yaml new file mode 100755 index 000000000..79f7d448a --- /dev/null +++ b/e2e-tests/tests/config-router/chainsaw-test.yaml @@ -0,0 +1,97 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: config-router +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n | kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type merge + \\\n\t-p '{\"spec\": {\"proxy\": {\"router\": {\"configuration\": \"[default]\\nlogging_folder=/tmp/router/log\\n\\n[logger]\\nlevel=DEBUG\\n\"}}}}'" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + pod=$(get_router_pods | head -n 1) + + echo "$pod" + + if ! kubectl -n "${NAMESPACE}" exec -it $pod -- bash -c 'cat /tmp/router/log/mysqlrouter.log' | grep -q 'DEBUG' ; then + echo "Failed to find necessary logs in $pod, expected logs in /tmp/router/log/mysqlrouter.log" + exit 1 + fi + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type=merge + \\\n\t-p '{\"spec\": {\"proxy\": {\"router\": {\"configuration\": \"\"}}}}'" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - apply: + file: 05-config-through-configmap.yaml + - assert: + file: 05-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + pod=$(get_router_pods | head -n 1) + + echo "$pod" + + if ! kubectl -n "${NAMESPACE}" exec -it $pod -- bash -c 'cat /tmp/router/log/mysqlrouter.log' | grep -q 'DEBUG' ; then + echo "Failed to find necessary logs in $pod, expected logs in /tmp/router/log/mysqlrouter.log" + exit 1 + fi + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/config/00-assert.yaml b/e2e-tests/tests/config/00-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/config/00-assert.yaml +++ b/e2e-tests/tests/config/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/config/00-deploy-operator.yaml b/e2e-tests/tests/config/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/config/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/config/01-assert.yaml b/e2e-tests/tests/config/01-assert.yaml index a3b8cd482..dffb33638 100644 --- a/e2e-tests/tests/config/01-assert.yaml +++ b/e2e-tests/tests/config/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -64,8 +60,8 @@ spec: optional: true - configMap: items: - - key: my.cnf - path: auto-config.cnf + - key: my.cnf + path: auto-config.cnf name: auto-config-mysql optional: true - secret: @@ -78,5 +74,5 @@ spec: name: backup-logs status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 diff --git a/e2e-tests/tests/config/01-create-cluster.yaml b/e2e-tests/tests/config/01-create-cluster.yaml deleted file mode 100644 index 888da9c74..000000000 --- a/e2e-tests/tests/config/01-create-cluster.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/config/02-assert.yaml b/e2e-tests/tests/config/02-assert.yaml index e75014f16..f69ae0415 100644 --- a/e2e-tests/tests/config/02-assert.yaml +++ b/e2e-tests/tests/config/02-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/config/02-config-through-cr.yaml b/e2e-tests/tests/config/02-config-through-cr.yaml deleted file mode 100644 index 387d20855..000000000 --- a/e2e-tests/tests/config/02-config-through-cr.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type merge \ - -p '{"spec": {"mysql": {"configuration": "max_connections=250"}}}' diff --git a/e2e-tests/tests/config/03-assert.yaml b/e2e-tests/tests/config/03-assert.yaml index 99618157c..b5a0f630b 100644 --- a/e2e-tests/tests/config/03-assert.yaml +++ b/e2e-tests/tests/config/03-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 60 ---- apiVersion: v1 +data: + max_connections: "250" kind: ConfigMap metadata: name: 03-check-config -data: - max_connections: "250" diff --git a/e2e-tests/tests/config/03-check-config.yaml b/e2e-tests/tests/config/03-check-config.yaml deleted file mode 100644 index 4ea869afe..000000000 --- a/e2e-tests/tests/config/03-check-config.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - mysql_args="-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - max_connections=$(run_mysql "SELECT @@max_connections" "${mysql_args}") - - kubectl create configmap -n "${NAMESPACE}" 03-check-config \ - --from-literal=max_connections="${max_connections}" diff --git a/e2e-tests/tests/config/04-assert.yaml b/e2e-tests/tests/config/04-assert.yaml index 4b5dcab71..067259874 100644 --- a/e2e-tests/tests/config/04-assert.yaml +++ b/e2e-tests/tests/config/04-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/config/04-remove-config.yaml b/e2e-tests/tests/config/04-remove-config.yaml deleted file mode 100644 index 834491f3d..000000000 --- a/e2e-tests/tests/config/04-remove-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type=merge \ - -p '{"spec": {"mysql": {"configuration": ""}}}' diff --git a/e2e-tests/tests/config/05-assert.yaml b/e2e-tests/tests/config/05-assert.yaml index ee4b594b0..356458fc8 100644 --- a/e2e-tests/tests/config/05-assert.yaml +++ b/e2e-tests/tests/config/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: v1 kind: ConfigMap metadata: @@ -20,4 +16,4 @@ status: observedGeneration: 4 readyReplicas: 3 replicas: 3 - updatedReplicas: 3 \ No newline at end of file + updatedReplicas: 3 diff --git a/e2e-tests/tests/config/07-assert.yaml b/e2e-tests/tests/config/07-assert.yaml index beb8849df..b7189212b 100644 --- a/e2e-tests/tests/config/07-assert.yaml +++ b/e2e-tests/tests/config/07-assert.yaml @@ -1,11 +1,7 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 60 ---- apiVersion: v1 +data: + max_connect_errors: "150" + max_connections: "250" kind: ConfigMap metadata: name: 07-check-config -data: - max_connections: "250" - max_connect_errors: "150" diff --git a/e2e-tests/tests/config/07-check-config.yaml b/e2e-tests/tests/config/07-check-config.yaml deleted file mode 100644 index f61cbab3b..000000000 --- a/e2e-tests/tests/config/07-check-config.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - echo "config-mysql-0" - kubectl exec -n "${NAMESPACE}" config-mysql-0 -- cat /etc/my.cnf.d/node.cnf - echo "config-mysql-1" - kubectl exec -n "${NAMESPACE}" config-mysql-1 -- cat /etc/my.cnf.d/node.cnf - echo "config-mysql-2" - kubectl exec -n "${NAMESPACE}" config-mysql-2 -- cat /etc/my.cnf.d/node.cnf - - mysql_args="-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - max_connections=$(run_mysql "SELECT @@max_connections" "${mysql_args}") - max_connect_errors=$(run_mysql "SELECT @@max_connect_errors" "${mysql_args}") - - kubectl create configmap -n "${NAMESPACE}" 07-check-config \ - --from-literal=max_connections="${max_connections}" \ - --from-literal=max_connect_errors="${max_connect_errors}" diff --git a/e2e-tests/tests/config/chainsaw-test.yaml b/e2e-tests/tests/config/chainsaw-test.yaml new file mode 100755 index 000000000..ea0923371 --- /dev/null +++ b/e2e-tests/tests/config/chainsaw-test.yaml @@ -0,0 +1,88 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: config +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type merge + \\\n\t-p '{\"spec\": {\"mysql\": {\"configuration\": \"max_connections=250\"}}}'" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nmysql_args=\"-h + $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"\nmax_connections=$(run_mysql + \"SELECT @@max_connections\" \"${mysql_args}\")\n\nkubectl create configmap + -n \"${NAMESPACE}\" 03-check-config \\\n\t--from-literal=max_connections=\"${max_connections}\"" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nkubectl + -n \"${NAMESPACE}\" patch ps \"$(get_cluster_name)\" \\\n\t--type=merge + \\\n\t-p '{\"spec\": {\"mysql\": {\"configuration\": \"\"}}}'" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - apply: + file: 05-config-through-configmap-and-secret.yaml + - assert: + file: 05-assert.yaml + - name: step-07 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\necho + \"config-mysql-0\"\nkubectl exec -n \"${NAMESPACE}\" config-mysql-0 -- cat + /etc/my.cnf.d/node.cnf\necho \"config-mysql-1\"\nkubectl exec -n \"${NAMESPACE}\" + config-mysql-1 -- cat /etc/my.cnf.d/node.cnf\necho \"config-mysql-2\"\nkubectl + exec -n \"${NAMESPACE}\" config-mysql-2 -- cat /etc/my.cnf.d/node.cnf\n\nmysql_args=\"-h + $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"\nmax_connections=$(run_mysql + \"SELECT @@max_connections\" \"${mysql_args}\")\nmax_connect_errors=$(run_mysql + \"SELECT @@max_connect_errors\" \"${mysql_args}\")\n\nkubectl create configmap + -n \"${NAMESPACE}\" 07-check-config \\\n\t--from-literal=max_connections=\"${max_connections}\" + \\\n\t--from-literal=max_connect_errors=\"${max_connect_errors}\"" + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/demand-backup/00-assert.yaml b/e2e-tests/tests/demand-backup/00-assert.yaml index fecdb222e..f57037ea4 100644 --- a/e2e-tests/tests/demand-backup/00-assert.yaml +++ b/e2e-tests/tests/demand-backup/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 150 ---- apiVersion: v1 kind: Secret metadata: diff --git a/e2e-tests/tests/demand-backup/01-assert.yaml b/e2e-tests/tests/demand-backup/01-assert.yaml index 30e8e19de..b7a766494 100644 --- a/e2e-tests/tests/demand-backup/01-assert.yaml +++ b/e2e-tests/tests/demand-backup/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 150 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/demand-backup/01-deploy-operator.yaml b/e2e-tests/tests/demand-backup/01-deploy-operator.yaml deleted file mode 100644 index cb9e3c5ab..000000000 --- a/e2e-tests/tests/demand-backup/01-deploy-operator.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - kubectl -n "${NAMESPACE}" apply -f "${TESTS_CONFIG_DIR}/cloud-secret.yml" - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client - deploy_minio - timeout: 300 diff --git a/e2e-tests/tests/demand-backup/02-assert.yaml b/e2e-tests/tests/demand-backup/02-assert.yaml index f5c04da48..de68b8f57 100644 --- a/e2e-tests/tests/demand-backup/02-assert.yaml +++ b/e2e-tests/tests/demand-backup/02-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: demand-backup-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: demand-backup-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: demand-backup-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: demand-backup finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: demand-backup status: haproxy: ready: 3 diff --git a/e2e-tests/tests/demand-backup/02-create-cluster.yaml b/e2e-tests/tests/demand-backup/02-create-cluster.yaml deleted file mode 100644 index 5adbd3644..000000000 --- a/e2e-tests/tests/demand-backup/02-create-cluster.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | yq eval '.spec.backup.storages.minio.type="s3"' - \ - | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ - | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ - | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ - | yq eval '.spec.backup.storages.aws-s3.type="s3"' - \ - | yq eval '.spec.backup.storages.aws-s3.verifyTLS=true' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.credentialsSecret="aws-s3-secret"' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.region="us-east-1"' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.prefix="ps"' - \ - | yq eval '.spec.backup.storages.gcp-cs.type="gcs"' - \ - | yq eval '.spec.backup.storages.gcp-cs.verifyTLS=true' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.credentialsSecret="gcp-cs-secret"' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.endpointUrl="https://storage.googleapis.com"' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.prefix="ps"' - \ - | yq eval '.spec.backup.storages.azure-blob.type="azure"' - \ - | yq eval '.spec.backup.storages.azure-blob.verifyTLS=true' - \ - | yq eval '.spec.backup.storages.azure-blob.azure.containerName="operator-testing"' - \ - | yq eval '.spec.backup.storages.azure-blob.azure.credentialsSecret="azure-secret"' - \ - | yq eval '.spec.backup.storages.azure-blob.azure.prefix="ps"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/demand-backup/03-write-data.yaml b/e2e-tests/tests/demand-backup/03-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/demand-backup/03-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/demand-backup/04-move-primary-before-backup.yaml b/e2e-tests/tests/demand-backup/04-move-primary-before-backup.yaml deleted file mode 100644 index fa544dcf2..000000000 --- a/e2e-tests/tests/demand-backup/04-move-primary-before-backup.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - primary_pod_from_label="$(get_primary_from_label)" - kubectl delete pod -n ${NAMESPACE} ${primary_pod_from_label} - wait_cluster_consistency_async "${test_name}" "3" "3" - - new_primary_pod_from_label="$(get_primary_from_label)" - if [ "${primary_pod_from_label}" == "${new_primary_pod_from_label}" ]; then - echo "Old (${primary_pod_from_label}) and new (${new_primary_pod_from_label}) primary are the same (the failover didn't happen)!" - exit 1 - fi - timeout: 180 diff --git a/e2e-tests/tests/demand-backup/05-assert.yaml b/e2e-tests/tests/demand-backup/05-assert.yaml index 13db16d7d..477761131 100644 --- a/e2e-tests/tests/demand-backup/05-assert.yaml +++ b/e2e-tests/tests/demand-backup/05-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: - name: demand-backup-minio finalizers: - - delete-backup + - delete-backup + name: demand-backup-minio status: state: Succeeded diff --git a/e2e-tests/tests/demand-backup/06-check-password-leak.yaml b/e2e-tests/tests/demand-backup/06-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/demand-backup/06-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/demand-backup/07-assert.yaml b/e2e-tests/tests/demand-backup/07-assert.yaml index b9141ada3..7ae8579e4 100644 --- a/e2e-tests/tests/demand-backup/07-assert.yaml +++ b/e2e-tests/tests/demand-backup/07-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 04-delete-data-minio-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-2 -data: - data: "" diff --git a/e2e-tests/tests/demand-backup/07-delete-data.yaml b/e2e-tests/tests/demand-backup/07-delete-data.yaml deleted file mode 100644 index e5d0ca056..000000000 --- a/e2e-tests/tests/demand-backup/07-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/08-assert.yaml b/e2e-tests/tests/demand-backup/08-assert.yaml index b0a45bad2..8bf91d08b 100644 --- a/e2e-tests/tests/demand-backup/08-assert.yaml +++ b/e2e-tests/tests/demand-backup/08-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: demand-backup finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: demand-backup status: haproxy: ready: 3 @@ -23,8 +19,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: demand-backup-restore-minio status: diff --git a/e2e-tests/tests/demand-backup/09-check-password-leak.yaml b/e2e-tests/tests/demand-backup/09-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/demand-backup/09-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/demand-backup/10-assert.yaml b/e2e-tests/tests/demand-backup/10-assert.yaml index 17deff5a9..46564cc3a 100644 --- a/e2e-tests/tests/demand-backup/10-assert.yaml +++ b/e2e-tests/tests/demand-backup/10-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-minio-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-minio-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-minio-2 -data: - data: "100500" diff --git a/e2e-tests/tests/demand-backup/10-read-data.yaml b/e2e-tests/tests/demand-backup/10-read-data.yaml deleted file mode 100644 index a82745a0a..000000000 --- a/e2e-tests/tests/demand-backup/10-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/11-assert.yaml b/e2e-tests/tests/demand-backup/11-assert.yaml index b7a0aab03..5ca1c9838 100644 --- a/e2e-tests/tests/demand-backup/11-assert.yaml +++ b/e2e-tests/tests/demand-backup/11-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 04-delete-data-minio-backup-source-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-backup-source-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-backup-source-2 -data: - data: "" diff --git a/e2e-tests/tests/demand-backup/11-delete-data.yaml b/e2e-tests/tests/demand-backup/11-delete-data.yaml deleted file mode 100644 index 81e79525d..000000000 --- a/e2e-tests/tests/demand-backup/11-delete-data.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2 - do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio-backup-source-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/12-assert.yaml b/e2e-tests/tests/demand-backup/12-assert.yaml index 2c6402930..fd4cd1e36 100644 --- a/e2e-tests/tests/demand-backup/12-assert.yaml +++ b/e2e-tests/tests/demand-backup/12-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: demand-backup finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: demand-backup status: haproxy: ready: 3 @@ -23,8 +19,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: demand-backup-restore-minio-backup-source status: diff --git a/e2e-tests/tests/demand-backup/12-restore-from-minio-backup-source.yaml b/e2e-tests/tests/demand-backup/12-restore-from-minio-backup-source.yaml deleted file mode 100644 index a3bca26ea..000000000 --- a/e2e-tests/tests/demand-backup/12-restore-from-minio-backup-source.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - storage_name="minio" - backup_name="demand-backup-minio" - restore_name="demand-backup-restore-minio-backup-source" - cluster_name="${test_name}${name_suffix:+-$name_suffix}" - destination=$(kubectl -n "${NAMESPACE}" get ps-backup "${backup_name}" -o jsonpath='{.status.destination}') - - cat "${DEPLOY_DIR}/restore.yaml" \ - | yq eval "$(printf '.metadata.name="%s"' "${restore_name}")" - \ - | yq eval "$(printf '.spec.clusterName="%s"' "${cluster_name}")" - \ - | yq eval "del(.spec.backupName)" - \ - | yq eval "$(printf '.spec.backupSource.destination="%s"' "${destination}")" - \ - | yq eval '.spec.backupSource.storage.type="s3"' - \ - | yq eval '.spec.backupSource.storage.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backupSource.storage.s3.credentialsSecret="minio-secret"' - \ - | yq eval '.spec.backupSource.storage.s3.endpointUrl="http://minio-service:9000"' - \ - | yq eval '.spec.backupSource.storage.s3.region="us-east-1"' - \ - | kubectl apply -n "${NAMESPACE}" -f - diff --git a/e2e-tests/tests/demand-backup/13-assert.yaml b/e2e-tests/tests/demand-backup/13-assert.yaml index 9c0c8e6fe..bf29bfa0d 100644 --- a/e2e-tests/tests/demand-backup/13-assert.yaml +++ b/e2e-tests/tests/demand-backup/13-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 09-read-data-minio-backup-source-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 09-read-data-minio-backup-source-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 09-read-data-minio-backup-source-2 -data: - data: "100500" diff --git a/e2e-tests/tests/demand-backup/13-read-data.yaml b/e2e-tests/tests/demand-backup/13-read-data.yaml deleted file mode 100644 index 6b5ca5f6b..000000000 --- a/e2e-tests/tests/demand-backup/13-read-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2 - do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 09-read-data-minio-backup-source-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/14-assert.yaml b/e2e-tests/tests/demand-backup/14-assert.yaml index e82428cb8..0c06deed9 100644 --- a/e2e-tests/tests/demand-backup/14-assert.yaml +++ b/e2e-tests/tests/demand-backup/14-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: - name: demand-backup-s3 finalizers: - - delete-backup + - delete-backup + name: demand-backup-s3 status: state: Succeeded diff --git a/e2e-tests/tests/demand-backup/15-assert.yaml b/e2e-tests/tests/demand-backup/15-assert.yaml index b945217e8..0276ea716 100644 --- a/e2e-tests/tests/demand-backup/15-assert.yaml +++ b/e2e-tests/tests/demand-backup/15-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 08-delete-data-s3-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 08-delete-data-s3-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 08-delete-data-s3-2 -data: - data: "" diff --git a/e2e-tests/tests/demand-backup/15-delete-data.yaml b/e2e-tests/tests/demand-backup/15-delete-data.yaml deleted file mode 100644 index 5d1c5fadc..000000000 --- a/e2e-tests/tests/demand-backup/15-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 08-delete-data-s3-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/16-assert.yaml b/e2e-tests/tests/demand-backup/16-assert.yaml index 699b59f0a..ddc9a9759 100644 --- a/e2e-tests/tests/demand-backup/16-assert.yaml +++ b/e2e-tests/tests/demand-backup/16-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: demand-backup finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: demand-backup status: haproxy: ready: 3 @@ -23,8 +19,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: demand-backup-restore-s3 status: diff --git a/e2e-tests/tests/demand-backup/17-assert.yaml b/e2e-tests/tests/demand-backup/17-assert.yaml index 8ec7c0a50..9f38ab9d5 100644 --- a/e2e-tests/tests/demand-backup/17-assert.yaml +++ b/e2e-tests/tests/demand-backup/17-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-s3-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-s3-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-s3-2 -data: - data: "100500" diff --git a/e2e-tests/tests/demand-backup/17-read-data.yaml b/e2e-tests/tests/demand-backup/17-read-data.yaml deleted file mode 100644 index 42c349b7b..000000000 --- a/e2e-tests/tests/demand-backup/17-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-s3-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/18-assert.yaml b/e2e-tests/tests/demand-backup/18-assert.yaml index 19074dea6..d2d51f930 100644 --- a/e2e-tests/tests/demand-backup/18-assert.yaml +++ b/e2e-tests/tests/demand-backup/18-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: - name: demand-backup-gcp finalizers: - - delete-backup + - delete-backup + name: demand-backup-gcp status: state: Succeeded diff --git a/e2e-tests/tests/demand-backup/19-assert.yaml b/e2e-tests/tests/demand-backup/19-assert.yaml index 1ccc31531..87260fab9 100644 --- a/e2e-tests/tests/demand-backup/19-assert.yaml +++ b/e2e-tests/tests/demand-backup/19-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 12-delete-data-gcp-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 12-delete-data-gcp-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 12-delete-data-gcp-2 -data: - data: "" diff --git a/e2e-tests/tests/demand-backup/19-delete-data.yaml b/e2e-tests/tests/demand-backup/19-delete-data.yaml deleted file mode 100644 index 21f97e525..000000000 --- a/e2e-tests/tests/demand-backup/19-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 12-delete-data-gcp-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/20-assert.yaml b/e2e-tests/tests/demand-backup/20-assert.yaml index 5ac4092e8..73745cc18 100644 --- a/e2e-tests/tests/demand-backup/20-assert.yaml +++ b/e2e-tests/tests/demand-backup/20-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: demand-backup finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: demand-backup status: haproxy: ready: 3 @@ -23,8 +19,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: demand-backup-restore-gcp status: diff --git a/e2e-tests/tests/demand-backup/21-assert.yaml b/e2e-tests/tests/demand-backup/21-assert.yaml index 77cef7012..58ba4e597 100644 --- a/e2e-tests/tests/demand-backup/21-assert.yaml +++ b/e2e-tests/tests/demand-backup/21-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-gcp-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-gcp-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-gcp-2 -data: - data: "100500" diff --git a/e2e-tests/tests/demand-backup/21-read-data.yaml b/e2e-tests/tests/demand-backup/21-read-data.yaml deleted file mode 100644 index 5d51b69de..000000000 --- a/e2e-tests/tests/demand-backup/21-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-gcp-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/22-assert.yaml b/e2e-tests/tests/demand-backup/22-assert.yaml index ab6757c21..ea06f4a4f 100644 --- a/e2e-tests/tests/demand-backup/22-assert.yaml +++ b/e2e-tests/tests/demand-backup/22-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: - name: demand-backup-azure finalizers: - - delete-backup + - delete-backup + name: demand-backup-azure status: state: Succeeded diff --git a/e2e-tests/tests/demand-backup/23-assert.yaml b/e2e-tests/tests/demand-backup/23-assert.yaml index d1ac765a0..bc67d3b86 100644 --- a/e2e-tests/tests/demand-backup/23-assert.yaml +++ b/e2e-tests/tests/demand-backup/23-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 16-delete-data-azure-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 16-delete-data-azure-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 16-delete-data-azure-2 -data: - data: "" diff --git a/e2e-tests/tests/demand-backup/23-delete-data.yaml b/e2e-tests/tests/demand-backup/23-delete-data.yaml deleted file mode 100644 index df9f53a59..000000000 --- a/e2e-tests/tests/demand-backup/23-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 16-delete-data-azure-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/24-assert.yaml b/e2e-tests/tests/demand-backup/24-assert.yaml index 0f99b8415..6df04ce0f 100644 --- a/e2e-tests/tests/demand-backup/24-assert.yaml +++ b/e2e-tests/tests/demand-backup/24-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: demand-backup finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: demand-backup status: haproxy: ready: 3 @@ -23,8 +19,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: demand-backup-restore-azure status: diff --git a/e2e-tests/tests/demand-backup/25-assert.yaml b/e2e-tests/tests/demand-backup/25-assert.yaml index 67d7b873a..cf3031fab 100644 --- a/e2e-tests/tests/demand-backup/25-assert.yaml +++ b/e2e-tests/tests/demand-backup/25-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-azure-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-azure-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-azure-2 -data: - data: "100500" diff --git a/e2e-tests/tests/demand-backup/25-read-data.yaml b/e2e-tests/tests/demand-backup/25-read-data.yaml deleted file mode 100644 index f209711d1..000000000 --- a/e2e-tests/tests/demand-backup/25-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-azure-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/demand-backup/26-delete-all-backups.yaml b/e2e-tests/tests/demand-backup/26-delete-all-backups.yaml deleted file mode 100644 index f9568d14d..000000000 --- a/e2e-tests/tests/demand-backup/26-delete-all-backups.yaml +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 100 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl delete ps-backup --all -n "${NAMESPACE}" - - backup_name_minio="demand-backup-minio" - - accessKey="$(kubectl -n "${NAMESPACE}" get secret minio-secret -o jsonpath='{.data.AWS_ACCESS_KEY_ID}' | base64 -d)" - secretKey="$(kubectl -n "${NAMESPACE}" get secret minio-secret -o jsonpath='{.data.AWS_SECRET_ACCESS_KEY}' | base64 -d)" - - backup_exists=$( - kubectl run -n "${NAMESPACE}" -i --rm aws-cli --image=perconalab/awscli --restart=Never -- \ - /usr/bin/env AWS_ACCESS_KEY_ID="${accessKey}" AWS_SECRET_ACCESS_KEY="${secretKey}" AWS_DEFAULT_REGION=us-east-1 \ - /usr/bin/aws --endpoint-url http://minio-service:9000 s3 ls 'operator-testing/' | grep -c "${backup_name_minio}/" | cat - exit "${PIPESTATUS[0]}" - ) - - if [[ 1 -eq $backup_exists ]]; then - echo "Backup was not removed from bucket -- minio" - exit 1 - fi diff --git a/e2e-tests/tests/demand-backup/chainsaw-test.yaml b/e2e-tests/tests/demand-backup/chainsaw-test.yaml new file mode 100755 index 000000000..bce887f08 --- /dev/null +++ b/e2e-tests/tests/demand-backup/chainsaw-test.yaml @@ -0,0 +1,408 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: demand-backup +spec: + steps: + - name: step-00 + try: + - apply: + file: 00-minio-secret.yaml + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + kubectl -n "${NAMESPACE}" apply -f "${TESTS_CONFIG_DIR}/cloud-secret.yml" + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + deploy_minio + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | yq eval '.spec.backup.storages.minio.type="s3"' - \ + | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ + | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ + | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ + | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ + | yq eval '.spec.backup.storages.aws-s3.type="s3"' - \ + | yq eval '.spec.backup.storages.aws-s3.verifyTLS=true' - \ + | yq eval '.spec.backup.storages.aws-s3.s3.bucket="operator-testing"' - \ + | yq eval '.spec.backup.storages.aws-s3.s3.credentialsSecret="aws-s3-secret"' - \ + | yq eval '.spec.backup.storages.aws-s3.s3.region="us-east-1"' - \ + | yq eval '.spec.backup.storages.aws-s3.s3.prefix="ps"' - \ + | yq eval '.spec.backup.storages.gcp-cs.type="gcs"' - \ + | yq eval '.spec.backup.storages.gcp-cs.verifyTLS=true' - \ + | yq eval '.spec.backup.storages.gcp-cs.gcs.bucket="operator-testing"' - \ + | yq eval '.spec.backup.storages.gcp-cs.gcs.credentialsSecret="gcp-cs-secret"' - \ + | yq eval '.spec.backup.storages.gcp-cs.gcs.endpointUrl="https://storage.googleapis.com"' - \ + | yq eval '.spec.backup.storages.gcp-cs.gcs.prefix="ps"' - \ + | yq eval '.spec.backup.storages.azure-blob.type="azure"' - \ + | yq eval '.spec.backup.storages.azure-blob.verifyTLS=true' - \ + | yq eval '.spec.backup.storages.azure-blob.azure.containerName="operator-testing"' - \ + | yq eval '.spec.backup.storages.azure-blob.azure.credentialsSecret="azure-secret"' - \ + | yq eval '.spec.backup.storages.azure-blob.azure.prefix="ps"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + primary_pod_from_label="$(get_primary_from_label)" + kubectl delete pod -n ${NAMESPACE} ${primary_pod_from_label} + wait_cluster_consistency_async "${test_name}" "3" "3" + + new_primary_pod_from_label="$(get_primary_from_label)" + if [ "${primary_pod_from_label}" == "${new_primary_pod_from_label}" ]; then + echo "Old (${primary_pod_from_label}) and new (${new_primary_pod_from_label}) primary are the same (the failover didn't happen)!" + exit 1 + fi + - name: step-05 + try: + - apply: + file: 05-create-backup-minio.yaml + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + run_mysql \ + "TRUNCATE TABLE myDB.myTable" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio-${i} --from-literal=data="${data}" + done + - assert: + file: 07-assert.yaml + - name: step-08 + try: + - apply: + file: 08-restore-from-minio.yaml + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-10 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio-${i} --from-literal=data="${data}" + done + - assert: + file: 10-assert.yaml + - name: step-11 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + run_mysql \ + "TRUNCATE TABLE myDB.myTable" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + cluster_name=$(get_cluster_name) + for i in 0 1 2 + do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio-backup-source-${i} --from-literal=data="${data}" + done + - assert: + file: 11-assert.yaml + - name: step-12 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + storage_name="minio" + backup_name="demand-backup-minio" + restore_name="demand-backup-restore-minio-backup-source" + cluster_name="${test_name}${name_suffix:+-$name_suffix}" + destination=$(kubectl -n "${NAMESPACE}" get ps-backup "${backup_name}" -o jsonpath='{.status.destination}') + + cat "${DEPLOY_DIR}/restore.yaml" \ + | yq eval "$(printf '.metadata.name="%s"' "${restore_name}")" - \ + | yq eval "$(printf '.spec.clusterName="%s"' "${cluster_name}")" - \ + | yq eval "del(.spec.backupName)" - \ + | yq eval "$(printf '.spec.backupSource.destination="%s"' "${destination}")" - \ + | yq eval '.spec.backupSource.storage.type="s3"' - \ + | yq eval '.spec.backupSource.storage.s3.bucket="operator-testing"' - \ + | yq eval '.spec.backupSource.storage.s3.credentialsSecret="minio-secret"' - \ + | yq eval '.spec.backupSource.storage.s3.endpointUrl="http://minio-service:9000"' - \ + | yq eval '.spec.backupSource.storage.s3.region="us-east-1"' - \ + | kubectl apply -n "${NAMESPACE}" -f - + - assert: + file: 12-assert.yaml + - name: step-13 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + cluster_name=$(get_cluster_name) + for i in 0 1 2 + do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 09-read-data-minio-backup-source-${i} --from-literal=data="${data}" + done + - assert: + file: 13-assert.yaml + - name: step-14 + try: + - apply: + file: 14-create-backup-s3.yaml + - assert: + file: 14-assert.yaml + - name: step-15 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + run_mysql \ + "TRUNCATE TABLE myDB.myTable" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 08-delete-data-s3-${i} --from-literal=data="${data}" + done + - assert: + file: 15-assert.yaml + - name: step-16 + try: + - apply: + file: 16-restore-from-s3.yaml + - assert: + file: 16-assert.yaml + - name: step-17 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 06-read-data-s3-${i} --from-literal=data="${data}" + done + - assert: + file: 17-assert.yaml + - name: step-18 + try: + - apply: + file: 18-create-backup-gcp.yaml + - assert: + file: 18-assert.yaml + - name: step-19 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + run_mysql \ + "TRUNCATE TABLE myDB.myTable" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 12-delete-data-gcp-${i} --from-literal=data="${data}" + done + - assert: + file: 19-assert.yaml + - name: step-20 + try: + - apply: + file: 20-restore-from-gcp.yaml + - assert: + file: 20-assert.yaml + - name: step-21 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 06-read-data-gcp-${i} --from-literal=data="${data}" + done + - assert: + file: 21-assert.yaml + - name: step-22 + try: + - apply: + file: 22-create-backup-azure.yaml + - assert: + file: 22-assert.yaml + - name: step-23 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + run_mysql \ + "TRUNCATE TABLE myDB.myTable" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 16-delete-data-azure-${i} --from-literal=data="${data}" + done + - assert: + file: 23-assert.yaml + - name: step-24 + try: + - apply: + file: 24-restore-from-azure.yaml + - assert: + file: 24-assert.yaml + - name: step-25 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + cluster_name=$(get_cluster_name) + for i in 0 1 2; do + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 06-read-data-azure-${i} --from-literal=data="${data}" + done + - assert: + file: 25-assert.yaml + - name: step-26 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl delete ps-backup --all -n "${NAMESPACE}" + + backup_name_minio="demand-backup-minio" + + accessKey="$(kubectl -n "${NAMESPACE}" get secret minio-secret -o jsonpath='{.data.AWS_ACCESS_KEY_ID}' | base64 -d)" + secretKey="$(kubectl -n "${NAMESPACE}" get secret minio-secret -o jsonpath='{.data.AWS_SECRET_ACCESS_KEY}' | base64 -d)" + + backup_exists=$( + kubectl run -n "${NAMESPACE}" -i --rm aws-cli --image=perconalab/awscli --restart=Never -- \ + /usr/bin/env AWS_ACCESS_KEY_ID="${accessKey}" AWS_SECRET_ACCESS_KEY="${secretKey}" AWS_DEFAULT_REGION=us-east-1 \ + /usr/bin/aws --endpoint-url http://minio-service:9000 s3 ls 'operator-testing/' | grep -c "${backup_name_minio}/" | cat + exit "${PIPESTATUS[0]}" + ) + + if [[ 1 -eq $backup_exists ]]; then + echo "Backup was not removed from bucket -- minio" + exit 1 + fi + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/00-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/00-assert.yaml index fecdb222e..f57037ea4 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/00-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 150 ---- apiVersion: v1 kind: Secret metadata: diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/01-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/01-assert.yaml index 30e8e19de..b7a766494 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/01-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 150 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/01-deploy-operator.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/01-deploy-operator.yaml deleted file mode 100644 index 6ace7783f..000000000 --- a/e2e-tests/tests/gr-demand-backup-haproxy/01-deploy-operator.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client - deploy_minio - timeout: 300 diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/02-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/02-assert.yaml index ccac3e744..9fd64504b 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/02-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/02-assert.yaml @@ -1,30 +1,26 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-demand-backup-haproxy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-demand-backup-haproxy-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL @@ -36,12 +32,12 @@ status: reason: InnoDBClusterBootstrapped status: "True" type: InnoDBClusterBootstrapped - mysql: + haproxy: ready: 3 size: 3 state: ready - haproxy: + mysql: ready: 3 size: 3 state: ready - state: ready \ No newline at end of file + state: ready diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/02-create-cluster.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/02-create-cluster.yaml deleted file mode 100644 index 7e50ded2d..000000000 --- a/e2e-tests/tests/gr-demand-backup-haproxy/02-create-cluster.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.backup.storages.minio.type="s3"' - \ - | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ - | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ - | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=false' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/03-write-data.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/03-write-data.yaml deleted file mode 100644 index c7ae38cbf..000000000 --- a/e2e-tests/tests/gr-demand-backup-haproxy/03-write-data.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o pipefail - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/04-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/04-assert.yaml index c72e6a09e..5218aa5a9 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/04-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/04-assert.yaml @@ -1,34 +1,30 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: gr-demand-backup-haproxy-minio status: state: Succeeded --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-demand-backup-haproxy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-demand-backup-haproxy-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 \ No newline at end of file diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/05-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/05-assert.yaml index b9141ada3..7ae8579e4 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/05-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/05-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 04-delete-data-minio-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-2 -data: - data: "" diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/05-delete-data.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/05-delete-data.yaml deleted file mode 100644 index 7857b208e..000000000 --- a/e2e-tests/tests/gr-demand-backup-haproxy/05-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/06-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/06-assert.yaml index b14f783b2..bb05aee5b 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/06-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/06-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: name: gr-demand-backup-haproxy status: - mysql: + haproxy: ready: 3 size: 3 state: ready - haproxy: + mysql: ready: 3 size: 3 state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: gr-demand-backup-haproxy-restore-minio status: diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/07-assert.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/07-assert.yaml index 17deff5a9..46564cc3a 100644 --- a/e2e-tests/tests/gr-demand-backup-haproxy/07-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup-haproxy/07-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-minio-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-minio-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-minio-2 -data: - data: "100500" diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/07-read-data.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/07-read-data.yaml deleted file mode 100644 index 7e6c5df6e..000000000 --- a/e2e-tests/tests/gr-demand-backup-haproxy/07-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup-haproxy/chainsaw-test.yaml b/e2e-tests/tests/gr-demand-backup-haproxy/chainsaw-test.yaml new file mode 100755 index 000000000..fe0c981ff --- /dev/null +++ b/e2e-tests/tests/gr-demand-backup-haproxy/chainsaw-test.yaml @@ -0,0 +1,89 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-demand-backup-haproxy +spec: + steps: + - name: step-00 + try: + - apply: + file: 00-minio-secret.yaml + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + deploy_minio + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.backup.storages.minio.type=\"s3\"' - \\\n\t| yq eval + '.spec.backup.storages.minio.s3.bucket=\"operator-testing\"' - \\\n\t| yq + eval '.spec.backup.storages.minio.s3.credentialsSecret=\"minio-secret\"' + - \\\n\t| yq eval '.spec.backup.storages.minio.s3.endpointUrl=\"http://minio-service:9000\"' + - \\\n\t| yq eval '.spec.backup.storages.minio.s3.region=\"us-east-1\"' + - \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=false' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=true' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o pipefail\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-04 + try: + - apply: + file: 04-create-backup-minio.yaml + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\ncluster_name=$(get_cluster_name)\nfor i in 0 + 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 04-delete-data-minio-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - apply: + file: 06-restore-from-minio.yaml + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 06-read-data-minio-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-demand-backup/00-assert.yaml b/e2e-tests/tests/gr-demand-backup/00-assert.yaml index fecdb222e..f57037ea4 100644 --- a/e2e-tests/tests/gr-demand-backup/00-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 150 ---- apiVersion: v1 kind: Secret metadata: diff --git a/e2e-tests/tests/gr-demand-backup/01-assert.yaml b/e2e-tests/tests/gr-demand-backup/01-assert.yaml index 30e8e19de..b7a766494 100644 --- a/e2e-tests/tests/gr-demand-backup/01-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 150 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-demand-backup/01-deploy-operator.yaml b/e2e-tests/tests/gr-demand-backup/01-deploy-operator.yaml deleted file mode 100644 index cb9e3c5ab..000000000 --- a/e2e-tests/tests/gr-demand-backup/01-deploy-operator.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - kubectl -n "${NAMESPACE}" apply -f "${TESTS_CONFIG_DIR}/cloud-secret.yml" - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client - deploy_minio - timeout: 300 diff --git a/e2e-tests/tests/gr-demand-backup/02-assert.yaml b/e2e-tests/tests/gr-demand-backup/02-assert.yaml index ce014534f..d3c50136a 100644 --- a/e2e-tests/tests/gr-demand-backup/02-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/02-assert.yaml @@ -1,27 +1,23 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-demand-backup-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-demand-backup-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 @@ -42,4 +38,4 @@ status: ready: 3 size: 3 state: ready - state: ready \ No newline at end of file + state: ready diff --git a/e2e-tests/tests/gr-demand-backup/02-create-cluster.yaml b/e2e-tests/tests/gr-demand-backup/02-create-cluster.yaml deleted file mode 100644 index 2f76185d5..000000000 --- a/e2e-tests/tests/gr-demand-backup/02-create-cluster.yaml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.backup.storages.minio.type="s3"' - \ - | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ - | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ - | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ - | yq eval '.spec.backup.storages.aws-s3.type="s3"' - \ - | yq eval '.spec.backup.storages.aws-s3.verifyTLS=true' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.credentialsSecret="aws-s3-secret"' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.region="us-east-1"' - \ - | yq eval '.spec.backup.storages.aws-s3.s3.prefix="ps"' - \ - | yq eval '.spec.backup.storages.gcp-cs.type="gcs"' - \ - | yq eval '.spec.backup.storages.gcp-cs.verifyTLS=true' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.credentialsSecret="gcp-cs-secret"' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.endpointUrl="https://storage.googleapis.com"' - \ - | yq eval '.spec.backup.storages.gcp-cs.gcs.prefix="ps"' - \ - | yq eval '.spec.backup.storages.azure-blob.type="azure"' - \ - | yq eval '.spec.backup.storages.azure-blob.verifyTLS=true' - \ - | yq eval '.spec.backup.storages.azure-blob.azure.containerName="operator-testing"' - \ - | yq eval '.spec.backup.storages.azure-blob.azure.credentialsSecret="azure-secret"' - \ - | yq eval '.spec.backup.storages.azure-blob.azure.prefix="ps"' - \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-demand-backup/03-write-data.yaml b/e2e-tests/tests/gr-demand-backup/03-write-data.yaml deleted file mode 100644 index 065ea3589..000000000 --- a/e2e-tests/tests/gr-demand-backup/03-write-data.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o pipefail - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/gr-demand-backup/04-assert.yaml b/e2e-tests/tests/gr-demand-backup/04-assert.yaml index ece34deb7..d4027ff7c 100644 --- a/e2e-tests/tests/gr-demand-backup/04-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/04-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: gr-demand-backup-minio status: diff --git a/e2e-tests/tests/gr-demand-backup/05-assert.yaml b/e2e-tests/tests/gr-demand-backup/05-assert.yaml index b9141ada3..7ae8579e4 100644 --- a/e2e-tests/tests/gr-demand-backup/05-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/05-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 04-delete-data-minio-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 04-delete-data-minio-2 -data: - data: "" diff --git a/e2e-tests/tests/gr-demand-backup/05-delete-data.yaml b/e2e-tests/tests/gr-demand-backup/05-delete-data.yaml deleted file mode 100644 index c8d4434ca..000000000 --- a/e2e-tests/tests/gr-demand-backup/05-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/06-assert.yaml b/e2e-tests/tests/gr-demand-backup/06-assert.yaml index 2f971099f..d86f872d9 100644 --- a/e2e-tests/tests/gr-demand-backup/06-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/06-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: @@ -17,8 +13,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: gr-demand-backup-restore-minio status: diff --git a/e2e-tests/tests/gr-demand-backup/07-assert.yaml b/e2e-tests/tests/gr-demand-backup/07-assert.yaml index 17deff5a9..46564cc3a 100644 --- a/e2e-tests/tests/gr-demand-backup/07-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/07-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-minio-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-minio-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-minio-2 -data: - data: "100500" diff --git a/e2e-tests/tests/gr-demand-backup/07-read-data.yaml b/e2e-tests/tests/gr-demand-backup/07-read-data.yaml deleted file mode 100644 index 7e6c5df6e..000000000 --- a/e2e-tests/tests/gr-demand-backup/07-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/08-assert.yaml b/e2e-tests/tests/gr-demand-backup/08-assert.yaml index e0d8d57e8..861e0e5e8 100644 --- a/e2e-tests/tests/gr-demand-backup/08-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/08-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: gr-demand-backup-s3 status: diff --git a/e2e-tests/tests/gr-demand-backup/09-assert.yaml b/e2e-tests/tests/gr-demand-backup/09-assert.yaml index b945217e8..0276ea716 100644 --- a/e2e-tests/tests/gr-demand-backup/09-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/09-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 08-delete-data-s3-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 08-delete-data-s3-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 08-delete-data-s3-2 -data: - data: "" diff --git a/e2e-tests/tests/gr-demand-backup/09-delete-data.yaml b/e2e-tests/tests/gr-demand-backup/09-delete-data.yaml deleted file mode 100644 index 5632c5342..000000000 --- a/e2e-tests/tests/gr-demand-backup/09-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 08-delete-data-s3-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/10-assert.yaml b/e2e-tests/tests/gr-demand-backup/10-assert.yaml index 50325e900..6b2b8972f 100644 --- a/e2e-tests/tests/gr-demand-backup/10-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/10-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: @@ -17,8 +13,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: gr-demand-backup-restore-s3 status: diff --git a/e2e-tests/tests/gr-demand-backup/11-assert.yaml b/e2e-tests/tests/gr-demand-backup/11-assert.yaml index 8ec7c0a50..9f38ab9d5 100644 --- a/e2e-tests/tests/gr-demand-backup/11-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/11-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-s3-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-s3-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-s3-2 -data: - data: "100500" diff --git a/e2e-tests/tests/gr-demand-backup/11-read-data.yaml b/e2e-tests/tests/gr-demand-backup/11-read-data.yaml deleted file mode 100644 index dacebd78c..000000000 --- a/e2e-tests/tests/gr-demand-backup/11-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-s3-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/12-assert.yaml b/e2e-tests/tests/gr-demand-backup/12-assert.yaml index e0b62f604..b6c77aaa7 100644 --- a/e2e-tests/tests/gr-demand-backup/12-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/12-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: gr-demand-backup-gcp status: diff --git a/e2e-tests/tests/gr-demand-backup/13-assert.yaml b/e2e-tests/tests/gr-demand-backup/13-assert.yaml index 1ccc31531..87260fab9 100644 --- a/e2e-tests/tests/gr-demand-backup/13-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/13-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 12-delete-data-gcp-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 12-delete-data-gcp-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 12-delete-data-gcp-2 -data: - data: "" diff --git a/e2e-tests/tests/gr-demand-backup/13-delete-data.yaml b/e2e-tests/tests/gr-demand-backup/13-delete-data.yaml deleted file mode 100644 index a35d7b4dd..000000000 --- a/e2e-tests/tests/gr-demand-backup/13-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 12-delete-data-gcp-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/14-assert.yaml b/e2e-tests/tests/gr-demand-backup/14-assert.yaml index 958659e16..05680fc5f 100644 --- a/e2e-tests/tests/gr-demand-backup/14-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/14-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: @@ -17,8 +13,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: gr-demand-backup-restore-gcp status: diff --git a/e2e-tests/tests/gr-demand-backup/15-assert.yaml b/e2e-tests/tests/gr-demand-backup/15-assert.yaml index 77cef7012..58ba4e597 100644 --- a/e2e-tests/tests/gr-demand-backup/15-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/15-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-gcp-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-gcp-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-gcp-2 -data: - data: "100500" diff --git a/e2e-tests/tests/gr-demand-backup/15-read-data.yaml b/e2e-tests/tests/gr-demand-backup/15-read-data.yaml deleted file mode 100644 index 264667fb8..000000000 --- a/e2e-tests/tests/gr-demand-backup/15-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-gcp-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/16-assert.yaml b/e2e-tests/tests/gr-demand-backup/16-assert.yaml index 54dfe8f1e..1c63fd92f 100644 --- a/e2e-tests/tests/gr-demand-backup/16-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/16-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: gr-demand-backup-azure status: diff --git a/e2e-tests/tests/gr-demand-backup/17-assert.yaml b/e2e-tests/tests/gr-demand-backup/17-assert.yaml index d1ac765a0..bc67d3b86 100644 --- a/e2e-tests/tests/gr-demand-backup/17-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/17-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "" +kind: ConfigMap metadata: name: 16-delete-data-azure-0 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 16-delete-data-azure-1 +--- +apiVersion: v1 data: data: "" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 16-delete-data-azure-2 -data: - data: "" diff --git a/e2e-tests/tests/gr-demand-backup/17-delete-data.yaml b/e2e-tests/tests/gr-demand-backup/17-delete-data.yaml deleted file mode 100644 index 11874075a..000000000 --- a/e2e-tests/tests/gr-demand-backup/17-delete-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 16-delete-data-azure-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/18-assert.yaml b/e2e-tests/tests/gr-demand-backup/18-assert.yaml index b17acc866..a80b0144b 100644 --- a/e2e-tests/tests/gr-demand-backup/18-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/18-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: @@ -17,8 +13,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: gr-demand-backup-restore-azure status: diff --git a/e2e-tests/tests/gr-demand-backup/19-assert.yaml b/e2e-tests/tests/gr-demand-backup/19-assert.yaml index 67d7b873a..cf3031fab 100644 --- a/e2e-tests/tests/gr-demand-backup/19-assert.yaml +++ b/e2e-tests/tests/gr-demand-backup/19-assert.yaml @@ -1,24 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 06-read-data-azure-0 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-azure-1 +--- +apiVersion: v1 data: data: "100500" ---- kind: ConfigMap -apiVersion: v1 metadata: name: 06-read-data-azure-2 -data: - data: "100500" diff --git a/e2e-tests/tests/gr-demand-backup/19-read-data.yaml b/e2e-tests/tests/gr-demand-backup/19-read-data.yaml deleted file mode 100644 index 717d1919a..000000000 --- a/e2e-tests/tests/gr-demand-backup/19-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_name=$(get_cluster_name) - for i in 0 1 2; do - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-azure-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-demand-backup/chainsaw-test.yaml b/e2e-tests/tests/gr-demand-backup/chainsaw-test.yaml new file mode 100755 index 000000000..62f0a2eb1 --- /dev/null +++ b/e2e-tests/tests/gr-demand-backup/chainsaw-test.yaml @@ -0,0 +1,201 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-demand-backup +spec: + steps: + - name: step-00 + try: + - apply: + file: 00-minio-secret.yaml + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + kubectl -n "${NAMESPACE}" apply -f "${TESTS_CONFIG_DIR}/cloud-secret.yml" + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + deploy_minio + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.backup.storages.minio.type=\"s3\"' - \\\n\t| yq eval + '.spec.backup.storages.minio.s3.bucket=\"operator-testing\"' - \\\n\t| yq + eval '.spec.backup.storages.minio.s3.credentialsSecret=\"minio-secret\"' + - \\\n\t| yq eval '.spec.backup.storages.minio.s3.endpointUrl=\"http://minio-service:9000\"' + - \\\n\t| yq eval '.spec.backup.storages.minio.s3.region=\"us-east-1\"' + - \\\n\t| yq eval '.spec.backup.storages.aws-s3.type=\"s3\"' - \\\n\t| yq + eval '.spec.backup.storages.aws-s3.verifyTLS=true' - \\\n\t| yq eval '.spec.backup.storages.aws-s3.s3.bucket=\"operator-testing\"' + - \\\n\t| yq eval '.spec.backup.storages.aws-s3.s3.credentialsSecret=\"aws-s3-secret\"' + - \\\n\t| yq eval '.spec.backup.storages.aws-s3.s3.region=\"us-east-1\"' + - \\\n\t| yq eval '.spec.backup.storages.aws-s3.s3.prefix=\"ps\"' - \\\n\t| + yq eval '.spec.backup.storages.gcp-cs.type=\"gcs\"' - \\\n\t| yq eval '.spec.backup.storages.gcp-cs.verifyTLS=true' + - \\\n\t| yq eval '.spec.backup.storages.gcp-cs.gcs.bucket=\"operator-testing\"' + - \\\n\t| yq eval '.spec.backup.storages.gcp-cs.gcs.credentialsSecret=\"gcp-cs-secret\"' + - \\\n\t| yq eval '.spec.backup.storages.gcp-cs.gcs.endpointUrl=\"https://storage.googleapis.com\"' + - \\\n\t| yq eval '.spec.backup.storages.gcp-cs.gcs.prefix=\"ps\"' - \\\n\t| + yq eval '.spec.backup.storages.azure-blob.type=\"azure\"' - \\\n\t| yq eval + '.spec.backup.storages.azure-blob.verifyTLS=true' - \\\n\t| yq eval '.spec.backup.storages.azure-blob.azure.containerName=\"operator-testing\"' + - \\\n\t| yq eval '.spec.backup.storages.azure-blob.azure.credentialsSecret=\"azure-secret\"' + - \\\n\t| yq eval '.spec.backup.storages.azure-blob.azure.prefix=\"ps\"' + - \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o pipefail\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) -uroot + -proot_password\"" + - name: step-04 + try: + - apply: + file: 04-create-backup-minio.yaml + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_mysql_router_service + $(get_cluster_name)) -uroot -proot_password\"\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 04-delete-data-minio-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - apply: + file: 06-restore-from-minio.yaml + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 06-read-data-minio-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 07-assert.yaml + - name: step-08 + try: + - apply: + file: 08-create-backup-s3.yaml + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_mysql_router_service + $(get_cluster_name)) -uroot -proot_password\"\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 08-delete-data-s3-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 09-assert.yaml + - name: step-10 + try: + - apply: + file: 10-restore-from-s3.yaml + - assert: + file: 10-assert.yaml + - name: step-11 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 06-read-data-s3-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 11-assert.yaml + - name: step-12 + try: + - apply: + file: 12-create-backup-gcp.yaml + - assert: + file: 12-assert.yaml + - name: step-13 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_mysql_router_service + $(get_cluster_name)) -uroot -proot_password\"\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 12-delete-data-gcp-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 13-assert.yaml + - name: step-14 + try: + - apply: + file: 14-restore-from-gcp.yaml + - assert: + file: 14-assert.yaml + - name: step-15 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 06-read-data-gcp-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 15-assert.yaml + - name: step-16 + try: + - apply: + file: 16-create-backup-azure.yaml + - assert: + file: 16-assert.yaml + - name: step-17 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_mysql_router_service + $(get_cluster_name)) -uroot -proot_password\"\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 16-delete-data-azure-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 17-assert.yaml + - name: step-18 + try: + - apply: + file: 18-restore-from-azure.yaml + - assert: + file: 18-assert.yaml + - name: step-19 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ncluster_name=$(get_cluster_name)\nfor + i in 0 1 2; do\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${cluster_name}-mysql-${i}.${cluster_name}-mysql + -uroot -proot_password\")\n\tkubectl create configmap -n \"${NAMESPACE}\" + 06-read-data-azure-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 19-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-haproxy/00-assert.yaml b/e2e-tests/tests/gr-haproxy/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/gr-haproxy/00-assert.yaml +++ b/e2e-tests/tests/gr-haproxy/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-haproxy/00-deploy-operator.yaml b/e2e-tests/tests/gr-haproxy/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/gr-haproxy/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-haproxy/01-assert.yaml b/e2e-tests/tests/gr-haproxy/01-assert.yaml index 168163cd8..2fb28964a 100644 --- a/e2e-tests/tests/gr-haproxy/01-assert.yaml +++ b/e2e-tests/tests/gr-haproxy/01-assert.yaml @@ -1,41 +1,37 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-haproxy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-haproxy-haproxy status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-haproxy finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-haproxy status: - mysql: + haproxy: ready: 3 size: 3 state: ready - haproxy: + mysql: ready: 3 size: 3 state: ready diff --git a/e2e-tests/tests/gr-haproxy/01-create-cluster.yaml b/e2e-tests/tests/gr-haproxy/01-create-cluster.yaml deleted file mode 100644 index d9353a336..000000000 --- a/e2e-tests/tests/gr-haproxy/01-create-cluster.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=false' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-haproxy/02-write-data.yaml b/e2e-tests/tests/gr-haproxy/02-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/gr-haproxy/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/gr-haproxy/03-assert.yaml b/e2e-tests/tests/gr-haproxy/03-assert.yaml index 6bf27cfa6..ef69312b2 100644 --- a/e2e-tests/tests/gr-haproxy/03-assert.yaml +++ b/e2e-tests/tests/gr-haproxy/03-assert.yaml @@ -1,14 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 03-check-connections data: + mysql_admin: "1" + mysqlx: "1" primary: "1" replica: "1" - # proxy_protocol: "1" - mysqlx: "1" - mysql_admin: "1" +kind: ConfigMap +metadata: + name: 03-check-connections diff --git a/e2e-tests/tests/gr-haproxy/03-check-connections.yaml b/e2e-tests/tests/gr-haproxy/03-check-connections.yaml deleted file mode 100644 index 0f715fc84..000000000 --- a/e2e-tests/tests/gr-haproxy/03-check-connections.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args="" - - primary=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") - args="${args} --from-literal=primary=${primary}" - - replica=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 3307 -uroot -proot_password") - args="${args} --from-literal=replica=${replica}" - - # uncomment after https://jira.percona.com/browse/K8SPS-284 - # proxy_protocol=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 3309 -uroot -proot_password") - # args="${args} --from-literal=proxy_protocol=${proxy_protocol}" - - mysqlx=$(run_mysqlsh "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 33060 -uroot -proot_password") - args="${args} --from-literal=mysqlx=${mysqlx}" - - mysql_admin=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 33062 -uroot -proot_password") - args="${args} --from-literal=mysql_admin=${mysql_admin}" - - kubectl create configmap -n "${NAMESPACE}" 03-check-connections $args - timeout: 30 diff --git a/e2e-tests/tests/gr-haproxy/04-check-password-leak.yaml b/e2e-tests/tests/gr-haproxy/04-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/gr-haproxy/04-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/gr-haproxy/chainsaw-test.yaml b/e2e-tests/tests/gr-haproxy/chainsaw-test.yaml new file mode 100755 index 000000000..267f9741e --- /dev/null +++ b/e2e-tests/tests/gr-haproxy/chainsaw-test.yaml @@ -0,0 +1,85 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-haproxy +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=false' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=true' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + args="" + + primary=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") + args="${args} --from-literal=primary=${primary}" + + replica=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 3307 -uroot -proot_password") + args="${args} --from-literal=replica=${replica}" + + # uncomment after https://jira.percona.com/browse/K8SPS-284 + # proxy_protocol=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 3309 -uroot -proot_password") + # args="${args} --from-literal=proxy_protocol=${proxy_protocol}" + + mysqlx=$(run_mysqlsh "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 33060 -uroot -proot_password") + args="${args} --from-literal=mysqlx=${mysqlx}" + + mysql_admin=$(run_mysql "SELECT count(*) FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P 33062 -uroot -proot_password") + args="${args} --from-literal=mysql_admin=${mysql_admin}" + + kubectl create configmap -n "${NAMESPACE}" 03-check-connections $args + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-ignore-annotations/00-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/gr-ignore-annotations/00-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-ignore-annotations/00-deploy-operator.yaml b/e2e-tests/tests/gr-ignore-annotations/00-deploy-operator.yaml deleted file mode 100644 index 1aaca58be..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/00-deploy-operator.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_client diff --git a/e2e-tests/tests/gr-ignore-annotations/01-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/01-assert.yaml index eae064fbb..1956a88bf 100644 --- a/e2e-tests/tests/gr-ignore-annotations/01-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/01-assert.yaml @@ -1,27 +1,23 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 600 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-ignore-annotations-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-ignore-annotations-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/gr-ignore-annotations/01-create-cluster.yaml b/e2e-tests/tests/gr-ignore-annotations/01-create-cluster.yaml deleted file mode 100644 index eedc3c201..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | yq eval '.spec.mysql.expose.enabled=true' - \ - | yq eval '.spec.mysql.expose.type="LoadBalancer"' - \ - | yq eval '.spec.proxy.router.expose.type="LoadBalancer"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-ignore-annotations/02-add-custom-annotations.yaml b/e2e-tests/tests/gr-ignore-annotations/02-add-custom-annotations.yaml deleted file mode 100644 index 0040373f6..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/02-add-custom-annotations.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - mysql_svc=$(get_mysql_service gr-ignore-annotations) - router_svc=$(get_mysql_router_service gr-ignore-annotations) - - kubectl get svc $mysql_svc-0 -o yaml -n "${NAMESPACE}" \ - | yq eval '.metadata.annotations += {"gr-annotations-to-ignore-mysql": "true", "gr-annotations-not-to-ignore-mysql": "true" }' - \ - | yq eval '.metadata.labels += {"gr-labels-to-ignore-mysql": "true", "gr-labels-not-to-ignore-mysql": "true" }' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - kubectl get svc $router_svc -o yaml -n "${NAMESPACE}"\ - | yq eval '.metadata.annotations += {"gr-annotations-to-ignore-router": "true", "gr-annotations-not-to-ignore-router": "true" }' - \ - | yq eval '.metadata.labels += {"gr-labels-to-ignore-router": "true", "gr-labels-not-to-ignore-router": "true" }' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - timeout: 100 - diff --git a/e2e-tests/tests/gr-ignore-annotations/02-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/02-assert.yaml index 3abe6c125..a55db124e 100644 --- a/e2e-tests/tests/gr-ignore-annotations/02-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/02-assert.yaml @@ -1,21 +1,17 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-not-to-ignore-mysql: "true" + gr-annotations-to-ignore-mysql: "true" labels: - gr-labels-to-ignore-mysql: "true" - gr-labels-not-to-ignore-mysql: "true" app.kubernetes.io/component: mysql app.kubernetes.io/instance: gr-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server - annotations: - gr-annotations-to-ignore-mysql: "true" - gr-annotations-not-to-ignore-mysql: "true" + gr-labels-not-to-ignore-mysql: "true" + gr-labels-to-ignore-mysql: "true" name: gr-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -57,17 +53,17 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-not-to-ignore-router: "true" + gr-annotations-to-ignore-router: "true" labels: - gr-labels-to-ignore-router: "true" - gr-labels-not-to-ignore-router: "true" app.kubernetes.io/component: router app.kubernetes.io/instance: gr-ignore-annotations app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server - annotations: - gr-annotations-to-ignore-router: "true" - gr-annotations-not-to-ignore-router: "true" + gr-labels-not-to-ignore-router: "true" + gr-labels-to-ignore-router: "true" name: gr-ignore-annotations-router ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/gr-ignore-annotations/03-add-annotations-to-ignore.yaml b/e2e-tests/tests/gr-ignore-annotations/03-add-annotations-to-ignore.yaml deleted file mode 100644 index b4044c020..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/03-add-annotations-to-ignore.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/ignoreAnnotations", "value": ["gr-annotations-to-ignore-mysql","gr-annotations-to-ignore-router"] }]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/ignoreLabels", "value": ["gr-labels-to-ignore-mysql","gr-labels-to-ignore-router"] }]' - - timeout: 30 diff --git a/e2e-tests/tests/gr-ignore-annotations/03-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/03-assert.yaml index 36c737a76..b6b088423 100644 --- a/e2e-tests/tests/gr-ignore-annotations/03-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/03-assert.yaml @@ -1,18 +1,14 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: name: gr-ignore-annotations spec: ignoreAnnotations: - - gr-annotations-to-ignore-mysql - - gr-annotations-to-ignore-router + - gr-annotations-to-ignore-mysql + - gr-annotations-to-ignore-router ignoreLabels: - - gr-labels-to-ignore-mysql - - gr-labels-to-ignore-router + - gr-labels-to-ignore-mysql + - gr-labels-to-ignore-router status: conditions: - message: InnoDB cluster successfully bootstrapped with 3 nodes diff --git a/e2e-tests/tests/gr-ignore-annotations/04-add-annotations-to-service-via-cr.yaml b/e2e-tests/tests/gr-ignore-annotations/04-add-annotations-to-service-via-cr.yaml deleted file mode 100644 index 48c2833c8..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/04-add-annotations-to-service-via-cr.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": LoadBalancer,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "add", "path": "/spec/proxy/router/expose", "value": {"type": LoadBalancer ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' - - timeout: 30 diff --git a/e2e-tests/tests/gr-ignore-annotations/04-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/04-assert.yaml index 0e44e75f8..396f80bb9 100644 --- a/e2e-tests/tests/gr-ignore-annotations/04-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/04-assert.yaml @@ -1,10 +1,10 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-to-ignore-mysql: "true" + service.beta.kubernetes.io/aws-load-balancer-backend: test-type + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: app.kubernetes.io/component: mysql app.kubernetes.io/instance: gr-ignore-annotations @@ -15,10 +15,6 @@ metadata: percona.com/exposed: "true" rack: rack-22 rack-test: rack-test-22 - annotations: - gr-annotations-to-ignore-mysql: "true" - service.beta.kubernetes.io/aws-load-balancer-backend: test-type - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: gr-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -54,14 +50,18 @@ spec: app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server - rack-test: rack-test-22 rack: rack-22 + rack-test: rack-test-22 sessionAffinity: None type: LoadBalancer --- apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-to-ignore-router: "true" + service.beta.kubernetes.io/aws-load-balancer-backend: test-type + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: app.kubernetes.io/component: router app.kubernetes.io/instance: gr-ignore-annotations @@ -71,10 +71,6 @@ metadata: gr-labels-to-ignore-router: "true" rack: rack-22 rack-test: rack-test-22 - annotations: - gr-annotations-to-ignore-router: "true" - service.beta.kubernetes.io/aws-load-balancer-backend: test-type - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: gr-ignore-annotations-router ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -122,7 +118,7 @@ spec: app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server - rack-test: rack-test-22 rack: rack-22 + rack-test: rack-test-22 sessionAffinity: None type: LoadBalancer diff --git a/e2e-tests/tests/gr-ignore-annotations/05-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/05-assert.yaml index 59e1cad34..5e2faddf6 100644 --- a/e2e-tests/tests/gr-ignore-annotations/05-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/05-assert.yaml @@ -1,10 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-to-ignore-mysql: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: app.kubernetes.io/component: mysql app.kubernetes.io/instance: gr-ignore-annotations @@ -14,9 +13,6 @@ metadata: gr-labels-to-ignore-mysql: "true" percona.com/exposed: "true" rack: rack-22 - annotations: - gr-annotations-to-ignore-mysql: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: gr-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -59,6 +55,9 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-to-ignore-router: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http labels: app.kubernetes.io/component: router app.kubernetes.io/instance: gr-ignore-annotations @@ -67,9 +66,6 @@ metadata: app.kubernetes.io/part-of: percona-server gr-labels-to-ignore-router: "true" rack: rack-22 - annotations: - gr-annotations-to-ignore-router: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http name: gr-ignore-annotations-router ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/gr-ignore-annotations/05-delete-annotations.yaml b/e2e-tests/tests/gr-ignore-annotations/05-delete-annotations.yaml deleted file mode 100644 index 902cfb3b5..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/05-delete-annotations.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": LoadBalancer,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/proxy/router/expose", "value": {"type": LoadBalancer ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' - - timeout: 30 diff --git a/e2e-tests/tests/gr-ignore-annotations/06-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/06-assert.yaml index 96be1be0a..a06be464c 100644 --- a/e2e-tests/tests/gr-ignore-annotations/06-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/06-assert.yaml @@ -1,10 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-to-ignore-mysql: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: app.kubernetes.io/component: mysql app.kubernetes.io/instance: gr-ignore-annotations @@ -14,9 +13,6 @@ metadata: gr-labels-to-ignore-mysql: "true" percona.com/exposed: "true" rack: rack-22-test - annotations: - gr-annotations-to-ignore-mysql: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: gr-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -59,6 +55,9 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + gr-annotations-to-ignore-router: "true" + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: app.kubernetes.io/component: router app.kubernetes.io/instance: gr-ignore-annotations @@ -67,9 +66,6 @@ metadata: app.kubernetes.io/part-of: percona-server gr-labels-to-ignore-router: "true" rack: rack-22-test - annotations: - gr-annotations-to-ignore-router: "true" - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: gr-ignore-annotations-router ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/gr-ignore-annotations/06-update-annotation.yaml b/e2e-tests/tests/gr-ignore-annotations/06-update-annotation.yaml deleted file mode 100644 index f5be03078..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/06-update-annotation.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": LoadBalancer,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/proxy/router/expose", "value": {"type": LoadBalancer ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' - - timeout: 30 diff --git a/e2e-tests/tests/gr-ignore-annotations/07-assert.yaml b/e2e-tests/tests/gr-ignore-annotations/07-assert.yaml index 2e911f1b4..6d7bfaa8a 100644 --- a/e2e-tests/tests/gr-ignore-annotations/07-assert.yaml +++ b/e2e-tests/tests/gr-ignore-annotations/07-assert.yaml @@ -1,10 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- apiVersion: v1 kind: Service metadata: + annotations: + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: app.kubernetes.io/component: mysql app.kubernetes.io/instance: gr-ignore-annotations @@ -13,8 +11,6 @@ metadata: app.kubernetes.io/part-of: percona-server percona.com/exposed: "true" rack: rack-22-test - annotations: - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: gr-ignore-annotations-mysql-0 ownerReferences: - apiVersion: ps.percona.com/v1alpha1 @@ -57,6 +53,8 @@ spec: apiVersion: v1 kind: Service metadata: + annotations: + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test labels: app.kubernetes.io/component: router app.kubernetes.io/instance: gr-ignore-annotations @@ -64,8 +62,6 @@ metadata: app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server rack: rack-22-test - annotations: - service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http-test name: gr-ignore-annotations-router ownerReferences: - apiVersion: ps.percona.com/v1alpha1 diff --git a/e2e-tests/tests/gr-ignore-annotations/07-delete-custom-annotations-from-ignore.yaml b/e2e-tests/tests/gr-ignore-annotations/07-delete-custom-annotations-from-ignore.yaml deleted file mode 100644 index 3b7415653..000000000 --- a/e2e-tests/tests/gr-ignore-annotations/07-delete-custom-annotations-from-ignore.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/ignoreAnnotations", "value": [] }]' - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/ignoreLabels", "value": [] }]' - - timeout: 30 diff --git a/e2e-tests/tests/gr-ignore-annotations/chainsaw-test.yaml b/e2e-tests/tests/gr-ignore-annotations/chainsaw-test.yaml new file mode 100755 index 000000000..b2116a041 --- /dev/null +++ b/e2e-tests/tests/gr-ignore-annotations/chainsaw-test.yaml @@ -0,0 +1,144 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-ignore-annotations +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n | yq eval '.spec.mysql.expose.enabled=true' - \\\n | yq eval '.spec.mysql.expose.type=\"LoadBalancer\"' + - \\\n | yq eval '.spec.proxy.router.expose.type=\"LoadBalancer\"' - \\\n + \ | kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\nmysql_svc=$(get_mysql_service + gr-ignore-annotations)\nrouter_svc=$(get_mysql_router_service gr-ignore-annotations)\n\nkubectl + get svc $mysql_svc-0 -o yaml -n \"${NAMESPACE}\" \\\n\t| yq eval '.metadata.annotations + += {\"gr-annotations-to-ignore-mysql\": \"true\", \"gr-annotations-not-to-ignore-mysql\": + \"true\" }' - \\\n\t| yq eval '.metadata.labels += {\"gr-labels-to-ignore-mysql\": + \"true\", \"gr-labels-not-to-ignore-mysql\": \"true\" }' - \\\n | kubectl + -n \"${NAMESPACE}\" apply -f -\n\nkubectl get svc $router_svc -o yaml -n + \"${NAMESPACE}\"\\\n | yq eval '.metadata.annotations += {\"gr-annotations-to-ignore-router\": + \"true\", \"gr-annotations-not-to-ignore-router\": \"true\" }' - \\\n | + yq eval '.metadata.labels += {\"gr-labels-to-ignore-router\": \"true\", + \"gr-labels-not-to-ignore-router\": \"true\" }' - \\\n | kubectl -n \"${NAMESPACE}\" + apply -f -" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/ignoreAnnotations", "value": ["gr-annotations-to-ignore-mysql","gr-annotations-to-ignore-router"] }]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/ignoreLabels", "value": ["gr-labels-to-ignore-mysql","gr-labels-to-ignore-router"] }]' + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": LoadBalancer,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "add", "path": "/spec/proxy/router/expose", "value": {"type": LoadBalancer ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http","service.beta.kubernetes.io/aws-load-balancer-backend": "test-type"}, "labels": {"rack": "rack-22","rack-test": "rack-test-22"}}}]' + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": LoadBalancer,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/proxy/router/expose", "value": {"type": LoadBalancer ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http"}, "labels": {"rack": "rack-22"}}}]' + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/mysql/expose", "value": {"enabled": true, "type": LoadBalancer,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/proxy/router/expose", "value": {"type": LoadBalancer ,"annotations": {"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http-test"}, "labels": {"rack": "rack-22-test"}}}]' + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/ignoreAnnotations", "value": [] }]' + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[{"op": "replace", "path": "/spec/ignoreLabels", "value": [] }]' + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-init-deploy/00-assert.yaml b/e2e-tests/tests/gr-init-deploy/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/gr-init-deploy/00-assert.yaml +++ b/e2e-tests/tests/gr-init-deploy/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-init-deploy/00-deploy-operator.yaml b/e2e-tests/tests/gr-init-deploy/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/gr-init-deploy/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-init-deploy/01-assert.yaml b/e2e-tests/tests/gr-init-deploy/01-assert.yaml index d13e2f01b..9589988e5 100644 --- a/e2e-tests/tests/gr-init-deploy/01-assert.yaml +++ b/e2e-tests/tests/gr-init-deploy/01-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-init-deploy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-init-deploy-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-init-deploy finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-init-deploy status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-init-deploy/01-create-cluster.yaml b/e2e-tests/tests/gr-init-deploy/01-create-cluster.yaml deleted file mode 100644 index 4636d46f2..000000000 --- a/e2e-tests/tests/gr-init-deploy/01-create-cluster.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-init-deploy/02-assert.yaml b/e2e-tests/tests/gr-init-deploy/02-assert.yaml index faee09842..0938880ff 100644 --- a/e2e-tests/tests/gr-init-deploy/02-assert.yaml +++ b/e2e-tests/tests/gr-init-deploy/02-assert.yaml @@ -1,13 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 02-check-topology data: - status: "OK" members: | gr-init-deploy-mysql-0.gr-init-deploy-mysql:3306 gr-init-deploy-mysql-1.gr-init-deploy-mysql:3306 @@ -15,3 +7,7 @@ data: online_members: "3" primary_count: "1" secondary_count: "2" + status: OK +kind: ConfigMap +metadata: + name: 02-check-topology diff --git a/e2e-tests/tests/gr-init-deploy/02-check-topology.yaml b/e2e-tests/tests/gr-init-deploy/02-check-topology.yaml deleted file mode 100644 index fe405899e..000000000 --- a/e2e-tests/tests/gr-init-deploy/02-check-topology.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - timeout: 60 - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - cluster_status=$(get_gr_status "$(get_mysqlsh_uri)") - status=$(echo ${cluster_status} | jq -r .defaultReplicaSet.status) - echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].address | sed "s/.${NAMESPACE}//g" > ${TEMP_DIR}/members - online_members=$(echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].status | grep ONLINE | wc -l | sed 's/^ *//') - primary=$(echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].memberRole | grep PRIMARY | wc -l | sed 's/^ *//') - secondary=$(echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].memberRole | grep SECONDARY | wc -l | sed 's/^ *//') - - kubectl create configmap -n "${NAMESPACE}" 02-check-topology \ - --from-file=members=${TEMP_DIR}/members \ - --from-literal=status=${status} \ - --from-literal=online_members=${online_members} \ - --from-literal=primary_count=${primary} \ - --from-literal=secondary_count=${secondary} diff --git a/e2e-tests/tests/gr-init-deploy/03-write-data.yaml b/e2e-tests/tests/gr-init-deploy/03-write-data.yaml deleted file mode 100644 index 0a0d69017..000000000 --- a/e2e-tests/tests/gr-init-deploy/03-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" diff --git a/e2e-tests/tests/gr-init-deploy/04-assert.yaml b/e2e-tests/tests/gr-init-deploy/04-assert.yaml index 084110451..2d99a3bfd 100644 --- a/e2e-tests/tests/gr-init-deploy/04-assert.yaml +++ b/e2e-tests/tests/gr-init-deploy/04-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 03-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 03-read-from-primary diff --git a/e2e-tests/tests/gr-init-deploy/04-read-from-primary.yaml b/e2e-tests/tests/gr-init-deploy/04-read-from-primary.yaml deleted file mode 100644 index eab97b742..000000000 --- a/e2e-tests/tests/gr-init-deploy/04-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-init-deploy/05-assert.yaml b/e2e-tests/tests/gr-init-deploy/05-assert.yaml index 05bfa08bf..f367d5a97 100644 --- a/e2e-tests/tests/gr-init-deploy/05-assert.yaml +++ b/e2e-tests/tests/gr-init-deploy/05-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-replicas data: data: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-replicas diff --git a/e2e-tests/tests/gr-init-deploy/05-read-from-replicas.yaml b/e2e-tests/tests/gr-init-deploy/05-read-from-replicas.yaml deleted file mode 100644 index 4dd430c32..000000000 --- a/e2e-tests/tests/gr-init-deploy/05-read-from-replicas.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -P 6447 -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-init-deploy/06-check-password-leak.yaml b/e2e-tests/tests/gr-init-deploy/06-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/gr-init-deploy/06-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/gr-init-deploy/07-assert.yaml b/e2e-tests/tests/gr-init-deploy/07-assert.yaml index 78eed4429..774320ae2 100644 --- a/e2e-tests/tests/gr-init-deploy/07-assert.yaml +++ b/e2e-tests/tests/gr-init-deploy/07-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- apiVersion: v1 -kind: ConfigMap -metadata: - name: 07-check-group-seeds data: gr-init-deploy-mysql-0: gr-init-deploy-mysql-0.gr-init-deploy-mysql.NAMESPACE:3306,gr-init-deploy-mysql-1.gr-init-deploy-mysql.NAMESPACE:3306,gr-init-deploy-mysql-2.gr-init-deploy-mysql.NAMESPACE:3306 gr-init-deploy-mysql-1: gr-init-deploy-mysql-0.gr-init-deploy-mysql.NAMESPACE:3306,gr-init-deploy-mysql-1.gr-init-deploy-mysql.NAMESPACE:3306,gr-init-deploy-mysql-2.gr-init-deploy-mysql.NAMESPACE:3306 gr-init-deploy-mysql-2: gr-init-deploy-mysql-0.gr-init-deploy-mysql.NAMESPACE:3306,gr-init-deploy-mysql-1.gr-init-deploy-mysql.NAMESPACE:3306,gr-init-deploy-mysql-2.gr-init-deploy-mysql.NAMESPACE:3306 +kind: ConfigMap +metadata: + name: 07-check-group-seeds diff --git a/e2e-tests/tests/gr-init-deploy/07-check-group-seeds.yaml b/e2e-tests/tests/gr-init-deploy/07-check-group-seeds.yaml deleted file mode 100644 index 29615af04..000000000 --- a/e2e-tests/tests/gr-init-deploy/07-check-group-seeds.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - pods=($(get_mysql_pods)) - - args="" - for pod in "${pods[@]}"; do - seeds=$(run_mysql "SELECT @@group_replication_group_seeds" "-h ${pod}.$(get_mysql_service gr-init-deploy).${NAMESPACE} -uroot -proot_password") - args="${args} --from-literal=${pod}=$(echo ${seeds} | sed "s/${NAMESPACE}/NAMESPACE/g")" - done - - kubectl create configmap -n "${NAMESPACE}" 07-check-group-seeds $args diff --git a/e2e-tests/tests/gr-init-deploy/chainsaw-test.yaml b/e2e-tests/tests/gr-init-deploy/chainsaw-test.yaml new file mode 100755 index 000000000..f866fa3a7 --- /dev/null +++ b/e2e-tests/tests/gr-init-deploy/chainsaw-test.yaml @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-init-deploy +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + cluster_status=$(get_gr_status "$(get_mysqlsh_uri)") + status=$(echo ${cluster_status} | jq -r .defaultReplicaSet.status) + echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].address | sed "s/.${NAMESPACE}//g" > ${TEMP_DIR}/members + online_members=$(echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].status | grep ONLINE | wc -l | sed 's/^ *//') + primary=$(echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].memberRole | grep PRIMARY | wc -l | sed 's/^ *//') + secondary=$(echo ${cluster_status} | jq -r .defaultReplicaSet.topology[].memberRole | grep SECONDARY | wc -l | sed 's/^ *//') + + kubectl create configmap -n "${NAMESPACE}" 02-check-topology \ + --from-file=members=${TEMP_DIR}/members \ + --from-literal=status=${status} \ + --from-literal=online_members=${online_members} \ + --from-literal=primary_count=${primary} \ + --from-literal=secondary_count=${secondary} + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) + -P 6446 -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable + (id) VALUES (100500)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) + -P 6446 -uroot -proot_password\"" + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -P 6447 -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas --from-literal=data="${data}" + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-07 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\npods=($(get_mysql_pods))\n\nargs=\"\"\nfor + pod in \"${pods[@]}\"; do\n\tseeds=$(run_mysql \"SELECT @@group_replication_group_seeds\" + \"-h ${pod}.$(get_mysql_service gr-init-deploy).${NAMESPACE} -uroot -proot_password\")\n\targs=\"${args} + --from-literal=${pod}=$(echo ${seeds} | sed \"s/${NAMESPACE}/NAMESPACE/g\")\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 07-check-group-seeds $args" + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-one-pod/00-assert.yaml b/e2e-tests/tests/gr-one-pod/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/gr-one-pod/00-assert.yaml +++ b/e2e-tests/tests/gr-one-pod/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-one-pod/00-deploy-operator.yaml b/e2e-tests/tests/gr-one-pod/00-deploy-operator.yaml deleted file mode 100644 index 273c0cc4c..000000000 --- a/e2e-tests/tests/gr-one-pod/00-deploy-operator.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - apply_s3_storage_secrets - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client - deploy_minio - timeout: 300 diff --git a/e2e-tests/tests/gr-one-pod/01-assert.yaml b/e2e-tests/tests/gr-one-pod/01-assert.yaml index 727d579cf..0b9ee280d 100644 --- a/e2e-tests/tests/gr-one-pod/01-assert.yaml +++ b/e2e-tests/tests/gr-one-pod/01-assert.yaml @@ -1,18 +1,14 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 240 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-one-pod-mysql status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 1 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- apiVersion: apps/v1 kind: Deployment diff --git a/e2e-tests/tests/gr-one-pod/01-create-cluster.yaml b/e2e-tests/tests/gr-one-pod/01-create-cluster.yaml deleted file mode 100644 index 1be63fa60..000000000 --- a/e2e-tests/tests/gr-one-pod/01-create-cluster.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | yq eval '.spec.allowUnsafeConfigurations=true' - \ - | yq eval '.spec.mysql.size=1' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | yq eval '.spec.proxy.router.size=1' - \ - | yq eval '.spec.orchestrator.enabled=false' - \ - | yq eval '.spec.backup.storages.minio.type="s3"' - \ - | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ - | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ - | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-one-pod/02-write-data.yaml b/e2e-tests/tests/gr-one-pod/02-write-data.yaml deleted file mode 100644 index 081bcc16f..000000000 --- a/e2e-tests/tests/gr-one-pod/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_router_service $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_router_service $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/gr-one-pod/03-assert.yaml b/e2e-tests/tests/gr-one-pod/03-assert.yaml index 25c129b6e..dc4fb88fc 100644 --- a/e2e-tests/tests/gr-one-pod/03-assert.yaml +++ b/e2e-tests/tests/gr-one-pod/03-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: gr-one-pod-minio status: diff --git a/e2e-tests/tests/gr-one-pod/04-assert.yaml b/e2e-tests/tests/gr-one-pod/04-assert.yaml index c00f03954..9b3c39cee 100644 --- a/e2e-tests/tests/gr-one-pod/04-assert.yaml +++ b/e2e-tests/tests/gr-one-pod/04-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-delete-data-minio data: data: "" +kind: ConfigMap +metadata: + name: 04-delete-data-minio diff --git a/e2e-tests/tests/gr-one-pod/04-delete-data.yaml b/e2e-tests/tests/gr-one-pod/04-delete-data.yaml deleted file mode 100644 index 1f11e1d0b..000000000 --- a/e2e-tests/tests/gr-one-pod/04-delete-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_router_service $(get_cluster_name)) -uroot -proot_password" - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_router_service $(get_cluster_name)) -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-one-pod/05-assert.yaml b/e2e-tests/tests/gr-one-pod/05-assert.yaml index 18e2f8ec3..531185f18 100644 --- a/e2e-tests/tests/gr-one-pod/05-assert.yaml +++ b/e2e-tests/tests/gr-one-pod/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: @@ -18,8 +14,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: gr-one-pod-restore-minio status: diff --git a/e2e-tests/tests/gr-one-pod/06-assert.yaml b/e2e-tests/tests/gr-one-pod/06-assert.yaml index e9d02e5bf..3c359c693 100644 --- a/e2e-tests/tests/gr-one-pod/06-assert.yaml +++ b/e2e-tests/tests/gr-one-pod/06-assert.yaml @@ -1,25 +1,21 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 06-read-data-minio data: data: "100500" +kind: ConfigMap +metadata: + name: 06-read-data-minio --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-one-pod-mysql status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 3 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- apiVersion: apps/v1 kind: Deployment diff --git a/e2e-tests/tests/gr-one-pod/06-read-data.yaml b/e2e-tests/tests/gr-one-pod/06-read-data.yaml deleted file mode 100644 index cbc2dfa93..000000000 --- a/e2e-tests/tests/gr-one-pod/06-read-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - wait_cluster_consistency_gr "${test_name}" "1" "1" - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_router_service $(get_cluster_name)) -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio --from-literal=data="${data}" - timeout: 120 diff --git a/e2e-tests/tests/gr-one-pod/chainsaw-test.yaml b/e2e-tests/tests/gr-one-pod/chainsaw-test.yaml new file mode 100755 index 000000000..9e317f339 --- /dev/null +++ b/e2e-tests/tests/gr-one-pod/chainsaw-test.yaml @@ -0,0 +1,94 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-one-pod +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + apply_s3_storage_secrets + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + deploy_minio + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n | yq eval '.spec.allowUnsafeConfigurations=true' - \\\n | yq eval + '.spec.mysql.size=1' - \\\n | yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n | yq eval '.spec.proxy.router.size=1' - \\\n | yq eval '.spec.orchestrator.enabled=false' + - \\\n | yq eval '.spec.backup.storages.minio.type=\"s3\"' - \\\n | yq + eval '.spec.backup.storages.minio.s3.bucket=\"operator-testing\"' - \\\n + \ | yq eval '.spec.backup.storages.minio.s3.credentialsSecret=\"minio-secret\"' + - \\\n | yq eval '.spec.backup.storages.minio.s3.endpointUrl=\"http://minio-service:9000\"' + - \\\n | yq eval '.spec.backup.storages.minio.s3.region=\"us-east-1\"' + - \\\n | kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - error: + file: 01-errors.yml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_router_service $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_router_service $(get_cluster_name)) -uroot -proot_password\"" + - name: step-03 + try: + - apply: + file: 03-create-backup-minio.yaml + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_router_service $(get_cluster_name)) + -uroot -proot_password\"\n\ndata=$(run_mysql \"SELECT * FROM myDB.myTable\" + \"-h $(get_router_service $(get_cluster_name)) -uroot -proot_password\")\nkubectl + create configmap -n \"${NAMESPACE}\" 04-delete-data-minio --from-literal=data=\"${data}\"" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - apply: + file: 05-restore-from-minio.yaml + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + wait_cluster_consistency_gr "${test_name}" "1" "1" + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_router_service $(get_cluster_name)) -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio --from-literal=data="${data}" + - assert: + file: 06-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-recreate/00-assert.yaml b/e2e-tests/tests/gr-recreate/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/gr-recreate/00-assert.yaml +++ b/e2e-tests/tests/gr-recreate/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-recreate/00-deploy-operator.yaml b/e2e-tests/tests/gr-recreate/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/gr-recreate/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-recreate/01-assert.yaml b/e2e-tests/tests/gr-recreate/01-assert.yaml index 0defb50bc..967c37345 100644 --- a/e2e-tests/tests/gr-recreate/01-assert.yaml +++ b/e2e-tests/tests/gr-recreate/01-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-recreate-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-recreate-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-recreate status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-recreate/01-create-cluster.yaml b/e2e-tests/tests/gr-recreate/01-create-cluster.yaml deleted file mode 100644 index 01393b781..000000000 --- a/e2e-tests/tests/gr-recreate/01-create-cluster.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.router.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-recreate/02-assert.yaml b/e2e-tests/tests/gr-recreate/02-assert.yaml index a0f47e109..8aa1cf335 100644 --- a/e2e-tests/tests/gr-recreate/02-assert.yaml +++ b/e2e-tests/tests/gr-recreate/02-assert.yaml @@ -1,27 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 02-write-data-0 -data: - data: |- - 100500 --- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 02-write-data-1 -data: - data: |- - 100500 --- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 02-write-data-2 -data: - data: |- - 100500 diff --git a/e2e-tests/tests/gr-recreate/02-write-data.yaml b/e2e-tests/tests/gr-recreate/02-write-data.yaml deleted file mode 100644 index 93dbb8aa7..000000000 --- a/e2e-tests/tests/gr-recreate/02-write-data.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 02-write-data-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-recreate/03-assert.yaml b/e2e-tests/tests/gr-recreate/03-assert.yaml index f6a32005e..3649ad893 100644 --- a/e2e-tests/tests/gr-recreate/03-assert.yaml +++ b/e2e-tests/tests/gr-recreate/03-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-recreate status: mysql: state: paused @@ -54,8 +50,8 @@ metadata: app.kubernetes.io/part-of: percona-server name: datadir-gr-recreate-mysql-2 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-recreate-mysql status: @@ -64,8 +60,8 @@ status: observedGeneration: 2 replicas: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-recreate-router status: diff --git a/e2e-tests/tests/gr-recreate/03-pause.yaml b/e2e-tests/tests/gr-recreate/03-pause.yaml deleted file mode 100644 index ef7ab7c50..000000000 --- a/e2e-tests/tests/gr-recreate/03-pause.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.pause=true' - \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.router.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 120 diff --git a/e2e-tests/tests/gr-recreate/04-assert.yaml b/e2e-tests/tests/gr-recreate/04-assert.yaml index 954091fa1..95e16f9fd 100644 --- a/e2e-tests/tests/gr-recreate/04-assert.yaml +++ b/e2e-tests/tests/gr-recreate/04-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-recreate-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-recreate-router status: observedGeneration: 3 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-recreate status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-recreate/04-unpause.yaml b/e2e-tests/tests/gr-recreate/04-unpause.yaml deleted file mode 100644 index a31679b33..000000000 --- a/e2e-tests/tests/gr-recreate/04-unpause.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.pause=false' - \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.router.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 120 diff --git a/e2e-tests/tests/gr-recreate/05-assert.yaml b/e2e-tests/tests/gr-recreate/05-assert.yaml index 0ddeb1c33..1be2b95d4 100644 --- a/e2e-tests/tests/gr-recreate/05-assert.yaml +++ b/e2e-tests/tests/gr-recreate/05-assert.yaml @@ -1,30 +1,26 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 06-write-data-0 data: data: |- 100500 100501 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 06-write-data-1 + name: 06-write-data-0 +--- +apiVersion: v1 data: data: |- 100500 100501 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 06-write-data-2 + name: 06-write-data-1 +--- +apiVersion: v1 data: data: |- 100500 100501 +kind: ConfigMap +metadata: + name: 06-write-data-2 diff --git a/e2e-tests/tests/gr-recreate/05-write-data.yaml b/e2e-tests/tests/gr-recreate/05-write-data.yaml deleted file mode 100644 index 7d3fcc717..000000000 --- a/e2e-tests/tests/gr-recreate/05-write-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100501)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-write-data-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-recreate/07-delete-cluster.yaml b/e2e-tests/tests/gr-recreate/07-delete-cluster.yaml deleted file mode 100644 index d79389828..000000000 --- a/e2e-tests/tests/gr-recreate/07-delete-cluster.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl delete ps -n ${NAMESPACE} gr-recreate - - timeout: 120 diff --git a/e2e-tests/tests/gr-recreate/08-assert.yaml b/e2e-tests/tests/gr-recreate/08-assert.yaml index d867cb58b..2e5cbceee 100644 --- a/e2e-tests/tests/gr-recreate/08-assert.yaml +++ b/e2e-tests/tests/gr-recreate/08-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: v1 kind: PersistentVolumeClaim metadata: diff --git a/e2e-tests/tests/gr-recreate/09-assert.yaml b/e2e-tests/tests/gr-recreate/09-assert.yaml index 8fbe7b5f8..967c37345 100644 --- a/e2e-tests/tests/gr-recreate/09-assert.yaml +++ b/e2e-tests/tests/gr-recreate/09-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-recreate-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-recreate-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-recreate status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-recreate/09-recreate-cluster.yaml b/e2e-tests/tests/gr-recreate/09-recreate-cluster.yaml deleted file mode 100644 index a372972e9..000000000 --- a/e2e-tests/tests/gr-recreate/09-recreate-cluster.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.router.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 120 diff --git a/e2e-tests/tests/gr-recreate/10-assert.yaml b/e2e-tests/tests/gr-recreate/10-assert.yaml index 5d31cbb83..a272bdb83 100644 --- a/e2e-tests/tests/gr-recreate/10-assert.yaml +++ b/e2e-tests/tests/gr-recreate/10-assert.yaml @@ -1,33 +1,29 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 11-write-data-0 data: data: |- 100500 100501 100502 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 11-write-data-1 + name: 11-write-data-0 +--- +apiVersion: v1 data: data: |- 100500 100501 100502 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 11-write-data-2 + name: 11-write-data-1 +--- +apiVersion: v1 data: data: |- 100500 100501 100502 +kind: ConfigMap +metadata: + name: 11-write-data-2 diff --git a/e2e-tests/tests/gr-recreate/10-write-data.yaml b/e2e-tests/tests/gr-recreate/10-write-data.yaml deleted file mode 100644 index eae3cbdcb..000000000 --- a/e2e-tests/tests/gr-recreate/10-write-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100502)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 11-write-data-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-recreate/chainsaw-test.yaml b/e2e-tests/tests/gr-recreate/chainsaw-test.yaml new file mode 100755 index 000000000..667e78558 --- /dev/null +++ b/e2e-tests/tests/gr-recreate/chainsaw-test.yaml @@ -0,0 +1,128 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-recreate +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="group-replication"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.proxy.router.enabled=true' - \ + | yq eval '.spec.proxy.router.size=3' - \ + | yq eval '.spec.proxy.haproxy.enabled=false' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) + -P 6446 -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable + (id) VALUES (100500)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) + -P 6446 -uroot -proot_password\"\n\nfor i in 0 1 2; do\n host=$(get_mysql_headless_fqdn + $(get_cluster_name) $i)\n data=$(run_mysql \"SELECT * FROM myDB.myTable\" + \"-h ${host} -uroot -proot_password\")\n kubectl create configmap -n \"${NAMESPACE}\" + 02-write-data-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.pause=true' - \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' + - \\\n | yq eval '.spec.mysql.size=3' - \\\n\t| yq eval '.spec.proxy.router.enabled=true' + - \\\n\t| yq eval '.spec.proxy.router.size=3' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.pause=false' - \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' + - \\\n | yq eval '.spec.mysql.size=3' - \\\n\t| yq eval '.spec.proxy.router.enabled=true' + - \\\n\t| yq eval '.spec.proxy.router.size=3' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100501)\" \\\n\t\"-h $(get_mysql_router_service + $(get_cluster_name)) -P 6446 -uroot -proot_password\"\n\nfor i in 0 1 2; + do\n host=$(get_mysql_headless_fqdn $(get_cluster_name) $i)\n data=$(run_mysql + \"SELECT * FROM myDB.myTable\" \"-h ${host} -uroot -proot_password\")\n + \ kubectl create configmap -n \"${NAMESPACE}\" 06-write-data-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 05-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl delete ps -n ${NAMESPACE} gr-recreate + - error: + file: 07-errors.yaml + - name: step-08 + try: + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n | + yq eval '.spec.mysql.size=3' - \\\n\t| yq eval '.spec.proxy.router.enabled=true' + - \\\n\t| yq eval '.spec.proxy.router.size=3' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 09-assert.yaml + - name: step-10 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100502)\" \\\n\t\"-h $(get_mysql_router_service + $(get_cluster_name)) -P 6446 -uroot -proot_password\"\n\nfor i in 0 1 2; + do\n host=$(get_mysql_headless_fqdn $(get_cluster_name) $i)\n data=$(run_mysql + \"SELECT * FROM myDB.myTable\" \"-h ${host} -uroot -proot_password\")\n + \ kubectl create configmap -n \"${NAMESPACE}\" 11-write-data-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 10-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-scaling/00-assert.yaml b/e2e-tests/tests/gr-scaling/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/gr-scaling/00-assert.yaml +++ b/e2e-tests/tests/gr-scaling/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-scaling/00-deploy-operator.yaml b/e2e-tests/tests/gr-scaling/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/gr-scaling/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-scaling/01-assert.yaml b/e2e-tests/tests/gr-scaling/01-assert.yaml index 0b9a460dc..b27cbc9ba 100644 --- a/e2e-tests/tests/gr-scaling/01-assert.yaml +++ b/e2e-tests/tests/gr-scaling/01-assert.yaml @@ -1,36 +1,32 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-scaling-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-scaling-router status: + availableReplicas: 3 observedGeneration: 1 + readyReplicas: 3 replicas: 3 updatedReplicas: 3 - readyReplicas: 3 - availableReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-scaling status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-scaling/01-create-cluster.yaml b/e2e-tests/tests/gr-scaling/01-create-cluster.yaml deleted file mode 100644 index 846563a69..000000000 --- a/e2e-tests/tests/gr-scaling/01-create-cluster.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.allowUnsafeConfigurations=true' - \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-scaling/02-write-data.yaml b/e2e-tests/tests/gr-scaling/02-write-data.yaml deleted file mode 100644 index 4044735b2..000000000 --- a/e2e-tests/tests/gr-scaling/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/gr-scaling/03-assert.yaml b/e2e-tests/tests/gr-scaling/03-assert.yaml index 084110451..2d99a3bfd 100644 --- a/e2e-tests/tests/gr-scaling/03-assert.yaml +++ b/e2e-tests/tests/gr-scaling/03-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 03-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 03-read-from-primary diff --git a/e2e-tests/tests/gr-scaling/03-read-from-primary.yaml b/e2e-tests/tests/gr-scaling/03-read-from-primary.yaml deleted file mode 100644 index da9f7306b..000000000 --- a/e2e-tests/tests/gr-scaling/03-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-scaling/04-assert.yaml b/e2e-tests/tests/gr-scaling/04-assert.yaml index 990172e9a..1b5a98440 100644 --- a/e2e-tests/tests/gr-scaling/04-assert.yaml +++ b/e2e-tests/tests/gr-scaling/04-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-replicas data: gr-scaling-mysql-0.gr-scaling-mysql: "100500" gr-scaling-mysql-1.gr-scaling-mysql: "100500" gr-scaling-mysql-2.gr-scaling-mysql: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-replicas diff --git a/e2e-tests/tests/gr-scaling/04-read-from-replicas.yaml b/e2e-tests/tests/gr-scaling/04-read-from-replicas.yaml deleted file mode 100644 index 24bbbdb57..000000000 --- a/e2e-tests/tests/gr-scaling/04-read-from-replicas.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}') - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas ${args} diff --git a/e2e-tests/tests/gr-scaling/05-assert.yaml b/e2e-tests/tests/gr-scaling/05-assert.yaml index 8540bd032..18468460d 100644 --- a/e2e-tests/tests/gr-scaling/05-assert.yaml +++ b/e2e-tests/tests/gr-scaling/05-assert.yaml @@ -1,36 +1,32 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-scaling-mysql status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 2 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-scaling-router status: + availableReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 - availableReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-scaling status: mysql: ready: 1 diff --git a/e2e-tests/tests/gr-scaling/06-assert.yaml b/e2e-tests/tests/gr-scaling/06-assert.yaml index 42fef8df8..1b8d5adb1 100644 --- a/e2e-tests/tests/gr-scaling/06-assert.yaml +++ b/e2e-tests/tests/gr-scaling/06-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 06-check-group-seeds data: gr-scaling-mysql-0.gr-scaling-mysql: "" +kind: ConfigMap +metadata: + name: 06-check-group-seeds diff --git a/e2e-tests/tests/gr-scaling/06-check-group-seeds.yaml b/e2e-tests/tests/gr-scaling/06-check-group-seeds.yaml deleted file mode 100644 index 8420b6261..000000000 --- a/e2e-tests/tests/gr-scaling/06-check-group-seeds.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}') - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - seeds=$(run_mysql "SELECT @@group_replication_group_seeds" "-h ${host} -uroot -proot_password") - echo ${seeds} - seeds=$(echo ${seeds} | sed -e "s/\.${NAMESPACE}//g") - args="${args} --from-literal=${host}=${seeds}" - done - - kubectl create configmap -n "${NAMESPACE}" 06-check-group-seeds ${args} diff --git a/e2e-tests/tests/gr-scaling/07-assert.yaml b/e2e-tests/tests/gr-scaling/07-assert.yaml index 4b7324be5..16f87b875 100644 --- a/e2e-tests/tests/gr-scaling/07-assert.yaml +++ b/e2e-tests/tests/gr-scaling/07-assert.yaml @@ -1,36 +1,32 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 90 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-scaling-mysql status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 2 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-scaling-router status: + availableReplicas: 1 observedGeneration: 2 + readyReplicas: 1 replicas: 1 updatedReplicas: 1 - readyReplicas: 1 - availableReplicas: 1 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-scaling status: mysql: ready: 1 diff --git a/e2e-tests/tests/gr-scaling/08-assert.yaml b/e2e-tests/tests/gr-scaling/08-assert.yaml index c02b5b4b9..c790b859c 100644 --- a/e2e-tests/tests/gr-scaling/08-assert.yaml +++ b/e2e-tests/tests/gr-scaling/08-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 09-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 09-read-from-primary diff --git a/e2e-tests/tests/gr-scaling/08-read-from-primary.yaml b/e2e-tests/tests/gr-scaling/08-read-from-primary.yaml deleted file mode 100644 index d4dea1d9b..000000000 --- a/e2e-tests/tests/gr-scaling/08-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 09-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-scaling/09-assert.yaml b/e2e-tests/tests/gr-scaling/09-assert.yaml index cf221f4db..5a9e96728 100644 --- a/e2e-tests/tests/gr-scaling/09-assert.yaml +++ b/e2e-tests/tests/gr-scaling/09-assert.yaml @@ -1,36 +1,32 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-scaling-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-scaling-router status: + availableReplicas: 3 observedGeneration: 3 + readyReplicas: 3 replicas: 3 updatedReplicas: 3 - readyReplicas: 3 - availableReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-scaling status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-scaling/10-assert.yaml b/e2e-tests/tests/gr-scaling/10-assert.yaml index 95fa326fb..fbae441ca 100644 --- a/e2e-tests/tests/gr-scaling/10-assert.yaml +++ b/e2e-tests/tests/gr-scaling/10-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + gr-scaling-mysql-0.gr-scaling-mysql: gr-scaling-mysql-1.gr-scaling-mysql:3306,gr-scaling-mysql-2.gr-scaling-mysql:3306 + gr-scaling-mysql-1.gr-scaling-mysql: gr-scaling-mysql-0.gr-scaling-mysql:3306,gr-scaling-mysql-1.gr-scaling-mysql:3306,gr-scaling-mysql-2.gr-scaling-mysql:3306 + gr-scaling-mysql-2.gr-scaling-mysql: gr-scaling-mysql-0.gr-scaling-mysql:3306,gr-scaling-mysql-1.gr-scaling-mysql:3306,gr-scaling-mysql-2.gr-scaling-mysql:3306 +kind: ConfigMap metadata: name: 10-check-group-seeds -data: - gr-scaling-mysql-0.gr-scaling-mysql: "gr-scaling-mysql-1.gr-scaling-mysql:3306,gr-scaling-mysql-2.gr-scaling-mysql:3306" - gr-scaling-mysql-1.gr-scaling-mysql: "gr-scaling-mysql-0.gr-scaling-mysql:3306,gr-scaling-mysql-1.gr-scaling-mysql:3306,gr-scaling-mysql-2.gr-scaling-mysql:3306" - gr-scaling-mysql-2.gr-scaling-mysql: "gr-scaling-mysql-0.gr-scaling-mysql:3306,gr-scaling-mysql-1.gr-scaling-mysql:3306,gr-scaling-mysql-2.gr-scaling-mysql:3306" diff --git a/e2e-tests/tests/gr-scaling/10-check-group-seeds.yaml b/e2e-tests/tests/gr-scaling/10-check-group-seeds.yaml deleted file mode 100644 index b9ce15a5e..000000000 --- a/e2e-tests/tests/gr-scaling/10-check-group-seeds.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}') - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - seeds=$(run_mysql "SELECT @@group_replication_group_seeds" "-h ${host} -uroot -proot_password") - echo ${seeds} - seeds=$(echo ${seeds} | sed -e "s/\.${NAMESPACE}//g") - args="${args} --from-literal=${host}=${seeds}" - done - - kubectl create configmap -n "${NAMESPACE}" 10-check-group-seeds ${args} diff --git a/e2e-tests/tests/gr-scaling/11-assert.yaml b/e2e-tests/tests/gr-scaling/11-assert.yaml index 5a5fbc15b..a258d0f9e 100644 --- a/e2e-tests/tests/gr-scaling/11-assert.yaml +++ b/e2e-tests/tests/gr-scaling/11-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 11-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 11-read-from-primary diff --git a/e2e-tests/tests/gr-scaling/11-read-from-primary.yaml b/e2e-tests/tests/gr-scaling/11-read-from-primary.yaml deleted file mode 100644 index fb24b63d9..000000000 --- a/e2e-tests/tests/gr-scaling/11-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 11-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-scaling/12-assert.yaml b/e2e-tests/tests/gr-scaling/12-assert.yaml index f5dc3ae66..81cadc7b9 100644 --- a/e2e-tests/tests/gr-scaling/12-assert.yaml +++ b/e2e-tests/tests/gr-scaling/12-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 12-read-from-replicas data: gr-scaling-mysql-0.gr-scaling-mysql: "100500" gr-scaling-mysql-1.gr-scaling-mysql: "100500" gr-scaling-mysql-2.gr-scaling-mysql: "100500" +kind: ConfigMap +metadata: + name: 12-read-from-replicas diff --git a/e2e-tests/tests/gr-scaling/12-read-from-replicas.yaml b/e2e-tests/tests/gr-scaling/12-read-from-replicas.yaml deleted file mode 100644 index 3b183cfd7..000000000 --- a/e2e-tests/tests/gr-scaling/12-read-from-replicas.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}') - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 12-read-from-replicas ${args} diff --git a/e2e-tests/tests/gr-scaling/chainsaw-test.yaml b/e2e-tests/tests/gr-scaling/chainsaw-test.yaml new file mode 100755 index 000000000..cdb955b71 --- /dev/null +++ b/e2e-tests/tests/gr-scaling/chainsaw-test.yaml @@ -0,0 +1,153 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-scaling +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.allowUnsafeConfigurations=true' - \\\n | yq eval + '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| yq eval '.spec.proxy.router.enabled=true' + - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' - \\\n | kubectl + -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_mysql_router_service $(get_cluster_name)) -uroot + -proot_password\"" + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}')\nfor + i in $(seq 0 $((size - 1))); do\n\thost=$(get_mysql_headless_fqdn $(get_cluster_name) + $i)\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${host} -uroot + -proot_password\")\n\targs=\"${args} --from-literal=${host}=${data}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 04-read-from-replicas ${args}" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - apply: + file: 05-scale-down-mysql.yaml + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}')\nfor + i in $(seq 0 $((size - 1))); do\n\thost=$(get_mysql_headless_fqdn $(get_cluster_name) + $i)\n\tseeds=$(run_mysql \"SELECT @@group_replication_group_seeds\" \"-h + ${host} -uroot -proot_password\")\n echo ${seeds}\n seeds=$(echo ${seeds} + | sed -e \"s/\\.${NAMESPACE}//g\")\n\targs=\"${args} --from-literal=${host}=${seeds}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 06-check-group-seeds ${args}" + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - apply: + file: 07-scale-down-proxy.yaml + - assert: + file: 07-assert.yaml + - name: step-08 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 09-read-from-primary --from-literal=data="${data}" + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - apply: + file: 09-scale-up-everything.yaml + - assert: + file: 09-assert.yaml + - name: step-10 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}')\nfor + i in $(seq 0 $((size - 1))); do\n\thost=$(get_mysql_headless_fqdn $(get_cluster_name) + $i)\n\tseeds=$(run_mysql \"SELECT @@group_replication_group_seeds\" \"-h + ${host} -uroot -proot_password\")\n echo ${seeds}\n seeds=$(echo ${seeds} + | sed -e \"s/\\.${NAMESPACE}//g\")\n\targs=\"${args} --from-literal=${host}=${seeds}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 10-check-group-seeds ${args}" + - assert: + file: 10-assert.yaml + - name: step-11 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 11-read-from-primary --from-literal=data="${data}" + - assert: + file: 11-assert.yaml + - name: step-12 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}')\nfor + i in $(seq 0 $((size - 1))); do\n\thost=$(get_mysql_headless_fqdn $(get_cluster_name) + $i)\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${host} -uroot + -proot_password\")\n\targs=\"${args} --from-literal=${host}=${data}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 12-read-from-replicas ${args}" + - assert: + file: 12-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-self-healing/00-assert.yaml b/e2e-tests/tests/gr-self-healing/00-assert.yaml index d9146fe1b..b028a4c22 100644 --- a/e2e-tests/tests/gr-self-healing/00-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -16,11 +12,3 @@ spec: - ps singular: perconaservermysql scope: Namespaced ---- -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -metadata: - name: check-operator-deploy-status -timeout: 120 -commands: - - script: kubectl assert exist-enhanced deployment percona-server-mysql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 diff --git a/e2e-tests/tests/gr-self-healing/00-deploy-operator.yaml b/e2e-tests/tests/gr-self-healing/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/gr-self-healing/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-self-healing/01-assert.yaml b/e2e-tests/tests/gr-self-healing/01-assert.yaml index 253d7158f..e457a94fe 100644 --- a/e2e-tests/tests/gr-self-healing/01-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 240 ---- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/e2e-tests/tests/gr-self-healing/01-deploy-chaos-mesh.yaml b/e2e-tests/tests/gr-self-healing/01-deploy-chaos-mesh.yaml deleted file mode 100644 index 2fcde5027..000000000 --- a/e2e-tests/tests/gr-self-healing/01-deploy-chaos-mesh.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - deploy_chaos_mesh diff --git a/e2e-tests/tests/gr-self-healing/02-assert.yaml b/e2e-tests/tests/gr-self-healing/02-assert.yaml index ea774179f..b7d9da5f7 100644 --- a/e2e-tests/tests/gr-self-healing/02-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/02-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-self-healing-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-self-healing status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-self-healing/02-create-cluster.yaml b/e2e-tests/tests/gr-self-healing/02-create-cluster.yaml deleted file mode 100644 index 4f0779353..000000000 --- a/e2e-tests/tests/gr-self-healing/02-create-cluster.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.router.size=3' - \ - | yq eval '.spec.proxy.router.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-self-healing/03-write-data.yaml b/e2e-tests/tests/gr-self-healing/03-write-data.yaml deleted file mode 100644 index 1bbd291a9..000000000 --- a/e2e-tests/tests/gr-self-healing/03-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" diff --git a/e2e-tests/tests/gr-self-healing/04-assert.yaml b/e2e-tests/tests/gr-self-healing/04-assert.yaml index 8a8037060..6b066ed1a 100644 --- a/e2e-tests/tests/gr-self-healing/04-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/04-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-primary diff --git a/e2e-tests/tests/gr-self-healing/04-read-from-primary.yaml b/e2e-tests/tests/gr-self-healing/04-read-from-primary.yaml deleted file mode 100644 index 68e1755aa..000000000 --- a/e2e-tests/tests/gr-self-healing/04-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/gr-self-healing/05-assert.yaml b/e2e-tests/tests/gr-self-healing/05-assert.yaml index f107033cd..4918904bb 100644 --- a/e2e-tests/tests/gr-self-healing/05-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/05-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 180 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-self-healing-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-self-healing status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-self-healing/05-kill-primary.yaml b/e2e-tests/tests/gr-self-healing/05-kill-primary.yaml deleted file mode 100644 index 255f6a0b6..000000000 --- a/e2e-tests/tests/gr-self-healing/05-kill-primary.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - init_pod="$(get_primary_from_group_replication)" - kill_pods "${NAMESPACE}" "pod" "$init_pod" "" "primary" - sleep 10 # wait a bit for pod to be killed - - if [ "$init_pod" == "$(get_primary_from_group_replication)" ]; then - echo "primary pod was not killed! something went wrong." - exit 1 - fi diff --git a/e2e-tests/tests/gr-self-healing/06-write-data.yaml b/e2e-tests/tests/gr-self-healing/06-write-data.yaml deleted file mode 100644 index a8da85c54..000000000 --- a/e2e-tests/tests/gr-self-healing/06-write-data.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100501)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" diff --git a/e2e-tests/tests/gr-self-healing/07-assert.yaml b/e2e-tests/tests/gr-self-healing/07-assert.yaml index d5acf9414..fba615946 100644 --- a/e2e-tests/tests/gr-self-healing/07-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/07-assert.yaml @@ -1,30 +1,26 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 07-read-from-replicas-0 data: data: |- 100500 100501 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 07-read-from-replicas-1 + name: 07-read-from-replicas-0 +--- +apiVersion: v1 data: data: |- 100500 100501 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 07-read-from-replicas-2 + name: 07-read-from-replicas-1 +--- +apiVersion: v1 data: data: |- 100500 100501 +kind: ConfigMap +metadata: + name: 07-read-from-replicas-2 diff --git a/e2e-tests/tests/gr-self-healing/07-read-from-replicas.yaml b/e2e-tests/tests/gr-self-healing/07-read-from-replicas.yaml deleted file mode 100644 index 30f4d2649..000000000 --- a/e2e-tests/tests/gr-self-healing/07-read-from-replicas.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 07-read-from-replicas-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-self-healing/08-assert.yaml b/e2e-tests/tests/gr-self-healing/08-assert.yaml index e2f394cc0..992b02452 100644 --- a/e2e-tests/tests/gr-self-healing/08-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/08-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 180 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-self-healing-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-self-healing status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-self-healing/08-failure-primary.yaml b/e2e-tests/tests/gr-self-healing/08-failure-primary.yaml deleted file mode 100644 index 59d48c526..000000000 --- a/e2e-tests/tests/gr-self-healing/08-failure-primary.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - failure_pod "${NAMESPACE}" "$(get_primary_from_group_replication)" "primary" - sleep 10 # wait a bit for pod to be killed diff --git a/e2e-tests/tests/gr-self-healing/09-write-data.yaml b/e2e-tests/tests/gr-self-healing/09-write-data.yaml deleted file mode 100644 index f3bb7eb48..000000000 --- a/e2e-tests/tests/gr-self-healing/09-write-data.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100502)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" diff --git a/e2e-tests/tests/gr-self-healing/10-assert.yaml b/e2e-tests/tests/gr-self-healing/10-assert.yaml index 2f9ba0826..f6b9d3826 100644 --- a/e2e-tests/tests/gr-self-healing/10-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/10-assert.yaml @@ -1,33 +1,29 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 10-read-from-replicas-0 data: data: |- 100500 100501 100502 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 10-read-from-replicas-1 + name: 10-read-from-replicas-0 +--- +apiVersion: v1 data: data: |- 100500 100501 100502 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 10-read-from-replicas-2 + name: 10-read-from-replicas-1 +--- +apiVersion: v1 data: data: |- 100500 100501 100502 +kind: ConfigMap +metadata: + name: 10-read-from-replicas-2 diff --git a/e2e-tests/tests/gr-self-healing/10-read-from-replicas.yaml b/e2e-tests/tests/gr-self-healing/10-read-from-replicas.yaml deleted file mode 100644 index 55a419ab7..000000000 --- a/e2e-tests/tests/gr-self-healing/10-read-from-replicas.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 10-read-from-replicas-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-self-healing/11-assert.yaml b/e2e-tests/tests/gr-self-healing/11-assert.yaml index 7075a30c6..9c8b7edd6 100644 --- a/e2e-tests/tests/gr-self-healing/11-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/11-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 180 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-self-healing-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-self-healing status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-self-healing/11-network-loss-primary.yaml b/e2e-tests/tests/gr-self-healing/11-network-loss-primary.yaml deleted file mode 100644 index f63192c0e..000000000 --- a/e2e-tests/tests/gr-self-healing/11-network-loss-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 90 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - network_loss "${NAMESPACE}" "$(get_primary_from_group_replication)" "primary" - sleep 30 # wait for new master to get elected - timeout: 90 diff --git a/e2e-tests/tests/gr-self-healing/12-write-data.yaml b/e2e-tests/tests/gr-self-healing/12-write-data.yaml deleted file mode 100644 index a683b8542..000000000 --- a/e2e-tests/tests/gr-self-healing/12-write-data.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100503)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" diff --git a/e2e-tests/tests/gr-self-healing/13-assert.yaml b/e2e-tests/tests/gr-self-healing/13-assert.yaml index 7d2f48cde..ab0f39543 100644 --- a/e2e-tests/tests/gr-self-healing/13-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/13-assert.yaml @@ -1,36 +1,32 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 13-read-from-replicas-0 data: - data: |2- + data: |- 100500 100501 100502 100503 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 13-read-from-replicas-1 + name: 13-read-from-replicas-0 +--- +apiVersion: v1 data: - data: |2- + data: |- 100500 100501 100502 100503 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 13-read-from-replicas-2 + name: 13-read-from-replicas-1 +--- +apiVersion: v1 data: - data: |2- + data: |- 100500 100501 100502 100503 +kind: ConfigMap +metadata: + name: 13-read-from-replicas-2 diff --git a/e2e-tests/tests/gr-self-healing/13-read-from-replicas.yaml b/e2e-tests/tests/gr-self-healing/13-read-from-replicas.yaml deleted file mode 100644 index 77b99efc0..000000000 --- a/e2e-tests/tests/gr-self-healing/13-read-from-replicas.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 13-read-from-replicas-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-self-healing/14-assert.yaml b/e2e-tests/tests/gr-self-healing/14-assert.yaml index 022a09012..a45a6bb0b 100644 --- a/e2e-tests/tests/gr-self-healing/14-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/14-assert.yaml @@ -1,35 +1,31 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: gr-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: name: gr-self-healing-router status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: gr-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: gr-self-healing status: mysql: ready: 3 diff --git a/e2e-tests/tests/gr-self-healing/14-cluster-crash.yaml b/e2e-tests/tests/gr-self-healing/14-cluster-crash.yaml deleted file mode 100644 index 23a786193..000000000 --- a/e2e-tests/tests/gr-self-healing/14-cluster-crash.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kill_pods "${NAMESPACE}" "label" "app.kubernetes.io/instance" "gr-self-healing" "cluster-crash" - sleep 30 # wait for crash diff --git a/e2e-tests/tests/gr-self-healing/15-write-data.yaml b/e2e-tests/tests/gr-self-healing/15-write-data.yaml deleted file mode 100644 index 9152934e0..000000000 --- a/e2e-tests/tests/gr-self-healing/15-write-data.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100504)" \ - "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password" diff --git a/e2e-tests/tests/gr-self-healing/16-assert.yaml b/e2e-tests/tests/gr-self-healing/16-assert.yaml index 5f278c285..92b9b4ea0 100644 --- a/e2e-tests/tests/gr-self-healing/16-assert.yaml +++ b/e2e-tests/tests/gr-self-healing/16-assert.yaml @@ -1,39 +1,35 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: |- + 100500 + 100501 + 100502 + 100503 + 100504 +kind: ConfigMap metadata: name: 16-read-from-replicas-0 +--- +apiVersion: v1 data: data: |- - 100500 - 100501 - 100502 - 100503 - 100504 ---- + 100500 + 100501 + 100502 + 100503 + 100504 kind: ConfigMap -apiVersion: v1 metadata: name: 16-read-from-replicas-1 +--- +apiVersion: v1 data: data: |- - 100500 - 100501 - 100502 - 100503 - 100504 ---- + 100500 + 100501 + 100502 + 100503 + 100504 kind: ConfigMap -apiVersion: v1 metadata: name: 16-read-from-replicas-2 -data: - data: |- - 100500 - 100501 - 100502 - 100503 - 100504 diff --git a/e2e-tests/tests/gr-self-healing/16-read-from-replicas.yaml b/e2e-tests/tests/gr-self-healing/16-read-from-replicas.yaml deleted file mode 100644 index ab4cfa84c..000000000 --- a/e2e-tests/tests/gr-self-healing/16-read-from-replicas.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 16-read-from-replicas-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/gr-self-healing/17-destroy-chaos-mesh.yaml b/e2e-tests/tests/gr-self-healing/17-destroy-chaos-mesh.yaml deleted file mode 100644 index 3f0cbc6b8..000000000 --- a/e2e-tests/tests/gr-self-healing/17-destroy-chaos-mesh.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 120 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - destroy_chaos_mesh - timeout: 120 diff --git a/e2e-tests/tests/gr-self-healing/chainsaw-test.yaml b/e2e-tests/tests/gr-self-healing/chainsaw-test.yaml new file mode 100755 index 000000000..77c4838d2 --- /dev/null +++ b/e2e-tests/tests/gr-self-healing/chainsaw-test.yaml @@ -0,0 +1,244 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-self-healing +spec: + steps: + - catch: + - script: + content: kubectl assert exist-enhanced deployment percona-server-mysql-operator + -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 + name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + deploy_chaos_mesh + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="group-replication"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.proxy.haproxy.enabled=false' - \ + | yq eval '.spec.proxy.router.enabled=true' - \ + | yq eval '.spec.proxy.router.size=3' - \ + | yq eval '.spec.proxy.router.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=false' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n \"-h $(get_mysql_router_service $(get_cluster_name)) + -P 6446 -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable + (id) VALUES (100500)\" \\\n \"-h $(get_mysql_router_service $(get_cluster_name)) + -P 6446 -uroot -proot_password\"" + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_mysql_router_service $(get_cluster_name)) -P 6446 -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 04-read-from-primary --from-literal=data="${data}" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + init_pod="$(get_primary_from_group_replication)" + kill_pods "${NAMESPACE}" "pod" "$init_pod" "" "primary" + sleep 10 # wait a bit for pod to be killed + + if [ "$init_pod" == "$(get_primary_from_group_replication)" ]; then + echo "primary pod was not killed! something went wrong." + exit 1 + fi + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100501)\" \\\n \"-h $(get_mysql_router_service + $(get_cluster_name)) -P 6446 -uroot -proot_password\"" + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + for i in 0 1 2; do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 07-read-from-replicas-${i} --from-literal=data="${data}" + done + - assert: + file: 07-assert.yaml + - name: step-08 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + failure_pod "${NAMESPACE}" "$(get_primary_from_group_replication)" "primary" + sleep 10 # wait a bit for pod to be killed + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100502)\" \\\n \"-h $(get_mysql_router_service + $(get_cluster_name)) -P 6446 -uroot -proot_password\"" + - name: step-10 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + for i in 0 1 2; do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 10-read-from-replicas-${i} --from-literal=data="${data}" + done + - assert: + file: 10-assert.yaml + - name: step-11 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + network_loss "${NAMESPACE}" "$(get_primary_from_group_replication)" "primary" + sleep 30 # wait for new master to get elected + - assert: + file: 11-assert.yaml + - name: step-12 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100503)\" \\\n \"-h $(get_mysql_router_service + $(get_cluster_name)) -P 6446 -uroot -proot_password\"" + - name: step-13 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + for i in 0 1 2; do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 13-read-from-replicas-${i} --from-literal=data="${data}" + done + - assert: + file: 13-assert.yaml + - name: step-14 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kill_pods "${NAMESPACE}" "label" "app.kubernetes.io/instance" "gr-self-healing" "cluster-crash" + sleep 30 # wait for crash + - assert: + file: 14-assert.yaml + - name: step-15 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100504)\" \\\n \"-h $(get_mysql_router_service + $(get_cluster_name)) -P 6446 -uroot -proot_password\"" + - name: step-16 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + for i in 0 1 2; do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 16-read-from-replicas-${i} --from-literal=data="${data}" + done + - assert: + file: 16-assert.yaml + - name: step-17 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + destroy_chaos_mesh + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-tls-cert-manager/00-assert.yaml b/e2e-tests/tests/gr-tls-cert-manager/00-assert.yaml index 89648a0b1..211867155 100644 --- a/e2e-tests/tests/gr-tls-cert-manager/00-assert.yaml +++ b/e2e-tests/tests/gr-tls-cert-manager/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 180 ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -13,4 +9,3 @@ status: readyReplicas: 1 replicas: 1 updatedReplicas: 1 - diff --git a/e2e-tests/tests/gr-tls-cert-manager/00-deploy-cert-manager.yaml b/e2e-tests/tests/gr-tls-cert-manager/00-deploy-cert-manager.yaml deleted file mode 100644 index fc26fff09..000000000 --- a/e2e-tests/tests/gr-tls-cert-manager/00-deploy-cert-manager.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 120 -commands: - - script: |- - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_cert_manager - diff --git a/e2e-tests/tests/gr-tls-cert-manager/01-assert.yaml b/e2e-tests/tests/gr-tls-cert-manager/01-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/gr-tls-cert-manager/01-assert.yaml +++ b/e2e-tests/tests/gr-tls-cert-manager/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-tls-cert-manager/01-deploy-operator.yaml b/e2e-tests/tests/gr-tls-cert-manager/01-deploy-operator.yaml deleted file mode 100644 index 95773f69d..000000000 --- a/e2e-tests/tests/gr-tls-cert-manager/01-deploy-operator.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 120 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-tls-cert-manager/02-assert.yaml b/e2e-tests/tests/gr-tls-cert-manager/02-assert.yaml index a8633a920..70a83e8aa 100644 --- a/e2e-tests/tests/gr-tls-cert-manager/02-assert.yaml +++ b/e2e-tests/tests/gr-tls-cert-manager/02-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: cert-manager.io/v1 kind: Certificate metadata: @@ -17,11 +13,11 @@ spec: secretName: gr-tls-cert-manager-ca-cert status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 1 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 1 + reason: Ready + status: "True" + type: Ready revision: 1 --- apiVersion: cert-manager.io/v1 @@ -35,11 +31,11 @@ spec: secretName: test-ssl status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 1 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 1 + reason: Ready + status: "True" + type: Ready revision: 1 --- apiVersion: apps/v1 @@ -49,22 +45,22 @@ metadata: name: gr-tls-cert-manager-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: - name: gr-tls-cert-manager-router labels: app.kubernetes.io/component: router app.kubernetes.io/instance: gr-tls-cert-manager app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + name: gr-tls-cert-manager-router status: + availableReplicas: 3 observedGeneration: 1 + readyReplicas: 3 replicas: 3 updatedReplicas: 3 - readyReplicas: 3 - availableReplicas: 3 diff --git a/e2e-tests/tests/gr-tls-cert-manager/02-create-cluster.yaml b/e2e-tests/tests/gr-tls-cert-manager/02-create-cluster.yaml deleted file mode 100644 index 9a366a342..000000000 --- a/e2e-tests/tests/gr-tls-cert-manager/02-create-cluster.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-tls-cert-manager/03-check-cert.yaml b/e2e-tests/tests/gr-tls-cert-manager/03-check-cert.yaml deleted file mode 100644 index 7a44e42ab..000000000 --- a/e2e-tests/tests/gr-tls-cert-manager/03-check-cert.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - verify_certificate_sans gr-tls-cert-manager-ssl '[ - "*.gr-tls-cert-manager-mysql", - "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'", - "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", - "*.gr-tls-cert-manager-orchestrator", - "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'", - "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", - "*.gr-tls-cert-manager-router", - "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'", - "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'.svc" - ]' diff --git a/e2e-tests/tests/gr-tls-cert-manager/04-assert.yaml b/e2e-tests/tests/gr-tls-cert-manager/04-assert.yaml index 46429cc2e..2c528cfeb 100644 --- a/e2e-tests/tests/gr-tls-cert-manager/04-assert.yaml +++ b/e2e-tests/tests/gr-tls-cert-manager/04-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- apiVersion: cert-manager.io/v1 kind: Certificate metadata: @@ -17,11 +13,11 @@ spec: secretName: gr-tls-cert-manager-ca-cert status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 1 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 1 + reason: Ready + status: "True" + type: Ready revision: 1 --- apiVersion: cert-manager.io/v1 @@ -35,11 +31,11 @@ spec: secretName: test-ssl status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 2 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 2 + reason: Ready + status: "True" + type: Ready revision: 2 --- apiVersion: apps/v1 @@ -49,22 +45,22 @@ metadata: name: gr-tls-cert-manager-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: - name: gr-tls-cert-manager-router labels: app.kubernetes.io/component: router app.kubernetes.io/instance: gr-tls-cert-manager app.kubernetes.io/managed-by: percona-server-operator app.kubernetes.io/name: percona-server app.kubernetes.io/part-of: percona-server + name: gr-tls-cert-manager-router status: + availableReplicas: 3 observedGeneration: 1 + readyReplicas: 3 replicas: 3 updatedReplicas: 3 - readyReplicas: 3 - availableReplicas: 3 diff --git a/e2e-tests/tests/gr-tls-cert-manager/04-update-cluster.yaml b/e2e-tests/tests/gr-tls-cert-manager/04-update-cluster.yaml deleted file mode 100644 index 1b4b0ca84..000000000 --- a/e2e-tests/tests/gr-tls-cert-manager/04-update-cluster.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[ - { - "op": "add", - "path": "/spec/tls", - "value": {"SANs": ["mysql-1.example.com"]}, - }, - ]' diff --git a/e2e-tests/tests/gr-tls-cert-manager/05-check-cert.yaml b/e2e-tests/tests/gr-tls-cert-manager/05-check-cert.yaml deleted file mode 100644 index 35ca29679..000000000 --- a/e2e-tests/tests/gr-tls-cert-manager/05-check-cert.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - verify_certificate_sans gr-tls-cert-manager-ssl '[ - "*.gr-tls-cert-manager-mysql", - "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'", - "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", - "*.gr-tls-cert-manager-orchestrator", - "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'", - "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", - "*.gr-tls-cert-manager-router", - "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'", - "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'.svc", - "mysql-1.example.com" - ]' diff --git a/e2e-tests/tests/gr-tls-cert-manager/chainsaw-test.yaml b/e2e-tests/tests/gr-tls-cert-manager/chainsaw-test.yaml new file mode 100755 index 000000000..33d48153f --- /dev/null +++ b/e2e-tests/tests/gr-tls-cert-manager/chainsaw-test.yaml @@ -0,0 +1,108 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-tls-cert-manager +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_cert_manager + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_client + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"group-replication\"' - \\\n\t| + yq eval '.spec.proxy.router.enabled=true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled=false' + - \\\n | kubectl -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + verify_certificate_sans gr-tls-cert-manager-ssl '[ + "*.gr-tls-cert-manager-mysql", + "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'", + "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", + "*.gr-tls-cert-manager-orchestrator", + "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'", + "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", + "*.gr-tls-cert-manager-router", + "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'", + "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'.svc" + ]' + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[ + { + "op": "add", + "path": "/spec/tls", + "value": {"SANs": ["mysql-1.example.com"]}, + }, + ]' + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + verify_certificate_sans gr-tls-cert-manager-ssl '[ + "*.gr-tls-cert-manager-mysql", + "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'", + "*.gr-tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", + "*.gr-tls-cert-manager-orchestrator", + "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'", + "*.gr-tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", + "*.gr-tls-cert-manager-router", + "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'", + "*.gr-tls-cert-manager-router.'"${NAMESPACE}"'.svc", + "mysql-1.example.com" + ]' + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/gr-users/00-assert.yaml b/e2e-tests/tests/gr-users/00-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/gr-users/00-assert.yaml +++ b/e2e-tests/tests/gr-users/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/gr-users/00-deploy-operator.yaml b/e2e-tests/tests/gr-users/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/gr-users/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/gr-users/01-assert.yaml b/e2e-tests/tests/gr-users/01-assert.yaml index 15595fc12..e6c83ac81 100644 --- a/e2e-tests/tests/gr-users/01-assert.yaml +++ b/e2e-tests/tests/gr-users/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: gr-users-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: Deployment diff --git a/e2e-tests/tests/gr-users/01-create-cluster.yaml b/e2e-tests/tests/gr-users/01-create-cluster.yaml deleted file mode 100644 index e98823039..000000000 --- a/e2e-tests/tests/gr-users/01-create-cluster.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="group-replication"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=false' - \ - | yq eval '.spec.proxy.router.enabled=true' - \ - | yq eval '.spec.proxy.router.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/gr-users/02-assert.yaml b/e2e-tests/tests/gr-users/02-assert.yaml index ce5604e3f..d1b433acf 100644 --- a/e2e-tests/tests/gr-users/02-assert.yaml +++ b/e2e-tests/tests/gr-users/02-assert.yaml @@ -1,11 +1,4 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- apiVersion: v1 -kind: ConfigMap -metadata: - name: 02-check-users data: heartbeat: | GRANT REPLICATION CLIENT ON *.* TO `heartbeat`@`localhost` @@ -29,3 +22,6 @@ data: GRANT SELECT ON `performance_schema`.`keyring_component_status` TO `xtrabackup`@`localhost` GRANT SELECT ON `performance_schema`.`log_status` TO `xtrabackup`@`localhost` GRANT SELECT ON `performance_schema`.`replication_group_members` TO `xtrabackup`@`localhost` +kind: ConfigMap +metadata: + name: 02-check-users diff --git a/e2e-tests/tests/gr-users/02-check-users.yaml b/e2e-tests/tests/gr-users/02-check-users.yaml deleted file mode 100644 index 837d9749f..000000000 --- a/e2e-tests/tests/gr-users/02-check-users.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - mysql_args="-h $(get_router_service $(get_cluster_name)) -uroot -proot_password" - users=($(get_mysql_users "${mysql_args}")) - - args='' - for user in "${users[@]}"; do - host="%" - case $user in - heartbeat | xtrabackup) - host="localhost" - ;; - esac - query="SHOW GRANTS FOR '${user}'@'${host}';" - - run_mysql "${query}" "${mysql_args}" \ - | sed -E "s/'(10|192)[.][0-9][^']*'//; s/'[^']*[.]internal'//" \ - >"${TEMP_DIR}/${user}.sql" - - args="${args} --from-file=${user}=${TEMP_DIR}/${user}.sql" - done - - kubectl create configmap -n "${NAMESPACE}" 02-check-users $args - kubectl get configmap -n "${NAMESPACE}" 02-check-users -o yaml diff --git a/e2e-tests/tests/gr-users/04-assert.yaml b/e2e-tests/tests/gr-users/04-assert.yaml index 0539b0c1d..79229895a 100644 --- a/e2e-tests/tests/gr-users/04-assert.yaml +++ b/e2e-tests/tests/gr-users/04-assert.yaml @@ -1,17 +1,13 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- -kind: ConfigMap apiVersion: v1 +data: + heartbeat: success + monitor: success + operator: success + orchestrator: success + xtrabackup: success +kind: ConfigMap metadata: name: 04-check-connections -data: - heartbeat: "success" - monitor: "success" - operator: "success" - orchestrator: "success" - xtrabackup: "success" --- apiVersion: apps/v1 kind: StatefulSet @@ -20,5 +16,5 @@ metadata: name: gr-users-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 diff --git a/e2e-tests/tests/gr-users/04-check-cluster.yaml b/e2e-tests/tests/gr-users/04-check-cluster.yaml deleted file mode 100644 index e0bd4220d..000000000 --- a/e2e-tests/tests/gr-users/04-check-cluster.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o pipefail - set -o errexit - set -o xtrace - - source ../../functions - - sleep 30 # wait for cluster status to change to initializing - wait_cluster_consistency_gr "${test_name}" "3" "3" - mysql_args="-h $(get_router_service $(get_cluster_name)) -uroot -proot_password_updated" - users=($(get_mysql_users "${mysql_args}")) - - # check connection - args="" - set +o errexit - for user in "${users[@]}"; do - mysql_args="-h $(get_router_service $(get_cluster_name)) -u${user} -p${user}_password_updated" - - pod=mysql-client - case $user in - heartbeat | xtrabackup) - mysql_args="-h localhost -u${user} -p${user}_password_updated" - pod="$(get_cluster_name)-mysql-0" - ;; - esac - - run_mysql "SELECT 1" "${mysql_args}" "${pod}" - - args="${args} --from-literal=${user}=$([ $? -eq 0 ] && echo 'success' || echo 'fail')" - done - set -o errexit - - kubectl create configmap -n "${NAMESPACE}" 04-check-connections $args - kubectl get configmap -n "${NAMESPACE}" 04-check-connections -o yaml - timeout: 300 diff --git a/e2e-tests/tests/gr-users/chainsaw-test.yaml b/e2e-tests/tests/gr-users/chainsaw-test.yaml new file mode 100755 index 000000000..554372f72 --- /dev/null +++ b/e2e-tests/tests/gr-users/chainsaw-test.yaml @@ -0,0 +1,81 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: gr-users +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="group-replication"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.proxy.haproxy.enabled=false' - \ + | yq eval '.spec.proxy.router.enabled=true' - \ + | yq eval '.spec.proxy.router.size=3' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nmysql_args=\"-h + $(get_router_service $(get_cluster_name)) -uroot -proot_password\"\nusers=($(get_mysql_users + \"${mysql_args}\"))\n\nargs=''\nfor user in \"${users[@]}\"; do\n\thost=\"%\"\n\tcase + $user in\n\t\theartbeat | xtrabackup)\n\t\t\thost=\"localhost\"\n\t\t\t;;\n\tesac\n\tquery=\"SHOW + GRANTS FOR '${user}'@'${host}';\"\n\n\trun_mysql \"${query}\" \"${mysql_args}\" + \\\n\t\t| sed -E \"s/'(10|192)[.][0-9][^']*'//; s/'[^']*[.]internal'//\" + \\\n\t\t\t>\"${TEMP_DIR}/${user}.sql\"\n\n\targs=\"${args} --from-file=${user}=${TEMP_DIR}/${user}.sql\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 02-check-users $args\nkubectl get configmap + -n \"${NAMESPACE}\" 02-check-users -o yaml" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - apply: + file: 03-update-passwords.yaml + - name: step-04 + try: + - script: + content: "set -o pipefail\nset -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsleep + 30 # wait for cluster status to change to initializing\nwait_cluster_consistency_gr + \"${test_name}\" \"3\" \"3\"\nmysql_args=\"-h $(get_router_service $(get_cluster_name)) + -uroot -proot_password_updated\"\nusers=($(get_mysql_users \"${mysql_args}\"))\n\n# + check connection\nargs=\"\"\nset +o errexit\nfor user in \"${users[@]}\"; + do\n\tmysql_args=\"-h $(get_router_service $(get_cluster_name)) -u${user} + -p${user}_password_updated\"\n\n\tpod=mysql-client\n\tcase $user in\n\t\theartbeat + | xtrabackup)\n\t\t\tmysql_args=\"-h localhost -u${user} -p${user}_password_updated\"\n\t\t\tpod=\"$(get_cluster_name)-mysql-0\"\n\t\t\t;;\n\tesac\n\n\trun_mysql + \"SELECT 1\" \"${mysql_args}\" \"${pod}\"\n\n\targs=\"${args} --from-literal=${user}=$([ + $? -eq 0 ] && echo 'success' || echo 'fail')\"\ndone\nset -o errexit\n\nkubectl + create configmap -n \"${NAMESPACE}\" 04-check-connections $args\nkubectl + get configmap -n \"${NAMESPACE}\" 04-check-connections -o yaml" + - assert: + file: 04-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/haproxy/00-assert.yaml b/e2e-tests/tests/haproxy/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/haproxy/00-assert.yaml +++ b/e2e-tests/tests/haproxy/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/haproxy/00-deploy-operator.yaml b/e2e-tests/tests/haproxy/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/haproxy/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/haproxy/01-assert.yaml b/e2e-tests/tests/haproxy/01-assert.yaml index 49126eeb1..cf07ee1f4 100644 --- a/e2e-tests/tests/haproxy/01-assert.yaml +++ b/e2e-tests/tests/haproxy/01-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: haproxy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: haproxy-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: haproxy-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: haproxy finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: haproxy status: haproxy: ready: 3 diff --git a/e2e-tests/tests/haproxy/01-create-cluster.yaml b/e2e-tests/tests/haproxy/01-create-cluster.yaml deleted file mode 100644 index 553abfb15..000000000 --- a/e2e-tests/tests/haproxy/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.allowUnsafeConfigurations=false' - \ - | yq eval '.spec.updateStrategy="RollingUpdate"' - \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/haproxy/02-write-data.yaml b/e2e-tests/tests/haproxy/02-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/haproxy/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/haproxy/03-assert.yaml b/e2e-tests/tests/haproxy/03-assert.yaml index 084110451..2d99a3bfd 100644 --- a/e2e-tests/tests/haproxy/03-assert.yaml +++ b/e2e-tests/tests/haproxy/03-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 03-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 03-read-from-primary diff --git a/e2e-tests/tests/haproxy/03-read-from-primary.yaml b/e2e-tests/tests/haproxy/03-read-from-primary.yaml deleted file mode 100644 index d6011e9b9..000000000 --- a/e2e-tests/tests/haproxy/03-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P3306 -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/haproxy/04-assert.yaml b/e2e-tests/tests/haproxy/04-assert.yaml index 6bb0b7744..c926d1b88 100644 --- a/e2e-tests/tests/haproxy/04-assert.yaml +++ b/e2e-tests/tests/haproxy/04-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-replicas data: haproxy-haproxy-replicas: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-replicas diff --git a/e2e-tests/tests/haproxy/04-read-from-replicas.yaml b/e2e-tests/tests/haproxy/04-read-from-replicas.yaml deleted file mode 100644 index a098142fa..000000000 --- a/e2e-tests/tests/haproxy/04-read-from-replicas.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P3307 -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas --from-literal=${test_name}-haproxy-replicas=${data} diff --git a/e2e-tests/tests/haproxy/05-check-pods-have-same-primary.yaml b/e2e-tests/tests/haproxy/05-check-pods-have-same-primary.yaml deleted file mode 100644 index a289dca25..000000000 --- a/e2e-tests/tests/haproxy/05-check-pods-have-same-primary.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=() - for i in $(seq 0 2); do - data+=("$(get_primary_from_haproxy ${test_name}-haproxy-$i)") - done - if [ "${data[0]}" != "${data[1]}" -o "${data[1]}" != "${data[2]}" ]; then - echo "Not all haproxy pods point to same primary: 0: ${data[0]} 1: ${data[1]} 2: ${data[2]}" - exit 1 - fi diff --git a/e2e-tests/tests/haproxy/06-check-label-haproxy-primary.yaml b/e2e-tests/tests/haproxy/06-check-label-haproxy-primary.yaml deleted file mode 100644 index f06ba58b6..000000000 --- a/e2e-tests/tests/haproxy/06-check-label-haproxy-primary.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - primary_pod_from_label="$(get_primary_from_label)" - primary_pod_from_haproxy="$(get_primary_from_haproxy ${test_name}-haproxy-0)" - if [ "${primary_pod_from_label}" != "${primary_pod_from_haproxy}" ]; then - echo "Primary in k8s label (${primary_pod_from_label}) is not set to same pod as in haproxy (${primary_pod_from_haproxy})!" - exit 1 - fi diff --git a/e2e-tests/tests/haproxy/07-check-primary-failover.yaml b/e2e-tests/tests/haproxy/07-check-primary-failover.yaml deleted file mode 100644 index 89c979718..000000000 --- a/e2e-tests/tests/haproxy/07-check-primary-failover.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - primary_pod_from_label="$(get_primary_from_label)" - - kubectl -n "${NAMESPACE}" delete pod ${primary_pod_from_label} - sleep 3 - - data=() - for i in $(seq 0 2); do - data+=("$(get_primary_from_haproxy ${test_name}-haproxy-$i)") - done - if [ "${data[0]}" != "${data[1]}" -o "${data[1]}" != "${data[2]}" ]; then - echo "Not all haproxy pods point to same primary: 0: ${data[0]} 1: ${data[1]} 2: ${data[2]}" - exit 1 - fi - - primary_pod_from_label="$(get_primary_from_label)" - primary_pod_from_haproxy="$(get_primary_from_haproxy ${test_name}-haproxy-0)" - if [ "${primary_pod_from_label}" != "${primary_pod_from_haproxy}" ]; then - echo "Primary in k8s label (${primary_pod_from_label}) is not set to same pod as in haproxy (${primary_pod_from_haproxy})!" - exit 1 - fi - timeout: 60 diff --git a/e2e-tests/tests/haproxy/08-check-password-leak.yaml b/e2e-tests/tests/haproxy/08-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/haproxy/08-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/haproxy/09-assert.yaml b/e2e-tests/tests/haproxy/09-assert.yaml index e471a1ad0..6d1c8b49e 100644 --- a/e2e-tests/tests/haproxy/09-assert.yaml +++ b/e2e-tests/tests/haproxy/09-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: haproxy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: haproxy-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: haproxy finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: haproxy status: haproxy: {} mysql: diff --git a/e2e-tests/tests/haproxy/09-disable-haproxy.yaml b/e2e-tests/tests/haproxy/09-disable-haproxy.yaml index aa46b2b77..aae13b03c 100644 --- a/e2e-tests/tests/haproxy/09-disable-haproxy.yaml +++ b/e2e-tests/tests/haproxy/09-disable-haproxy.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: diff --git a/e2e-tests/tests/haproxy/chainsaw-test.yaml b/e2e-tests/tests/haproxy/chainsaw-test.yaml new file mode 100755 index 000000000..0a14343b7 --- /dev/null +++ b/e2e-tests/tests/haproxy/chainsaw-test.yaml @@ -0,0 +1,135 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: haproxy +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.allowUnsafeConfigurations=false' - \ + | yq eval '.spec.updateStrategy="RollingUpdate"' - \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P3306 -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -P3307 -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas --from-literal=${test_name}-haproxy-replicas=${data} + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ndata=()\nfor + i in $(seq 0 2); do\n\tdata+=(\"$(get_primary_from_haproxy ${test_name}-haproxy-$i)\")\ndone\nif + [ \"${data[0]}\" != \"${data[1]}\" -o \"${data[1]}\" != \"${data[2]}\" ]; + then\n echo \"Not all haproxy pods point to same primary: 0: ${data[0]} + 1: ${data[1]} 2: ${data[2]}\"\n exit 1\nfi" + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + primary_pod_from_label="$(get_primary_from_label)" + primary_pod_from_haproxy="$(get_primary_from_haproxy ${test_name}-haproxy-0)" + if [ "${primary_pod_from_label}" != "${primary_pod_from_haproxy}" ]; then + echo "Primary in k8s label (${primary_pod_from_label}) is not set to same pod as in haproxy (${primary_pod_from_haproxy})!" + exit 1 + fi + - name: step-07 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nprimary_pod_from_label=\"$(get_primary_from_label)\"\n\nkubectl + -n \"${NAMESPACE}\" delete pod ${primary_pod_from_label}\nsleep 3\n\ndata=()\nfor + i in $(seq 0 2); do\n\tdata+=(\"$(get_primary_from_haproxy ${test_name}-haproxy-$i)\")\ndone\nif + [ \"${data[0]}\" != \"${data[1]}\" -o \"${data[1]}\" != \"${data[2]}\" ]; + then\n echo \"Not all haproxy pods point to same primary: 0: ${data[0]} + 1: ${data[1]} 2: ${data[2]}\"\n exit 1\nfi\n\nprimary_pod_from_label=\"$(get_primary_from_label)\"\nprimary_pod_from_haproxy=\"$(get_primary_from_haproxy + ${test_name}-haproxy-0)\"\nif [ \"${primary_pod_from_label}\" != \"${primary_pod_from_haproxy}\" + ]; then\n echo \"Primary in k8s label (${primary_pod_from_label}) is not + set to same pod as in haproxy (${primary_pod_from_haproxy})!\"\n exit 1\nfi" + - name: step-08 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-09 + try: + - apply: + file: 09-disable-haproxy.yaml + - assert: + file: 09-assert.yaml + - error: + file: 09-errors.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/init-deploy/00-assert.yaml b/e2e-tests/tests/init-deploy/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/init-deploy/00-assert.yaml +++ b/e2e-tests/tests/init-deploy/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/init-deploy/00-deploy-operator.yaml b/e2e-tests/tests/init-deploy/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/init-deploy/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/init-deploy/01-assert.yaml b/e2e-tests/tests/init-deploy/01-assert.yaml index 3af6bb3c4..8536c1849 100644 --- a/e2e-tests/tests/init-deploy/01-assert.yaml +++ b/e2e-tests/tests/init-deploy/01-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: init-deploy-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: init-deploy-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: init-deploy-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: init-deploy finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: init-deploy status: haproxy: ready: 3 diff --git a/e2e-tests/tests/init-deploy/01-create-cluster.yaml b/e2e-tests/tests/init-deploy/01-create-cluster.yaml deleted file mode 100644 index 44a61e442..000000000 --- a/e2e-tests/tests/init-deploy/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/init-deploy/02-write-data.yaml b/e2e-tests/tests/init-deploy/02-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/init-deploy/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/init-deploy/03-assert.yaml b/e2e-tests/tests/init-deploy/03-assert.yaml index 084110451..2d99a3bfd 100644 --- a/e2e-tests/tests/init-deploy/03-assert.yaml +++ b/e2e-tests/tests/init-deploy/03-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 03-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 03-read-from-primary diff --git a/e2e-tests/tests/init-deploy/03-read-from-primary.yaml b/e2e-tests/tests/init-deploy/03-read-from-primary.yaml deleted file mode 100644 index e9f47d126..000000000 --- a/e2e-tests/tests/init-deploy/03-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/init-deploy/04-assert.yaml b/e2e-tests/tests/init-deploy/04-assert.yaml index 7f0cbff1d..c0f54f686 100644 --- a/e2e-tests/tests/init-deploy/04-assert.yaml +++ b/e2e-tests/tests/init-deploy/04-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-replicas data: init-deploy-mysql-0.init-deploy-mysql: "100500" init-deploy-mysql-1.init-deploy-mysql: "100500" init-deploy-mysql-2.init-deploy-mysql: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-replicas diff --git a/e2e-tests/tests/init-deploy/04-read-from-replicas.yaml b/e2e-tests/tests/init-deploy/04-read-from-replicas.yaml deleted file mode 100644 index 24bbbdb57..000000000 --- a/e2e-tests/tests/init-deploy/04-read-from-replicas.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}') - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas ${args} diff --git a/e2e-tests/tests/init-deploy/05-assert.yaml b/e2e-tests/tests/init-deploy/05-assert.yaml index 892d5799e..511d42e78 100644 --- a/e2e-tests/tests/init-deploy/05-assert.yaml +++ b/e2e-tests/tests/init-deploy/05-assert.yaml @@ -1,14 +1,10 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 05-check-orchestrator data: cluster: init-deploy-mysql-0.init-deploy-mysql:3306 instances: | init-deploy-mysql-0.init-deploy-mysql init-deploy-mysql-1.init-deploy-mysql init-deploy-mysql-2.init-deploy-mysql +kind: ConfigMap +metadata: + name: 05-check-orchestrator diff --git a/e2e-tests/tests/init-deploy/05-check-orchestrator.yaml b/e2e-tests/tests/init-deploy/05-check-orchestrator.yaml deleted file mode 100644 index 7b57c0f42..000000000 --- a/e2e-tests/tests/init-deploy/05-check-orchestrator.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - orc_host=$(get_orc_headless_fqdn $(get_cluster_name) 0) - cluster=$(run_curl "http://${orc_host}:3000/api/clusters/" | jq -r .[0] | sed "s/.${NAMESPACE}//g") - args="--from-literal=cluster=${cluster}" - - run_curl "http://${orc_host}:3000/api/cluster/${cluster}/" | jq -r .[].Key.Hostname | sed "s/.${NAMESPACE}//g" >"${TEMP_DIR}/instances" - args="${args} --from-file=instances=${TEMP_DIR}/instances" - - kubectl create configmap -n "${NAMESPACE}" 05-check-orchestrator ${args} diff --git a/e2e-tests/tests/init-deploy/06-check-password-leak.yaml b/e2e-tests/tests/init-deploy/06-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/init-deploy/06-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/init-deploy/chainsaw-test.yaml b/e2e-tests/tests/init-deploy/chainsaw-test.yaml new file mode 100755 index 000000000..d641a7396 --- /dev/null +++ b/e2e-tests/tests/init-deploy/chainsaw-test.yaml @@ -0,0 +1,109 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: init-deploy +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps $(get_cluster_name) -o jsonpath='{.spec.mysql.size}')\nfor + i in $(seq 0 $((size - 1))); do\n\thost=$(get_mysql_headless_fqdn $(get_cluster_name) + $i)\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h ${host} -uroot + -proot_password\")\n\targs=\"${args} --from-literal=${host}=${data}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 04-read-from-replicas ${args}" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + orc_host=$(get_orc_headless_fqdn $(get_cluster_name) 0) + cluster=$(run_curl "http://${orc_host}:3000/api/clusters/" | jq -r .[0] | sed "s/.${NAMESPACE}//g") + args="--from-literal=cluster=${cluster}" + + run_curl "http://${orc_host}:3000/api/cluster/${cluster}/" | jq -r .[].Key.Hostname | sed "s/.${NAMESPACE}//g" >"${TEMP_DIR}/instances" + args="${args} --from-file=instances=${TEMP_DIR}/instances" + + kubectl create configmap -n "${NAMESPACE}" 05-check-orchestrator ${args} + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/limits/00-assert.yaml b/e2e-tests/tests/limits/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/limits/00-assert.yaml +++ b/e2e-tests/tests/limits/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/limits/00-deploy-operator.yaml b/e2e-tests/tests/limits/00-deploy-operator.yaml deleted file mode 100644 index b4c10659e..000000000 --- a/e2e-tests/tests/limits/00-deploy-operator.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets diff --git a/e2e-tests/tests/limits/01-assert.yaml b/e2e-tests/tests/limits/01-assert.yaml index b40a120e4..751554bee 100644 --- a/e2e-tests/tests/limits/01-assert.yaml +++ b/e2e-tests/tests/limits/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 10 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/limits/01-create-cluster-no-limits.yaml b/e2e-tests/tests/limits/01-create-cluster-no-limits.yaml deleted file mode 100644 index 1c2866cfd..000000000 --- a/e2e-tests/tests/limits/01-create-cluster-no-limits.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - suffix="no-limits" - get_cr "${suffix}" \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval 'del(.spec."*".resources.limits)' - \ - | kubectl -n "${NAMESPACE}" apply -f - - wait_pod "${test_name}-${suffix}-mysql-0" - timeout: 180 diff --git a/e2e-tests/tests/limits/02-delete-cluster.yaml b/e2e-tests/tests/limits/02-delete-cluster.yaml deleted file mode 100644 index 18a7b73db..000000000 --- a/e2e-tests/tests/limits/02-delete-cluster.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr "no-limits" \ - | kubectl -n "${NAMESPACE}" delete -f - - timeout: 180 diff --git a/e2e-tests/tests/limits/03-assert.yaml b/e2e-tests/tests/limits/03-assert.yaml index 066ecd64e..974e606f2 100644 --- a/e2e-tests/tests/limits/03-assert.yaml +++ b/e2e-tests/tests/limits/03-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 10 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/limits/03-create-cluster-no-requests.yaml b/e2e-tests/tests/limits/03-create-cluster-no-requests.yaml deleted file mode 100644 index a92683118..000000000 --- a/e2e-tests/tests/limits/03-create-cluster-no-requests.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - suffix="no-requests" - get_cr "${suffix}" \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval 'del(.spec."*".resources.requests)' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - wait_pod "${test_name}-${suffix}-mysql-0" - timeout: 180 diff --git a/e2e-tests/tests/limits/04-delete-cluster.yaml b/e2e-tests/tests/limits/04-delete-cluster.yaml deleted file mode 100644 index 6a13ef780..000000000 --- a/e2e-tests/tests/limits/04-delete-cluster.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr "no-requests" \ - | kubectl -n "${NAMESPACE}" delete -f - - timeout: 180 diff --git a/e2e-tests/tests/limits/05-assert.yaml b/e2e-tests/tests/limits/05-assert.yaml index 9a33aed96..672992069 100644 --- a/e2e-tests/tests/limits/05-assert.yaml +++ b/e2e-tests/tests/limits/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 10 ---- apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/e2e-tests/tests/limits/05-create-cluster-no-resources.yaml b/e2e-tests/tests/limits/05-create-cluster-no-resources.yaml deleted file mode 100644 index 543d099af..000000000 --- a/e2e-tests/tests/limits/05-create-cluster-no-resources.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - suffix="no-resources" - get_cr "${suffix}" \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval 'del(.spec."*".resources.requests)' - \ - | yq eval 'del(.spec."*".resources.limits)' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - wait_pod "${test_name}-${suffix}-mysql-0" - timeout: 180 diff --git a/e2e-tests/tests/limits/06-delete-cluster.yaml b/e2e-tests/tests/limits/06-delete-cluster.yaml deleted file mode 100644 index 95e96bd75..000000000 --- a/e2e-tests/tests/limits/06-delete-cluster.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr "no-resources" \ - | kubectl -n "${NAMESPACE}" delete -f - - timeout: 180 diff --git a/e2e-tests/tests/limits/07-create-cluster-no-storage.yaml b/e2e-tests/tests/limits/07-create-cluster-no-storage.yaml deleted file mode 100644 index 2478cb1ff..000000000 --- a/e2e-tests/tests/limits/07-create-cluster-no-storage.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - suffix="no-storage" - get_cr "${suffix}" \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval 'del(.spec."*".volumeSpec)' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - timeout: 180 diff --git a/e2e-tests/tests/limits/chainsaw-test.yaml b/e2e-tests/tests/limits/chainsaw-test.yaml new file mode 100755 index 000000000..53180de7c --- /dev/null +++ b/e2e-tests/tests/limits/chainsaw-test.yaml @@ -0,0 +1,84 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: limits +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsuffix=\"no-limits\"\nget_cr + \"${suffix}\" \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n + \ | yq eval 'del(.spec.\"*\".resources.limits)' - \\\n\t| kubectl -n \"${NAMESPACE}\" + apply -f -\nwait_pod \"${test_name}-${suffix}-mysql-0\"" + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \"no-limits\" \\\n\t| kubectl -n \"${NAMESPACE}\" delete -f -" + - error: + file: 02-errors.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsuffix=\"no-requests\"\nget_cr + \"${suffix}\" \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n + \ | yq eval 'del(.spec.\"*\".resources.requests)' - \\\n\t| kubectl -n \"${NAMESPACE}\" + apply -f -\n\nwait_pod \"${test_name}-${suffix}-mysql-0\"" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \"no-requests\" \\\n\t| kubectl -n \"${NAMESPACE}\" delete -f -" + - error: + file: 04-errors.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsuffix=\"no-resources\"\nget_cr + \"${suffix}\" \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n + \ | yq eval 'del(.spec.\"*\".resources.requests)' - \\\n | yq eval 'del(.spec.\"*\".resources.limits)' + - \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -\n\nwait_pod \"${test_name}-${suffix}-mysql-0\"" + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \"no-resources\" \\\n\t| kubectl -n \"${NAMESPACE}\" delete -f -" + - error: + file: 06-errors.yaml + - name: step-07 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsuffix=\"no-storage\"\nget_cr + \"${suffix}\" \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n + \ | yq eval 'del(.spec.\"*\".volumeSpec)' - \\\n\t| kubectl -n \"${NAMESPACE}\" + apply -f -" + - error: + file: 07-errors.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/monitoring/00-assert.yaml b/e2e-tests/tests/monitoring/00-assert.yaml index 41a42ab02..011f26c95 100644 --- a/e2e-tests/tests/monitoring/00-assert.yaml +++ b/e2e-tests/tests/monitoring/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/monitoring/00-deploy-operator.yaml b/e2e-tests/tests/monitoring/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/monitoring/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/monitoring/01-assert.yaml b/e2e-tests/tests/monitoring/01-assert.yaml index c2400a569..9abf15aa7 100644 --- a/e2e-tests/tests/monitoring/01-assert.yaml +++ b/e2e-tests/tests/monitoring/01-assert.yaml @@ -1,20 +1,16 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: monitoring status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 1 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- -kind: Service apiVersion: v1 +kind: Service metadata: name: monitoring-service diff --git a/e2e-tests/tests/monitoring/01-deploy-pmm-server.yaml b/e2e-tests/tests/monitoring/01-deploy-pmm-server.yaml deleted file mode 100644 index 50713e40f..000000000 --- a/e2e-tests/tests/monitoring/01-deploy-pmm-server.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - deploy_pmm_server - sleep 30 # wait for PMM Server to start - - API_KEY=$(get_pmm_api_key) - kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch '{"stringData": {"pmmserverkey": '$API_KEY'}}' - timeout: 120 diff --git a/e2e-tests/tests/monitoring/02-assert.yaml b/e2e-tests/tests/monitoring/02-assert.yaml index 2ebeb2c96..bffc52cb0 100644 --- a/e2e-tests/tests/monitoring/02-assert.yaml +++ b/e2e-tests/tests/monitoring/02-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: monitoring-mysql spec: @@ -13,115 +9,115 @@ spec: - name: mysql - name: xtrabackup - name: pt-heartbeat - - name: pmm-client - env: - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.namespace - - name: CLUSTER_NAME - value: monitoring - - name: CLIENT_PORT_LISTEN - value: "7777" - - name: CLIENT_PORT_MIN - value: "30100" - - name: CLIENT_PORT_MAX - value: "30105" - - name: PMM_AGENT_SERVER_ADDRESS - value: monitoring-service - - name: PMM_AGENT_SERVER_USERNAME - value: api_key - - name: PMM_AGENT_SERVER_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_SERVER - value: monitoring-service - - name: PMM_USER - value: api_key - - name: PMM_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_AGENT_LISTEN_PORT - value: "7777" - - name: PMM_AGENT_PORTS_MIN - value: "30100" - - name: PMM_AGENT_PORTS_MAX - value: "30105" - - name: PMM_AGENT_CONFIG_FILE - value: /usr/local/percona/pmm2/config/pmm-agent.yaml - - name: PMM_AGENT_SERVER_INSECURE_TLS - value: "1" - - name: PMM_AGENT_LISTEN_ADDRESS - value: 0.0.0.0 - - name: PMM_AGENT_SETUP_NODE_NAME - value: $(POD_NAMESPACE)-$(POD_NAME) - - name: PMM_AGENT_SETUP_METRICS_MODE - value: push - - name: PMM_AGENT_SETUP - value: "1" - - name: PMM_AGENT_SETUP_FORCE - value: "1" - - name: PMM_AGENT_SETUP_NODE_TYPE - value: container - - name: PMM_AGENT_PRERUN_SCRIPT - value: /opt/percona/pmm-prerun.sh - - name: PMM_AGENT_SIDECAR - value: "true" - - name: PMM_AGENT_SIDECAR_SLEEP - value: "5" - - name: DB_CLUSTER - value: monitoring - - name: DB_TYPE - value: mysql - - name: DB_HOST - value: localhost - - name: DB_PORT - value: "33062" - - name: DB_USER - value: monitor - - name: DB_PASSWORD - valueFrom: - secretKeyRef: - key: monitor - name: internal-monitoring - - name: DB_ARGS - value: --query-source=perfschema + - env: + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: CLUSTER_NAME + value: monitoring + - name: CLIENT_PORT_LISTEN + value: "7777" + - name: CLIENT_PORT_MIN + value: "30100" + - name: CLIENT_PORT_MAX + value: "30105" + - name: PMM_AGENT_SERVER_ADDRESS + value: monitoring-service + - name: PMM_AGENT_SERVER_USERNAME + value: api_key + - name: PMM_AGENT_SERVER_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_SERVER + value: monitoring-service + - name: PMM_USER + value: api_key + - name: PMM_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_AGENT_LISTEN_PORT + value: "7777" + - name: PMM_AGENT_PORTS_MIN + value: "30100" + - name: PMM_AGENT_PORTS_MAX + value: "30105" + - name: PMM_AGENT_CONFIG_FILE + value: /usr/local/percona/pmm2/config/pmm-agent.yaml + - name: PMM_AGENT_SERVER_INSECURE_TLS + value: "1" + - name: PMM_AGENT_LISTEN_ADDRESS + value: 0.0.0.0 + - name: PMM_AGENT_SETUP_NODE_NAME + value: $(POD_NAMESPACE)-$(POD_NAME) + - name: PMM_AGENT_SETUP_METRICS_MODE + value: push + - name: PMM_AGENT_SETUP + value: "1" + - name: PMM_AGENT_SETUP_FORCE + value: "1" + - name: PMM_AGENT_SETUP_NODE_TYPE + value: container + - name: PMM_AGENT_PRERUN_SCRIPT + value: /opt/percona/pmm-prerun.sh + - name: PMM_AGENT_SIDECAR + value: "true" + - name: PMM_AGENT_SIDECAR_SLEEP + value: "5" + - name: DB_CLUSTER + value: monitoring + - name: DB_TYPE + value: mysql + - name: DB_HOST + value: localhost + - name: DB_PORT + value: "33062" + - name: DB_USER + value: monitor + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: monitor + name: internal-monitoring + - name: DB_ARGS + value: --query-source=perfschema + name: pmm-client status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: monitoring-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: monitoring finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: monitoring status: mysql: ready: 3 @@ -143,109 +139,109 @@ spec: containers: - name: haproxy - name: mysql-monit - - name: pmm-client - env: - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.namespace - - name: CLUSTER_NAME - value: monitoring - - name: CLIENT_PORT_LISTEN - value: "7777" - - name: CLIENT_PORT_MIN - value: "30100" - - name: CLIENT_PORT_MAX - value: "30105" - - name: PMM_AGENT_SERVER_ADDRESS - value: monitoring-service - - name: PMM_AGENT_SERVER_USERNAME - value: api_key - - name: PMM_AGENT_SERVER_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_SERVER - value: monitoring-service - - name: PMM_USER - value: api_key - - name: PMM_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_AGENT_LISTEN_PORT - value: "7777" - - name: PMM_AGENT_PORTS_MIN - value: "30100" - - name: PMM_AGENT_PORTS_MAX - value: "30105" - - name: PMM_AGENT_CONFIG_FILE - value: /usr/local/percona/pmm2/config/pmm-agent.yaml - - name: PMM_AGENT_SERVER_INSECURE_TLS - value: "1" - - name: PMM_AGENT_LISTEN_ADDRESS - value: 0.0.0.0 - - name: PMM_AGENT_SETUP_NODE_NAME - value: $(POD_NAMESPACE)-$(POD_NAME) - - name: PMM_AGENT_SETUP_METRICS_MODE - value: push - - name: PMM_AGENT_SETUP - value: "1" - - name: PMM_AGENT_SETUP_FORCE - value: "1" - - name: PMM_AGENT_SETUP_NODE_TYPE - value: container - - name: PMM_AGENT_PRERUN_SCRIPT - value: /opt/percona/pmm-prerun.sh - - name: PMM_AGENT_SIDECAR - value: "true" - - name: PMM_AGENT_SIDECAR_SLEEP - value: "5" - - name: DB_CLUSTER - value: monitoring - - name: DB_TYPE - value: haproxy - - name: DB_HOST - value: localhost - - name: DB_PORT - value: "33062" - - name: DB_USER - value: monitor - - name: DB_PASSWORD - valueFrom: - secretKeyRef: - key: monitor - name: internal-monitoring - - name: DB_ARGS - value: --query-source=perfschema - - name: PMM_ADMIN_CUSTOM_PARAMS - value: --listen-port=8404 + - env: + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: CLUSTER_NAME + value: monitoring + - name: CLIENT_PORT_LISTEN + value: "7777" + - name: CLIENT_PORT_MIN + value: "30100" + - name: CLIENT_PORT_MAX + value: "30105" + - name: PMM_AGENT_SERVER_ADDRESS + value: monitoring-service + - name: PMM_AGENT_SERVER_USERNAME + value: api_key + - name: PMM_AGENT_SERVER_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_SERVER + value: monitoring-service + - name: PMM_USER + value: api_key + - name: PMM_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_AGENT_LISTEN_PORT + value: "7777" + - name: PMM_AGENT_PORTS_MIN + value: "30100" + - name: PMM_AGENT_PORTS_MAX + value: "30105" + - name: PMM_AGENT_CONFIG_FILE + value: /usr/local/percona/pmm2/config/pmm-agent.yaml + - name: PMM_AGENT_SERVER_INSECURE_TLS + value: "1" + - name: PMM_AGENT_LISTEN_ADDRESS + value: 0.0.0.0 + - name: PMM_AGENT_SETUP_NODE_NAME + value: $(POD_NAMESPACE)-$(POD_NAME) + - name: PMM_AGENT_SETUP_METRICS_MODE + value: push + - name: PMM_AGENT_SETUP + value: "1" + - name: PMM_AGENT_SETUP_FORCE + value: "1" + - name: PMM_AGENT_SETUP_NODE_TYPE + value: container + - name: PMM_AGENT_PRERUN_SCRIPT + value: /opt/percona/pmm-prerun.sh + - name: PMM_AGENT_SIDECAR + value: "true" + - name: PMM_AGENT_SIDECAR_SLEEP + value: "5" + - name: DB_CLUSTER + value: monitoring + - name: DB_TYPE + value: haproxy + - name: DB_HOST + value: localhost + - name: DB_PORT + value: "33062" + - name: DB_USER + value: monitor + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: monitor + name: internal-monitoring + - name: DB_ARGS + value: --query-source=perfschema + - name: PMM_ADMIN_CUSTOM_PARAMS + value: --listen-port=8404 imagePullPolicy: Always + name: pmm-client ports: - - containerPort: 7777 - protocol: TCP - - containerPort: 30100 - protocol: TCP - - containerPort: 30101 - protocol: TCP - - containerPort: 30102 - protocol: TCP - - containerPort: 30103 - protocol: TCP - - containerPort: 30104 - protocol: TCP - - containerPort: 30105 - protocol: TCP - - containerPort: 8404 - protocol: TCP + - containerPort: 7777 + protocol: TCP + - containerPort: 30100 + protocol: TCP + - containerPort: 30101 + protocol: TCP + - containerPort: 30102 + protocol: TCP + - containerPort: 30103 + protocol: TCP + - containerPort: 30104 + protocol: TCP + - containerPort: 30105 + protocol: TCP + - containerPort: 8404 + protocol: TCP resources: requests: cpu: 300m diff --git a/e2e-tests/tests/monitoring/02-create-cluster.yaml b/e2e-tests/tests/monitoring/02-create-cluster.yaml deleted file mode 100644 index eab95f741..000000000 --- a/e2e-tests/tests/monitoring/02-create-cluster.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.pmm.enabled = true' - \ - | yq eval '.spec.proxy.haproxy.enabled = true' - \ - | yq eval '.spec.proxy.haproxy.expose.type = "LoadBalancer"' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 10 diff --git a/e2e-tests/tests/monitoring/03-assert.yaml b/e2e-tests/tests/monitoring/03-assert.yaml index 0d8982c96..1292985fd 100644 --- a/e2e-tests/tests/monitoring/03-assert.yaml +++ b/e2e-tests/tests/monitoring/03-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: monitoring-mysql spec: @@ -13,114 +9,114 @@ spec: - name: mysql - name: xtrabackup - name: pt-heartbeat - - name: pmm-client - env: - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.namespace - - name: CLUSTER_NAME - value: monitoring - - name: CLIENT_PORT_LISTEN - value: "7777" - - name: CLIENT_PORT_MIN - value: "30100" - - name: CLIENT_PORT_MAX - value: "30105" - - name: PMM_AGENT_SERVER_ADDRESS - value: monitoring-service - - name: PMM_AGENT_SERVER_USERNAME - value: api_key - - name: PMM_AGENT_SERVER_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_SERVER - value: monitoring-service - - name: PMM_USER - value: api_key - - name: PMM_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_AGENT_LISTEN_PORT - value: "7777" - - name: PMM_AGENT_PORTS_MIN - value: "30100" - - name: PMM_AGENT_PORTS_MAX - value: "30105" - - name: PMM_AGENT_CONFIG_FILE - value: /usr/local/percona/pmm2/config/pmm-agent.yaml - - name: PMM_AGENT_SERVER_INSECURE_TLS - value: "1" - - name: PMM_AGENT_LISTEN_ADDRESS - value: 0.0.0.0 - - name: PMM_AGENT_SETUP_NODE_NAME - value: $(POD_NAMESPACE)-$(POD_NAME) - - name: PMM_AGENT_SETUP_METRICS_MODE - value: push - - name: PMM_AGENT_SETUP - value: "1" - - name: PMM_AGENT_SETUP_FORCE - value: "1" - - name: PMM_AGENT_SETUP_NODE_TYPE - value: container - - name: PMM_AGENT_PRERUN_SCRIPT - value: /opt/percona/pmm-prerun.sh - - name: PMM_AGENT_SIDECAR - value: "true" - - name: PMM_AGENT_SIDECAR_SLEEP - value: "5" - - name: DB_CLUSTER - value: monitoring - - name: DB_TYPE - value: mysql - - name: DB_HOST - value: localhost - - name: DB_PORT - value: "33062" - - name: DB_USER - value: monitor - - name: DB_PASSWORD - valueFrom: - secretKeyRef: - key: monitor - name: internal-monitoring - - name: DB_ARGS - value: --query-source=perfschema + - env: + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: CLUSTER_NAME + value: monitoring + - name: CLIENT_PORT_LISTEN + value: "7777" + - name: CLIENT_PORT_MIN + value: "30100" + - name: CLIENT_PORT_MAX + value: "30105" + - name: PMM_AGENT_SERVER_ADDRESS + value: monitoring-service + - name: PMM_AGENT_SERVER_USERNAME + value: api_key + - name: PMM_AGENT_SERVER_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_SERVER + value: monitoring-service + - name: PMM_USER + value: api_key + - name: PMM_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_AGENT_LISTEN_PORT + value: "7777" + - name: PMM_AGENT_PORTS_MIN + value: "30100" + - name: PMM_AGENT_PORTS_MAX + value: "30105" + - name: PMM_AGENT_CONFIG_FILE + value: /usr/local/percona/pmm2/config/pmm-agent.yaml + - name: PMM_AGENT_SERVER_INSECURE_TLS + value: "1" + - name: PMM_AGENT_LISTEN_ADDRESS + value: 0.0.0.0 + - name: PMM_AGENT_SETUP_NODE_NAME + value: $(POD_NAMESPACE)-$(POD_NAME) + - name: PMM_AGENT_SETUP_METRICS_MODE + value: push + - name: PMM_AGENT_SETUP + value: "1" + - name: PMM_AGENT_SETUP_FORCE + value: "1" + - name: PMM_AGENT_SETUP_NODE_TYPE + value: container + - name: PMM_AGENT_PRERUN_SCRIPT + value: /opt/percona/pmm-prerun.sh + - name: PMM_AGENT_SIDECAR + value: "true" + - name: PMM_AGENT_SIDECAR_SLEEP + value: "5" + - name: DB_CLUSTER + value: monitoring + - name: DB_TYPE + value: mysql + - name: DB_HOST + value: localhost + - name: DB_PORT + value: "33062" + - name: DB_USER + value: monitor + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: monitor + name: internal-monitoring + - name: DB_ARGS + value: --query-source=perfschema + name: pmm-client status: + collisionCount: 0 observedGeneration: 2 - replicas: 3 readyReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: monitoring-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: monitoring finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: monitoring status: mysql: ready: 3 @@ -142,109 +138,109 @@ spec: containers: - name: haproxy - name: mysql-monit - - name: pmm-client - env: - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.namespace - - name: CLUSTER_NAME - value: monitoring - - name: CLIENT_PORT_LISTEN - value: "7777" - - name: CLIENT_PORT_MIN - value: "30100" - - name: CLIENT_PORT_MAX - value: "30105" - - name: PMM_AGENT_SERVER_ADDRESS - value: monitoring-service - - name: PMM_AGENT_SERVER_USERNAME - value: api_key - - name: PMM_AGENT_SERVER_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_SERVER - value: monitoring-service - - name: PMM_USER - value: api_key - - name: PMM_PASSWORD - valueFrom: - secretKeyRef: - key: pmmserverkey - name: internal-monitoring - - name: PMM_AGENT_LISTEN_PORT - value: "7777" - - name: PMM_AGENT_PORTS_MIN - value: "30100" - - name: PMM_AGENT_PORTS_MAX - value: "30105" - - name: PMM_AGENT_CONFIG_FILE - value: /usr/local/percona/pmm2/config/pmm-agent.yaml - - name: PMM_AGENT_SERVER_INSECURE_TLS - value: "1" - - name: PMM_AGENT_LISTEN_ADDRESS - value: 0.0.0.0 - - name: PMM_AGENT_SETUP_NODE_NAME - value: $(POD_NAMESPACE)-$(POD_NAME) - - name: PMM_AGENT_SETUP_METRICS_MODE - value: push - - name: PMM_AGENT_SETUP - value: "1" - - name: PMM_AGENT_SETUP_FORCE - value: "1" - - name: PMM_AGENT_SETUP_NODE_TYPE - value: container - - name: PMM_AGENT_PRERUN_SCRIPT - value: /opt/percona/pmm-prerun.sh - - name: PMM_AGENT_SIDECAR - value: "true" - - name: PMM_AGENT_SIDECAR_SLEEP - value: "5" - - name: DB_CLUSTER - value: monitoring - - name: DB_TYPE - value: haproxy - - name: DB_HOST - value: localhost - - name: DB_PORT - value: "33062" - - name: DB_USER - value: monitor - - name: DB_PASSWORD - valueFrom: - secretKeyRef: - key: monitor - name: internal-monitoring - - name: DB_ARGS - value: --query-source=perfschema - - name: PMM_ADMIN_CUSTOM_PARAMS - value: --listen-port=8404 + - env: + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: CLUSTER_NAME + value: monitoring + - name: CLIENT_PORT_LISTEN + value: "7777" + - name: CLIENT_PORT_MIN + value: "30100" + - name: CLIENT_PORT_MAX + value: "30105" + - name: PMM_AGENT_SERVER_ADDRESS + value: monitoring-service + - name: PMM_AGENT_SERVER_USERNAME + value: api_key + - name: PMM_AGENT_SERVER_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_SERVER + value: monitoring-service + - name: PMM_USER + value: api_key + - name: PMM_PASSWORD + valueFrom: + secretKeyRef: + key: pmmserverkey + name: internal-monitoring + - name: PMM_AGENT_LISTEN_PORT + value: "7777" + - name: PMM_AGENT_PORTS_MIN + value: "30100" + - name: PMM_AGENT_PORTS_MAX + value: "30105" + - name: PMM_AGENT_CONFIG_FILE + value: /usr/local/percona/pmm2/config/pmm-agent.yaml + - name: PMM_AGENT_SERVER_INSECURE_TLS + value: "1" + - name: PMM_AGENT_LISTEN_ADDRESS + value: 0.0.0.0 + - name: PMM_AGENT_SETUP_NODE_NAME + value: $(POD_NAMESPACE)-$(POD_NAME) + - name: PMM_AGENT_SETUP_METRICS_MODE + value: push + - name: PMM_AGENT_SETUP + value: "1" + - name: PMM_AGENT_SETUP_FORCE + value: "1" + - name: PMM_AGENT_SETUP_NODE_TYPE + value: container + - name: PMM_AGENT_PRERUN_SCRIPT + value: /opt/percona/pmm-prerun.sh + - name: PMM_AGENT_SIDECAR + value: "true" + - name: PMM_AGENT_SIDECAR_SLEEP + value: "5" + - name: DB_CLUSTER + value: monitoring + - name: DB_TYPE + value: haproxy + - name: DB_HOST + value: localhost + - name: DB_PORT + value: "33062" + - name: DB_USER + value: monitor + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + key: monitor + name: internal-monitoring + - name: DB_ARGS + value: --query-source=perfschema + - name: PMM_ADMIN_CUSTOM_PARAMS + value: --listen-port=8404 imagePullPolicy: Always + name: pmm-client ports: - - containerPort: 7777 - protocol: TCP - - containerPort: 30100 - protocol: TCP - - containerPort: 30101 - protocol: TCP - - containerPort: 30102 - protocol: TCP - - containerPort: 30103 - protocol: TCP - - containerPort: 30104 - protocol: TCP - - containerPort: 30105 - protocol: TCP - - containerPort: 8404 - protocol: TCP + - containerPort: 7777 + protocol: TCP + - containerPort: 30100 + protocol: TCP + - containerPort: 30101 + protocol: TCP + - containerPort: 30102 + protocol: TCP + - containerPort: 30103 + protocol: TCP + - containerPort: 30104 + protocol: TCP + - containerPort: 30105 + protocol: TCP + - containerPort: 8404 + protocol: TCP resources: requests: cpu: 300m diff --git a/e2e-tests/tests/monitoring/03-rotate-pmm-key.yaml b/e2e-tests/tests/monitoring/03-rotate-pmm-key.yaml deleted file mode 100644 index d5b20f0e6..000000000 --- a/e2e-tests/tests/monitoring/03-rotate-pmm-key.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - # add new PMM API key to secret - API_KEY_NEW=$(get_pmm_api_key "operator-new") - kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch '{"stringData": {"pmmserverkey": '$API_KEY_NEW'}}' - - # delete old PMM key - delete_pmm_api_key "operator" - sleep 10 - timeout: 120 diff --git a/e2e-tests/tests/monitoring/04-check-metrics.yaml b/e2e-tests/tests/monitoring/04-check-metrics.yaml deleted file mode 100644 index 509caff8b..000000000 --- a/e2e-tests/tests/monitoring/04-check-metrics.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - sleep 70 # we should wait more than one minute because `get_metric_values` gets data for the last 60 seconds - - API_KEY=$(kubectl get secret internal-monitoring -o jsonpath='{.data.pmmserverkey}' -n "${NAMESPACE}" | base64 --decode) - - for i in $(seq 0 2); do - get_metric_values node_boot_time_seconds ${NAMESPACE}-$(get_cluster_name)-mysql-${i} api_key:$API_KEY - get_metric_values mysql_global_status_uptime ${NAMESPACE}-$(get_cluster_name)-mysql-${i} api_key:$API_KEY - done - - sleep 90 # wait for QAN - - get_qan20_values monitoring-mysql-0 api_key:$API_KEY - - haproxy_svc=$(get_service_ip "monitoring-haproxy") - http_code=$(curl -s -o /dev/null -w "%{http_code}" http://${haproxy_svc}:8404/metrics) - if [[ $http_code != 200 ]]; then - echo "Error: http code is $http_code" - exit 1 - fi - timeout: 300 diff --git a/e2e-tests/tests/monitoring/05-check-password-leak.yaml b/e2e-tests/tests/monitoring/05-check-password-leak.yaml deleted file mode 100644 index 35fbdbee0..000000000 --- a/e2e-tests/tests/monitoring/05-check-password-leak.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - check_passwords_leak diff --git a/e2e-tests/tests/monitoring/chainsaw-test.yaml b/e2e-tests/tests/monitoring/chainsaw-test.yaml new file mode 100755 index 000000000..56de7c709 --- /dev/null +++ b/e2e-tests/tests/monitoring/chainsaw-test.yaml @@ -0,0 +1,110 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: monitoring +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + deploy_pmm_server + sleep 30 # wait for PMM Server to start + + API_KEY=$(get_pmm_api_key) + kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch '{"stringData": {"pmmserverkey": '$API_KEY'}}' + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n\t| yq eval '.spec.pmm.enabled + = true' - \\\n\t| yq eval '.spec.proxy.haproxy.enabled = true' - \\\n\t| + yq eval '.spec.proxy.haproxy.expose.type = \"LoadBalancer\"' - \\\n\t| kubectl + -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + # add new PMM API key to secret + API_KEY_NEW=$(get_pmm_api_key "operator-new") + kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch '{"stringData": {"pmmserverkey": '$API_KEY_NEW'}}' + + # delete old PMM key + delete_pmm_api_key "operator" + sleep 10 + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + sleep 70 # we should wait more than one minute because `get_metric_values` gets data for the last 60 seconds + + API_KEY=$(kubectl get secret internal-monitoring -o jsonpath='{.data.pmmserverkey}' -n "${NAMESPACE}" | base64 --decode) + + for i in $(seq 0 2); do + get_metric_values node_boot_time_seconds ${NAMESPACE}-$(get_cluster_name)-mysql-${i} api_key:$API_KEY + get_metric_values mysql_global_status_uptime ${NAMESPACE}-$(get_cluster_name)-mysql-${i} api_key:$API_KEY + done + + sleep 90 # wait for QAN + + get_qan20_values monitoring-mysql-0 api_key:$API_KEY + + haproxy_svc=$(get_service_ip "monitoring-haproxy") + http_code=$(curl -s -o /dev/null -w "%{http_code}" http://${haproxy_svc}:8404/metrics) + if [[ $http_code != 200 ]]; then + echo "Error: http code is $http_code" + exit 1 + fi + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + check_passwords_leak + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/one-pod/00-assert.yaml b/e2e-tests/tests/one-pod/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/one-pod/00-assert.yaml +++ b/e2e-tests/tests/one-pod/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/one-pod/00-deploy-operator.yaml b/e2e-tests/tests/one-pod/00-deploy-operator.yaml deleted file mode 100644 index 273c0cc4c..000000000 --- a/e2e-tests/tests/one-pod/00-deploy-operator.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - apply_s3_storage_secrets - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client - deploy_minio - timeout: 300 diff --git a/e2e-tests/tests/one-pod/01-assert.yaml b/e2e-tests/tests/one-pod/01-assert.yaml index af6d9793c..85ce6ccf3 100644 --- a/e2e-tests/tests/one-pod/01-assert.yaml +++ b/e2e-tests/tests/one-pod/01-assert.yaml @@ -1,42 +1,38 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 240 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: one-pod-mysql status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 1 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: one-pod-orc status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 1 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: one-pod-haproxy status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 1 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL diff --git a/e2e-tests/tests/one-pod/01-create-cluster.yaml b/e2e-tests/tests/one-pod/01-create-cluster.yaml deleted file mode 100644 index 86781403b..000000000 --- a/e2e-tests/tests/one-pod/01-create-cluster.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.allowUnsafeConfigurations=true' - \ - | yq eval '.spec.mysql.size=1' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=1' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=1' - \ - | yq eval '.spec.backup.storages.minio.type="s3"' - \ - | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ - | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ - | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ - | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/one-pod/02-write-data.yaml b/e2e-tests/tests/one-pod/02-write-data.yaml deleted file mode 100644 index 6c5de746c..000000000 --- a/e2e-tests/tests/one-pod/02-write-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - sleep 5 - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/one-pod/03-assert.yaml b/e2e-tests/tests/one-pod/03-assert.yaml index 62c2525df..b1e43be09 100644 --- a/e2e-tests/tests/one-pod/03-assert.yaml +++ b/e2e-tests/tests/one-pod/03-assert.yaml @@ -1,9 +1,5 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: PerconaServerMySQLBackup apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLBackup metadata: name: one-pod-minio status: diff --git a/e2e-tests/tests/one-pod/04-assert.yaml b/e2e-tests/tests/one-pod/04-assert.yaml index c00f03954..9b3c39cee 100644 --- a/e2e-tests/tests/one-pod/04-assert.yaml +++ b/e2e-tests/tests/one-pod/04-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-delete-data-minio data: data: "" +kind: ConfigMap +metadata: + name: 04-delete-data-minio diff --git a/e2e-tests/tests/one-pod/04-delete-data.yaml b/e2e-tests/tests/one-pod/04-delete-data.yaml deleted file mode 100644 index ec00d25a9..000000000 --- a/e2e-tests/tests/one-pod/04-delete-data.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "TRUNCATE TABLE myDB.myTable" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 04-delete-data-minio --from-literal=data="${data}" diff --git a/e2e-tests/tests/one-pod/05-assert.yaml b/e2e-tests/tests/one-pod/05-assert.yaml index 4abeae36d..2b2019868 100644 --- a/e2e-tests/tests/one-pod/05-assert.yaml +++ b/e2e-tests/tests/one-pod/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: @@ -20,8 +16,8 @@ status: state: ready state: ready --- -kind: PerconaServerMySQLRestore apiVersion: ps.percona.com/v1alpha1 +kind: PerconaServerMySQLRestore metadata: name: one-pod-restore-minio status: diff --git a/e2e-tests/tests/one-pod/06-assert.yaml b/e2e-tests/tests/one-pod/06-assert.yaml index 8b09bfd34..778cf8678 100644 --- a/e2e-tests/tests/one-pod/06-assert.yaml +++ b/e2e-tests/tests/one-pod/06-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 06-read-data-minio data: data: "100500" +kind: ConfigMap +metadata: + name: 06-read-data-minio --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: one-pod-mysql status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 3 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: one-pod-orc status: + collisionCount: 0 + currentReplicas: 1 observedGeneration: 3 - replicas: 1 readyReplicas: 1 - currentReplicas: 1 + replicas: 1 updatedReplicas: 1 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL diff --git a/e2e-tests/tests/one-pod/06-read-data.yaml b/e2e-tests/tests/one-pod/06-read-data.yaml deleted file mode 100644 index b3d9bf774..000000000 --- a/e2e-tests/tests/one-pod/06-read-data.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - sleep 5 - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio --from-literal=data="${data}" diff --git a/e2e-tests/tests/one-pod/chainsaw-test.yaml b/e2e-tests/tests/one-pod/chainsaw-test.yaml new file mode 100755 index 000000000..932586996 --- /dev/null +++ b/e2e-tests/tests/one-pod/chainsaw-test.yaml @@ -0,0 +1,100 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: one-pod +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + apply_s3_storage_secrets + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + deploy_minio + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.allowUnsafeConfigurations=true' - \ + | yq eval '.spec.mysql.size=1' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=1' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=1' - \ + | yq eval '.spec.backup.storages.minio.type="s3"' - \ + | yq eval '.spec.backup.storages.minio.s3.bucket="operator-testing"' - \ + | yq eval '.spec.backup.storages.minio.s3.credentialsSecret="minio-secret"' - \ + | yq eval '.spec.backup.storages.minio.s3.endpointUrl="http://minio-service:9000"' - \ + | yq eval '.spec.backup.storages.minio.s3.region="us-east-1"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsleep + 5\n\nrun_mysql \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE + IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc + $(get_cluster_name)) -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT + myDB.myTable (id) VALUES (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"" + - name: step-03 + try: + - apply: + file: 03-create-backup-minio.yaml + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"TRUNCATE TABLE myDB.myTable\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\ndata=$(run_mysql \"SELECT * FROM myDB.myTable\" + \"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\")\nkubectl + create configmap -n \"${NAMESPACE}\" 04-delete-data-minio --from-literal=data=\"${data}\"" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - apply: + file: 05-restore-from-minio.yaml + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + sleep 5 + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 06-read-data-minio --from-literal=data="${data}" + - assert: + file: 06-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/operator-self-healing/00-assert.yaml b/e2e-tests/tests/operator-self-healing/00-assert.yaml index d9146fe1b..b028a4c22 100644 --- a/e2e-tests/tests/operator-self-healing/00-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -16,11 +12,3 @@ spec: - ps singular: perconaservermysql scope: Namespaced ---- -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -metadata: - name: check-operator-deploy-status -timeout: 120 -commands: - - script: kubectl assert exist-enhanced deployment percona-server-mysql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 diff --git a/e2e-tests/tests/operator-self-healing/00-deploy-operator.yaml b/e2e-tests/tests/operator-self-healing/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/operator-self-healing/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/operator-self-healing/01-assert.yaml b/e2e-tests/tests/operator-self-healing/01-assert.yaml index 253d7158f..e457a94fe 100644 --- a/e2e-tests/tests/operator-self-healing/01-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 240 ---- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/e2e-tests/tests/operator-self-healing/01-deploy-chaos-mesh.yaml b/e2e-tests/tests/operator-self-healing/01-deploy-chaos-mesh.yaml deleted file mode 100644 index 2fcde5027..000000000 --- a/e2e-tests/tests/operator-self-healing/01-deploy-chaos-mesh.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - deploy_chaos_mesh diff --git a/e2e-tests/tests/operator-self-healing/02-assert.yaml b/e2e-tests/tests/operator-self-healing/02-assert.yaml index 143e658f6..1ba4ededc 100644 --- a/e2e-tests/tests/operator-self-healing/02-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/02-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: operator-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: operator-self-healing status: haproxy: ready: 3 diff --git a/e2e-tests/tests/operator-self-healing/02-create-cluster.yaml b/e2e-tests/tests/operator-self-healing/02-create-cluster.yaml deleted file mode 100644 index 3dd3dea43..000000000 --- a/e2e-tests/tests/operator-self-healing/02-create-cluster.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/operator-self-healing/03-write-data.yaml b/e2e-tests/tests/operator-self-healing/03-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/operator-self-healing/03-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/operator-self-healing/04-assert.yaml b/e2e-tests/tests/operator-self-healing/04-assert.yaml index 8a8037060..6b066ed1a 100644 --- a/e2e-tests/tests/operator-self-healing/04-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/04-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-primary diff --git a/e2e-tests/tests/operator-self-healing/04-read-from-primary.yaml b/e2e-tests/tests/operator-self-healing/04-read-from-primary.yaml deleted file mode 100644 index 274332522..000000000 --- a/e2e-tests/tests/operator-self-healing/04-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/operator-self-healing/05-assert.yaml b/e2e-tests/tests/operator-self-healing/05-assert.yaml index d9146fe1b..b028a4c22 100644 --- a/e2e-tests/tests/operator-self-healing/05-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -16,11 +12,3 @@ spec: - ps singular: perconaservermysql scope: Namespaced ---- -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -metadata: - name: check-operator-deploy-status -timeout: 120 -commands: - - script: kubectl assert exist-enhanced deployment percona-server-mysql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 diff --git a/e2e-tests/tests/operator-self-healing/05-kill-pod.yaml b/e2e-tests/tests/operator-self-healing/05-kill-pod.yaml deleted file mode 100644 index 7151998d3..000000000 --- a/e2e-tests/tests/operator-self-healing/05-kill-pod.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - init_pod=$(get_operator_pod) - kill_pods "${OPERATOR_NS:-$NAMESPACE}" "pod" "$init_pod" "" "operator" - sleep 10 # wait a bit for pod to be killed - wait_deployment percona-server-mysql-operator "${OPERATOR_NS:-$NAMESPACE}" - - if [ "$init_pod" == "$(get_operator_pod)" ]; then - echo "operator pod was not killed! something went wrong." - exit 1 - fi diff --git a/e2e-tests/tests/operator-self-healing/06-assert.yaml b/e2e-tests/tests/operator-self-healing/06-assert.yaml index f5a696df9..cdd0fae2a 100644 --- a/e2e-tests/tests/operator-self-healing/06-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/06-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-haproxy status: + collisionCount: 0 + currentReplicas: 5 observedGeneration: 2 - replicas: 5 readyReplicas: 5 - currentReplicas: 5 + replicas: 5 updatedReplicas: 5 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: operator-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: operator-self-healing status: haproxy: ready: 5 diff --git a/e2e-tests/tests/operator-self-healing/06-scale-up.yaml b/e2e-tests/tests/operator-self-healing/06-scale-up.yaml deleted file mode 100644 index aaa7cdb70..000000000 --- a/e2e-tests/tests/operator-self-healing/06-scale-up.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=5' - \ - | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/operator-self-healing/07-assert.yaml b/e2e-tests/tests/operator-self-healing/07-assert.yaml index d9146fe1b..b028a4c22 100644 --- a/e2e-tests/tests/operator-self-healing/07-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/07-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -16,11 +12,3 @@ spec: - ps singular: perconaservermysql scope: Namespaced ---- -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -metadata: - name: check-operator-deploy-status -timeout: 120 -commands: - - script: kubectl assert exist-enhanced deployment percona-server-mysql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 diff --git a/e2e-tests/tests/operator-self-healing/07-network-loss.yaml b/e2e-tests/tests/operator-self-healing/07-network-loss.yaml deleted file mode 100644 index 44fb0c5b1..000000000 --- a/e2e-tests/tests/operator-self-healing/07-network-loss.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - network_loss "${OPERATOR_NS:-$NAMESPACE}" "$(get_operator_pod)" "operator" - sleep 30 # wait for network loss to happen diff --git a/e2e-tests/tests/operator-self-healing/08-assert.yaml b/e2e-tests/tests/operator-self-healing/08-assert.yaml index b4e8f08af..7d0fd659e 100644 --- a/e2e-tests/tests/operator-self-healing/08-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/08-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: operator-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: operator-self-healing status: haproxy: ready: 3 diff --git a/e2e-tests/tests/operator-self-healing/08-scale-down.yaml b/e2e-tests/tests/operator-self-healing/08-scale-down.yaml deleted file mode 100644 index 3dd3dea43..000000000 --- a/e2e-tests/tests/operator-self-healing/08-scale-down.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/operator-self-healing/09-assert.yaml b/e2e-tests/tests/operator-self-healing/09-assert.yaml index d9146fe1b..b028a4c22 100644 --- a/e2e-tests/tests/operator-self-healing/09-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/09-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -16,11 +12,3 @@ spec: - ps singular: perconaservermysql scope: Namespaced ---- -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -metadata: - name: check-operator-deploy-status -timeout: 120 -commands: - - script: kubectl assert exist-enhanced deployment percona-server-mysql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 diff --git a/e2e-tests/tests/operator-self-healing/09-pod-failure.yaml b/e2e-tests/tests/operator-self-healing/09-pod-failure.yaml deleted file mode 100644 index 1abeeb648..000000000 --- a/e2e-tests/tests/operator-self-healing/09-pod-failure.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - failure_pod "${OPERATOR_NS:-$NAMESPACE}" "$(get_operator_pod)" "operator" - sleep 30 # wait for pod failure to happen diff --git a/e2e-tests/tests/operator-self-healing/10-assert.yaml b/e2e-tests/tests/operator-self-healing/10-assert.yaml index c3121eccc..f7dd52d74 100644 --- a/e2e-tests/tests/operator-self-healing/10-assert.yaml +++ b/e2e-tests/tests/operator-self-healing/10-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: operator-self-healing-haproxy status: + collisionCount: 0 + currentReplicas: 5 observedGeneration: 4 - replicas: 5 readyReplicas: 5 - currentReplicas: 5 + replicas: 5 updatedReplicas: 5 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: operator-self-healing finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: operator-self-healing status: haproxy: ready: 5 diff --git a/e2e-tests/tests/operator-self-healing/10-scale-up.yaml b/e2e-tests/tests/operator-self-healing/10-scale-up.yaml deleted file mode 100644 index aaa7cdb70..000000000 --- a/e2e-tests/tests/operator-self-healing/10-scale-up.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=5' - \ - | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/operator-self-healing/11-destroy-chaos-mesh.yaml b/e2e-tests/tests/operator-self-healing/11-destroy-chaos-mesh.yaml deleted file mode 100644 index 3f0cbc6b8..000000000 --- a/e2e-tests/tests/operator-self-healing/11-destroy-chaos-mesh.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 120 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - destroy_chaos_mesh - timeout: 120 diff --git a/e2e-tests/tests/operator-self-healing/chainsaw-test.yaml b/e2e-tests/tests/operator-self-healing/chainsaw-test.yaml new file mode 100755 index 000000000..a2c33af53 --- /dev/null +++ b/e2e-tests/tests/operator-self-healing/chainsaw-test.yaml @@ -0,0 +1,222 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: operator-self-healing +spec: + steps: + - catch: + - script: + content: kubectl assert exist-enhanced deployment percona-server-mysql-operator + -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 + name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + deploy_chaos_mesh + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 04-read-from-primary --from-literal=data="${data}" + - assert: + file: 04-assert.yaml + - catch: + - script: + content: kubectl assert exist-enhanced deployment percona-server-mysql-operator + -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 + name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + init_pod=$(get_operator_pod) + kill_pods "${OPERATOR_NS:-$NAMESPACE}" "pod" "$init_pod" "" "operator" + sleep 10 # wait a bit for pod to be killed + wait_deployment percona-server-mysql-operator "${OPERATOR_NS:-$NAMESPACE}" + + if [ "$init_pod" == "$(get_operator_pod)" ]; then + echo "operator pod was not killed! something went wrong." + exit 1 + fi + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=5' - \ + | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 06-assert.yaml + - catch: + - script: + content: kubectl assert exist-enhanced deployment percona-server-mysql-operator + -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 + name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + network_loss "${OPERATOR_NS:-$NAMESPACE}" "$(get_operator_pod)" "operator" + sleep 30 # wait for network loss to happen + - assert: + file: 07-assert.yaml + - name: step-08 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 08-assert.yaml + - catch: + - script: + content: kubectl assert exist-enhanced deployment percona-server-mysql-operator + -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 + name: step-09 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + failure_pod "${OPERATOR_NS:-$NAMESPACE}" "$(get_operator_pod)" "operator" + sleep 30 # wait for pod failure to happen + - assert: + file: 09-assert.yaml + - name: step-10 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=5' - \ + | yq eval '.spec.proxy.haproxy.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 10-assert.yaml + - name: step-11 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + destroy_chaos_mesh + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/recreate/00-assert.yaml b/e2e-tests/tests/recreate/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/recreate/00-assert.yaml +++ b/e2e-tests/tests/recreate/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/recreate/00-deploy-operator.yaml b/e2e-tests/tests/recreate/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/recreate/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/recreate/01-assert.yaml b/e2e-tests/tests/recreate/01-assert.yaml index bb37dfc40..8df77d612 100644 --- a/e2e-tests/tests/recreate/01-assert.yaml +++ b/e2e-tests/tests/recreate/01-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: recreate status: haproxy: ready: 3 diff --git a/e2e-tests/tests/recreate/01-create-cluster.yaml b/e2e-tests/tests/recreate/01-create-cluster.yaml deleted file mode 100644 index 44a61e442..000000000 --- a/e2e-tests/tests/recreate/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/recreate/02-assert.yaml b/e2e-tests/tests/recreate/02-assert.yaml index a0f47e109..8aa1cf335 100644 --- a/e2e-tests/tests/recreate/02-assert.yaml +++ b/e2e-tests/tests/recreate/02-assert.yaml @@ -1,27 +1,20 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 02-write-data-0 -data: - data: |- - 100500 --- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 02-write-data-1 -data: - data: |- - 100500 --- -kind: ConfigMap apiVersion: v1 +data: + data: "100500" +kind: ConfigMap metadata: name: 02-write-data-2 -data: - data: |- - 100500 diff --git a/e2e-tests/tests/recreate/02-write-data.yaml b/e2e-tests/tests/recreate/02-write-data.yaml deleted file mode 100644 index cffb9e3d7..000000000 --- a/e2e-tests/tests/recreate/02-write-data.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 02-write-data-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/recreate/03-assert.yaml b/e2e-tests/tests/recreate/03-assert.yaml index 75e60f85a..296c9835e 100644 --- a/e2e-tests/tests/recreate/03-assert.yaml +++ b/e2e-tests/tests/recreate/03-assert.yaml @@ -1,13 +1,9 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: recreate status: haproxy: state: paused @@ -17,8 +13,8 @@ status: state: paused state: paused --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-mysql status: @@ -27,8 +23,8 @@ status: observedGeneration: 2 replicas: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-haproxy status: @@ -37,8 +33,8 @@ status: observedGeneration: 2 replicas: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-orc status: @@ -181,17 +177,17 @@ metadata: spec: internalTrafficPolicy: Cluster ipFamilies: - - IPv4 + - IPv4 ipFamilyPolicy: SingleStack ports: - - name: web - port: 3000 - protocol: TCP - targetPort: 3000 - - name: raft - port: 10008 - protocol: TCP - targetPort: 10008 + - name: web + port: 3000 + protocol: TCP + targetPort: 3000 + - name: raft + port: 10008 + protocol: TCP + targetPort: 10008 selector: app.kubernetes.io/component: orc app.kubernetes.io/instance: recreate @@ -215,29 +211,29 @@ metadata: spec: internalTrafficPolicy: Cluster ipFamilies: - - IPv4 + - IPv4 ipFamilyPolicy: SingleStack ports: - - name: mysql - port: 3306 - protocol: TCP - targetPort: 3306 - - name: mysql-replicas - port: 3307 - protocol: TCP - targetPort: 3307 - - name: proxy-protocol - port: 3309 - protocol: TCP - targetPort: 3309 - - name: mysqlx - port: 33060 - protocol: TCP - targetPort: 33060 - - name: mysql-admin - port: 33062 - protocol: TCP - targetPort: 33062 + - name: mysql + port: 3306 + protocol: TCP + targetPort: 3306 + - name: mysql-replicas + port: 3307 + protocol: TCP + targetPort: 3307 + - name: proxy-protocol + port: 3309 + protocol: TCP + targetPort: 3309 + - name: mysqlx + port: 33060 + protocol: TCP + targetPort: 33060 + - name: mysql-admin + port: 33062 + protocol: TCP + targetPort: 33062 selector: app.kubernetes.io/component: haproxy app.kubernetes.io/instance: recreate diff --git a/e2e-tests/tests/recreate/03-pause.yaml b/e2e-tests/tests/recreate/03-pause.yaml deleted file mode 100644 index b57b89630..000000000 --- a/e2e-tests/tests/recreate/03-pause.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.pause=true' - \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 120 diff --git a/e2e-tests/tests/recreate/04-assert.yaml b/e2e-tests/tests/recreate/04-assert.yaml index 90f7e13d3..ca311df58 100644 --- a/e2e-tests/tests/recreate/04-assert.yaml +++ b/e2e-tests/tests/recreate/04-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: recreate status: haproxy: ready: 3 diff --git a/e2e-tests/tests/recreate/04-unpause.yaml b/e2e-tests/tests/recreate/04-unpause.yaml deleted file mode 100644 index 904f2b2ba..000000000 --- a/e2e-tests/tests/recreate/04-unpause.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.pause=false' - \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 120 diff --git a/e2e-tests/tests/recreate/05-assert.yaml b/e2e-tests/tests/recreate/05-assert.yaml index 0ddeb1c33..1be2b95d4 100644 --- a/e2e-tests/tests/recreate/05-assert.yaml +++ b/e2e-tests/tests/recreate/05-assert.yaml @@ -1,30 +1,26 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 06-write-data-0 data: data: |- 100500 100501 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 06-write-data-1 + name: 06-write-data-0 +--- +apiVersion: v1 data: data: |- 100500 100501 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 06-write-data-2 + name: 06-write-data-1 +--- +apiVersion: v1 data: data: |- 100500 100501 +kind: ConfigMap +metadata: + name: 06-write-data-2 diff --git a/e2e-tests/tests/recreate/05-write-data.yaml b/e2e-tests/tests/recreate/05-write-data.yaml deleted file mode 100644 index 0b9d85ebb..000000000 --- a/e2e-tests/tests/recreate/05-write-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100501)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 06-write-data-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/recreate/07-delete-cluster.yaml b/e2e-tests/tests/recreate/07-delete-cluster.yaml deleted file mode 100644 index 7ddaf223f..000000000 --- a/e2e-tests/tests/recreate/07-delete-cluster.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl delete ps -n ${NAMESPACE} recreate - - timeout: 120 diff --git a/e2e-tests/tests/recreate/08-assert.yaml b/e2e-tests/tests/recreate/08-assert.yaml index f20b4299c..5f22c74d9 100644 --- a/e2e-tests/tests/recreate/08-assert.yaml +++ b/e2e-tests/tests/recreate/08-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: v1 kind: PersistentVolumeClaim metadata: diff --git a/e2e-tests/tests/recreate/09-assert.yaml b/e2e-tests/tests/recreate/09-assert.yaml index 041fc7797..8df77d612 100644 --- a/e2e-tests/tests/recreate/09-assert.yaml +++ b/e2e-tests/tests/recreate/09-assert.yaml @@ -1,49 +1,45 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 480 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: recreate-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: recreate finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: recreate status: haproxy: ready: 3 diff --git a/e2e-tests/tests/recreate/09-recreate-cluster.yaml b/e2e-tests/tests/recreate/09-recreate-cluster.yaml deleted file mode 100644 index 904f2b2ba..000000000 --- a/e2e-tests/tests/recreate/09-recreate-cluster.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.pause=false' - \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 120 diff --git a/e2e-tests/tests/recreate/10-assert.yaml b/e2e-tests/tests/recreate/10-assert.yaml index 5d31cbb83..a272bdb83 100644 --- a/e2e-tests/tests/recreate/10-assert.yaml +++ b/e2e-tests/tests/recreate/10-assert.yaml @@ -1,33 +1,29 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 11-write-data-0 data: data: |- 100500 100501 100502 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 11-write-data-1 + name: 11-write-data-0 +--- +apiVersion: v1 data: data: |- 100500 100501 100502 ---- kind: ConfigMap -apiVersion: v1 metadata: - name: 11-write-data-2 + name: 11-write-data-1 +--- +apiVersion: v1 data: data: |- 100500 100501 100502 +kind: ConfigMap +metadata: + name: 11-write-data-2 diff --git a/e2e-tests/tests/recreate/10-write-data.yaml b/e2e-tests/tests/recreate/10-write-data.yaml deleted file mode 100644 index e42bc7182..000000000 --- a/e2e-tests/tests/recreate/10-write-data.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100502)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - for i in 0 1 2; do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - kubectl create configmap -n "${NAMESPACE}" 11-write-data-${i} --from-literal=data="${data}" - done diff --git a/e2e-tests/tests/recreate/chainsaw-test.yaml b/e2e-tests/tests/recreate/chainsaw-test.yaml new file mode 100755 index 000000000..c39a1be10 --- /dev/null +++ b/e2e-tests/tests/recreate/chainsaw-test.yaml @@ -0,0 +1,142 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: recreate +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + run_mysql \ + "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + run_mysql \ + "INSERT myDB.myTable (id) VALUES (100500)" \ + "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" + + for i in 0 1 2; do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + kubectl create configmap -n "${NAMESPACE}" 02-write-data-${i} --from-literal=data="${data}" + done + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.pause=true' - \\\n | yq eval '.spec.mysql.clusterType=\"async\"' + - \\\n | yq eval '.spec.mysql.size=3' - \\\n | yq eval '.spec.proxy.haproxy.enabled=true' + - \\\n | yq eval '.spec.proxy.haproxy.size=3' - \\\n | yq eval '.spec.orchestrator.enabled=true' + - \\\n | yq eval '.spec.orchestrator.size=3' - \\\n | kubectl -n \"${NAMESPACE}\" + apply -f -" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.pause=false' - \\\n | yq eval '.spec.mysql.clusterType=\"async\"' + - \\\n | yq eval '.spec.mysql.size=3' - \\\n | yq eval '.spec.proxy.haproxy.enabled=true' + - \\\n | yq eval '.spec.proxy.haproxy.size=3' - \\\n | yq eval '.spec.orchestrator.enabled=true' + - \\\n | yq eval '.spec.orchestrator.size=3' - \\\n | kubectl -n \"${NAMESPACE}\" + apply -f -" + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100501)\" \\\n \"-h $(get_haproxy_svc + $(get_cluster_name)) -uroot -proot_password\"\n\nfor i in 0 1 2; do\n host=$(get_mysql_headless_fqdn + $(get_cluster_name) $i)\n data=$(run_mysql \"SELECT * FROM myDB.myTable\" + \"-h ${host} -uroot -proot_password\")\n kubectl create configmap -n \"${NAMESPACE}\" + 06-write-data-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 05-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl delete ps -n ${NAMESPACE} recreate + - error: + file: 07-errors.yaml + - name: step-08 + try: + - assert: + file: 08-assert.yaml + - name: step-09 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n\t| yq eval '.spec.pause=false' - \\\n | yq eval '.spec.mysql.clusterType=\"async\"' + - \\\n | yq eval '.spec.mysql.size=3' - \\\n | yq eval '.spec.proxy.haproxy.enabled=true' + - \\\n | yq eval '.spec.proxy.haproxy.size=3' - \\\n | yq eval '.spec.orchestrator.enabled=true' + - \\\n | yq eval '.spec.orchestrator.size=3' - \\\n | kubectl -n \"${NAMESPACE}\" + apply -f -" + - assert: + file: 09-assert.yaml + - name: step-10 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"INSERT myDB.myTable (id) VALUES (100502)\" \\\n \"-h $(get_haproxy_svc + $(get_cluster_name)) -uroot -proot_password\"\n\nfor i in 0 1 2; do\n host=$(get_mysql_headless_fqdn + $(get_cluster_name) $i)\n data=$(run_mysql \"SELECT * FROM myDB.myTable\" + \"-h ${host} -uroot -proot_password\")\n kubectl create configmap -n \"${NAMESPACE}\" + 11-write-data-${i} --from-literal=data=\"${data}\"\ndone" + - assert: + file: 10-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/scaling/00-assert.yaml b/e2e-tests/tests/scaling/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/scaling/00-assert.yaml +++ b/e2e-tests/tests/scaling/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/scaling/00-deploy-operator.yaml b/e2e-tests/tests/scaling/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/scaling/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/scaling/01-assert.yaml b/e2e-tests/tests/scaling/01-assert.yaml index 4c158f53e..e5930a792 100644 --- a/e2e-tests/tests/scaling/01-assert.yaml +++ b/e2e-tests/tests/scaling/01-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: scaling-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: scaling-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: scaling status: mysql: ready: 3 diff --git a/e2e-tests/tests/scaling/01-create-cluster.yaml b/e2e-tests/tests/scaling/01-create-cluster.yaml deleted file mode 100644 index 43c4b90c0..000000000 --- a/e2e-tests/tests/scaling/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/scaling/02-write-data.yaml b/e2e-tests/tests/scaling/02-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/scaling/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/scaling/03-assert.yaml b/e2e-tests/tests/scaling/03-assert.yaml index 084110451..2d99a3bfd 100644 --- a/e2e-tests/tests/scaling/03-assert.yaml +++ b/e2e-tests/tests/scaling/03-assert.yaml @@ -1,10 +1,6 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 03-read-from-primary data: data: "100500" +kind: ConfigMap +metadata: + name: 03-read-from-primary diff --git a/e2e-tests/tests/scaling/03-read-from-primary.yaml b/e2e-tests/tests/scaling/03-read-from-primary.yaml deleted file mode 100644 index e9f47d126..000000000 --- a/e2e-tests/tests/scaling/03-read-from-primary.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") - - kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" diff --git a/e2e-tests/tests/scaling/04-assert.yaml b/e2e-tests/tests/scaling/04-assert.yaml index d6b2ff9b0..e917b9a9a 100644 --- a/e2e-tests/tests/scaling/04-assert.yaml +++ b/e2e-tests/tests/scaling/04-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-replicas data: scaling-mysql-0.scaling-mysql: "100500" scaling-mysql-1.scaling-mysql: "100500" scaling-mysql-2.scaling-mysql: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-replicas diff --git a/e2e-tests/tests/scaling/04-read-from-replicas.yaml b/e2e-tests/tests/scaling/04-read-from-replicas.yaml deleted file mode 100644 index 98a1b63fc..000000000 --- a/e2e-tests/tests/scaling/04-read-from-replicas.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=3 - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas ${args} diff --git a/e2e-tests/tests/scaling/05-assert.yaml b/e2e-tests/tests/scaling/05-assert.yaml index d7624a183..df0967780 100644 --- a/e2e-tests/tests/scaling/05-assert.yaml +++ b/e2e-tests/tests/scaling/05-assert.yaml @@ -1,14 +1,10 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 05-check-orchestrator data: cluster: scaling-mysql-0.scaling-mysql:3306 instances: | scaling-mysql-0.scaling-mysql scaling-mysql-1.scaling-mysql scaling-mysql-2.scaling-mysql +kind: ConfigMap +metadata: + name: 05-check-orchestrator diff --git a/e2e-tests/tests/scaling/05-check-orchestrator.yaml b/e2e-tests/tests/scaling/05-check-orchestrator.yaml deleted file mode 100644 index 7b57c0f42..000000000 --- a/e2e-tests/tests/scaling/05-check-orchestrator.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - orc_host=$(get_orc_headless_fqdn $(get_cluster_name) 0) - cluster=$(run_curl "http://${orc_host}:3000/api/clusters/" | jq -r .[0] | sed "s/.${NAMESPACE}//g") - args="--from-literal=cluster=${cluster}" - - run_curl "http://${orc_host}:3000/api/cluster/${cluster}/" | jq -r .[].Key.Hostname | sed "s/.${NAMESPACE}//g" >"${TEMP_DIR}/instances" - args="${args} --from-file=instances=${TEMP_DIR}/instances" - - kubectl create configmap -n "${NAMESPACE}" 05-check-orchestrator ${args} diff --git a/e2e-tests/tests/scaling/06-assert.yaml b/e2e-tests/tests/scaling/06-assert.yaml index 1d1166849..6826f850a 100644 --- a/e2e-tests/tests/scaling/06-assert.yaml +++ b/e2e-tests/tests/scaling/06-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: scaling-mysql status: + collisionCount: 0 + currentReplicas: 5 observedGeneration: 2 - replicas: 5 readyReplicas: 5 - currentReplicas: 5 + replicas: 5 updatedReplicas: 5 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: scaling-orc status: + collisionCount: 0 + currentReplicas: 5 observedGeneration: 2 - replicas: 5 readyReplicas: 5 - currentReplicas: 5 + replicas: 5 updatedReplicas: 5 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: scaling status: mysql: ready: 5 diff --git a/e2e-tests/tests/scaling/06-scale-up.yaml b/e2e-tests/tests/scaling/06-scale-up.yaml deleted file mode 100644 index 8a2fcc5c5..000000000 --- a/e2e-tests/tests/scaling/06-scale-up.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.mysql.size=5' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=5' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/scaling/07-assert.yaml b/e2e-tests/tests/scaling/07-assert.yaml index 4921b60a2..1c14254bc 100644 --- a/e2e-tests/tests/scaling/07-assert.yaml +++ b/e2e-tests/tests/scaling/07-assert.yaml @@ -1,17 +1,13 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 07-read-from-replicas data: scaling-mysql-0.scaling-mysql: "100500" scaling-mysql-1.scaling-mysql: "100500" scaling-mysql-2.scaling-mysql: "100500" scaling-mysql-3.scaling-mysql: "100500" scaling-mysql-4.scaling-mysql: "100500" +kind: ConfigMap +metadata: + name: 07-read-from-replicas --- apiVersion: v1 kind: PersistentVolumeClaim diff --git a/e2e-tests/tests/scaling/07-read-from-replicas.yaml b/e2e-tests/tests/scaling/07-read-from-replicas.yaml deleted file mode 100644 index 93f643cd1..000000000 --- a/e2e-tests/tests/scaling/07-read-from-replicas.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=5 - for i in $(seq 0 $((size - 1))); do - host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 07-read-from-replicas ${args} diff --git a/e2e-tests/tests/scaling/08-assert.yaml b/e2e-tests/tests/scaling/08-assert.yaml index a30411631..e08f18784 100644 --- a/e2e-tests/tests/scaling/08-assert.yaml +++ b/e2e-tests/tests/scaling/08-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: scaling-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: scaling-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 3 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: scaling finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: scaling status: mysql: ready: 3 diff --git a/e2e-tests/tests/scaling/08-scale-down.yaml b/e2e-tests/tests/scaling/08-scale-down.yaml deleted file mode 100644 index 1f2fd47b4..000000000 --- a/e2e-tests/tests/scaling/08-scale-down.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/scaling/chainsaw-test.yaml b/e2e-tests/tests/scaling/chainsaw-test.yaml new file mode 100755 index 000000000..0db999525 --- /dev/null +++ b/e2e-tests/tests/scaling/chainsaw-test.yaml @@ -0,0 +1,166 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: scaling +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password") + + kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + args='' + size=3 + for i in $(seq 0 $((size - 1))); do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + args="${args} --from-literal=${host}=${data}" + done + + kubectl create configmap -n "${NAMESPACE}" 04-read-from-replicas ${args} + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + orc_host=$(get_orc_headless_fqdn $(get_cluster_name) 0) + cluster=$(run_curl "http://${orc_host}:3000/api/clusters/" | jq -r .[0] | sed "s/.${NAMESPACE}//g") + args="--from-literal=cluster=${cluster}" + + run_curl "http://${orc_host}:3000/api/cluster/${cluster}/" | jq -r .[].Key.Hostname | sed "s/.${NAMESPACE}//g" >"${TEMP_DIR}/instances" + args="${args} --from-file=instances=${TEMP_DIR}/instances" + + kubectl create configmap -n "${NAMESPACE}" 05-check-orchestrator ${args} + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.mysql.size=5' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=5' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 06-assert.yaml + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + args='' + size=5 + for i in $(seq 0 $((size - 1))); do + host=$(get_mysql_headless_fqdn $(get_cluster_name) $i) + data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${host} -uroot -proot_password") + args="${args} --from-literal=${host}=${data}" + done + + kubectl create configmap -n "${NAMESPACE}" 07-read-from-replicas ${args} + - assert: + file: 07-assert.yaml + - name: step-08 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.orchestrator.affinity.antiAffinityTopologyKey="none"' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 08-assert.yaml + - error: + file: 08-errors.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/service-per-pod/00-assert.yaml b/e2e-tests/tests/service-per-pod/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/service-per-pod/00-assert.yaml +++ b/e2e-tests/tests/service-per-pod/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/service-per-pod/00-deploy-operator.yaml b/e2e-tests/tests/service-per-pod/00-deploy-operator.yaml deleted file mode 100644 index 724f3af88..000000000 --- a/e2e-tests/tests/service-per-pod/00-deploy-operator.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/service-per-pod/01-assert.yaml b/e2e-tests/tests/service-per-pod/01-assert.yaml index 9fb5f5e2e..deff960ad 100644 --- a/e2e-tests/tests/service-per-pod/01-assert.yaml +++ b/e2e-tests/tests/service-per-pod/01-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: service-per-pod-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: service-per-pod-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: service-per-pod finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: service-per-pod status: mysql: ready: 3 diff --git a/e2e-tests/tests/service-per-pod/01-create-cluster-clusterip.yaml b/e2e-tests/tests/service-per-pod/01-create-cluster-clusterip.yaml deleted file mode 100644 index 500506d6b..000000000 --- a/e2e-tests/tests/service-per-pod/01-create-cluster-clusterip.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.expose.enabled = true' - \ - | yq eval '.spec.mysql.expose.type = "ClusterIP"' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 10 diff --git a/e2e-tests/tests/service-per-pod/02-write-data.yaml b/e2e-tests/tests/service-per-pod/02-write-data.yaml deleted file mode 100644 index bc82e7920..000000000 --- a/e2e-tests/tests/service-per-pod/02-write-data.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - run_mysql \ - "CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable (id int PRIMARY KEY)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - - run_mysql \ - "INSERT myDB.myTable (id) VALUES (100500)" \ - "-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" diff --git a/e2e-tests/tests/service-per-pod/03-assert.yaml b/e2e-tests/tests/service-per-pod/03-assert.yaml index 2d9c34595..ec1d6578d 100644 --- a/e2e-tests/tests/service-per-pod/03-assert.yaml +++ b/e2e-tests/tests/service-per-pod/03-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-clusterip data: service-per-pod-mysql-0.service-per-pod-mysql: "100500" service-per-pod-mysql-1.service-per-pod-mysql: "100500" service-per-pod-mysql-2.service-per-pod-mysql: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-clusterip diff --git a/e2e-tests/tests/service-per-pod/03-read-from-clusterip.yaml b/e2e-tests/tests/service-per-pod/03-read-from-clusterip.yaml deleted file mode 100644 index d07295829..000000000 --- a/e2e-tests/tests/service-per-pod/03-read-from-clusterip.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps ${test_name} -o jsonpath='{.spec.mysql.size}') - for i in $(seq 0 $((size - 1))); do - ip=$(get_service_ip ${test_name}-mysql-${i}) - host=$(get_mysql_headless_fqdn ${test_name} $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${ip} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-clusterip ${args} - timeout: 60 diff --git a/e2e-tests/tests/service-per-pod/04-assert.yaml b/e2e-tests/tests/service-per-pod/04-assert.yaml index b7cebc665..dcf72d013 100644 --- a/e2e-tests/tests/service-per-pod/04-assert.yaml +++ b/e2e-tests/tests/service-per-pod/04-assert.yaml @@ -1,37 +1,33 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: service-per-pod-mysql status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: service-per-pod-orc status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: service-per-pod finalizers: - - delete-mysql-pods-in-order + - delete-mysql-pods-in-order + name: service-per-pod status: mysql: ready: 3 diff --git a/e2e-tests/tests/service-per-pod/04-create-cluster-loadbalancer.yaml b/e2e-tests/tests/service-per-pod/04-create-cluster-loadbalancer.yaml deleted file mode 100644 index a870fe7b7..000000000 --- a/e2e-tests/tests/service-per-pod/04-create-cluster-loadbalancer.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.expose.enabled = true' - \ - | yq eval '.spec.mysql.expose.type = "LoadBalancer"' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 10 diff --git a/e2e-tests/tests/service-per-pod/05-assert.yaml b/e2e-tests/tests/service-per-pod/05-assert.yaml index 8e9d5319b..9b837bbc3 100644 --- a/e2e-tests/tests/service-per-pod/05-assert.yaml +++ b/e2e-tests/tests/service-per-pod/05-assert.yaml @@ -1,12 +1,8 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 30 ---- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-read-from-loadbalancer data: service-per-pod-mysql-0.service-per-pod-mysql: "100500" service-per-pod-mysql-1.service-per-pod-mysql: "100500" service-per-pod-mysql-2.service-per-pod-mysql: "100500" +kind: ConfigMap +metadata: + name: 04-read-from-loadbalancer diff --git a/e2e-tests/tests/service-per-pod/05-read-from-loadbalancer.yaml b/e2e-tests/tests/service-per-pod/05-read-from-loadbalancer.yaml deleted file mode 100644 index ddb801a45..000000000 --- a/e2e-tests/tests/service-per-pod/05-read-from-loadbalancer.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - args='' - size=$(kubectl -n ${NAMESPACE} get ps ${test_name} -o jsonpath='{.spec.mysql.size}') - sleep 75 - for i in $(seq 0 $((size - 1))); do - ip=$(get_service_ip ${test_name}-mysql-$i) - host=$(get_mysql_headless_fqdn ${test_name} $i) - data=$(run_mysql "SELECT * FROM myDB.myTable" "-h ${ip} -uroot -proot_password") - args="${args} --from-literal=${host}=${data}" - done - - kubectl create configmap -n "${NAMESPACE}" 04-read-from-loadbalancer ${args} - timeout: 180 diff --git a/e2e-tests/tests/service-per-pod/chainsaw-test.yaml b/e2e-tests/tests/service-per-pod/chainsaw-test.yaml new file mode 100755 index 000000000..e2746b2c1 --- /dev/null +++ b/e2e-tests/tests/service-per-pod/chainsaw-test.yaml @@ -0,0 +1,80 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: service-per-pod +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n\t| yq eval '.spec.mysql.expose.enabled + = true' - \\\n\t| yq eval '.spec.mysql.expose.type = \"ClusterIP\"' - \\\n\t| + kubectl -n \"${NAMESPACE}\" apply -f -" + + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nrun_mysql + \\\n\t\"CREATE DATABASE IF NOT EXISTS myDB; CREATE TABLE IF NOT EXISTS myDB.myTable + (id int PRIMARY KEY)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password\"\n\nrun_mysql \\\n\t\"INSERT myDB.myTable (id) VALUES + (100500)\" \\\n\t\"-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"" + - name: step-03 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps ${test_name} -o jsonpath='{.spec.mysql.size}')\nfor + i in $(seq 0 $((size - 1))); do\n\tip=$(get_service_ip ${test_name}-mysql-${i})\n\thost=$(get_mysql_headless_fqdn + ${test_name} $i)\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h + ${ip} -uroot -proot_password\")\n\targs=\"${args} --from-literal=${host}=${data}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 04-read-from-clusterip ${args}" + + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n\t| yq eval '.spec.mysql.expose.enabled + = true' - \\\n\t| yq eval '.spec.mysql.expose.type = \"LoadBalancer\"' - + \\\n\t| kubectl -n \"${NAMESPACE}\" apply -f -" + + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nargs=''\nsize=$(kubectl + -n ${NAMESPACE} get ps ${test_name} -o jsonpath='{.spec.mysql.size}')\nsleep + 75\nfor i in $(seq 0 $((size - 1))); do\n\tip=$(get_service_ip ${test_name}-mysql-$i)\n\thost=$(get_mysql_headless_fqdn + ${test_name} $i)\n\tdata=$(run_mysql \"SELECT * FROM myDB.myTable\" \"-h + ${ip} -uroot -proot_password\")\n\targs=\"${args} --from-literal=${host}=${data}\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 04-read-from-loadbalancer ${args}" + + - assert: + file: 05-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/sidecars/00-assert.yaml b/e2e-tests/tests/sidecars/00-assert.yaml index 1f9a51683..b7a766494 100644 --- a/e2e-tests/tests/sidecars/00-assert.yaml +++ b/e2e-tests/tests/sidecars/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/sidecars/00-deploy-operator.yaml b/e2e-tests/tests/sidecars/00-deploy-operator.yaml deleted file mode 100644 index 4a03710b9..000000000 --- a/e2e-tests/tests/sidecars/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - diff --git a/e2e-tests/tests/sidecars/01-assert.yaml b/e2e-tests/tests/sidecars/01-assert.yaml index eddf5f4be..6792cfd63 100644 --- a/e2e-tests/tests/sidecars/01-assert.yaml +++ b/e2e-tests/tests/sidecars/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -87,8 +83,8 @@ spec: optional: true - configMap: items: - - key: my.cnf - path: auto-config.cnf + - key: my.cnf + path: auto-config.cnf name: auto-sidecars-mysql optional: true - secret: diff --git a/e2e-tests/tests/sidecars/01-create-cluster.yaml b/e2e-tests/tests/sidecars/01-create-cluster.yaml deleted file mode 100644 index 3705f7cd0..000000000 --- a/e2e-tests/tests/sidecars/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.sidecars = [{"name": "sidecar1", "image": "busybox", "command": ["sleep", "30d"], "volumeMounts": [{"name": "empty-vol", "mountPath": "/var/app/empty"}]}]' - \ - | yq eval '.spec.mysql.sidecars += [{"name": "sidecar2", "image": "busybox", "command": ["sleep", "30d"], "volumeMounts": [{"name": "pvc-vol", "mountPath": "/var/app/pvc"}]}]' - \ - | yq eval '.spec.mysql.sidecarVolumes = [{"name": "empty-vol", "emptyDir": {"medium": "Memory"}}]' - \ - | yq eval '.spec.mysql.sidecarPVCs = [{"name": "pvc-vol", "spec": {"resources": {"requests": {"storage": "1G"}}}}]' - \ - | kubectl -n "${NAMESPACE}" apply -f - - timeout: 30 diff --git a/e2e-tests/tests/sidecars/chainsaw-test.yaml b/e2e-tests/tests/sidecars/chainsaw-test.yaml new file mode 100755 index 000000000..ae0b3e6b6 --- /dev/null +++ b/e2e-tests/tests/sidecars/chainsaw-test.yaml @@ -0,0 +1,43 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: sidecars +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nget_cr + \\\n | yq eval '.spec.mysql.clusterType=\"async\"' - \\\n\t| yq eval '.spec.mysql.sidecars + = [{\"name\": \"sidecar1\", \"image\": \"busybox\", \"command\": [\"sleep\", + \"30d\"], \"volumeMounts\": [{\"name\": \"empty-vol\", \"mountPath\": \"/var/app/empty\"}]}]' + - \\\n\t| yq eval '.spec.mysql.sidecars += [{\"name\": \"sidecar2\", \"image\": + \"busybox\", \"command\": [\"sleep\", \"30d\"], \"volumeMounts\": [{\"name\": + \"pvc-vol\", \"mountPath\": \"/var/app/pvc\"}]}]' - \\\n\t| yq eval '.spec.mysql.sidecarVolumes + = [{\"name\": \"empty-vol\", \"emptyDir\": {\"medium\": \"Memory\"}}]' - + \\\n\t| yq eval '.spec.mysql.sidecarPVCs = [{\"name\": \"pvc-vol\", \"spec\": + {\"resources\": {\"requests\": {\"storage\": \"1G\"}}}}]' - \\\n\t| kubectl + -n \"${NAMESPACE}\" apply -f -" + - assert: + file: 01-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/smart-update/00-assert.yaml b/e2e-tests/tests/smart-update/00-assert.yaml index 0a8381628..9c964b159 100644 --- a/e2e-tests/tests/smart-update/00-assert.yaml +++ b/e2e-tests/tests/smart-update/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -55,35 +51,35 @@ spec: name: percona-version-service spec: containers: - - env: - - name: SERVE_HTTP - value: "true" - imagePullPolicy: Always - name: percona-version-service - ports: - - containerPort: 11000 - name: http - protocol: TCP - resources: {} - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - volumeMounts: - - mountPath: /sources/operator.9.9.9.ps-operator.dep.json - name: versions - subPath: operator.9.9.9.ps-operator.dep.json - - mountPath: /sources/operator.9.9.9.ps-operator.json - name: versions - subPath: operator.9.9.9.ps-operator.json + - env: + - name: SERVE_HTTP + value: "true" + imagePullPolicy: Always + name: percona-version-service + ports: + - containerPort: 11000 + name: http + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /sources/operator.9.9.9.ps-operator.dep.json + name: versions + subPath: operator.9.9.9.ps-operator.dep.json + - mountPath: /sources/operator.9.9.9.ps-operator.json + name: versions + subPath: operator.9.9.9.ps-operator.json dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 volumes: - - configMap: - defaultMode: 420 - name: versions + - configMap: + defaultMode: 420 name: versions + name: versions status: readyReplicas: 1 --- @@ -95,12 +91,12 @@ metadata: name: percona-version-service spec: ipFamilies: - - IPv4 + - IPv4 ipFamilyPolicy: SingleStack ports: - - port: 80 - protocol: TCP - targetPort: 11000 + - port: 80 + protocol: TCP + targetPort: 11000 selector: name: percona-version-service sessionAffinity: None diff --git a/e2e-tests/tests/smart-update/00-deploy-operator.yaml b/e2e-tests/tests/smart-update/00-deploy-operator.yaml deleted file mode 100644 index 5d116a602..000000000 --- a/e2e-tests/tests/smart-update/00-deploy-operator.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client - deploy_version_service diff --git a/e2e-tests/tests/smart-update/01-assert.yaml b/e2e-tests/tests/smart-update/01-assert.yaml index e85619ed8..5faa66c83 100644 --- a/e2e-tests/tests/smart-update/01-assert.yaml +++ b/e2e-tests/tests/smart-update/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -12,8 +8,8 @@ spec: type: OnDelete status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -25,20 +21,20 @@ spec: type: RollingUpdate status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: smart-update-haproxy spec: updateStrategy: type: RollingUpdate status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 diff --git a/e2e-tests/tests/smart-update/01-create-cluster.yaml b/e2e-tests/tests/smart-update/01-create-cluster.yaml deleted file mode 100644 index 278e8c737..000000000 --- a/e2e-tests/tests/smart-update/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.updateStrategy="SmartUpdate"' - \ - | yq eval '.spec.upgradeOptions.apply="disabled"' - \ - | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-19"' - \ - | yq eval '.spec.backup.enabled=false' - \ - | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/smart-update/02-check-smart-update.yaml b/e2e-tests/tests/smart-update/02-check-smart-update.yaml deleted file mode 100644 index 0fd43d376..000000000 --- a/e2e-tests/tests/smart-update/02-check-smart-update.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - initialPrimary=$(get_primary_from_haproxy ${test_name}-haproxy-0) - - # Upgrade cluster - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[{"op": "replace", "path": "/spec/mysql/image", "value": "percona/percona-server:8.0.28-20"}]' - - wait_cluster_consistency_async "${test_name}" "3" "3" - - pods=$(kubectl get pods -n "${NAMESPACE}" --sort-by=.status.startTime --no-headers --selector=app.kubernetes.io/component=mysql -ojson | jq --raw-output '.items[].metadata.name') - - lastRestarted=$(echo $pods | awk '{print $NF}') - - if [ "$lastRestarted" == "$initialPrimary" ]; then - exit 0 - fi - - echo "last restarted pod is not initial primary" - exit 1 - timeout: 480 - diff --git a/e2e-tests/tests/smart-update/chainsaw-test.yaml b/e2e-tests/tests/smart-update/chainsaw-test.yaml new file mode 100755 index 000000000..0276d071e --- /dev/null +++ b/e2e-tests/tests/smart-update/chainsaw-test.yaml @@ -0,0 +1,61 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: smart-update +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + deploy_version_service + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.updateStrategy="SmartUpdate"' - \ + | yq eval '.spec.upgradeOptions.apply="disabled"' - \ + | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-19"' - \ + | yq eval '.spec.backup.enabled=false' - \ + | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\ninitialPrimary=$(get_primary_from_haproxy + ${test_name}-haproxy-0)\n\n# Upgrade cluster\nkubectl -n \"${NAMESPACE}\" + patch ps \"$(get_cluster_name)\" \\\n\t--type json \\\n\t-p '[{\"op\": \"replace\", + \"path\": \"/spec/mysql/image\", \"value\": \"percona/percona-server:8.0.28-20\"}]'\n\nwait_cluster_consistency_async + \"${test_name}\" \"3\" \"3\"\n\npods=$(kubectl get pods -n \"${NAMESPACE}\" + --sort-by=.status.startTime --no-headers --selector=app.kubernetes.io/component=mysql + -ojson | jq --raw-output '.items[].metadata.name')\n\nlastRestarted=$(echo + $pods | awk '{print $NF}')\n\nif [ \"$lastRestarted\" == \"$initialPrimary\" + ]; then\n exit 0\nfi\n\necho \"last restarted pod is not initial primary\"\nexit + 1" + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/tls-cert-manager/00-assert.yaml b/e2e-tests/tests/tls-cert-manager/00-assert.yaml index e039585af..211867155 100644 --- a/e2e-tests/tests/tls-cert-manager/00-assert.yaml +++ b/e2e-tests/tests/tls-cert-manager/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -13,4 +9,3 @@ status: readyReplicas: 1 replicas: 1 updatedReplicas: 1 - diff --git a/e2e-tests/tests/tls-cert-manager/00-deploy-cert-manager.yaml b/e2e-tests/tests/tls-cert-manager/00-deploy-cert-manager.yaml deleted file mode 100644 index fc26fff09..000000000 --- a/e2e-tests/tests/tls-cert-manager/00-deploy-cert-manager.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 120 -commands: - - script: |- - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_cert_manager - diff --git a/e2e-tests/tests/tls-cert-manager/01-assert.yaml b/e2e-tests/tests/tls-cert-manager/01-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/tls-cert-manager/01-assert.yaml +++ b/e2e-tests/tests/tls-cert-manager/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/tls-cert-manager/01-deploy-operator.yaml b/e2e-tests/tests/tls-cert-manager/01-deploy-operator.yaml deleted file mode 100644 index 95773f69d..000000000 --- a/e2e-tests/tests/tls-cert-manager/01-deploy-operator.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 120 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/tls-cert-manager/02-assert.yaml b/e2e-tests/tests/tls-cert-manager/02-assert.yaml index 9ece08ea6..87f2149a0 100644 --- a/e2e-tests/tests/tls-cert-manager/02-assert.yaml +++ b/e2e-tests/tests/tls-cert-manager/02-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 400 ---- apiVersion: cert-manager.io/v1 kind: Certificate metadata: @@ -17,11 +13,11 @@ spec: secretName: tls-cert-manager-ca-cert status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 1 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 1 + reason: Ready + status: "True" + type: Ready revision: 1 --- apiVersion: cert-manager.io/v1 @@ -35,11 +31,11 @@ spec: secretName: test-ssl status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 1 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 1 + reason: Ready + status: "True" + type: Ready revision: 1 --- apiVersion: apps/v1 @@ -49,8 +45,8 @@ metadata: name: tls-cert-manager-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -59,5 +55,5 @@ metadata: name: tls-cert-manager-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 diff --git a/e2e-tests/tests/tls-cert-manager/02-create-cluster.yaml b/e2e-tests/tests/tls-cert-manager/02-create-cluster.yaml deleted file mode 100644 index 888da9c74..000000000 --- a/e2e-tests/tests/tls-cert-manager/02-create-cluster.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/tls-cert-manager/03-check-cert.yaml b/e2e-tests/tests/tls-cert-manager/03-check-cert.yaml deleted file mode 100644 index b65c07694..000000000 --- a/e2e-tests/tests/tls-cert-manager/03-check-cert.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - verify_certificate_sans tls-cert-manager-ssl '[ - "*.tls-cert-manager-mysql", - "*.tls-cert-manager-mysql.'"${NAMESPACE}"'", - "*.tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", - "*.tls-cert-manager-orchestrator", - "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'", - "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", - "*.tls-cert-manager-router", - "*.tls-cert-manager-router.'"${NAMESPACE}"'", - "*.tls-cert-manager-router.'"${NAMESPACE}"'.svc" - ]' diff --git a/e2e-tests/tests/tls-cert-manager/04-assert.yaml b/e2e-tests/tests/tls-cert-manager/04-assert.yaml index 8d61a1487..ba8fe9027 100644 --- a/e2e-tests/tests/tls-cert-manager/04-assert.yaml +++ b/e2e-tests/tests/tls-cert-manager/04-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- apiVersion: cert-manager.io/v1 kind: Certificate metadata: @@ -17,11 +13,11 @@ spec: secretName: tls-cert-manager-ca-cert status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 1 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 1 + reason: Ready + status: "True" + type: Ready revision: 1 --- apiVersion: cert-manager.io/v1 @@ -35,11 +31,11 @@ spec: secretName: test-ssl status: conditions: - - message: Certificate is up to date and has not expired - observedGeneration: 2 - reason: Ready - status: 'True' - type: Ready + - message: Certificate is up to date and has not expired + observedGeneration: 2 + reason: Ready + status: "True" + type: Ready revision: 2 --- apiVersion: apps/v1 @@ -49,8 +45,8 @@ metadata: name: tls-cert-manager-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -59,5 +55,5 @@ metadata: name: tls-cert-manager-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 diff --git a/e2e-tests/tests/tls-cert-manager/04-update-cluster.yaml b/e2e-tests/tests/tls-cert-manager/04-update-cluster.yaml deleted file mode 100644 index 1b4b0ca84..000000000 --- a/e2e-tests/tests/tls-cert-manager/04-update-cluster.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ - --type json \ - -p '[ - { - "op": "add", - "path": "/spec/tls", - "value": {"SANs": ["mysql-1.example.com"]}, - }, - ]' diff --git a/e2e-tests/tests/tls-cert-manager/05-check-cert.yaml b/e2e-tests/tests/tls-cert-manager/05-check-cert.yaml deleted file mode 100644 index d1b5b786c..000000000 --- a/e2e-tests/tests/tls-cert-manager/05-check-cert.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - verify_certificate_sans tls-cert-manager-ssl '[ - "*.tls-cert-manager-mysql", - "*.tls-cert-manager-mysql.'"${NAMESPACE}"'", - "*.tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", - "*.tls-cert-manager-orchestrator", - "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'", - "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", - "*.tls-cert-manager-router", - "*.tls-cert-manager-router.'"${NAMESPACE}"'", - "*.tls-cert-manager-router.'"${NAMESPACE}"'.svc", - "mysql-1.example.com" - ]' diff --git a/e2e-tests/tests/tls-cert-manager/chainsaw-test.yaml b/e2e-tests/tests/tls-cert-manager/chainsaw-test.yaml new file mode 100755 index 000000000..b3db35a92 --- /dev/null +++ b/e2e-tests/tests/tls-cert-manager/chainsaw-test.yaml @@ -0,0 +1,113 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: tls-cert-manager +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_cert_manager + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_client + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + verify_certificate_sans tls-cert-manager-ssl '[ + "*.tls-cert-manager-mysql", + "*.tls-cert-manager-mysql.'"${NAMESPACE}"'", + "*.tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", + "*.tls-cert-manager-orchestrator", + "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'", + "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", + "*.tls-cert-manager-router", + "*.tls-cert-manager-router.'"${NAMESPACE}"'", + "*.tls-cert-manager-router.'"${NAMESPACE}"'.svc" + ]' + - name: step-04 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + kubectl -n "${NAMESPACE}" patch ps "$(get_cluster_name)" \ + --type json \ + -p '[ + { + "op": "add", + "path": "/spec/tls", + "value": {"SANs": ["mysql-1.example.com"]}, + }, + ]' + - assert: + file: 04-assert.yaml + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + verify_certificate_sans tls-cert-manager-ssl '[ + "*.tls-cert-manager-mysql", + "*.tls-cert-manager-mysql.'"${NAMESPACE}"'", + "*.tls-cert-manager-mysql.'"${NAMESPACE}"'.svc", + "*.tls-cert-manager-orchestrator", + "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'", + "*.tls-cert-manager-orchestrator.'"${NAMESPACE}"'.svc", + "*.tls-cert-manager-router", + "*.tls-cert-manager-router.'"${NAMESPACE}"'", + "*.tls-cert-manager-router.'"${NAMESPACE}"'.svc", + "mysql-1.example.com" + ]' + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/users/00-assert.yaml b/e2e-tests/tests/users/00-assert.yaml index b30c7d718..ff52cbab5 100644 --- a/e2e-tests/tests/users/00-assert.yaml +++ b/e2e-tests/tests/users/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/e2e-tests/tests/users/00-deploy-operator.yaml b/e2e-tests/tests/users/00-deploy-operator.yaml deleted file mode 100644 index 755246211..000000000 --- a/e2e-tests/tests/users/00-deploy-operator.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_client diff --git a/e2e-tests/tests/users/01-assert.yaml b/e2e-tests/tests/users/01-assert.yaml index 9274db343..fee81b65f 100644 --- a/e2e-tests/tests/users/01-assert.yaml +++ b/e2e-tests/tests/users/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 420 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: users-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -19,17 +15,17 @@ metadata: name: users-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: users-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 diff --git a/e2e-tests/tests/users/01-create-cluster.yaml b/e2e-tests/tests/users/01-create-cluster.yaml deleted file mode 100644 index 44a61e442..000000000 --- a/e2e-tests/tests/users/01-create-cluster.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.spec.mysql.size=3' - \ - | yq eval '.spec.proxy.haproxy.enabled=true' - \ - | yq eval '.spec.proxy.haproxy.size=3' - \ - | yq eval '.spec.orchestrator.enabled=true' - \ - | yq eval '.spec.orchestrator.size=3' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/users/02-assert.yaml b/e2e-tests/tests/users/02-assert.yaml index b2f906276..24d98a056 100644 --- a/e2e-tests/tests/users/02-assert.yaml +++ b/e2e-tests/tests/users/02-assert.yaml @@ -1,11 +1,4 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- apiVersion: v1 -kind: ConfigMap -metadata: - name: 02-check-users data: heartbeat: | GRANT REPLICATION CLIENT ON *.* TO `heartbeat`@`localhost` @@ -28,10 +21,12 @@ data: GRANT BACKUP_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,GROUP_REPLICATION_ADMIN,GROUP_REPLICATION_STREAM,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,ROLE_ADMIN,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN ON *.* TO `replication`@`%` WITH GRANT OPTION GRANT INSERT, UPDATE, DELETE ON `mysql`.* TO `replication`@`%` WITH GRANT OPTION GRANT SELECT ON `performance_schema`.`threads` TO `replication`@`%` - xtrabackup: | GRANT RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT ON *.* TO `xtrabackup`@`localhost` GRANT BACKUP_ADMIN,GROUP_REPLICATION_ADMIN,REPLICATION_SLAVE_ADMIN,SYSTEM_USER ON *.* TO `xtrabackup`@`localhost` GRANT SELECT ON `performance_schema`.`keyring_component_status` TO `xtrabackup`@`localhost` GRANT SELECT ON `performance_schema`.`log_status` TO `xtrabackup`@`localhost` GRANT SELECT ON `performance_schema`.`replication_group_members` TO `xtrabackup`@`localhost` +kind: ConfigMap +metadata: + name: 02-check-users diff --git a/e2e-tests/tests/users/02-check-users.yaml b/e2e-tests/tests/users/02-check-users.yaml deleted file mode 100644 index 00a90062e..000000000 --- a/e2e-tests/tests/users/02-check-users.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - mysql_args="-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password" - users=($(get_mysql_users "${mysql_args}")) - - args='' - for user in "${users[@]}"; do - host="%" - case $user in - heartbeat | xtrabackup) - host="localhost" - ;; - esac - query="SHOW GRANTS FOR '${user}'@'${host}';" - - run_mysql "${query}" "${mysql_args}" \ - | sed -E "s/'(10|192)[.][0-9][^']*'//; s/'[^']*[.]internal'//" \ - >"${TEMP_DIR}/${user}.sql" - - args="${args} --from-file=${user}=${TEMP_DIR}/${user}.sql" - done - - kubectl create configmap -n "${NAMESPACE}" 02-check-users $args - kubectl get configmap -n "${NAMESPACE}" 02-check-users -o yaml diff --git a/e2e-tests/tests/users/03-assert.yaml b/e2e-tests/tests/users/03-assert.yaml index 659ffa91d..af93051a0 100644 --- a/e2e-tests/tests/users/03-assert.yaml +++ b/e2e-tests/tests/users/03-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 300 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,5 +5,5 @@ metadata: name: users-orc status: observedGeneration: 2 - replicas: 3 readyReplicas: 3 + replicas: 3 diff --git a/e2e-tests/tests/users/04-assert.yaml b/e2e-tests/tests/users/04-assert.yaml index cff929e86..2c3aaf480 100644 --- a/e2e-tests/tests/users/04-assert.yaml +++ b/e2e-tests/tests/users/04-assert.yaml @@ -1,25 +1,21 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 360 ---- -kind: ConfigMap apiVersion: v1 +data: + heartbeat: success + monitor: success + operator: success + orchestrator: success + replication: success + xtrabackup: success +kind: ConfigMap metadata: name: 04-check-connections -data: - heartbeat: "success" - monitor: "success" - operator: "success" - orchestrator: "success" - replication: "success" - xtrabackup: "success" --- -kind: ConfigMap apiVersion: v1 -metadata: - name: 04-check-replication data: replicating: "2" +kind: ConfigMap +metadata: + name: 04-check-replication --- apiVersion: apps/v1 kind: StatefulSet @@ -28,8 +24,8 @@ metadata: name: users-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -38,17 +34,17 @@ metadata: name: users-orc status: observedGeneration: 2 - replicas: 3 readyReplicas: 3 + replicas: 3 --- -kind: StatefulSet apiVersion: apps/v1 +kind: StatefulSet metadata: name: users-haproxy status: + collisionCount: 0 + currentReplicas: 3 observedGeneration: 1 - replicas: 3 readyReplicas: 3 - currentReplicas: 3 + replicas: 3 updatedReplicas: 3 - collisionCount: 0 diff --git a/e2e-tests/tests/users/04-check-cluster.yaml b/e2e-tests/tests/users/04-check-cluster.yaml deleted file mode 100644 index de63a2dbe..000000000 --- a/e2e-tests/tests/users/04-check-cluster.yaml +++ /dev/null @@ -1,52 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - set -o pipefail - set -o errexit - set -o xtrace - - source ../../functions - - sleep 30 # wait for cluster status to change to initializing - wait_cluster_consistency_async "${test_name}" "3" "3" - mysql_args="-h $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password_updated" - users=($(get_mysql_users "${mysql_args}")) - - # check connection - args="" - set +o errexit - for user in "${users[@]}"; do - mysql_args="-h $(get_haproxy_svc $(get_cluster_name)) -u${user} -p${user}_password_updated" - - pod=mysql-client - case $user in - heartbeat | xtrabackup) - mysql_args="-h localhost -u${user} -p${user}_password_updated" - pod="$(get_cluster_name)-mysql-0" - ;; - esac - - run_mysql "SELECT 1" "${mysql_args}" "${pod}" - - args="${args} --from-literal=${user}=$([ $? -eq 0 ] && echo 'success' || echo 'fail')" - done - set -o errexit - - kubectl create configmap -n "${NAMESPACE}" 04-check-connections $args - kubectl get configmap -n "${NAMESPACE}" 04-check-connections -o yaml - - # check replication - wait_cluster_consistency_async "${test_name}" "3" "3" - orc_host=$(get_orc_headless_fqdn $(get_cluster_name) 0) - cluster=$(run_curl "http://${orc_host}:3000/api/clusters/" | jq -r .[0]) - - replicating=$(run_curl "http://${orc_host}:3000/api/cluster/${cluster}/" \ - | tee \ - | jq -r '.[] | "\(.ReplicationSQLThreadRuning) \(.ReplicationIOThreadRuning)"' \ - | grep "true" \ - | wc -l \ - | sed 's/ *//') - - kubectl create configmap -n "${NAMESPACE}" 04-check-replication --from-literal=replicating="${replicating}" - timeout: 300 diff --git a/e2e-tests/tests/users/chainsaw-test.yaml b/e2e-tests/tests/users/chainsaw-test.yaml new file mode 100755 index 000000000..a619d5932 --- /dev/null +++ b/e2e-tests/tests/users/chainsaw-test.yaml @@ -0,0 +1,90 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: users +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.spec.mysql.size=3' - \ + | yq eval '.spec.proxy.haproxy.enabled=true' - \ + | yq eval '.spec.proxy.haproxy.size=3' - \ + | yq eval '.spec.orchestrator.enabled=true' - \ + | yq eval '.spec.orchestrator.size=3' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: "set -o errexit\nset -o xtrace\n\nsource ../../functions\n\nmysql_args=\"-h + $(get_haproxy_svc $(get_cluster_name)) -uroot -proot_password\"\nusers=($(get_mysql_users + \"${mysql_args}\"))\n\nargs=''\nfor user in \"${users[@]}\"; do\n\thost=\"%\"\n\tcase + $user in\n\t\theartbeat | xtrabackup)\n\t\t\thost=\"localhost\"\n\t\t\t;;\n\tesac\n\tquery=\"SHOW + GRANTS FOR '${user}'@'${host}';\"\n\n\trun_mysql \"${query}\" \"${mysql_args}\" + \\\n\t\t| sed -E \"s/'(10|192)[.][0-9][^']*'//; s/'[^']*[.]internal'//\" + \\\n\t\t\t>\"${TEMP_DIR}/${user}.sql\"\n\n\targs=\"${args} --from-file=${user}=${TEMP_DIR}/${user}.sql\"\ndone\n\nkubectl + create configmap -n \"${NAMESPACE}\" 02-check-users $args\nkubectl get configmap + -n \"${NAMESPACE}\" 02-check-users -o yaml" + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - apply: + file: 03-update-passwords.yaml + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - script: + content: "set -o pipefail\nset -o errexit\nset -o xtrace\n\nsource ../../functions\n\nsleep + 30 # wait for cluster status to change to initializing\nwait_cluster_consistency_async + \"${test_name}\" \"3\" \"3\"\nmysql_args=\"-h $(get_haproxy_svc $(get_cluster_name)) + -uroot -proot_password_updated\"\nusers=($(get_mysql_users \"${mysql_args}\"))\n\n# + check connection\nargs=\"\"\nset +o errexit\nfor user in \"${users[@]}\"; + do\n\tmysql_args=\"-h $(get_haproxy_svc $(get_cluster_name)) -u${user} -p${user}_password_updated\"\n\n\tpod=mysql-client\n\tcase + $user in\n\t\theartbeat | xtrabackup)\n\t\t\tmysql_args=\"-h localhost -u${user} + -p${user}_password_updated\"\n\t\t\tpod=\"$(get_cluster_name)-mysql-0\"\n\t\t\t;;\n\tesac\n\n\trun_mysql + \"SELECT 1\" \"${mysql_args}\" \"${pod}\"\n\n\targs=\"${args} --from-literal=${user}=$([ + $? -eq 0 ] && echo 'success' || echo 'fail')\"\ndone\nset -o errexit\n\nkubectl + create configmap -n \"${NAMESPACE}\" 04-check-connections $args\nkubectl + get configmap -n \"${NAMESPACE}\" 04-check-connections -o yaml\n\n# check + replication\nwait_cluster_consistency_async \"${test_name}\" \"3\" \"3\"\norc_host=$(get_orc_headless_fqdn + $(get_cluster_name) 0)\ncluster=$(run_curl \"http://${orc_host}:3000/api/clusters/\" + | jq -r .[0])\n\nreplicating=$(run_curl \"http://${orc_host}:3000/api/cluster/${cluster}/\" + \\\n\t| tee \\\n\t| jq -r '.[] | \"\\(.ReplicationSQLThreadRuning) \\(.ReplicationIOThreadRuning)\"' + \\\n\t| grep \"true\" \\\n\t| wc -l \\\n\t| sed 's/ *//')\n\nkubectl create + configmap -n \"${NAMESPACE}\" 04-check-replication --from-literal=replicating=\"${replicating}\"" + - assert: + file: 04-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml diff --git a/e2e-tests/tests/version-service/00-assert.yaml b/e2e-tests/tests/version-service/00-assert.yaml index 0a8381628..9c964b159 100644 --- a/e2e-tests/tests/version-service/00-assert.yaml +++ b/e2e-tests/tests/version-service/00-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 120 ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -55,35 +51,35 @@ spec: name: percona-version-service spec: containers: - - env: - - name: SERVE_HTTP - value: "true" - imagePullPolicy: Always - name: percona-version-service - ports: - - containerPort: 11000 - name: http - protocol: TCP - resources: {} - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - volumeMounts: - - mountPath: /sources/operator.9.9.9.ps-operator.dep.json - name: versions - subPath: operator.9.9.9.ps-operator.dep.json - - mountPath: /sources/operator.9.9.9.ps-operator.json - name: versions - subPath: operator.9.9.9.ps-operator.json + - env: + - name: SERVE_HTTP + value: "true" + imagePullPolicy: Always + name: percona-version-service + ports: + - containerPort: 11000 + name: http + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /sources/operator.9.9.9.ps-operator.dep.json + name: versions + subPath: operator.9.9.9.ps-operator.dep.json + - mountPath: /sources/operator.9.9.9.ps-operator.json + name: versions + subPath: operator.9.9.9.ps-operator.json dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 volumes: - - configMap: - defaultMode: 420 - name: versions + - configMap: + defaultMode: 420 name: versions + name: versions status: readyReplicas: 1 --- @@ -95,12 +91,12 @@ metadata: name: percona-version-service spec: ipFamilies: - - IPv4 + - IPv4 ipFamilyPolicy: SingleStack ports: - - port: 80 - protocol: TCP - targetPort: 11000 + - port: 80 + protocol: TCP + targetPort: 11000 selector: name: percona-version-service sessionAffinity: None diff --git a/e2e-tests/tests/version-service/00-deploy-operator.yaml b/e2e-tests/tests/version-service/00-deploy-operator.yaml deleted file mode 100644 index 3f115d95c..000000000 --- a/e2e-tests/tests/version-service/00-deploy-operator.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - init_temp_dir # do this only in the first TestStep - - deploy_operator - deploy_non_tls_cluster_secrets - deploy_tls_cluster_secrets - deploy_version_service - deploy_client diff --git a/e2e-tests/tests/version-service/01-assert.yaml b/e2e-tests/tests/version-service/01-assert.yaml index d51e02382..187073a4c 100644 --- a/e2e-tests/tests/version-service/01-assert.yaml +++ b/e2e-tests/tests/version-service/01-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 600 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: cluster-recommended-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -19,8 +15,8 @@ metadata: name: cluster-recommended-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL @@ -44,5 +40,5 @@ metadata: name: cluster-recommended-mysql-0 spec: containers: - - image: percona/percona-server:8.0.28-20 - - name: pt-heartbeat + - image: percona/percona-server:8.0.28-20 + - name: pt-heartbeat diff --git a/e2e-tests/tests/version-service/01-create-cluster-recommended.yaml b/e2e-tests/tests/version-service/01-create-cluster-recommended.yaml deleted file mode 100644 index 9ad2011e2..000000000 --- a/e2e-tests/tests/version-service/01-create-cluster-recommended.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.metadata.name="cluster-recommended"' - \ - | yq eval '.spec.upgradeOptions.apply="recommended"' - \ - | yq eval '.spec.crVersion="9.9.9"' - \ - | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-19"' - \ - | yq eval '.spec.backup.enabled=false' - \ - | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/version-service/02-assert.yaml b/e2e-tests/tests/version-service/02-assert.yaml index 4d0902fc7..2edaacc34 100644 --- a/e2e-tests/tests/version-service/02-assert.yaml +++ b/e2e-tests/tests/version-service/02-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 100 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: cluster-recommended-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -19,8 +15,8 @@ metadata: name: cluster-recommended-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL @@ -44,5 +40,5 @@ metadata: name: cluster-recommended-mysql-0 spec: containers: - - image: percona/percona-server:8.0.28-20 - - name: pt-heartbeat + - image: percona/percona-server:8.0.28-20 + - name: pt-heartbeat diff --git a/e2e-tests/tests/version-service/02-set-upgradeOption-never.yaml b/e2e-tests/tests/version-service/02-set-upgradeOption-never.yaml index 552e46530..59d200927 100644 --- a/e2e-tests/tests/version-service/02-set-upgradeOption-never.yaml +++ b/e2e-tests/tests/version-service/02-set-upgradeOption-never.yaml @@ -1,11 +1,7 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: cluster-recommended + name: cluster-recommended spec: - upgradeOptions: - apply: never + upgradeOptions: + apply: never diff --git a/e2e-tests/tests/version-service/03-assert.yaml b/e2e-tests/tests/version-service/03-assert.yaml index 1df50d605..f4c25222e 100644 --- a/e2e-tests/tests/version-service/03-assert.yaml +++ b/e2e-tests/tests/version-service/03-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 100 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: cluster-recommended-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -19,8 +15,8 @@ metadata: name: cluster-recommended-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL @@ -44,5 +40,5 @@ metadata: name: cluster-recommended-mysql-0 spec: containers: - - image: percona/percona-server:8.0.28-20 - - name: pt-heartbeat + - image: percona/percona-server:8.0.28-20 + - name: pt-heartbeat diff --git a/e2e-tests/tests/version-service/03-set-upgradeOption-disabled.yaml b/e2e-tests/tests/version-service/03-set-upgradeOption-disabled.yaml index ad475e67c..5c3668bc1 100644 --- a/e2e-tests/tests/version-service/03-set-upgradeOption-disabled.yaml +++ b/e2e-tests/tests/version-service/03-set-upgradeOption-disabled.yaml @@ -1,11 +1,7 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 ---- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL metadata: - name: cluster-recommended + name: cluster-recommended spec: - upgradeOptions: - apply: disabled + upgradeOptions: + apply: disabled diff --git a/e2e-tests/tests/version-service/04-delete-previous-cluster.yaml b/e2e-tests/tests/version-service/04-delete-previous-cluster.yaml deleted file mode 100644 index e78c91909..000000000 --- a/e2e-tests/tests/version-service/04-delete-previous-cluster.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -delete: - - apiVersion: ps.percona.com/v1alpha1 - kind: PerconaServerMySQL - name: cluster-recommended \ No newline at end of file diff --git a/e2e-tests/tests/version-service/05-assert.yaml b/e2e-tests/tests/version-service/05-assert.yaml index 1c3c5f16b..dfb3f9b87 100644 --- a/e2e-tests/tests/version-service/05-assert.yaml +++ b/e2e-tests/tests/version-service/05-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: cluster-latest-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -19,8 +15,8 @@ metadata: name: cluster-latest-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL @@ -44,5 +40,5 @@ metadata: name: cluster-latest-mysql-0 spec: containers: - - image: percona/percona-server:8.0.28-20 - - name: pt-heartbeat + - image: percona/percona-server:8.0.28-20 + - name: pt-heartbeat diff --git a/e2e-tests/tests/version-service/05-create-cluster-latest.yaml b/e2e-tests/tests/version-service/05-create-cluster-latest.yaml deleted file mode 100644 index 6b246ead3..000000000 --- a/e2e-tests/tests/version-service/05-create-cluster-latest.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.metadata.name="cluster-latest"' - \ - | yq eval '.spec.upgradeOptions.apply="latest"' - \ - | yq eval '.spec.crVersion="9.9.9"' - \ - | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-19"' - \ - | yq eval '.spec.backup.enabled=false' - \ - | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/version-service/06-delete-previous-cluster.yaml b/e2e-tests/tests/version-service/06-delete-previous-cluster.yaml deleted file mode 100644 index d05a71f8d..000000000 --- a/e2e-tests/tests/version-service/06-delete-previous-cluster.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -delete: - - apiVersion: ps.percona.com/v1alpha1 - kind: PerconaServerMySQL - name: cluster-latest \ No newline at end of file diff --git a/e2e-tests/tests/version-service/07-assert.yaml b/e2e-tests/tests/version-service/07-assert.yaml index d82023cbb..5612ee489 100644 --- a/e2e-tests/tests/version-service/07-assert.yaml +++ b/e2e-tests/tests/version-service/07-assert.yaml @@ -1,7 +1,3 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 500 ---- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -9,8 +5,8 @@ metadata: name: cluster-exact-mysql status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: apps/v1 kind: StatefulSet @@ -19,8 +15,8 @@ metadata: name: cluster-exact-orc status: observedGeneration: 1 - replicas: 3 readyReplicas: 3 + replicas: 3 --- apiVersion: ps.percona.com/v1alpha1 kind: PerconaServerMySQL @@ -44,5 +40,5 @@ metadata: name: cluster-exact-mysql-0 spec: containers: - - image: percona/percona-server:8.0.28-19 - - name: pt-heartbeat + - image: percona/percona-server:8.0.28-19 + - name: pt-heartbeat diff --git a/e2e-tests/tests/version-service/07-create-cluster-exact.yaml b/e2e-tests/tests/version-service/07-create-cluster-exact.yaml deleted file mode 100644 index e145ea1ad..000000000 --- a/e2e-tests/tests/version-service/07-create-cluster-exact.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 10 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval '.spec.mysql.clusterType="async"' - \ - | yq eval '.metadata.name="cluster-exact"' - \ - | yq eval '.spec.upgradeOptions.apply="8.0.28-19"' - \ - | yq eval '.spec.crVersion="9.9.9"' - \ - | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-20"' - \ - | yq eval '.spec.backup.enabled=false' - \ - | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ - | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/version-service/chainsaw-test.yaml b/e2e-tests/tests/version-service/chainsaw-test.yaml new file mode 100755 index 000000000..7709a679e --- /dev/null +++ b/e2e-tests/tests/version-service/chainsaw-test.yaml @@ -0,0 +1,115 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: version-service +spec: + steps: + - name: step-00 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + init_temp_dir # do this only in the first TestStep + + deploy_operator + deploy_non_tls_cluster_secrets + deploy_tls_cluster_secrets + deploy_version_service + deploy_client + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.metadata.name="cluster-recommended"' - \ + | yq eval '.spec.upgradeOptions.apply="recommended"' - \ + | yq eval '.spec.crVersion="9.9.9"' - \ + | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-19"' - \ + | yq eval '.spec.backup.enabled=false' - \ + | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - apply: + file: 02-set-upgradeOption-never.yaml + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - apply: + file: 03-set-upgradeOption-disabled.yaml + - assert: + file: 03-assert.yaml + - name: step-04 + try: + - delete: + ref: + apiVersion: ps.percona.com/v1alpha1 + kind: PerconaServerMySQL + name: cluster-recommended + - name: step-05 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.metadata.name="cluster-latest"' - \ + | yq eval '.spec.upgradeOptions.apply="latest"' - \ + | yq eval '.spec.crVersion="9.9.9"' - \ + | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-19"' - \ + | yq eval '.spec.backup.enabled=false' - \ + | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 05-assert.yaml + - name: step-06 + try: + - delete: + ref: + apiVersion: ps.percona.com/v1alpha1 + kind: PerconaServerMySQL + name: cluster-latest + - name: step-07 + try: + - script: + content: |- + set -o errexit + set -o xtrace + + source ../../functions + + get_cr \ + | yq eval '.spec.mysql.clusterType="async"' - \ + | yq eval '.metadata.name="cluster-exact"' - \ + | yq eval '.spec.upgradeOptions.apply="8.0.28-19"' - \ + | yq eval '.spec.crVersion="9.9.9"' - \ + | yq eval '.spec.mysql.image="percona/percona-server:8.0.28-20"' - \ + | yq eval '.spec.backup.enabled=false' - \ + | yq eval '.spec.upgradeOptions.versionServiceEndpoint="http://percona-version-service:80"' - \ + | kubectl -n "${NAMESPACE}" apply -f - + - assert: + file: 07-assert.yaml + - name: step-99 + try: + - apply: + file: 99-drop-finalizer.yaml