From de85735ed8a5b2c35d02cde24e5246a0fee9057e Mon Sep 17 00:00:00 2001 From: Pavel Tankov <4014969+ptankov@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:59:10 +0300 Subject: [PATCH 1/2] CLOUD-808 Fix PMM server deployment in tests --- e2e-tests/README.md | 2 +- e2e-tests/default-cr/run | 19 ++----------------- e2e-tests/functions | 28 ++++++++++++++++++++++++---- e2e-tests/monitoring-2-0/run | 21 +-------------------- e2e-tests/upgrade-sharded/run | 10 +++++----- e2e-tests/upgrade/run | 10 +++++----- e2e-tests/version-service/run | 4 ++-- 7 files changed, 40 insertions(+), 54 deletions(-) diff --git a/e2e-tests/README.md b/e2e-tests/README.md index 11aba43c27..f227aab5c2 100644 --- a/e2e-tests/README.md +++ b/e2e-tests/README.md @@ -130,7 +130,7 @@ full list of variables is the following one: * `IMAGE` - Percona Server for MongoDB Operator, `perconalab/percona-server-mongodb-operator:main` by default, * `IMAGE_MONGOD` - mongod, `perconalab/percona-server-mongodb-operator:main-mongod4.4` by default, -* `IMAGE_PMM` - Percona Monitoring and Management (PMM) client, `perconalab/pmm-client:dev-latest` by default, +* `IMAGE_PMM_CLIENT` - Percona Monitoring and Management (PMM) client, `perconalab/pmm-client:dev-latest` by default, * `IMAGE_BACKUP` - backup, `perconalab/percona-server-mongodb-operator:main-backup` by default, ### Using automatic clean-up after testing diff --git a/e2e-tests/default-cr/run b/e2e-tests/default-cr/run index 8c6fdaffb4..6484d4914a 100755 --- a/e2e-tests/default-cr/run +++ b/e2e-tests/default-cr/run @@ -81,23 +81,8 @@ function main() { compare_generation "1" "statefulset" "${cluster}-mongos" compare_generation "1" "psmdb" "${cluster}" - desc 'starting PMM server' - if [ ! -z "$OPENSHIFT" ]; then - platform=openshift - oc create sa pmm-server - oc adm policy add-scc-to-user privileged -z pmm-server - if [ -n "$OPERATOR_NS" ]; then - timeout 30 oc delete clusterrolebinding $(kubectl get clusterrolebinding | grep 'pmm-psmdb-operator-' | awk '{print $1}') || : - oc create clusterrolebinding pmm-psmdb-operator-cluster-wide --clusterrole=percona-server-mongodb-operator --serviceaccount=$namespace:pmm-server - oc patch clusterrole/percona-server-mongodb-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' ${OPERATOR_NS:+-n $OPERATOR_NS} - else - oc create rolebinding pmm-psmdb-operator-namespace-only --role percona-server-mongodb-operator --serviceaccount=$namespace:pmm-server - oc patch role/percona-server-mongodb-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' - fi - retry 10 60 helm install monitoring --set imageTag=$IMAGE_PMM_SERVER_TAG --set imageRepo=$IMAGE_PMM_SERVER_REPO --set platform=$platform --set sa=pmm-server --set supresshttp2=false https://percona-charts.storage.googleapis.com/pmm-server-${PMM_SERVER_VER}.tgz - else - retry 10 60 helm install monitoring --set imageTag=$IMAGE_PMM_SERVER_TAG --set imageRepo=$IMAGE_PMM_SERVER_REPO --set platform=$platform https://percona-charts.storage.googleapis.com/pmm-server-${PMM_SERVER_VER}.tgz - fi + desc 'install PMM Server' + deploy_pmm_server sleep 20 kubectl_bin patch psmdb ${cluster} --type=merge --patch '{ "spec": {"pmm":{"enabled":true}} diff --git a/e2e-tests/functions b/e2e-tests/functions index 3ba0a89596..b3a4e313b4 100755 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -5,7 +5,6 @@ GIT_BRANCH=${VERSION:-$(git rev-parse --abbrev-ref HEAD | sed -e 's^/^-^g; s^[.] API="psmdb.percona.com/v1" OPERATOR_VERSION="$(grep 'crVersion' $(realpath $(dirname ${BASH_SOURCE[0]})/../deploy/cr.yaml) | awk '{print $2}')" IMAGE=${IMAGE:-"perconalab/percona-server-mongodb-operator:${GIT_BRANCH}"} -IMAGE_PMM=${IMAGE_PMM:-"perconalab/pmm-client:dev-latest"} IMAGE_MONGOD=${IMAGE_MONGOD:-"perconalab/percona-server-mongodb-operator:main-mongod5.0"} IMAGE_MONGOD_CHAIN=${IMAGE_MONGOD_CHAIN:-$' perconalab/percona-server-mongodb-operator:main-mongod4.4 @@ -14,8 +13,8 @@ perconalab/percona-server-mongodb-operator:main-mongod6.0'} IMAGE_BACKUP=${IMAGE_BACKUP:-"perconalab/percona-server-mongodb-operator:main-backup"} SKIP_BACKUPS_TO_AWS_GCP_AZURE=${SKIP_BACKUPS_TO_AWS_GCP_AZURE:-1} PMM_SERVER_VER=${PMM_SERVER_VER:-"9.9.9"} -IMAGE_PMM_SERVER_REPO=${IMAGE_PMM_SERVER_REPO:-"perconalab/pmm-server"} -IMAGE_PMM_SERVER_TAG=${IMAGE_PMM_SERVER_TAG:-"dev-latest"} +IMAGE_PMM_CLIENT=${IMAGE_PMM_CLIENT:-"perconalab/pmm-client:dev-latest"} +IMAGE_PMM_SERVER=${IMAGE_PMM_SERVER:-"perconalab/pmm-server:dev-latest"} CERT_MANAGER_VER="1.12.4" tmp_dir=$(mktemp -d) sed=$(which gsed || which sed) @@ -1036,7 +1035,7 @@ EOF cat_config() { cat "$1" \ | yq eval '(.spec | select(.image == null)).image = "'"$IMAGE_MONGOD"'"' \ - | yq eval '(.spec | select(has("pmm"))).pmm.image = "'"$IMAGE_PMM"'"' \ + | yq eval '(.spec | select(has("pmm"))).pmm.image = "'"$IMAGE_PMM_CLIENT"'"' \ | yq eval '(.spec | select(has("backup"))).backup.image = "'"$IMAGE_BACKUP"'"' \ | yq eval '.spec.upgradeOptions.apply="Never"' } @@ -1332,3 +1331,24 @@ insert_data_mongos() { "myApp:myPass@$cluster-mongos.$namespace" "" "" \ "$flags" } + +deploy_pmm_server() { + helm uninstall monitoring || : + helm repo remove stable || : + helm repo add stable https://charts.helm.sh/stable + if [[ $OPENSHIFT ]]; then + oc create sa pmm-server + oc adm policy add-scc-to-user privileged -z pmm-server + if [[ $OPERATOR_NS ]]; then + timeout 30 oc delete clusterrolebinding $(kubectl get clusterrolebinding | grep 'pmm-psmdb-operator-' | awk '{print $1}') || : + oc create clusterrolebinding pmm-psmdb-operator-cluster-wide --clusterrole=percona-server-mongodb-operator --serviceaccount=$namespace:pmm-server + oc patch clusterrole/percona-server-mongodb-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' -n $OPERATOR_NS + else + oc create rolebinding pmm-psmdb-operator-namespace-only --role percona-server-mongodb-operator --serviceaccount=$namespace:pmm-server + oc patch role/percona-server-mongodb-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' + fi + local additional_params="--set platform=openshift --set sa=pmm-server --set supresshttp2=false" + fi + + retry 10 60 helm install monitoring --set imageTag=${IMAGE_PMM_SERVER#*:} --set imageRepo=${IMAGE_PMM_SERVER%:*} $additional_params https://percona-charts.storage.googleapis.com/pmm-server-$PMM_SERVER_VER.tgz +} diff --git a/e2e-tests/monitoring-2-0/run b/e2e-tests/monitoring-2-0/run index 58ec2c006d..c1df2a1b52 100755 --- a/e2e-tests/monitoring-2-0/run +++ b/e2e-tests/monitoring-2-0/run @@ -10,27 +10,8 @@ deploy_cert_manager create_infra $namespace desc 'install PMM Server' -platform=kubernetes -helm uninstall monitoring || : -helm repo remove stable || : -helm repo add stable https://charts.helm.sh/stable -if [[ -n ${OPENSHIFT} ]]; then - platform=openshift - oc create sa pmm-server - oc adm policy add-scc-to-user privileged -z pmm-server - if [ -n "$OPERATOR_NS" ]; then - timeout 30 oc delete clusterrolebinding $(kubectl get clusterrolebinding | grep 'pmm-psmdb-operator-' | awk '{print $1}') || : - oc create clusterrolebinding pmm-psmdb-operator-cluster-wide --clusterrole=percona-server-mongodb-operator --serviceaccount=$namespace:pmm-server - oc patch clusterrole/percona-server-mongodb-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' ${OPERATOR_NS:+-n $OPERATOR_NS} - else - oc create rolebinding pmm-psmdb-operator-namespace-only --role percona-server-mongodb-operator --serviceaccount=$namespace:pmm-server - oc patch role/percona-server-mongodb-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' - fi - retry 10 60 helm install monitoring --set imageTag=$IMAGE_PMM_SERVER_TAG --set imageRepo=$IMAGE_PMM_SERVER_REPO --set platform=$platform --set sa=pmm-server --set supresshttp2=false https://percona-charts.storage.googleapis.com/pmm-server-${PMM_SERVER_VER}.tgz -else - retry 10 60 helm install monitoring --set imageTag=$IMAGE_PMM_SERVER_TAG --set imageRepo=$IMAGE_PMM_SERVER_REPO --set platform=$platform https://percona-charts.storage.googleapis.com/pmm-server-${PMM_SERVER_VER}.tgz -fi +deploy_pmm_server sleep 20 SERVICE="postgres" until kubectl_bin exec monitoring-0 -- bash -c "pgrep -x $SERVICE >/dev/null"; do diff --git a/e2e-tests/upgrade-sharded/run b/e2e-tests/upgrade-sharded/run index 285d870435..6c0e56f177 100755 --- a/e2e-tests/upgrade-sharded/run +++ b/e2e-tests/upgrade-sharded/run @@ -11,7 +11,7 @@ CLUSTER_SIZE=3 TARGET_OPERATOR_VER="${OPERATOR_VERSION}" TARGET_IMAGE="${IMAGE}" TARGET_IMAGE_MONGOD="${IMAGE_MONGOD}" -TARGET_IMAGE_PMM="${IMAGE_PMM}" +TARGET_IMAGE_PMM_CLIENT="${IMAGE_PMM_CLIENT}" TARGET_IMAGE_BACKUP="${IMAGE_BACKUP}" FULL_VER=$(get_mongod_ver_from_image ${TARGET_IMAGE_MONGOD}) MONGO_VER=${FULL_VER:0:3} @@ -45,7 +45,7 @@ if [[ "$(echo ${TARGET_IMAGE} | cut -d'/' -f1)" == "perconalab" ]]; then IMAGE="${IMAGE/percona\//perconalab\/}" fi IMAGE_MONGOD=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.mongod[].imagePath') -IMAGE_PMM=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.pmm[].imagePath') +IMAGE_PMM_CLIENT=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.pmm[].imagePath') IMAGE_BACKUP=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.backup[].imagePath') if [[ ${TARGET_OPERATOR_VER} == "${INIT_OPERATOR_VER}" ]]; then @@ -88,7 +88,7 @@ function check_applied_images() { "operator") if [[ ${TARGET_IMAGE} == $(kubectl_bin get pod ${OPERATOR_NS:+-n $OPERATOR_NS} --selector=name="${OPERATOR_NAME}" -o jsonpath='{.items[*].spec.containers[?(@.name == "'"${OPERATOR_NAME}"'")].image}') && ${IMAGE_BACKUP} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.backup.image}') && - ${IMAGE_PMM} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && + ${IMAGE_PMM_CLIENT} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && ${IMAGE_MONGOD} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.image}') ]]; then : Operator image has been updated correctly else @@ -99,7 +99,7 @@ function check_applied_images() { "all") if [[ ${TARGET_IMAGE} == $(kubectl_bin get pod ${OPERATOR_NS:+-n $OPERATOR_NS} --selector=name="${OPERATOR_NAME}" -o jsonpath='{.items[*].spec.containers[?(@.name == "'"${OPERATOR_NAME}"'")].image}') && ${TARGET_IMAGE_BACKUP} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.backup.image}') && - ${TARGET_IMAGE_PMM} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && + ${TARGET_IMAGE_PMM_CLIENT} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && ${TARGET_IMAGE_MONGOD} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.image}') ]]; then : Cluster images have been updated correctly else @@ -236,7 +236,7 @@ function main() { "spec": { "crVersion": "'"${TARGET_OPERATOR_VER}"'", "image": "'"${TARGET_IMAGE_MONGOD}"'", - "pmm": { "image": "'"${TARGET_IMAGE_PMM}"'" }, + "pmm": { "image": "'"${TARGET_IMAGE_PMM_CLIENT}"'" }, "backup": { "image": "'"${TARGET_IMAGE_BACKUP}"'" } }}' sleep 10 diff --git a/e2e-tests/upgrade/run b/e2e-tests/upgrade/run index 74efb3fbda..78df239e26 100755 --- a/e2e-tests/upgrade/run +++ b/e2e-tests/upgrade/run @@ -11,7 +11,7 @@ CLUSTER_SIZE=3 TARGET_OPERATOR_VER="${OPERATOR_VERSION}" TARGET_IMAGE="${IMAGE}" TARGET_IMAGE_MONGOD="${IMAGE_MONGOD}" -TARGET_IMAGE_PMM="${IMAGE_PMM}" +TARGET_IMAGE_PMM_CLIENT="${IMAGE_PMM_CLIENT}" TARGET_IMAGE_BACKUP="${IMAGE_BACKUP}" FULL_VER=$(get_mongod_ver_from_image ${TARGET_IMAGE_MONGOD}) MONGO_VER=${FULL_VER:0:3} @@ -48,7 +48,7 @@ if [[ "$(echo ${TARGET_IMAGE} | cut -d'/' -f1)" == "perconalab" ]]; then IMAGE="${IMAGE/percona\//perconalab\/}" fi IMAGE_MONGOD=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.mongod[].imagePath') -IMAGE_PMM=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.pmm[].imagePath') +IMAGE_PMM_CLIENT=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.pmm[].imagePath') IMAGE_BACKUP=$(echo "${INIT_OPERATOR_IMAGES}" | jq -r '.versions[].matrix.backup[].imagePath') if [[ ${TARGET_OPERATOR_VER} == "${INIT_OPERATOR_VER}" ]]; then @@ -90,7 +90,7 @@ function check_applied_images() { "operator") if [[ ${TARGET_IMAGE} == $(kubectl_bin get pod ${OPERATOR_NS:+-n $OPERATOR_NS} --selector=name="${OPERATOR_NAME}" -o jsonpath='{.items[*].spec.containers[?(@.name == "'"${OPERATOR_NAME}"'")].image}') && ${IMAGE_BACKUP} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.backup.image}') && - ${IMAGE_PMM} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && + ${IMAGE_PMM_CLIENT} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && ${IMAGE_MONGOD} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.image}') ]]; then : Operator image has been updated correctly else @@ -101,7 +101,7 @@ function check_applied_images() { "all") if [[ ${TARGET_IMAGE} == $(kubectl_bin get pod ${OPERATOR_NS:+-n $OPERATOR_NS} --selector=name="${OPERATOR_NAME}" -o jsonpath='{.items[*].spec.containers[?(@.name == "'"${OPERATOR_NAME}"'")].image}') && ${TARGET_IMAGE_BACKUP} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.backup.image}') && - ${TARGET_IMAGE_PMM} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && + ${TARGET_IMAGE_PMM_CLIENT} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.pmm.image}') && ${TARGET_IMAGE_MONGOD} == $(kubectl_bin get psmdb "${cluster}" -o jsonpath='{.spec.image}') ]]; then : Cluster images have been updated correctly else @@ -202,7 +202,7 @@ function main() { "spec": { "crVersion": "'"${TARGET_OPERATOR_VER}"'", "image": "'"${TARGET_IMAGE_MONGOD}"'", - "pmm": { "image": "'"${TARGET_IMAGE_PMM}"'" }, + "pmm": { "image": "'"${TARGET_IMAGE_PMM_CLIENT}"'" }, "backup": { "image": "'"${TARGET_IMAGE_BACKUP}"'" } }}' sleep 10 diff --git a/e2e-tests/version-service/run b/e2e-tests/version-service/run index 452e3a9c6e..d96bab2857 100755 --- a/e2e-tests/version-service/run +++ b/e2e-tests/version-service/run @@ -24,7 +24,7 @@ function check_telemetry_transfer() { .spec.initImage = "'$IMAGE'" | .spec.crVersion = "9.9.9" | .spec.image = "'$IMAGE_MONGOD'" | - .spec.pmm.image = "'$IMAGE_PMM'" | + .spec.pmm.image = "'$IMAGE_PMM_CLIENT'" | .spec.backup.enabled = false | .spec.backup.image = "'$IMAGE_BACKUP'"' ${src_dir}/deploy/cr-minimal.yaml \ | kubectl_bin apply -f - @@ -162,7 +162,7 @@ for i in "${!cases[@]}"; do .spec.backup.enabled = false | del(.spec.backup.tasks) | .spec.image = "'$IMAGE_MONGOD'" | - .spec.pmm.image = "'$IMAGE_PMM'" | + .spec.pmm.image = "'$IMAGE_PMM_CLIENT'" | .spec.backup.image = "'$IMAGE_BACKUP'"' "$tmp_file" \ | kubectl_bin apply -f - From 57bbd0e76291445c0178873faa219c5cd52d1442 Mon Sep 17 00:00:00 2001 From: Pavel Tankov <4014969+ptankov@users.noreply.github.com> Date: Fri, 13 Oct 2023 21:12:12 +0300 Subject: [PATCH 2/2] some updates of the diff files (for init-deploy test case) --- e2e-tests/init-deploy/compare/backup-50.json | 1 - e2e-tests/init-deploy/compare/clusterAdmin-50.json | 2 -- e2e-tests/init-deploy/compare/clusterMonitor-50.json | 1 - 3 files changed, 4 deletions(-) diff --git a/e2e-tests/init-deploy/compare/backup-50.json b/e2e-tests/init-deploy/compare/backup-50.json index 7db2b3950a..388e9b783a 100644 --- a/e2e-tests/init-deploy/compare/backup-50.json +++ b/e2e-tests/init-deploy/compare/backup-50.json @@ -387,7 +387,6 @@ }, "actions": [ "appendOplogNote", - "checkFreeMonitoringStatus", "connPoolStats", "forceUUID", "getDefaultRWConcern", diff --git a/e2e-tests/init-deploy/compare/clusterAdmin-50.json b/e2e-tests/init-deploy/compare/clusterAdmin-50.json index 031da091c3..554afe14a7 100644 --- a/e2e-tests/init-deploy/compare/clusterAdmin-50.json +++ b/e2e-tests/init-deploy/compare/clusterAdmin-50.json @@ -219,7 +219,6 @@ "appendOplogNote", "applicationMessage", "auditConfigure", - "checkFreeMonitoringStatus", "cleanupOrphaned", "connPoolStats", "connPoolSync", @@ -256,7 +255,6 @@ "serverStatus", "setDefaultRWConcern", "setFeatureCompatibilityVersion", - "setFreeMonitoring", "setParameter", "shardingState", "shutdown", diff --git a/e2e-tests/init-deploy/compare/clusterMonitor-50.json b/e2e-tests/init-deploy/compare/clusterMonitor-50.json index 2db1b5e6ec..9a1e7eb308 100644 --- a/e2e-tests/init-deploy/compare/clusterMonitor-50.json +++ b/e2e-tests/init-deploy/compare/clusterMonitor-50.json @@ -156,7 +156,6 @@ "cluster": true }, "actions": [ - "checkFreeMonitoringStatus", "connPoolStats", "getDefaultRWConcern", "getCmdLineOpts",