diff --git a/test/create_db.sh b/test/create_db.sh index d485b243601..c61e08360f2 100755 --- a/test/create_db.sh +++ b/test/create_db.sh @@ -37,15 +37,10 @@ function create_empty_db() { local db="${1}" local dbconn="${2}" create_script="drop database if exists \`${db}\`; create database if not exists \`${db}\`;" - mysql ${dbconn} -e "${create_script}" || exit_err "unable to create ${db}" + mysql ${dbconn} -e "${create_script}" || exit_err "unable to create ${db} on ${cbconn}" } -# set db connection for if running in a separate container or not -dbconn="-u root" -if [[ $MYSQL_CONTAINER ]] -then - dbconn="-u root -h ${DB_HOST} --port ${DB_PORT}" -fi +dbconn="-u root -h ${DB_HOST} --port ${DB_PORT}" if ! mysql ${dbconn} -e "select 1" >/dev/null 2>&1; then exit_err "unable to connect to ${DB_HOST}:${DB_PORT}" @@ -94,11 +89,11 @@ for db in $DBS; do r=`sql-migrate up -config="${DB_CONFIG_FILE}" -env="${dbname}" | xargs -0 echo` if [[ "${r}" == "Migration failed"* ]] then - echo "Migration failed - dropping and recreating" - create_empty_db "${dbname}" "${dbconn}" - sql-migrate up -config="${DB_CONFIG_FILE}" -env="${dbname}" || exit_err "Migration failed after dropping and recreating" + echo "sql-migrate: ${r}" + echo "Try \`docker compose down --volumes\` and running again" + exit 1 else - echo "${r}" + echo "sql-migrate: ${r}" fi USERS_SQL="../db-users/${db}.sql" @@ -106,14 +101,8 @@ for db in $DBS; do then echo "Skipping user grants for ${dbname}" else - if [[ $MYSQL_CONTAINER ]] - then - sed -e "s/'localhost'/'%'/g" < "${USERS_SQL}" | \ - mysql ${dbconn} -D "${dbname}" -f || exit_err "Unable to add users from ${USERS_SQL}" - else - sed -e "s/'localhost'/'127.%'/g" < "${USERS_SQL}" | \ - mysql ${dbconn} -D "${dbname}" -f || exit_err "Unable to add users from ${USERS_SQL}" - fi + sed -e "s/'localhost'/'%'/g" < "${USERS_SQL}" | \ + mysql ${dbconn} -D "${dbname}" -f || exit_err "Unable to add users from ${USERS_SQL}" echo "Added users from ${USERS_SQL}" fi diff --git a/test/entrypoint.sh b/test/entrypoint.sh index 331c0c731df..e9978fdd379 100755 --- a/test/entrypoint.sh +++ b/test/entrypoint.sh @@ -21,7 +21,6 @@ rsyslogd ./test/wait-for-it.sh bpkimetal 8080 # create the databases -MYSQL_CONTAINER=1 \ DB_HOST="boulder-mariadb" \ DB_PORT=3306 \ DB_CONFIG_FILE="${DIR}/../sa/db/dbconfig.mariadb.yml" \ @@ -29,7 +28,6 @@ SKIP_CREATE=0 \ SKIP_USERS=0 \ "$DIR/create_db.sh" -MYSQL_CONTAINER=1 \ DB_HOST="boulder-vitess" \ DB_PORT=33577 \ DB_CONFIG_FILE="${DIR}/../sa/db/dbconfig.mysql8.yml" \