From bebce829af17161597b07f40770bcf31a6045601 Mon Sep 17 00:00:00 2001
From: Kenneth Kehl <@kkehl@flexion.us>
Date: Thu, 28 Sep 2023 14:27:16 -0700
Subject: [PATCH 1/2] instructions for bulk testing and change delivery receipt
delay to 2 minutes
---
app/celery/provider_tasks.py | 8 +++++++-
docs/bulk_testing.md | 20 ++++++++++++++++++++
tests/app/test_utils.py | 10 ++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 docs/bulk_testing.md
diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py
index 3619298d9..acd2910b3 100644
--- a/app/celery/provider_tasks.py
+++ b/app/celery/provider_tasks.py
@@ -23,6 +23,10 @@ from app.models import (
NOTIFICATION_TECHNICAL_FAILURE,
)
+# This is the amount of time to wait after sending an sms message before we check the aws logs and look for delivery
+# receipts
+DELIVERY_RECEIPT_DELAY_IN_SECONDS = 120
+
@notify_celery.task(
bind=True,
@@ -96,7 +100,9 @@ def deliver_sms(self, notification_id):
message_id = send_to_providers.send_sms_to_provider(notification)
# We have to put it in UTC. For other timezones, the delay
# will be ignored and it will fire immediately (although this probably only affects developer testing)
- my_eta = datetime.utcnow() + timedelta(seconds=300)
+ my_eta = datetime.utcnow() + timedelta(
+ seconds=DELIVERY_RECEIPT_DELAY_IN_SECONDS
+ )
check_sms_delivery_receipt.apply_async(
[message_id, notification_id, now], eta=my_eta, queue=QueueNames.CHECK_SMS
)
diff --git a/docs/bulk_testing.md b/docs/bulk_testing.md
new file mode 100644
index 000000000..668901557
--- /dev/null
+++ b/docs/bulk_testing.md
@@ -0,0 +1,20 @@
+How to Run a Bulk Send Simulation
+==================================
+
+Assuming that you have followed all steps to set up localstack successfully, do the following:
+
+1. Create an sms template that requires no inputs from the user (i.e. the csv file will only have phone numbers)
+2. Uncomment the test 'test_generate_csv_for_bulk_testing' in app/test_utils.py
+3. Run `make test` on this project. This will generate the csv file for the bulk test.
+4. If you are not a platform admin for your service when you run locally, do the following:
+ - >psql -d notification_api
+ - update users set platform_admin='t';
+ - \q
+ - sign out
+ - sign in.
+ - Go to settings and set the organization for your service to 'Broadcast services' (scroll down to platform admin)
+ - Go to settings and set your service to 'live' (scroll down to platform admin)
+5. Run your app 'locally'. I.e. run `make run-procfile` on this project and `make run-flask` on the admin project
+6. Sign in. Verify you are running with localstack. I.e., you do NOT receive a text message on sign in. Instead,
+ you see your authentication code in green in the api logs
+7. Go to send messages and upload your csv file and send your 100000 messages
\ No newline at end of file
diff --git a/tests/app/test_utils.py b/tests/app/test_utils.py
index 77ea48688..dff502c4a 100644
--- a/tests/app/test_utils.py
+++ b/tests/app/test_utils.py
@@ -90,3 +90,13 @@ def test_get_uuid_string_or_none():
def test_get_public_notify_type_text():
assert get_public_notify_type_text(UPLOAD_DOCUMENT) == "document"
+
+
+# This method is used for simulating bulk sends. We use localstack and run on a developer's machine to do the
+# simulation. Please see docs->bulk_testing.md for instructions.
+# def test_generate_csv_for_bulk_testing():
+# f = open("bulktest_100000.csv", "w")
+# f.write("phone number\n")
+# for _ in range(0, 100000):
+# f.write("16615555555\n")
+# f.close()
From 27197b60bb7e153cebac1cff642d443854531e6e Mon Sep 17 00:00:00 2001
From: Kenneth Kehl <@kkehl@flexion.us>
Date: Fri, 29 Sep 2023 07:30:12 -0700
Subject: [PATCH 2/2] code review feedback
---
docs/all.md | 37 +++++++++++++++++++++++++++++--------
docs/bulk_testing.md | 20 --------------------
2 files changed, 29 insertions(+), 28 deletions(-)
delete mode 100644 docs/bulk_testing.md
diff --git a/docs/all.md b/docs/all.md
index 276fa649d..aa1ee5f59 100644
--- a/docs/all.md
+++ b/docs/all.md
@@ -286,7 +286,6 @@ The equivalent command if you are running the API locally:
docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-weekly zap-api-scan.py -t http://host.docker.internal:6011/docs/openapi.yml -f openapi -c zap.conf -r report.html
```
-
# Deploying
We deploy automatically to cloud.gov for production, demo, and staging environments.
@@ -727,13 +726,14 @@ Any changes to policies and procedures defined both here and in the SSPP must be
that the security of the system is maintained.
1. [Alerts, Notifications, Monitoring](#alerts)
-1. [Restaging Apps](#restaging-apps)
-1. [Smoke-testing the App](#smoke-testing)
-1. [Configuration Management](#cm)
-1. [DNS Changes](#dns)
-1. [Known Gotchas](#gotcha)
-1. [User Account Management](#ac)
-1. [SMS Phone Number Management](#phone-numbers)
+2. [Restaging Apps](#restaging-apps)
+3. [Smoke-testing the App](#smoke-testing)
+4. [Simulated bulk send testing](#simulated-bulk-send-testing)
+5. [Configuration Management](#cm)
+6. [DNS Changes](#dns)
+7. [Known Gotchas](#gotcha)
+8. [User Account Management](#ac)
+9. [SMS Phone Number Management](#phone-numbers)
## Alerts, Notifications, Monitoring
@@ -792,6 +792,27 @@ To ensure that notifications are passing through the application properly, the f
1. Log into the app. This will verify SNS integration for a one-off message.
1. Upload a CSV and schedule send for the soonest time after "Now". This will verify S3 connections as well as scheduler and worker processes are running properly.
+## Simulated bulk send testing
+
+Assuming that you have followed all steps to set up localstack successfully (see docs/localstack.md), do the following:
+
+1. Create an sms template that requires no inputs from the user (i.e. the csv file will only have phone numbers)
+2. Uncomment the test 'test_generate_csv_for_bulk_testing' in app/test_utils.py
+3. Run `make test` on this project. This will generate the csv file for the bulk test.
+4. If you are not a platform admin for your service when you run locally, do the following:
+ - >psql -d notification_api
+ - update users set platform_admin='t';
+ - \q
+ - sign out
+ - sign in.
+ - Go to settings and set the organization for your service to 'Broadcast services' (scroll down to platform admin)
+ - Go to settings and set your service to 'live' (scroll down to platform admin)
+5. Run your app 'locally'. I.e. run `make run-procfile` on this project and `make run-flask` on the admin project
+6. Sign in. Verify you are running with localstack. I.e., you do NOT receive a text message on sign in. Instead,
+ you see your authentication code in green in the api logs
+7. Go to send messages and upload your csv file and send your 100000 messages
+
+
## Configuration Management
Also known as: **How to move code from my machine to production**
diff --git a/docs/bulk_testing.md b/docs/bulk_testing.md
deleted file mode 100644
index 668901557..000000000
--- a/docs/bulk_testing.md
+++ /dev/null
@@ -1,20 +0,0 @@
-How to Run a Bulk Send Simulation
-==================================
-
-Assuming that you have followed all steps to set up localstack successfully, do the following:
-
-1. Create an sms template that requires no inputs from the user (i.e. the csv file will only have phone numbers)
-2. Uncomment the test 'test_generate_csv_for_bulk_testing' in app/test_utils.py
-3. Run `make test` on this project. This will generate the csv file for the bulk test.
-4. If you are not a platform admin for your service when you run locally, do the following:
- - >psql -d notification_api
- - update users set platform_admin='t';
- - \q
- - sign out
- - sign in.
- - Go to settings and set the organization for your service to 'Broadcast services' (scroll down to platform admin)
- - Go to settings and set your service to 'live' (scroll down to platform admin)
-5. Run your app 'locally'. I.e. run `make run-procfile` on this project and `make run-flask` on the admin project
-6. Sign in. Verify you are running with localstack. I.e., you do NOT receive a text message on sign in. Instead,
- you see your authentication code in green in the api logs
-7. Go to send messages and upload your csv file and send your 100000 messages
\ No newline at end of file