Skip to content

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

Unified logging approach for api and ingestion server (#2380)

Ashir Amin1d6404b35176
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index b72ea5901..7f5eb7457 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -324,6 +324,11 @@ jobs:
- name: Run ingestion-server tests
run: just ingestion_server/test-local
+ - name: Print ingestion-server test logs
+ run: |
+ just ingestion_server/test-logs > ingestion_server/test/ingestion_logs.txt
+ cat ingestion_server/test/ingestion_logs.txt
+
- name: Upload ingestion test logs
if: success() || failure()
uses: actions/upload-artifact@v3
@@ -331,10 +336,6 @@ jobs:
name: ing_logs
path: ingestion_server/test/ingestion_logs.txt
- - name: Print ingestion test logs
- if: success() || failure()
- run: cat ingestion_server/test/ingestion_logs.txt
-
#######
# API #
#######
diff --git a/ingestion_server/justfile b/ingestion_server/justfile
index 41d565cce..a7d1f5ed8 100644
--- a/ingestion_server/justfile
+++ b/ingestion_server/justfile
@@ -2,6 +2,7 @@ set dotenv-load := false
COLOR := "\\033[0;36m"
NO_COLOR := "\\033[0m"
+IS_CI := env_var_or_default("CI", "")
# Show all available recipes
@_default:
@@ -99,7 +100,11 @@ create-and-populate-filtered-index model="image" destination_suffix="init":
# Run ingestion-server tests locally
test-local *args:
pipenv run pytest {{ args }}
+ {{ if IS_CI == "" { "just test-logs > test/ingestion_logs.txt && just test-clean-dc" } else { "" } }}
-# Clean integration test docker-compose stack. Useful if test tear down does not run due to catastrophic test failure.
+test-logs:
+ docker-compose --profile=ingestion_server -f test/integration-docker-compose.yml logs --no-color
+
+# Clean integration test docker-compose stack. Is run after tests are finished locally.
test-clean-dc:
docker-compose --profile=ingestion_server -f test/integration-docker-compose.yml down -v
diff --git a/ingestion_server/test/integration_test.py b/ingestion_server/test/integration_test.py
index a0275e46c..3c9678143 100644
--- a/ingestion_server/test/integration_test.py
+++ b/ingestion_server/test/integration_test.py
@@ -431,19 +431,6 @@ class TestIngestion(unittest.TestCase):
# Terminate the Bottle process started in ``setUp``
cls.cb_process.terminate()
- # 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:
- cls._compose_cmd(
- ["logs", "--no-color"], stderr=subprocess.STDOUT, stdout=file
- )
-
- cls._compose_cmd(
- ["down", "-v"],
- capture_output=True,
- )
-
# Close connections with databases
for conn in [cls.upstream_db, cls.downstream_db]:
if conn: