From c56cd58b5ba004e5a657fea0e5726a46fe9f9cc9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Jul 2025 02:04:56 +0000 Subject: [PATCH 1/4] Initial plan From 1d2c5c55f8ef5be4404edef204ba8cad7b1adc60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Jul 2025 02:11:49 +0000 Subject: [PATCH 2/4] Update Docker Compose to use constant MongoDB host and port values Co-authored-by: eecavanna <134325062+eecavanna@users.noreply.github.com> --- docker-compose.yml | 15 +++---- tests/test_docker_compose_constants.py | 59 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 tests/test_docker_compose_constants.py diff --git a/docker-compose.yml b/docker-compose.yml index 2da64b5..c1096b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,14 +3,11 @@ services: # Use the container image built in the "development" stage of the Dockerfile. build: { context: ".", dockerfile: Dockerfile, target: development } restart: unless-stopped - # Propagate environment variables from the host into the container. - # Note: The `:?` suffix makes it so Docker Compose displays an error if the - # environment variable is either (a) undefined, or (b) empty, in the - # host environment. - # Docs: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#additional-information + # Use constant values for MongoDB connection within the Docker Compose stack. + # The MongoDB service is accessible at hostname 'mongo' (service name) on port 27017. environment: - MONGO_HOST: ${MONGO_HOST:?} - MONGO_PORT: ${MONGO_PORT:?} + MONGO_HOST: mongo + MONGO_PORT: 27017 MONGO_USERNAME: ${MONGO_USERNAME:?} MONGO_PASSWORD: ${MONGO_PASSWORD:?} MONGO_DATABASE: ${MONGO_DATABASE:?} @@ -65,8 +62,8 @@ services: # This service should not start automatically - only run on demand profiles: ["tools"] environment: - MONGO_HOST: ${MONGO_HOST:?} - MONGO_PORT: ${MONGO_PORT:?} + MONGO_HOST: mongo + MONGO_PORT: 27017 MONGO_USERNAME: ${MONGO_USERNAME:?} MONGO_PASSWORD: ${MONGO_PASSWORD:?} MONGO_DATABASE: ${MONGO_DATABASE:?} # the test suite will disregard this diff --git a/tests/test_docker_compose_constants.py b/tests/test_docker_compose_constants.py new file mode 100644 index 0000000..92c8397 --- /dev/null +++ b/tests/test_docker_compose_constants.py @@ -0,0 +1,59 @@ +""" +Test to verify that the Docker Compose file uses constant values for MongoDB connection. +""" +import yaml +import pytest +from pathlib import Path + + +def test_docker_compose_uses_constant_mongo_values(): + """Test that MONGO_HOST and MONGO_PORT are set to constants in docker-compose.yml""" + + # Load the docker-compose.yml file + compose_file = Path(__file__).parent.parent / "docker-compose.yml" + + with open(compose_file, 'r') as f: + compose_config = yaml.safe_load(f) + + # Check app service environment + app_env = compose_config['services']['app']['environment'] + assert app_env['MONGO_HOST'] == 'mongo', "app service should use constant MONGO_HOST=mongo" + assert app_env['MONGO_PORT'] == 27017, "app service should use constant MONGO_PORT=27017" + + # Check test service environment + test_env = compose_config['services']['test']['environment'] + assert test_env['MONGO_HOST'] == 'mongo', "test service should use constant MONGO_HOST=mongo" + assert test_env['MONGO_PORT'] == 27017, "test service should use constant MONGO_PORT=27017" + + # Verify that the mongo service name matches the constant + assert 'mongo' in compose_config['services'], "mongo service should exist" + + # Verify that the port mapping uses 27017 as container port + mongo_ports = compose_config['services']['mongo']['ports'] + assert len(mongo_ports) == 1, "mongo service should have exactly one port mapping" + port_mapping = mongo_ports[0] + # The mapping should be in format "${MONGO_PORT:-27017}:27017" + assert port_mapping.endswith(':27017'), "mongo service should map to container port 27017" + + +def test_ingest_service_uses_correct_mongo_uri(): + """Test that ingest service command uses the same constants in its mongo URI""" + + # Load the docker-compose.yml file + compose_file = Path(__file__).parent.parent / "docker-compose.yml" + + with open(compose_file, 'r') as f: + compose_config = yaml.safe_load(f) + + # Check ingest service command + ingest_command = compose_config['services']['ingest']['command'] + + # Find the mongo-uri argument + mongo_uri = None + for i, arg in enumerate(ingest_command): + if arg == '--mongo-uri' and i + 1 < len(ingest_command): + mongo_uri = ingest_command[i + 1] + break + + assert mongo_uri is not None, "ingest service should have --mongo-uri argument" + assert 'mongo:27017' in mongo_uri, "ingest service should use mongo:27017 in URI" \ No newline at end of file From d7bbfdb8ed91ef5a7e111c0f69a017c9fe5fd20f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Jul 2025 02:23:30 +0000 Subject: [PATCH 3/4] Restore original comments and remove test file per feedback Co-authored-by: eecavanna <134325062+eecavanna@users.noreply.github.com> --- docker-compose.yml | 7 ++- tests/test_docker_compose_constants.py | 59 -------------------------- 2 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 tests/test_docker_compose_constants.py diff --git a/docker-compose.yml b/docker-compose.yml index c1096b5..099536c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,11 @@ services: # Use the container image built in the "development" stage of the Dockerfile. build: { context: ".", dockerfile: Dockerfile, target: development } restart: unless-stopped - # Use constant values for MongoDB connection within the Docker Compose stack. - # The MongoDB service is accessible at hostname 'mongo' (service name) on port 27017. + # Propagate environment variables from the host into the container. + # Note: The `:?` suffix makes it so Docker Compose displays an error if the + # environment variable is either (a) undefined, or (b) empty, in the + # host environment. + # Docs: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#additional-information environment: MONGO_HOST: mongo MONGO_PORT: 27017 diff --git a/tests/test_docker_compose_constants.py b/tests/test_docker_compose_constants.py deleted file mode 100644 index 92c8397..0000000 --- a/tests/test_docker_compose_constants.py +++ /dev/null @@ -1,59 +0,0 @@ -""" -Test to verify that the Docker Compose file uses constant values for MongoDB connection. -""" -import yaml -import pytest -from pathlib import Path - - -def test_docker_compose_uses_constant_mongo_values(): - """Test that MONGO_HOST and MONGO_PORT are set to constants in docker-compose.yml""" - - # Load the docker-compose.yml file - compose_file = Path(__file__).parent.parent / "docker-compose.yml" - - with open(compose_file, 'r') as f: - compose_config = yaml.safe_load(f) - - # Check app service environment - app_env = compose_config['services']['app']['environment'] - assert app_env['MONGO_HOST'] == 'mongo', "app service should use constant MONGO_HOST=mongo" - assert app_env['MONGO_PORT'] == 27017, "app service should use constant MONGO_PORT=27017" - - # Check test service environment - test_env = compose_config['services']['test']['environment'] - assert test_env['MONGO_HOST'] == 'mongo', "test service should use constant MONGO_HOST=mongo" - assert test_env['MONGO_PORT'] == 27017, "test service should use constant MONGO_PORT=27017" - - # Verify that the mongo service name matches the constant - assert 'mongo' in compose_config['services'], "mongo service should exist" - - # Verify that the port mapping uses 27017 as container port - mongo_ports = compose_config['services']['mongo']['ports'] - assert len(mongo_ports) == 1, "mongo service should have exactly one port mapping" - port_mapping = mongo_ports[0] - # The mapping should be in format "${MONGO_PORT:-27017}:27017" - assert port_mapping.endswith(':27017'), "mongo service should map to container port 27017" - - -def test_ingest_service_uses_correct_mongo_uri(): - """Test that ingest service command uses the same constants in its mongo URI""" - - # Load the docker-compose.yml file - compose_file = Path(__file__).parent.parent / "docker-compose.yml" - - with open(compose_file, 'r') as f: - compose_config = yaml.safe_load(f) - - # Check ingest service command - ingest_command = compose_config['services']['ingest']['command'] - - # Find the mongo-uri argument - mongo_uri = None - for i, arg in enumerate(ingest_command): - if arg == '--mongo-uri' and i + 1 < len(ingest_command): - mongo_uri = ingest_command[i + 1] - break - - assert mongo_uri is not None, "ingest service should have --mongo-uri argument" - assert 'mongo:27017' in mongo_uri, "ingest service should use mongo:27017 in URI" \ No newline at end of file From 28b49d157de9493d80838e8e60414b224a01098d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Jul 2025 02:36:09 +0000 Subject: [PATCH 4/4] Remove MONGO_HOST and MONGO_PORT environment variables from CI workflow Co-authored-by: eecavanna <134325062+eecavanna@users.noreply.github.com> --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10f2458..8f85f1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,6 @@ jobs: # Define environment variables that will be available to all steps within this job. env: - MONGO_HOST: mongo - MONGO_PORT: 27017 MONGO_USERNAME: admin MONGO_PASSWORD: root MONGO_DATABASE: bertron