Skip to content

Commit

Permalink
change port used for unit tests redis server
Browse files Browse the repository at this point in the history
  • Loading branch information
bgunnar5 committed Aug 15, 2023
1 parent af8bf04 commit acba79e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion tests/unit/study/dummy_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from celery import Celery


dummy_app = Celery("dummy_app", broker="redis://localhost:6379/0")
PORT = 6380

dummy_app = Celery("dummy_app", broker=f"redis://localhost:{PORT}/0", result_backend=f"redis://localhost:{PORT}/1")
14 changes: 8 additions & 6 deletions tests/unit/study/test_celeryadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Tests for the celeryadapter module.
If tests are failing/erroring make sure that you don't have a local redis server
already up and running on 127.0.0.1.
already up and running on 127.0.0.1 port PORT.
"""
import csv
import json
Expand All @@ -47,7 +47,7 @@
from merlin.config import Config
from merlin.spec.specification import MerlinSpec
from merlin.study import celeryadapter
from tests.unit.study.dummy_app import dummy_app
from tests.unit.study.dummy_app import PORT, dummy_app
from tests.unit.study.status_test_files.shared_tests import _format_csv_data
from tests.unit.study.status_test_files.status_test_variables import PATH_TO_TEST_FILES, SPEC_PATH

Expand All @@ -68,12 +68,14 @@ def setUpClass(cls):
Set up a redis server to connect to our dummy app one time that can be used for any test we need.
"""
# Launch a local redis server that we'll connect our dummy celery app to
# NOTE if the redis server is having trouble launching, make sure there isn't already one running on 127.0.0.1:6379
cls.redis_server = subprocess.Popen(["redis-server"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# NOTE if the redis server is having trouble launching, make sure there isn't already one running on 127.0.0.1:PORT
cls.redis_server = subprocess.Popen(
["redis-server", "--port", str(PORT)], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)

# Wait for the redis server to spin up and then connect to it (no arguments will set host to localhost and port to 6379 by default)
# Wait for the redis server to spin up and then connect to it
sleep(1)
cls.redis_connection = Redis()
cls.redis_connection = Redis(host="localhost", port=PORT)

@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit acba79e

Please sign in to comment.