aboutsummaryrefslogtreecommitdiffstats
path: root/policy-db-migrator/smoke-test
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-02-08 09:24:26 +0000
committeradheli.tavares <adheli.tavares@est.tech>2023-02-08 11:34:05 +0000
commit864b6236aa7caa2e27f9e188c6e34666e2dce9be (patch)
treea9a31d65cdd0648201015a6dbd82592ee17258a7 /policy-db-migrator/smoke-test
parent8a98552c7f5a0b58e3a524db24e8bfb47a4494b1 (diff)
Improve MariaDB Sqls for db-migrator tool
Issue-ID: POLICY-4549 Change-Id: I4a1cd6514ae8025726ca015081632633ea49361a Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'policy-db-migrator/smoke-test')
-rwxr-xr-xpolicy-db-migrator/smoke-test/mariadb-tests.sh61
1 files changed, 41 insertions, 20 deletions
diff --git a/policy-db-migrator/smoke-test/mariadb-tests.sh b/policy-db-migrator/smoke-test/mariadb-tests.sh
index a5f1e31f..418a4740 100755
--- a/policy-db-migrator/smoke-test/mariadb-tests.sh
+++ b/policy-db-migrator/smoke-test/mariadb-tests.sh
@@ -31,12 +31,30 @@ export SCRIPT_DIRECTORY=sql
# Test variables
TOTAL_COUNT=0
-HONOLULU_UPGRADE_COUNT=$(ls /home/policy/sql/0800/upgrade/*.sql | wc -l)
-HONOLULU_DOWNGRADE_COUNT=$(ls /home/policy/sql/0800/downgrade/*.sql | wc -l)
-ISTANBUL_UPGRADE_COUNT=$(ls /home/policy/sql/0900/upgrade/*.sql | wc -l)
-ISTANBUL_DOWNGRADE_COUNT=$(ls /home/policy/sql/0900/downgrade/*.sql | wc -l)
-JAKARTA_UPGRADE_COUNT=$(ls /home/policy/sql/1000/upgrade/*.sql | wc -l)
-JAKARTA_DOWNGRADE_COUNT=$(ls /home/policy/sql/1000/downgrade/*.sql | wc -l)
+H_UPGRADE_COUNT=$(ls /home/policy/sql/0800/upgrade/*.sql | wc -l)
+H_DOWNGRADE_COUNT=$(ls /home/policy/sql/0800/downgrade/*.sql | wc -l)
+TOTAL_SQLS_UPGRADE=$H_UPGRADE_COUNT
+TOTAL_SQLS_DOWNGRADE=$H_DOWNGRADE_COUNT
+
+I_UPGRADE_COUNT=$(ls /home/policy/sql/0900/upgrade/*.sql | wc -l)
+I_DOWNGRADE_COUNT=$(ls /home/policy/sql/0900/downgrade/*.sql | wc -l)
+TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$I_UPGRADE_COUNT))
+TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$I_DOWNGRADE_COUNT))
+
+J_UPGRADE_COUNT=$(ls /home/policy/sql/1000/upgrade/*.sql | wc -l)
+J_DOWNGRADE_COUNT=$(ls /home/policy/sql/1000/downgrade/*.sql | wc -l)
+TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$J_UPGRADE_COUNT))
+TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$J_DOWNGRADE_COUNT))
+
+K_UPGRADE_COUNT=$(ls /home/policy/sql/1100/upgrade/*.sql | wc -l)
+K_DOWNGRADE_COUNT=$(ls /home/policy/sql/1100/downgrade/*.sql | wc -l)
+TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$K_UPGRADE_COUNT))
+TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$K_DOWNGRADE_COUNT))
+
+L_UPGRADE_COUNT=$(ls /home/policy/sql/1200/upgrade/*.sql | wc -l)
+L_DOWNGRADE_COUNT=$(ls /home/policy/sql/1200/downgrade/*.sql | wc -l)
+TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$L_UPGRADE_COUNT))
+TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$L_DOWNGRADE_COUNT))
NEW_SQL_EXECUTIONS=0
START_VERSION=""
@@ -154,7 +172,7 @@ check_results() {
start_test
/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -t 0900
end_test
-let TOTAL_COUNT=$HONOLULU_UPGRADE_COUNT+$ISTANBUL_UPGRADE_COUNT
+let TOTAL_COUNT=$H_UPGRADE_COUNT+$I_UPGRADE_COUNT
check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $RECENT_SQL_EXECUTIONS $TOTAL_COUNT
sleep 5
@@ -165,7 +183,7 @@ start_test
/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
-check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $ISTANBUL_DOWNGRADE_COUNT
+check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
sleep 5
@@ -175,7 +193,7 @@ start_test
/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -f 0800 -t 0900
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
-check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $ISTANBUL_UPGRADE_COUNT
+check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
sleep 5
@@ -188,7 +206,7 @@ run_sql "root" "${MYSQL_ROOT_PASSWORD}" "${SCHEMA}" "DROP DATABASE IF EXISTS mig
/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -t 0900
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS
-check_results $END_STATUS 'upgrade' "0800" "${END_VERSION}" $NEW_SQL_EXECUTIONS $ISTANBUL_UPGRADE_COUNT
+check_results $END_STATUS 'upgrade' "0800" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
sleep 5
@@ -220,7 +238,7 @@ run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${IDX_TSIDX1}"
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
# +1 to run the file again
-let TOTAL_COUNT=$ISTANBUL_DOWNGRADE_COUNT+1
+let TOTAL_COUNT=$I_UPGRADE_COUNT+1
check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
sleep 5
@@ -251,7 +269,7 @@ run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${PDPSTATISTICS}"
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
# +1 to run the file again
-let TOTAL_COUNT=$ISTANBUL_UPGRADE_COUNT+1
+let TOTAL_COUNT=$I_UPGRADE_COUNT+1
check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
sleep 5
@@ -272,7 +290,7 @@ run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL4}"
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
# +1 to run the file again
-let TOTAL_COUNT=$ISTANBUL_UPGRADE_COUNT
+let TOTAL_COUNT=$I_UPGRADE_COUNT
check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
sleep 5
@@ -286,7 +304,7 @@ sleep 1
run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL6}"
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
-check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $ISTANBUL_DOWNGRADE_COUNT
+check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
sleep 5
@@ -296,7 +314,7 @@ start_test
/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0800
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
-check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $HONOLULU_DOWNGRADE_COUNT
+check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $H_DOWNGRADE_COUNT
sleep 5
@@ -306,19 +324,22 @@ start_test
/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
-let TOTAL_COUNT=$HONOLULU_UPGRADE_COUNT+$ISTANBUL_UPGRADE_COUNT+$JAKARTA_UPGRADE_COUNT
-check_results $END_STATUS 'upgrade' "0" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
+check_results $END_STATUS 'upgrade' "0" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_SQLS_UPGRADE
sleep 5
# Test 13 - Full downgrade
start_test
/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
-/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 1000 -t 0
+/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 1200 -t 0
end_test
let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
-let TOTAL_COUNT=$HONOLULU_DOWNGRADE_COUNT+$ISTANBUL_DOWNGRADE_COUNT+$JAKARTA_DOWNGRADE_COUNT
-check_results $END_STATUS 'downgrade' "${START_VERSION}" "0" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
+check_results $END_STATUS 'downgrade' "${START_VERSION}" "0" $NEW_SQL_EXECUTIONS $TOTAL_SQLS_DOWNGRADE
+
+# Install database
+/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
+/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade
+/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report
echo
echo "-----------------------------------------------------------------------"