Skip to content

Commit

Permalink
Set CF_APP_NAME via the cf manifest.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewoh531 committed Nov 22, 2018
1 parent 436dbcc commit b156725
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
3 changes: 3 additions & 0 deletions admin/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
integrations=[FlaskIntegration()]
)

with sentry_sdk.configure_scope() as scope:
scope.set_tag("cf_app", os.environ.get('CF_APP_NAME'))

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'app', 'static')
STATIC_URL = 'static/'
Expand Down
3 changes: 2 additions & 1 deletion admin/manifest-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ defaults: &defaults
command: make run-gunicorn

applications:
- name: notify
- name: notify-((stg))
<<: *defaults
env:
<<: *defaults_env
ADMIN_BASE_URL: https://notify-((stg)).apps.y.cld.gov.au
DOCS_BASE_URL: https://notify-docs-((stg)).apps.y.cld.gov.au
API_HOST_NAME: https://notify-api-((stg)).apps.y.cld.gov.au
CF_APP_NAME: notify-((stg))
1 change: 1 addition & 0 deletions admin/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ applications:
<<: *defaults_env
ADMIN_BASE_URL: https://notify.gov.au
API_HOST_NAME: https://rest-api.notify.gov.au
CF_APP_NAME: notify
3 changes: 3 additions & 0 deletions api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
integrations=[FlaskIntegration()]
)

with sentry_sdk.configure_scope() as scope:
scope.set_tag("cf_app", os.environ.get('CF_APP_NAME'))

application = Flask('app')

create_app(application)
6 changes: 6 additions & 0 deletions api/manifest-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ applications:
- name: notify-api-((stg))
<<: *defaults
command: make run-production
env:
CF_APP_NAME: notify-api-((stg))
- name: notify-celery-worker-((stg))
<<: *defaults
health-check-type: process
no-route: true
command: make run-celery-worker
env:
CF_APP_NAME: notify-celery-worker-((stg))
- name: notify-celery-beat-((stg))
<<: *defaults
memory: 256M
health-check-type: process
no-route: true
command: make run-celery-beat
env:
CF_APP_NAME: notify-celery-beat-((stg))
6 changes: 6 additions & 0 deletions api/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ applications:
routes:
- route: rest-api.notify.gov.au
- route: notify-api.apps.b.cld.gov.au
env:
CF_APP_NAME: notify-api
- name: notify-celery-worker
<<: *defaults
health-check-type: process
no-route: true
command: make run-celery-worker
env:
CF_APP_NAME: notify-celery-worker
- name: notify-celery-beat
<<: *defaults
memory: 256M
health-check-type: process
no-route: true
command: make run-celery-beat
env:
CF_APP_NAME: notify-celery-beat
1 change: 1 addition & 0 deletions api/run_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

with sentry_sdk.configure_scope() as scope:
scope.set_tag("celery_cmd", os.environ['NOTIFY_CELERY_CMD'])
scope.set_tag("cf_app", os.environ.get('CF_APP_NAME'))

application = Flask('delivery')
create_app(application)
Expand Down
19 changes: 9 additions & 10 deletions api/tests/app/celery/test_scheduled_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,15 @@ def __getattr__(self, name):

def test_switch_providers_on_slow_delivery_should_not_throw_if_providers_updated_at_is_none(
notify_api, mocker, capsys):
with capsys.disabled():
mocker.patch('app.celery.scheduled_tasks.is_delivery_slow_for_provider', return_value=[])
mocker.patch('app.celery.scheduled_tasks.get_current_provider',
return_value=Getter(identifier="123", updated_at=None))

with set_config_values(notify_api, {
'FUNCTIONAL_TEST_PROVIDER_SERVICE_ID': '7954469d-8c6d-43dc-b8f7-86be2d69f5f3',
'FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID': '331a63e6-f1aa-4588-ad3f-96c268788ae7'
}):
switch_current_sms_provider_on_slow_delivery()
mocker.patch('app.celery.scheduled_tasks.is_delivery_slow_for_provider', return_value=[])
mocker.patch('app.celery.scheduled_tasks.get_current_provider',
return_value=Getter(identifier="123", updated_at=None))

with set_config_values(notify_api, {
'FUNCTIONAL_TEST_PROVIDER_SERVICE_ID': '7954469d-8c6d-43dc-b8f7-86be2d69f5f3',
'FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID': '331a63e6-f1aa-4588-ad3f-96c268788ae7'
}):
switch_current_sms_provider_on_slow_delivery()


@pytest.mark.skip(reason="We currently do not support sms fallback functionality")
Expand Down

0 comments on commit b156725

Please sign in to comment.