Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
jimleroyer opened this issue Oct 2, 2024 · 4 comments
Open
5 tasks done
Assignees
Labels
Test Related to testing

Comments

@jimleroyer
Copy link
Member

jimleroyer commented Oct 2, 2024

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

  • We can send emulated SMS based on either a service, template, or specific test phone numbers.

QA Steps

  • Test sending SMS notifications with the predetermined switch mechanism.
  • Verify in the CloudWatch logs if any SMS was sent using that phone number.
  • Verify in the CloudWatch logs if any notifications were queued and sent to AWS.
  • Verify that the send did not incur any charge. This can be checked in CloudWatch logs for Pinpoint success of failure log groups.
@jimleroyer jimleroyer added the Test Related to testing label Oct 2, 2024
@sastels
Copy link

sastels commented Oct 7, 2024

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

  • get a boto call and return a message id
  • do not generate a delivery receipt
  • do not cost us

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 sastels self-assigned this Oct 8, 2024
@sastels
Copy link

sastels commented Oct 8, 2024

Use DryRun for INTERNAL_TEST_NUMBER
cds-snc/notification-api#2320

@sastels
Copy link

sastels commented Oct 9, 2024

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

@P0NDER0SA P0NDER0SA self-assigned this Oct 10, 2024
@P0NDER0SA
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Test Related to testing
Projects
None yet
Development

No branches or pull requests

3 participants