diff --git a/tests/functions.sh b/tests/functions.sh index 8453c499..8507cf95 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -24,3 +24,63 @@ ping_site() { exit 1 fi } + +docker_compose_with_args() { + # shellcheck disable=SC2068 + docker-compose \ + -p $project_name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-frappe.yml \ + -f installation/frappe-publish.yml \ + $@ +} + +check_migration_complete() { + print_group Check migration + + container_id=$(docker_compose_with_args ps -q frappe-python) + cmd="docker logs ${container_id} 2>&1 | grep 'Starting gunicorn' || echo ''" + worker_log=$(eval "$cmd") + INCREMENT=0 + + while [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -lt 120 ]]; do + sleep 3 + ((INCREMENT = INCREMENT + 1)) + echo "Wait for migration to complete..." + worker_log=$(eval "$cmd") + if [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -eq 120 ]]; then + echo Migration timeout + docker logs "${container_id}" + exit 1 + fi + done + + echo Migration Log + docker logs "${container_id}" +} + +check_health() { + print_group Loop health check + + docker run --name frappe_doctor \ + -v "${project_name}_sites-vol:/home/frappe/frappe-bench/sites" \ + --network "${project_name}_default" \ + frappe/frappe-worker:edge doctor || true + + cmd='docker logs frappe_doctor | grep "Health check successful" || echo ""' + doctor_log=$(eval "$cmd") + INCREMENT=0 + + while [[ -z "${doctor_log}" && ${INCREMENT} -lt 60 ]]; do + sleep 1 + ((INCREMENT = INCREMENT + 1)) + container=$(docker start frappe_doctor) + echo "Restarting ${container}..." + doctor_log=$(eval "$cmd") + + if [[ ${INCREMENT} -eq 60 ]]; then + docker logs "${container}" + exit 1 + fi + done +} diff --git a/tests/integration-test.sh b/tests/integration-test.sh index af7a8831..44c6e1e7 100755 --- a/tests/integration-test.sh +++ b/tests/integration-test.sh @@ -6,66 +6,6 @@ source tests/functions.sh project_name=frappe_bench_00 -docker_compose_with_args() { - # shellcheck disable=SC2068 - docker-compose \ - -p $project_name \ - -f installation/docker-compose-common.yml \ - -f installation/docker-compose-frappe.yml \ - -f installation/frappe-publish.yml \ - $@ -} - -check_migration_complete() { - print_group Check migration - - container_id=$(docker_compose_with_args ps -q frappe-python) - cmd="docker logs ${container_id} 2>&1 | grep 'Starting gunicorn' || echo ''" - worker_log=$(eval "$cmd") - INCREMENT=0 - - while [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -lt 120 ]]; do - sleep 3 - ((INCREMENT = INCREMENT + 1)) - echo "Wait for migration to complete..." - worker_log=$(eval "$cmd") - if [[ ${worker_log} != *"Starting gunicorn"* && ${INCREMENT} -eq 120 ]]; then - echo Migration timeout - docker logs "${container_id}" - exit 1 - fi - done - - echo Migration Log - docker logs "${container_id}" -} - -check_health() { - print_group Loop health check - - docker run --name frappe_doctor \ - -v "${project_name}_sites-vol:/home/frappe/frappe-bench/sites" \ - --network "${project_name}_default" \ - frappe/frappe-worker:edge doctor || true - - cmd='docker logs frappe_doctor | grep "Health check successful" || echo ""' - doctor_log=$(eval "$cmd") - INCREMENT=0 - - while [[ -z "${doctor_log}" && ${INCREMENT} -lt 60 ]]; do - sleep 1 - ((INCREMENT = INCREMENT + 1)) - container=$(docker start frappe_doctor) - echo "Restarting ${container}..." - doctor_log=$(eval "$cmd") - - if [[ ${INCREMENT} -eq 60 ]]; then - docker logs "${container}" - exit 1 - fi - done -} - # Initial group echo ::group::Setup .env cp env-example .env diff --git a/tests/test-erpnext.sh b/tests/test-erpnext.sh index 75df4543..f4a848c6 100755 --- a/tests/test-erpnext.sh +++ b/tests/test-erpnext.sh @@ -24,7 +24,6 @@ FRAPPE_VERSION=$FRAPPE_VERSION ERPNEXT_VERSION="test" \ -f installation/erpnext-publish.yml \ up -d -docker restart test_erpnext_fix-vol-permissions_1 test_erpnext_erpnext-nginx_1 print_group Create site docker run \ --rm \ @@ -34,5 +33,10 @@ docker run \ --network ${project_name}_default \ frappe/erpnext-worker:test new +docker restart ${project_name}_erpnext-nginx_1 +docker restart ${project_name}_fix-vol-permissions_1 + +check_health + ping_site rm .env