44ROOT_REPO=${ROOT_REPO:- $(realpath ../ ../ ..)}
55test_name=$( basename " $( pwd) " )
66source " ${ROOT_REPO} /e2e-tests/vars.sh"
7+ sed=$( which gsed || which sed)
78
89if oc get projects 2> /dev/null; then
910 OPENSHIFT=4
@@ -176,7 +177,7 @@ get_pmm_server_token() {
176177 -w " \n%{http_code}" )
177178
178179 create_status_code=$( echo " $create_response " | tail -n1)
179- create_json_response=$( echo " $create_response " | sed ' $ d' )
180+ create_json_response=$( echo " $create_response " | $ sed ' $ d' )
180181
181182 if [[ $create_status_code -ne 201 ]]; then
182183 echo " Error: Failed to create PMM service account. HTTP Status: $create_status_code " >&2
@@ -200,7 +201,7 @@ get_pmm_server_token() {
200201 -w " \n%{http_code}" )
201202
202203 token_status_code=$( echo " $token_response " | tail -n1)
203- token_json_response=$( echo " $token_response " | sed ' $ d' )
204+ token_json_response=$( echo " $token_response " | $ sed ' $ d' )
204205
205206 if [[ $token_status_code -ne 200 ]]; then
206207 echo " Error: Failed to create token. HTTP Status: $token_status_code " >&2
@@ -234,7 +235,7 @@ delete_pmm_server_token() {
234235 -w " \n%{http_code}" )
235236
236237 service_accounts_status=$( echo " $service_accounts_response " | tail -n1)
237- service_accounts_json=$( echo " $service_accounts_response " | sed ' $ d' )
238+ service_accounts_json=$( echo " $service_accounts_response " | $ sed ' $ d' )
238239
239240 if [[ $service_accounts_status -ne 200 ]]; then
240241 echo " Error: Failed to fetch service accounts. HTTP Status: $service_accounts_status " >&2
@@ -256,7 +257,7 @@ delete_pmm_server_token() {
256257 -w " \n%{http_code}" )
257258
258259 tokens_status=$( echo " $tokens_response " | tail -n1)
259- tokens_json=$( echo " $tokens_response " | sed ' $ d' )
260+ tokens_json=$( echo " $tokens_response " | $ sed ' $ d' )
260261
261262 if [[ $tokens_status -ne 200 ]]; then
262263 echo " Error: Failed to fetch tokens. HTTP Status: $tokens_status " >&2
@@ -533,17 +534,17 @@ deploy_vault() {
533534 fi
534535
535536 cat ${secret} \
536- | sed -e " s/#token/$token /" \
537- | sed -e " s/#vault_url/$protocol :\/\/$name .$name .svc.cluster.local:8200/" \
538- | sed -e " s/#secret/secret/" > " ${tmp_dir} /vault-secret.yaml"
537+ | $ sed -e " s/#token/$token /" \
538+ | $ sed -e " s/#vault_url/$protocol :\/\/$name .$name .svc.cluster.local:8200/" \
539+ | $ sed -e " s/#secret/secret/" > " ${tmp_dir} /vault-secret.yaml"
539540
540541 if [ $protocol == " https" ]; then
541- sed -e ' s/^/ /' ${tmp_dir} /vault.ca > ${tmp_dir} /vault.new.ca
542- sed -i " s/#vault_ca/vault_ca/" " ${tmp_dir} /vault-secret.yaml"
543- sed -i " /#certVal/r ${tmp_dir} /vault.new.ca" " ${tmp_dir} /vault-secret.yaml"
544- sed -i " /#certVal/d" " ${tmp_dir} /vault-secret.yaml"
542+ $ sed -e ' s/^/ /' ${tmp_dir} /vault.ca > ${tmp_dir} /vault.new.ca
543+ $ sed -i " s/#vault_ca/vault_ca/" " ${tmp_dir} /vault-secret.yaml"
544+ $ sed -i " /#certVal/r ${tmp_dir} /vault.new.ca" " ${tmp_dir} /vault-secret.yaml"
545+ $ sed -i " /#certVal/d" " ${tmp_dir} /vault-secret.yaml"
545546 else
546- sed -i " /#vault_ca/d" " ${tmp_dir} /vault-secret.yaml"
547+ $ sed -i " /#vault_ca/d" " ${tmp_dir} /vault-secret.yaml"
547548 fi
548549
549550 kubectl apply -n " ${NAMESPACE} " -f ${tmp_dir} /vault-secret.yaml
@@ -613,7 +614,7 @@ run_mysql() {
613614
614615 kubectl -n " ${NAMESPACE} " exec " ${pod:- mysql-client} " -- \
615616 bash -c " printf '%s\n' \" ${command} \" | mysql -sN $uri " 2>&1 \
616- | sed -e ' s/mysql: //' \
617+ | $ sed -e ' s/mysql: //' \
617618 | (grep -v ' Using a password on the command line interface can be insecure.' || :)
618619}
619620
@@ -676,7 +677,7 @@ get_gr_status() {
676677 client_pod=$( get_client_pod)
677678
678679 kubectl -n " ${NAMESPACE} " exec " ${pod:- mysql-client} " -- mysqlsh --js --uri $uri --cluster --result-format json -- cluster status \
679- | sed -e ' s/mysql: //' \
680+ | $ sed -e ' s/mysql: //' \
680681 | (grep -v ' Using a password on the command line interface can be insecure.' || :)
681682}
682683
@@ -776,7 +777,7 @@ get_qan20_values() {
776777EOF
777778 )
778779
779- run_curl -XPOST -d " '$( echo ${payload} | sed ' s/\n//g' ) '" " -H 'Authorization: Bearer ${token} '" " https://${user_pass} @${endpoint} /v1/qan/metrics:getReport" \
780+ run_curl -XPOST -d " '$( echo ${payload} | $ sed ' s/\n//g' ) '" " -H 'Authorization: Bearer ${token} '" " https://${user_pass} @${endpoint} /v1/qan/metrics:getReport" \
780781 | jq ' .rows[].fingerprint'
781782}
782783
@@ -1069,7 +1070,7 @@ deploy_chaos_mesh() {
10691070}
10701071
10711072destroy_chaos_mesh () {
1072- local chaos_mesh_ns=$( helm list --all-namespaces --filter chaos-mesh | tail -n1 | awk -F' ' ' {print $2}' | sed ' s/NAMESPACE//' )
1073+ local chaos_mesh_ns=$( helm list --all-namespaces --filter chaos-mesh | tail -n1 | awk -F' ' ' {print $2}' | $ sed ' s/NAMESPACE//' )
10731074
10741075 if [ -n " ${chaos_mesh_ns} " ]; then
10751076 helm uninstall --wait --timeout 60s chaos-mesh --namespace ${chaos_mesh_ns} || :
@@ -1252,7 +1253,7 @@ check_primary_chaos() {
12521253 | jq .defaultReplicaSet.topology[].status \
12531254 | grep ONLINE \
12541255 | wc -l \
1255- | sed ' s/ //g' )
1256+ | $ sed ' s/ //g' )
12561257
12571258 if [[ ${online_members} != 3 ]]; then
12581259 echo " expected 3 online members, got ${online_members} "
@@ -1285,7 +1286,7 @@ renew_certificate() {
12851286deploy_cmctl () {
12861287 local service_account=" cmctl"
12871288
1288- sed -e " s/percona-server-mysql-operator/$service_account /g" " ${DEPLOY_DIR} /rbac.yaml" \
1289+ $ sed -e " s/percona-server-mysql-operator/$service_account /g" " ${DEPLOY_DIR} /rbac.yaml" \
12891290 | yq ' (select(.rules).rules[] | select(contains({"apiGroups": ["cert-manager.io"]}))).resources += "certificates/status"' \
12901291 | kubectl apply -n " ${NAMESPACE} " -f -
12911292 kubectl apply -n " ${NAMESPACE} " -f " ${TESTS_CONFIG_DIR} /cmctl.yml"
0 commit comments