Skip to content

Commit

Permalink
fix(tests): mariadb deprecated mysql stuff, so stuff needs to be done
Browse files Browse the repository at this point in the history
  • Loading branch information
iamwacko committed Feb 16, 2024
1 parent 1ac7a4b commit 48c3404
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions synth/testing_harness/mysql/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function help() {
commands:
load-schema [--no-data]|Fills DB with test schema - defaults to loading data too
test-generate|Test generating data to mysql
test-generate|Test generating data to mysql
test-import|Test importing from mysql data
test-warnings|Test all warnings
test-warning <warning>|Test a specific warning
Expand All @@ -35,24 +35,24 @@ commands:
}

function load-schema() {
docker exec -i $NAME mysql -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" < 0_hospital_schema.sql || return 1
[ ${1} == "--no-data" ] || docker exec -i $NAME mysql -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" < 1_hospital_data.sql || return 1
docker exec -i $NAME $SCHEME -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" < 0_hospital_schema.sql || return 1
[ ${1} == "--no-data" ] || docker exec -i $NAME $SCHEME -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" < 1_hospital_data.sql || return 1
}

function test-generate() {
echo -e "${INFO}Test generate${NC}"
load-schema --no-data || { echo -e "${ERROR}Failed to load schema${NC}"; return 1; }
$SYNTH generate hospital_master --to $SCHEME://root:${PASSWORD}@localhost:${PORT}/test_db --size 30 || return 1
$SYNTH generate hospital_master --to mysql://root:${PASSWORD}@localhost:${PORT}/test_db --size 30 || return 1

sum_rows_query="SELECT (SELECT count(*) FROM hospitals) + (SELECT count(*) FROM doctors) + (SELECT count(*) FROM patients)"
sum=`docker exec -i $NAME mysql -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" -e "$sum_rows_query" | grep -o '[[:digit:]]*'`
sum=`docker exec -i $NAME $SCHEME -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" -e "$sum_rows_query" | grep -o '[[:digit:]]*'`
[ "$sum" -gt "30" ] || { echo -e "${ERROR}Generation did not create more than 30 records${NC}"; return 1; }
}

function test-import() {
echo -e "${INFO}Testing import${NC}"
load-schema --all || { echo -e "${ERROR}Failed to load schema${NC}"; return 1; }
$SYNTH import --from $SCHEME://root:${PASSWORD}@localhost:${PORT}/test_db hospital_import || { echo -e "${ERROR}Import failed${NC}"; return 1; }
$SYNTH import --from mysql://root:${PASSWORD}@localhost:${PORT}/test_db hospital_import || { echo -e "${ERROR}Import failed${NC}"; return 1; }
diff <(jq --sort-keys . hospital_import/*) <(jq --sort-keys . hospital_master/*) || { echo -e "${ERROR}Import namespaces do not match${NC}"; return 1; }
}

Expand All @@ -69,8 +69,8 @@ function test-warning() {

echo -e "${INFO}[$folder] Testing warning${NC}"

docker exec -i $NAME mysql -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" < "$folder/schema.sql"
output=$($SYNTH generate --size 10 --to $SCHEME://root:${PASSWORD}@localhost:${PORT}/test_db "$folder" 2>&1)
docker exec -i $NAME $SCHEME -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" < "$folder/schema.sql"
output=$($SYNTH generate --size 10 --to mysql://root:${PASSWORD}@localhost:${PORT}/test_db "$folder" 2>&1)
warnings=$(echo "$output" | grep "WARN" | grep -Po "(?<=\]\s).*$")

if [ -z "$warnings" ]
Expand Down Expand Up @@ -105,7 +105,7 @@ function up() {
docker run --rm --name $NAME -p $PORT:3306 -e MYSQL_ROOT_PASSWORD=$PASSWORD -e MYSQL_DATABASE="test_db" -d $SCHEME > /dev/null

wait_count=0
while ! docker exec -i $NAME mysql -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" -e "SELECT 1" > /dev/null 2>&1
while ! docker exec -i $NAME $SCHEME -h 127.0.0.1 -u root --password=$PASSWORD -P 3306 "test_db" -e "SELECT 1" > /dev/null 2>&1
do
range=$(printf "%${wait_count}s")
echo -en "\\r${DEBUG}Waiting for DB to come up${range// /.}${NC}"
Expand Down

0 comments on commit 48c3404

Please sign in to comment.