Skip to content

Commit

Permalink
Fix post mariadb import checks
Browse files Browse the repository at this point in the history
Signed-off-by: Bohdan Dobrelia <[email protected]>
  • Loading branch information
bogdando committed Dec 20, 2024
1 parent 4582406 commit 294fe29
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,28 +334,23 @@ $ . ~/.source_cloud_exported_variables_default
$ set -u
$ dbs=$(oc exec openstack-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" -e 'SHOW databases;')
$ echo $dbs | grep -Eq '\bkeystone\b' && echo "OK" || echo "CHECK FAILED"
$ echo $dbs | grep -Eq '\bneutron\b'
$ echo $dbs | grep -Eq '\bneutron\b' && echo "OK" || echo "CHECK FAILED"
$ echo "${PULL_OPENSTACK_CONFIGURATION_DATABASES[@]}" | grep -Eq '\bovs_neutron\b' && echo "OK" || echo "CHECK FAILED" <1>
$ novadb_mapped_cells=$(oc exec openstack-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" \
> nova_api -e 'select uuid,name,transport_url,database_connection,disabled from cell_mappings;') <2>
$ uuidf='\S{8,}-\S{4,}-\S{4,}-\S{4,}-\S{12,}'
$ left_behind=$(comm -23 \
> <(echo $PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS | grep -oE " $uuidf \S+") \
> <(echo $novadb_mapped_cells | tr -s "| " " " | grep -oE " $uuidf \S+"))
$ changed=$(comm -13 \
> <(echo $PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS | grep -oE " $uuidf \S+") \
> <(echo $novadb_mapped_cells | tr -s "| " " " | grep -oE " $uuidf \S+"))
$ test $(grep -Ec ' \S+$' <<<$left_behind) -eq 1 && echo "OK" || echo "CHECK FAILED"
$ default=$(grep -E ' default$' <<<$left_behind)
$ test $(grep -Ec ' \S+$' <<<$changed) -eq 1 && echo "OK" || echo "CHECK FAILED"
$ grep -qE " $(awk '{print $1}' <<<$default) ${DEFAULT_CELL_NAME}$" <<<$changed && echo "OK" || echo "CHECK FAILED"
$ default=$(printf "%s\n" "$PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS" | sed -rn "s/^($uuidf)\s+default\b.*$/\1/p")
$ difference=$(diff -ZNua \
> <(printf "%s\n" "$PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS") \
> <(printf "%s\n" "$novadb_mapped_cells")) || true
$ if [ "$DEFAULT_CELL_NAME" != "default" ]; then
> printf "%s\n" "$difference" | grep -qE "^\-$default\s+default\b" && echo "OK" || echo "CHECK FAILED"
> printf "%s\n" "$difference" | grep -qE "^\+$default\s+$DEFAULT_CELL_NAME\b" && echo "OK" || echo "CHECK FAILED"
> [ $(grep -E "^[-\+]$uuidf" <<<"$difference" | wc -l) -eq 2 ] && echo "OK" || echo "CHECK FAILED"
> else
> [ "x$difference" = "x" ] && echo "OK" || echo "CHECK FAILED"
> fi
$ for CELL in $(echo $RENAMED_CELLS); do <3>
> unset PULL_OPENSTACK_CONFIGURATION_DATABASES
> unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
> unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
> declare -A PULL_OPENSTACK_CONFIGURATION_DATABASES
> declare -A PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
> declare -A PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
> RCELL=$CELL
> [ "$CELL" = "$DEFAULT_CELL_NAME" ] && RCELL=default
> set +u
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,7 @@ After the {OpenStackShort} control plane services are shut down, if any of the e
+
----
$ unset SRIOV_AGENTS
$ unset PULL_OPENSTACK_CONFIGURATION_DATABASES
$ unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
$ unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
$ declare -xA SRIOV_AGENTS <1>
$ declare -xA PULL_OPENSTACK_CONFIGURATION_DATABASES
$ declare -xA PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
$ declare -xA PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
$ for CELL in $(echo $CELLS); do
> cat > ~/.source_cloud_exported_variables_$CELL << EOF
> PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]="$(oc run mariadb-client-5-$CELL ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \
Expand Down
12 changes: 10 additions & 2 deletions tests/roles/get_services_configuration/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@
ansible.builtin.shell: |
{{ oc_header }}
{{ mariadb_copy_shell_vars_src }}
for CELL in $(echo $CELLS); do
cat > ~/.source_cloud_exported_variables_$CELL << EOF
unset PULL_OPENSTACK_CONFIGURATION_DATABASES
unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
unset PULL_OPENSTACK_CONFIGURATION_NOVAMANAGE_CELL_MAPPINGS
declare -xA PULL_OPENSTACK_CONFIGURATION_DATABASES
declare -xA PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
declare -xA PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
for CELL in $(echo $CELLS); do
cat > ~/.source_cloud_exported_variables_$CELL << EOF
PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]="$(oc run mariadb-client-5-$CELL ${MARIADB_CLIENT_ANNOTATIONS} {{ mysql_client_override }} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \
mysql -rsh ${SOURCE_MARIADB_IP[$CELL]} -uroot -p${SOURCE_DB_ROOT_PASSWORD[$CELL]} -e 'SHOW databases;')"
PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK[$CELL]="$(oc run mariadb-client-6-$CELL ${MARIADB_CLIENT_ANNOTATIONS} {{ mysql_client_override }} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \
Expand All @@ -97,6 +98,13 @@
EOF
done
cat >> ~/.source_cloud_exported_variables_default << EOF
unset PULL_OPENSTACK_CONFIGURATION_DATABASES
unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
unset PULL_OPENSTACK_CONFIGURATION_NOVAMANAGE_CELL_MAPPINGS
declare -xA PULL_OPENSTACK_CONFIGURATION_DATABASES
declare -xA PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
declare -xA PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS="$(oc run mariadb-client-2 ${MARIADB_CLIENT_ANNOTATIONS} {{ mysql_client_override }} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \
mysql -rsh ${SOURCE_MARIADB_IP['default']} -uroot -p${SOURCE_DB_ROOT_PASSWORD['default']} -e \
'select uuid,name,transport_url,database_connection,disabled from nova_api.cell_mappings;' || echo None)"
Expand Down
29 changes: 12 additions & 17 deletions tests/roles/mariadb_copy/templates/post_checks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,23 @@ set +u
set -u
dbs=$(oc exec openstack-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" -e 'SHOW databases;')
echo $dbs | grep -Eq '\bkeystone\b' && echo "OK" || echo "CHECK FAILED"
echo $dbs | grep -Eq '\bneutron\b'
echo $dbs | grep -Eq '\bneutron\b' && echo "OK" || echo "CHECK FAILED"
echo "${PULL_OPENSTACK_CONFIGURATION_DATABASES[@]}" | grep -Eq '\bovs_neutron\b' && echo "OK" || echo "CHECK FAILED" # <1>
novadb_mapped_cells=$(oc exec openstack-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" \
nova_api -e 'select uuid,name,transport_url,database_connection,disabled from cell_mappings;') # <2>
uuidf='\S{8,}-\S{4,}-\S{4,}-\S{4,}-\S{12,}'
left_behind=$(comm -23 \
<(echo $PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS | grep -oE " $uuidf \S+") \
<(echo $novadb_mapped_cells | tr -s "| " " " | grep -oE " $uuidf \S+"))
changed=$(comm -13 \
<(echo $PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS | grep -oE " $uuidf \S+") \
<(echo $novadb_mapped_cells | tr -s "| " " " | grep -oE " $uuidf \S+"))
test $(grep -Ec ' \S+$' <<<$left_behind) -eq 1 && echo "OK" || echo "CHECK FAILED"
default=$(grep -E ' default$' <<<$left_behind)
test $(grep -Ec ' \S+$' <<<$changed) -eq 1 && echo "OK" || echo "CHECK FAILED"
grep -qE " $(awk '{print $1}' <<<$default) ${DEFAULT_CELL_NAME}$" <<<$changed && echo "OK" || echo "CHECK FAILED"
default=$(printf "%s\n" "$PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS" | sed -rn "s/^($uuidf)\s+default\b.*$/\1/p")
difference=$(diff -ZNua \
<(printf "%s\n" "$PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS") \
<(printf "%s\n" "$novadb_mapped_cells")) || true
if [ "$DEFAULT_CELL_NAME" != "default" ]; then
printf "%s\n" "$difference" | grep -qE "^\-$default\s+default\b" && echo "OK" || echo "CHECK FAILED"
printf "%s\n" "$difference" | grep -qE "^\+$default\s+$DEFAULT_CELL_NAME\b" && echo "OK" || echo "CHECK FAILED"
[ $(grep -E "^[-\+]$uuidf" <<<"$difference" | wc -l) -eq 2 ] && echo "OK" || echo "CHECK FAILED"
else
[ "x$difference" = "x" ] && echo "OK" || echo "CHECK FAILED"
fi
for CELL in $(echo $RENAMED_CELLS); do # <3>
unset PULL_OPENSTACK_CONFIGURATION_DATABASES
unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
declare -A PULL_OPENSTACK_CONFIGURATION_DATABASES
declare -A PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
declare -A PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
RCELL=$CELL
[ "$CELL" = "$DEFAULT_CELL_NAME" ] && RCELL=default
set +u
Expand Down

0 comments on commit 294fe29

Please sign in to comment.