cds-snc / notification-planning-core

Project planning for GC Notify Core Team
0 stars 0 forks source link

Leverage the DryRun parameter in Pinpoint to emulate SMS sending #426

Open jimleroyer opened 3 weeks ago

jimleroyer commented 3 weeks ago

Description

As a tester of GCNotify, I need to emulate SMS sending So that I can achieve test the system properly without paying for the sending.

WHY are we building?

We need to emulate the SMS sending.

WHAT are we building?

Enable the DryRun parameter via pinpoint and trigger it on a pre-established mechanism (by service/template ID for example).

VALUE created by our solution

Test our system without incurring charges.

Acceptance Criteria

QA Steps

sastels commented 2 weeks ago

Changed code to

    response = self._client.send_text_message(
                        DestinationPhoneNumber=destinationNumber,
                        OriginationIdentity=pool_id,
                        MessageBody=content,
                        MessageType=messageType,
                        ConfigurationSetName=self.current_app.config["AWS_PINPOINT_CONFIGURATION_SET_NAME"],
                        dryRun=(destinationNumber == self.current_app.config["INTERNAL_TEST_NUMBER"]),
                    )

and get

 Start sending SMS for notification id: 2b032412-6029-4a27-a8ac-a58731496e8a
[2024-10-07 19:33:03,771: INFO/ForkPoolWorker-3] AWS Pinpoint request finished in 0.523636832000193
[2024-10-07 19:33:03,782: INFO/ForkPoolWorker-3] deliver_sms took 0.5913
[2024-10-07 19:33:03,782: INFO/ForkPoolWorker-3] Task deliver_sms[0a89b86a-382b-4d62-8c31-0641b46b3457] succeeded in 0.5926313859999937s: None

So the sms is sent to AWS. After that it looks like it goes into the void. There are no delivery recipts.

Question: does it cost us anything? Use the cli to send to myself with and without the --dry-run flag

4:07 Pinpoint cost $0.16176 Sent 1 real sms

4:11 $0.17524

4:17 send 2 dry runs

4:27 $0.17524

So looks like dry runs

I think we can safely switch the INTERNAL_TEST_NUMBER to send with DryRun enabled. I'll put in that PR, then I can do 1000 in staging and make sure our costs don't go up $10.

sastels commented 2 weeks ago

Use DryRun for INTERNAL_TEST_NUMBER https://github.com/cds-snc/notification-api/pull/2320

sastels commented 2 weeks ago

ugh, broke the smoke test when we stopped sending a delivery receipt for the test number. fix: https://github.com/cds-snc/notification-api/pull/2323

P0NDER0SA commented 2 weeks ago

Did the QA. Sent a text from my service to the dry run number. Verified that it did not actually send a text via the logs in Quicksight. Did a followup test with the same service -- sent to my personal number, and verified that it did indeed send it.

Verified that AWS did indeed get both requests via the logs, but that only the non-dry run number actually was processed/sent.

There were no logs for the dry run, which verifies that we didn't spend any money!

QA -- COMPLETE!