From 48c3404b52ef270d676df42956bb8b5cfaeae2d3 Mon Sep 17 00:00:00 2001 From: iamawacko Date: Fri, 16 Feb 2024 13:49:25 -0800 Subject: [PATCH] fix(tests): mariadb deprecated mysql stuff, so stuff needs to be done --- synth/testing_harness/mysql/e2e.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/synth/testing_harness/mysql/e2e.sh b/synth/testing_harness/mysql/e2e.sh index 2ce17140..abe98243 100755 --- a/synth/testing_harness/mysql/e2e.sh +++ b/synth/testing_harness/mysql/e2e.sh @@ -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 |Test a specific warning @@ -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; } } @@ -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" ] @@ -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}"