Fix tests

This commit is contained in:
cytopia
2018-03-04 11:16:06 +01:00
parent 1730094042
commit ba5ec48c72
10 changed files with 154 additions and 49 deletions

View File

@@ -30,21 +30,37 @@ run "sleep 5"
did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e FORWARD_PORTS_TO_LOCALHOST=3306:${mname}:3306 --link ${mname}" )"
if ! run "docker logs ${did} 2>&1 | grep 'Forwarding ${mname}:3306'"; then
docker_logs "${did}" || true
docker_stop "${did}" || true
docker_logs "${did}" || true
docker_logs "${mdid}" || true
docker_stop "${did}" || true
docker_stop "${mdid}" || true
echo "Failed"
exit 1
fi
# Test connectivity
docker_exec "${did}" "ping -c 1 ${mname}"
docker_exec "${did}" "echo | nc -w 1 ${mname} 3306"
docker_exec "${did}" "echo | nc -w 1 127.0.0.1 3306"
#docker_exec "${did}" "echo | nc -w 1 ${mname} 3306"
#docker_exec "${did}" "echo | nc -w 1 127.0.0.1 3306"
# Only work container has mysql binary installed
if [ "${FLAVOUR}" = "work" ]; then
docker_exec "${did}" "mysql --user=root --password= --host=${mname} -e 'SHOW DATABASES;'"
docker_exec "${did}" "mysql --user=root --password= --host=127.0.0.1 -e 'SHOW DATABASES;'"
if ! docker_exec "${did}" "mysql --user=root --password= --host=${mname} -e 'SHOW DATABASES;'"; then
docker_logs "${did}" || true
docker_logs "${mdid}" || true
docker_stop "${did}" || true
docker_stop "${mdid}" || true
echo "Failed"
exit 1
fi
if ! docker_exec "${did}" "mysql --user=root --password= --host=127.0.0.1 -e 'SHOW DATABASES;'"; then
docker_logs "${did}" || true
docker_logs "${mdid}" || true
docker_stop "${did}" || true
docker_stop "${mdid}" || true
echo "Failed"
exit 1
fi
fi
docker_stop "${mdid}"
docker_stop "${did}"