blob: 513300c0bf8f2960308330c97355134770f89b74 [file] [log] [blame]
adheli.tavares7a58ae12022-03-28 12:29:01 +01001#!/bin/sh
2# ============LICENSE_START====================================================
3# Copyright (C) 2022 Nordix Foundation.
4# =============================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# SPDX-License-Identifier: Apache-2.0
18# ============LICENSE_END======================================================
19# shellcheck disable=SC2039
20# shellcheck disable=SC2086
21# shellcheck disable=SC2012
22echo "Start of test $(date +%F-%T)"
23
24export POLICY_HOME=/opt/app/policy
25export SQL_USER=policy_user
26export SQL_PASSWORD=policy_user
27export SQL_HOST=mariadb
28export MYSQL_ROOT_PASSWORD=secret
29export SCHEMA=policyadmin
30export SCRIPT_DIRECTORY=sql
31
32# Test variables
33TOTAL_COUNT=0
adheli.tavares864b6232023-02-08 09:24:26 +000034H_UPGRADE_COUNT=$(ls /home/policy/sql/0800/upgrade/*.sql | wc -l)
35H_DOWNGRADE_COUNT=$(ls /home/policy/sql/0800/downgrade/*.sql | wc -l)
36TOTAL_SQLS_UPGRADE=$H_UPGRADE_COUNT
37TOTAL_SQLS_DOWNGRADE=$H_DOWNGRADE_COUNT
38
39I_UPGRADE_COUNT=$(ls /home/policy/sql/0900/upgrade/*.sql | wc -l)
40I_DOWNGRADE_COUNT=$(ls /home/policy/sql/0900/downgrade/*.sql | wc -l)
41TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$I_UPGRADE_COUNT))
42TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$I_DOWNGRADE_COUNT))
43
44J_UPGRADE_COUNT=$(ls /home/policy/sql/1000/upgrade/*.sql | wc -l)
45J_DOWNGRADE_COUNT=$(ls /home/policy/sql/1000/downgrade/*.sql | wc -l)
46TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$J_UPGRADE_COUNT))
47TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$J_DOWNGRADE_COUNT))
48
49K_UPGRADE_COUNT=$(ls /home/policy/sql/1100/upgrade/*.sql | wc -l)
50K_DOWNGRADE_COUNT=$(ls /home/policy/sql/1100/downgrade/*.sql | wc -l)
51TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$K_UPGRADE_COUNT))
52TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$K_DOWNGRADE_COUNT))
53
54L_UPGRADE_COUNT=$(ls /home/policy/sql/1200/upgrade/*.sql | wc -l)
55L_DOWNGRADE_COUNT=$(ls /home/policy/sql/1200/downgrade/*.sql | wc -l)
56TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$L_UPGRADE_COUNT))
57TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$L_DOWNGRADE_COUNT))
adheli.tavares7a58ae12022-03-28 12:29:01 +010058
adheli.tavares9fb99a62023-11-08 15:52:05 +000059M_UPGRADE_COUNT=$(ls /home/policy/sql/1300/upgrade/*.sql | wc -l)
60M_DOWNGRADE_COUNT=$(ls /home/policy/sql/1300/downgrade/*.sql | wc -l)
61TOTAL_SQLS_UPGRADE=$(($TOTAL_SQLS_UPGRADE+$M_UPGRADE_COUNT))
62TOTAL_SQLS_DOWNGRADE=$(($TOTAL_SQLS_DOWNGRADE+$M_DOWNGRADE_COUNT))
63
adheli.tavares7a58ae12022-03-28 12:29:01 +010064NEW_SQL_EXECUTIONS=0
65START_VERSION=""
66PREVIOUS_SQL_EXECUTIONS=0
67END_VERSION=""
68RECENT_SQL_EXECUTIONS=0
69END_STATUS=0
70TEST_STATUS="FAIL"
71TEST_MSG=""
72TESTS=0
73PASSED=0
74FAILED=0
75
76# SQL statements
77PDPSTATISTICS="CREATE TABLE IF NOT EXISTS pdpstatistics ("
78PDPSTATISTICS=${PDPSTATISTICS}"PDPGROUPNAME VARCHAR(120) NULL, "
79PDPSTATISTICS=${PDPSTATISTICS}"PDPSUBGROUPNAME VARCHAR(120) NULL, "
80PDPSTATISTICS=${PDPSTATISTICS}"POLICYDEPLOYCOUNT BIGINT DEFAULT NULL NULL, "
81PDPSTATISTICS=${PDPSTATISTICS}"POLICYDEPLOYFAILCOUNT BIGINT DEFAULT NULL NULL, "
82PDPSTATISTICS=${PDPSTATISTICS}"POLICYDEPLOYSUCCESSCOUNT BIGINT DEFAULT NULL NULL, "
83PDPSTATISTICS=${PDPSTATISTICS}"POLICYEXECUTEDCOUNT BIGINT DEFAULT NULL NULL, "
84PDPSTATISTICS=${PDPSTATISTICS}"POLICYEXECUTEDFAILCOUNT BIGINT DEFAULT NULL NULL, "
85PDPSTATISTICS=${PDPSTATISTICS}"POLICYEXECUTEDSUCCESSCOUNT BIGINT DEFAULT NULL NULL, "
86PDPSTATISTICS2=${PDPSTATISTICS}"POLICYUNDEPLOYCOUNT BIGINT DEFAULT NULL NULL, "
87PDPSTATISTICS2=${PDPSTATISTICS2}"POLICYUNDEPLOYFAILCOUNT BIGINT DEFAULT NULL NULL, "
88PDPSTATISTICS2=${PDPSTATISTICS2}"POLICYUNDEPLOYSUCCESSCOUNT BIGINT DEFAULT NULL NULL, "
89PDPSTATISTICS=${PDPSTATISTICS}"timeStamp datetime NOT NULL, "
90PDPSTATISTICS2=${PDPSTATISTICS2}"timeStamp datetime DEFAULT NULL NULL, "
91PDPSTATISTICS2=${PDPSTATISTICS2}"ID BIGINT NOT NULL, "
92PDPSTATISTICS=${PDPSTATISTICS}"name VARCHAR(120) NOT NULL, "
93PDPSTATISTICS2=${PDPSTATISTICS2}"name VARCHAR(120) NOT NULL, "
94PDPSTATISTICS=${PDPSTATISTICS}"version VARCHAR(20) NOT NULL,"
95PDPSTATISTICS2=${PDPSTATISTICS2}"version VARCHAR(20) NOT NULL,"
96PDPSTATISTICS=${PDPSTATISTICS}"CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (timeStamp, name, version));"
97PDPSTATISTICS2=${PDPSTATISTICS2}"CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (ID, name, version));"
98
99IDX_TSIDX1="CREATE INDEX IDX_TSIDX1 ON pdpstatistics(timeStamp, name, version);"
100INSERT="INSERT INTO pdpstatistics(PDPGROUPNAME,PDPSUBGROUPNAME,POLICYDEPLOYCOUNT,POLICYDEPLOYFAILCOUNT,POLICYDEPLOYSUCCESSCOUNT,"
101INSERT1="${INSERT}""POLICYEXECUTEDCOUNT,POLICYEXECUTEDFAILCOUNT,POLICYEXECUTEDSUCCESSCOUNT,timeStamp,name,version)"
102INSERT2="${INSERT}""POLICYEXECUTEDCOUNT,POLICYEXECUTEDFAILCOUNT,POLICYEXECUTEDSUCCESSCOUNT,POLICYUNDEPLOYCOUNT,"
103INSERT2="${INSERT2}""POLICYUNDEPLOYFAILCOUNT,POLICYUNDEPLOYSUCCESSCOUNT,timeStamp,ID,name,version)"
104SQL1="${INSERT1}"" values('groupname', 'subgroup',1,1,1,1,1,1,now(),'test1', '1.0')"
105SQL2="${INSERT1}"" values('groupname', 'subgroup',1,1,1,1,1,1,now(),'test1', '1.0')"
106SQL3="${INSERT2}"" values('groupname', 'subgroup',1,1,1,1,1,1,1,1,1,now(),3,'test1', '1.0')"
107SQL4="${INSERT2}"" values('groupname', 'subgroup',1,1,1,1,1,1,1,1,1,now(),4,'test1', '1.0')"
108SQL5="${INSERT1}"" values('groupname', 'subgroup',1,1,1,1,1,1,now(),'test2', '1.0')"
109SQL6="${INSERT1}"" values('groupname', 'subgroup',1,1,1,1,1,1,now(),'test2', '1.0')"
110
111run_sql() {
112 local user="${1}" password="${2}" schema="${3}" sql="${4}"
113 MYSQL="mysql -u${user} -p${password} -h ${SQL_HOST} ${schema}"
114 ${MYSQL} --execute "${sql}"
115 return $?
116}
117
118start_test() {
119 echo ""
120 echo "############################################################################################################"
121 echo ""
122 let TESTS=$TESTS+1
123 reportStatus=$(/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report | tail -2)
124 echo "Starting test $TESTS"
125 echo "$reportStatus"
126 START_VERSION=$(echo $reportStatus | cut -f13 -d' ')
127 PREVIOUS_SQL_EXECUTIONS=$(echo $reportStatus | cut -f1 -d' ')
128
129 if [ "${START_VERSION}" == "" ]; then
130 START_VERSION="0"
131 PREVIOUS_SQL_EXECUTIONS=0
132 fi
133}
134
135end_test() {
136 reportStatus=$(/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report | tail -2)
137 echo "Ending test $TESTS"
138 echo "$reportStatus"
139 END_VERSION=$(echo $reportStatus | cut -f13 -d' ')
140 RECENT_SQL_EXECUTIONS=$(echo $reportStatus | cut -f1 -d' ')
141 END_STATUS=$(echo $reportStatus | cut -f7 -d' ')
142}
143
144check_results() {
145 local status="${1}" operation="${2}" startVer="${3}" endVer="${4}" newRecords="${5}" filesRan="${6}"
146
147 echo ""
148 echo "Test summary: status:$status, operation:$operation, from:$startVer, to:$endVer, new executions:$newRecords, sqlFiles:$filesRan"
149 # Convert to number
150 startVer=$(echo ${startVer} | awk '{$0=int($0)}1')
151 endVer=$(echo ${endVer} | awk '{$0=int($0)}1')
152
153 if [ ${startVer} -eq ${endVer} ] && [ $newRecords -eq $filesRan ] && [ $newRecords -eq 0 ]; then
154 TEST_MSG="No ${operation} required"
155 TEST_STATUS="PASS"
156 let PASSED=$PASSED+1
157 elif [ $status -eq 1 ] && [ "${operation}" == "upgrade" ] && [ ${startVer} -le ${endVer} ] && [ $newRecords -eq $filesRan ]; then
158 TEST_MSG="Successful ${operation}"
159 TEST_STATUS="PASS"
160 let PASSED=$PASSED+1
161 elif [ $status -eq 1 ] && [ "${operation}" == "downgrade" ] && [ ${startVer} -ge ${endVer} ] && [ $newRecords -eq $filesRan ]; then
162 TEST_MSG="Successful ${operation}"
163 TEST_STATUS="PASS"
164 let PASSED=$PASSED+1
165 else
166 TEST_MSG="Errors occurred during ${operation}"
167 TEST_STATUS="FAIL"
168 let FAILED=$FAILED+1
169 fi
170 echo ""
171 echo "*** Test $TESTS: $TEST_STATUS , $TEST_MSG, current version: $END_VERSION ***"
172 echo ""
173}
174
175# Test 1 - Upgrade to Istanbul
176/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
177start_test
178/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -t 0900
179end_test
adheli.tavares864b6232023-02-08 09:24:26 +0000180let TOTAL_COUNT=$H_UPGRADE_COUNT+$I_UPGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100181check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $RECENT_SQL_EXECUTIONS $TOTAL_COUNT
182
183sleep 5
184
185# Test 2 - downgrade to 0800
186start_test
187/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
188/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
189end_test
190let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000191check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100192
193sleep 5
194
195# Test 3 - upgrade to 0900
196start_test
197/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
198/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -f 0800 -t 0900
199end_test
200let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000201check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100202
203sleep 5
204
205# Test4 - run upgrade on db where tables already exist and migration schema is empty
206start_test
207/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
208/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
209run_sql "root" "${MYSQL_ROOT_PASSWORD}" "${SCHEMA}" "DROP DATABASE IF EXISTS migration;"
210/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
211/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -t 0900
212end_test
213let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000214check_results $END_STATUS 'upgrade' "0800" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100215
216sleep 5
217
218# Test5 - upgrade after failed downgrade
219start_test
220/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
221run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "DROP table pdpstatistics;"
222/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
223run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${PDPSTATISTICS2}"
224run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${IDX_TSIDX1}"
225/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
226/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -f 0800 -t 0900
227end_test
228let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
229# (files run before error * 2) + 1 to run the file again
230let TOTAL_COUNT=11
231check_results $END_STATUS 'upgrade' "0800" "0900" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
232
233sleep 5
234
235# Test6 - Downgrade after failed downgrade
236start_test
237/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
238run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "DROP table pdpstatistics;"
239/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
240run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${PDPSTATISTICS2}"
241run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${IDX_TSIDX1}"
242/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
243end_test
244let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
245# +1 to run the file again
adheli.tavares864b6232023-02-08 09:24:26 +0000246let TOTAL_COUNT=$I_UPGRADE_COUNT+1
adheli.tavares7a58ae12022-03-28 12:29:01 +0100247check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
248
249sleep 5
250
251# Test7 - downgrade after failed upgrade
252start_test
253/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
254run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "DROP table pdpstatistics;"
255/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -f 0800 -t 0900
256run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${PDPSTATISTICS}"
257/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
258/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
259end_test
260let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
261# (files run before error * 2) + 1 to run the file again
262let TOTAL_COUNT=3
263check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
264
265sleep 5
266
267# Test 8 - Upgrade after failed upgrade
268start_test
269/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
270run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "DROP table pdpstatistics;"
271/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -f 0800 -t 0900
272run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${PDPSTATISTICS}"
273/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -t 0900
274end_test
275let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
276# +1 to run the file again
adheli.tavares864b6232023-02-08 09:24:26 +0000277let TOTAL_COUNT=$I_UPGRADE_COUNT+1
adheli.tavares7a58ae12022-03-28 12:29:01 +0100278check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
279
280sleep 5
281
282# Test 9 - Upgrade when pdpstatistics contains data
283/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
284/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
285start_test
286run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL1}"
287sleep 1
288run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL2}"
289sleep 1
290/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
291/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -f 0800 -t 0900
292run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL3}"
293sleep 1
294run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL4}"
295end_test
296let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
297# +1 to run the file again
adheli.tavares864b6232023-02-08 09:24:26 +0000298let TOTAL_COUNT=$I_UPGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100299check_results $END_STATUS 'upgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_COUNT
300
301sleep 5
302
303# Test 10 - downgrade to 0800 with records in pdpstatistics
304start_test
305/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
306/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0900 -t 0800
307run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL5}"
308sleep 1
309run_sql "${SQL_USER}" "${SQL_PASSWORD}" "${SCHEMA}" "${SQL6}"
310end_test
311let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000312check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $I_UPGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100313
314sleep 5
315
316# Test 11 - downgrade from 0800
317start_test
318/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
319/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 0800
320end_test
321let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000322check_results $END_STATUS 'downgrade' "${START_VERSION}" "${END_VERSION}" $NEW_SQL_EXECUTIONS $H_DOWNGRADE_COUNT
adheli.tavares7a58ae12022-03-28 12:29:01 +0100323
324sleep 5
325
326# Test 12 - Full upgrade
327start_test
328/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
329/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade
330end_test
331let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000332check_results $END_STATUS 'upgrade' "0" "${END_VERSION}" $NEW_SQL_EXECUTIONS $TOTAL_SQLS_UPGRADE
adheli.tavares7a58ae12022-03-28 12:29:01 +0100333
334sleep 5
335
336# Test 13 - Full downgrade
337start_test
338/opt/app/policy/bin/prepare_downgrade.sh ${SQL_DB}
adheli.tavares9fb99a62023-11-08 15:52:05 +0000339/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 1300 -t 0
adheli.tavares7a58ae12022-03-28 12:29:01 +0100340end_test
341let NEW_SQL_EXECUTIONS=$RECENT_SQL_EXECUTIONS-$PREVIOUS_SQL_EXECUTIONS
adheli.tavares864b6232023-02-08 09:24:26 +0000342check_results $END_STATUS 'downgrade' "${START_VERSION}" "0" $NEW_SQL_EXECUTIONS $TOTAL_SQLS_DOWNGRADE
343
344# Install database
345/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
346/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade
347/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report
adheli.tavares7a58ae12022-03-28 12:29:01 +0100348
349echo
350echo "-----------------------------------------------------------------------"
351echo "Number of Tests: $TESTS, Tests Passed: $PASSED, Tests Failed: $FAILED"
352echo "-----------------------------------------------------------------------"
353
354echo "End of test $(date +%F-%T)"
355
356nc -lk -p 6824
357
358exit 0