Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Capture log output before docker stack is torn down (#360)

Madison Swain-Bowdena42bf5c244ec
diff --git a/ingestion_server/test/.gitignore b/ingestion_server/test/.gitignore
index 5e797c167..35789b70e 100644
--- a/ingestion_server/test/.gitignore
+++ b/ingestion_server/test/.gitignore
@@ -1 +1,2 @@
integration-docker-compose.yml
+ingestion_logs.txt
diff --git a/ingestion_server/test/integration_test.py b/ingestion_server/test/integration_test.py
index dc36b9f77..b80083596 100644
--- a/ingestion_server/test/integration_test.py
+++ b/ingestion_server/test/integration_test.py
@@ -214,6 +214,16 @@ class TestIngestion(unittest.TestCase):
# Stop all running containers and delete all data in volumes
compose_path = cls.compose_path
+ log_output = compose_path.parent / "ingestion_logs.txt"
+ with log_output.open("w") as file:
+ subprocess.run(
+ ["docker-compose", "-f", compose_path.name, "logs"],
+ cwd=compose_path.parent,
+ check=True,
+ stderr=subprocess.STDOUT,
+ stdout=file,
+ )
+
stop_cmd = ["docker-compose", "-f", compose_path.name, "down", "-v"]
subprocess.run(
stop_cmd,
diff --git a/ingestion_server/test/run_test.sh b/ingestion_server/test/run_test.sh
index 4d0219c6d..a4f8273e0 100755
--- a/ingestion_server/test/run_test.sh
+++ b/ingestion_server/test/run_test.sh
@@ -19,7 +19,7 @@ if [[ $succeeded -eq 0 ]]; then
printf "${green}:-) All tests passed${endcol}\n"
else
printf "Full system logs:\n"
- docker-compose -f integration-docker-compose.yml logs
+ cat test/ingestion_logs.txt
printf "${red}:'( Some tests did not pass${endcol}\n"
fi
exit $succeeded