diff --git a/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc b/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc index 8fc4c46c4..740b41941 100644 --- a/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc +++ b/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc @@ -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 diff --git a/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc b/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc index b666d6b77..93f052b04 100644 --- a/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc +++ b/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc @@ -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 -- \ diff --git a/tests/roles/get_services_configuration/tasks/main.yaml b/tests/roles/get_services_configuration/tasks/main.yaml index 1704ff0ba..a7a792d16 100644 --- a/tests/roles/get_services_configuration/tasks/main.yaml +++ b/tests/roles/get_services_configuration/tasks/main.yaml @@ -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 -- \ @@ -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)" diff --git a/tests/roles/mariadb_copy/templates/post_checks.bash b/tests/roles/mariadb_copy/templates/post_checks.bash index 572ac2e10..6e4fc634c 100755 --- a/tests/roles/mariadb_copy/templates/post_checks.bash +++ b/tests/roles/mariadb_copy/templates/post_checks.bash @@ -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