Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ dot-env:
grep -q -o MONGO_INITDB_ROOT_PASSWORD .env || echo "MONGO_INITDB_ROOT_PASSWORD=$$(xxd -l 16 -p /dev/urandom)" >> .env
grep -q -o TNB_SECRET_KEY .env || echo "TNB_SECRET_KEY=$$(xxd -c 48 -l 48 -p /dev/urandom)" >> .env
grep -q -o TNB_NODE_SIGNING_KEY .env || echo "TNB_NODE_SIGNING_KEY=$$(poetry run python -m node.manage generate_signing_key)" >> .env
grep -q -o TNB_NODE_SCHEDULE_CAPACITY .env || echo "TNB_NODE_SCHEDULE_CAPACITY=20" >> .env
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:
TNB_DATABASES: '{"default":{"CLIENT":{"host":"node-mongo","password":"${MONGO_INITDB_ROOT_PASSWORD}"}}}'
TNB_CELERY_BROKER_URL: 'amqp://guest:guest@celery-broker:5672//'
env_file: .env
command: poetry run celery -A node.config.celery worker --loglevel=INFO
command: poetry run celery -A node.config.celery worker --loglevel=INFO --concurrency=${TNB_NODE_SCHEDULE_CAPACITY}
depends_on:
- node-mongo
- celery-broker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def should_not_be_empty(cls, schedule):

@validator('schedule')
def should_contain_not_more_elements(cls, schedule):
if len(schedule) > (schedule_capacity := settings.SCHEDULE_CAPACITY):
if len(schedule) > (schedule_capacity := settings.NODE_SCHEDULE_CAPACITY):
raise ValidationError(f'Schedule should contain not more than {schedule_capacity} elements')
return schedule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def test_schedule_contain_at_least_one_element():

def test_schedule_capacity():
with pytest.raises(
ValidationError, match=f'Schedule should contain not more than {settings.SCHEDULE_CAPACITY} elements'
ValidationError, match=f'Schedule should contain not more than {settings.NODE_SCHEDULE_CAPACITY} elements'
):
PVScheduleUpdateSignedChangeRequestMessage(
schedule={str(n): (str(n) * 64)[:64] for n in range(settings.SCHEDULE_CAPACITY + 1)},
schedule={str(n): (str(n) * 64)[:64] for n in range(settings.NODE_SCHEDULE_CAPACITY + 1)},
account_lock='0' * 64,
)

Expand Down
1 change: 1 addition & 0 deletions node/config/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@
if not is_pytest_running():
assert SECRET_KEY is not NotImplemented # type: ignore # noqa: F821
assert NODE_SIGNING_KEY is not NotImplemented # type: ignore # noqa: F821
assert NODE_SCHEDULE_CAPACITY is not NotImplemented # type: ignore # noqa: F821
2 changes: 1 addition & 1 deletion node/config/settings/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

NODE_LIST_JSON_PATH = None
SYNC_BATCH_SIZE = 10
SCHEDULE_CAPACITY = 20
NODE_SCHEDULE_CAPACITY = NotImplemented

SUPPRESS_WARNINGS_TB = True

Expand Down
1 change: 1 addition & 0 deletions node/config/settings/templates/settings.dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
DATABASES['default']['CLIENT']['connectTimeoutMS'] = 1000

NODE_SIGNING_KEY = 'a37e2836805975f334108b55523634c995bd2a4db610062f404510617e83126f'
NODE_SCHEDULE_CAPACITY = 20
1 change: 1 addition & 0 deletions node/core/tests/fixtures/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_settings(settings):
NODE_SIGNING_KEY='a025da120a1c95b27f17bb9442af9c27d3a357733aa150b458f21682a2d539a9',
CELERY_BROKER_URL='memory://',
CELERY_TASK_ALWAYS_EAGER=True,
NODE_SCHEDULE_CAPACITY=20,
):
# For some reason we need to import the app to make celery settings work
from node.config.celery import app # noqa: F401
Expand Down
1 change: 1 addition & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ echo 'Creating/updating .env file...'
test -f .env || touch .env
grep -q -o MONGO_INITDB_ROOT_PASSWORD .env || echo "MONGO_INITDB_ROOT_PASSWORD=$(xxd -l 16 -p /dev/urandom)" >> .env
grep -q -o TNB_SECRET_KEY .env || echo "TNB_SECRET_KEY=$(xxd -c 48 -l 48 -p /dev/urandom)" >> .env
grep -q -o TNB_NODE_SCHEDULE_CAPACITY .env || echo "TNB_NODE_SCHEDULE_CAPACITY=20" >> .env

docker-compose pull

Expand Down