Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUD-808 Fix PMM server deployment in tests #1361

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 2 additions & 17 deletions e2e-tests/default-cr/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
28 changes: 24 additions & 4 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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"'
}
Expand Down Expand Up @@ -1337,3 +1336,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
}
21 changes: 1 addition & 20 deletions e2e-tests/monitoring-2-0/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
until kubectl_bin exec monitoring-0 -- bash -c "ls -l /proc/*/exe 2>/dev/null| grep postgres >/dev/null"; do
echo "Retry $retry"
Expand Down
10 changes: 5 additions & 5 deletions e2e-tests/upgrade-sharded/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions e2e-tests/upgrade/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/version-service/run
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down Expand Up @@ -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 -

Expand Down
Loading