From 6ae04269794ecc1d1b622a43e4a0655be4299002 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Fri, 14 Apr 2023 16:45:23 +0200 Subject: [PATCH 1/4] Fix: Users had to override many defaults during deployment Instead of making the defaults developer friendly (assuming the developer runs all these services on localhost), assume that users use docker-compose by default. --- src/aleph/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aleph/config.py b/src/aleph/config.py index e656f0f83..d5ecfab1c 100644 --- a/src/aleph/config.py +++ b/src/aleph/config.py @@ -92,7 +92,7 @@ def get_defaults(): "sync_contract": "KT1FfEoaNvooDfYrP61Ykct6L8z7w7e2pgnT", }, "postgres": { - "host": "127.0.0.1", + "host": "postgres", "port": 5432, "database": "aleph", "user": "aleph", @@ -105,7 +105,7 @@ def get_defaults(): }, "ipfs": { "enabled": True, - "host": "127.0.0.1", + "host": "ipfs", "port": 5001, "gateway_port": 8080, "id": None, @@ -118,7 +118,7 @@ def get_defaults(): ], }, "rabbitmq": { - "host": "127.0.0.1", + "host": "rabbitmq", "port": 5672, "username": "aleph-p2p", "password": "change-me!", @@ -127,7 +127,7 @@ def get_defaults(): "message_exchange": "aleph-messages", }, "redis": { - "host": "127.0.0.1", + "host": "redis", "port": 6379, }, "sentry": { From 331c64203523ed17881a46751d17e22a48f9bba1 Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Fri, 21 Apr 2023 16:28:03 +0200 Subject: [PATCH 2/4] ci config --- .github/ci-config.yml | 5 +++++ .github/workflows/pyaleph-ci.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .github/ci-config.yml diff --git a/.github/ci-config.yml b/.github/ci-config.yml new file mode 100644 index 000000000..e0c3832e0 --- /dev/null +++ b/.github/ci-config.yml @@ -0,0 +1,5 @@ +postgres: + host: postgres + +redis: + host: redis diff --git a/.github/workflows/pyaleph-ci.yml b/.github/workflows/pyaleph-ci.yml index bf967ac94..2bd3594d2 100644 --- a/.github/workflows/pyaleph-ci.yml +++ b/.github/workflows/pyaleph-ci.yml @@ -70,7 +70,7 @@ jobs: run: | sudo cp .github/openssl-ci.cnf /etc/ssl/openssl.cnf export OPENSSL_CONF=/etc/ssl/openssl.cnf - touch config.yml # Fake config file for alembic + cp .github/ci-config.yml config.yml pytest -v . build: runs-on: ubuntu-22.04 From 3aeba7fb262cdfc068e71bd36b367cc4f42dddf9 Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Fri, 21 Apr 2023 16:39:13 +0200 Subject: [PATCH 3/4] fix --- .github/ci-config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ci-config.yml b/.github/ci-config.yml index e0c3832e0..326cb4c3a 100644 --- a/.github/ci-config.yml +++ b/.github/ci-config.yml @@ -1,5 +1,5 @@ postgres: - host: postgres + host: 127.0.0.1 redis: - host: redis + host: 127.0.0.1 From 078c5e7412bbdf5a6c4f9e6509d05115fd555a7e Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Fri, 21 Apr 2023 16:55:36 +0200 Subject: [PATCH 4/4] revert previous solution and hardcode instead --- .github/ci-config.yml | 5 ----- .github/workflows/pyaleph-ci.yml | 2 +- tests/conftest.py | 6 ++++++ 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .github/ci-config.yml diff --git a/.github/ci-config.yml b/.github/ci-config.yml deleted file mode 100644 index 326cb4c3a..000000000 --- a/.github/ci-config.yml +++ /dev/null @@ -1,5 +0,0 @@ -postgres: - host: 127.0.0.1 - -redis: - host: 127.0.0.1 diff --git a/.github/workflows/pyaleph-ci.yml b/.github/workflows/pyaleph-ci.yml index 2bd3594d2..bf967ac94 100644 --- a/.github/workflows/pyaleph-ci.yml +++ b/.github/workflows/pyaleph-ci.yml @@ -70,7 +70,7 @@ jobs: run: | sudo cp .github/openssl-ci.cnf /etc/ssl/openssl.cnf export OPENSSL_CONF=/etc/ssl/openssl.cnf - cp .github/ci-config.yml config.yml + touch config.yml # Fake config file for alembic pytest -v . build: runs-on: ubuntu-22.04 diff --git a/tests/conftest.py b/tests/conftest.py index d3594cd37..3d837f52f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -67,6 +67,12 @@ def session_factory(mock_config): @pytest.fixture def mock_config(mocker): config = Config(aleph.config.get_defaults()) + + # The postgres/redis hosts use Docker network names in the default config. + # We always use localhost for tests. + config.postgres.host.value = "127.0.0.1" + config.redis.host.value = "127.0.0.1" + # To test handle_new_storage config.storage.store_files.value = True