Skip to content

chore: Use timestamp instead of random number for test resource names#1497

Merged
manupedrozo merged 3 commits intomasterfrom
use-timestamp-in-test-names
Dec 4, 2025
Merged

chore: Use timestamp instead of random number for test resource names#1497
manupedrozo merged 3 commits intomasterfrom
use-timestamp-in-test-names

Conversation

@manupedrozo
Copy link
Copy Markdown
Collaborator

Move to use timestamps when generating test resource names.
The current approach can generate duplicate names which cause failures for the resources that require unique names.
It is also confusing to see duplicates in the UI when debugging issues.

Link to any related issue(s):

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Manual QA performed:

  • cfn invoke for each of CRUDL/cfn test
  • Updated resource in example
  • Published to AWS private registry
  • Used the template in example to create and update a stack in AWS
  • Deleted stack to ensure resources are deleted
  • Created multiple resources in same stack
  • Validated in Atlas UI
  • Included screenshots

Required Checklist:

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • For CFN Resources: I have released by changes in the private registry and proved by change
    works in Atlas

Further comments

@manupedrozo manupedrozo force-pushed the use-timestamp-in-test-names branch 2 times, most recently from 20e3803 to 23b6647 Compare December 3, 2025 13:06
@manupedrozo manupedrozo force-pushed the use-timestamp-in-test-names branch from 23b6647 to 42f5481 Compare December 3, 2025 18:27
@manupedrozo
Copy link
Copy Markdown
Collaborator Author

Only organization tests failing - known issue: CLOUDP-332705

@manupedrozo manupedrozo marked this pull request as ready for review December 4, 2025 08:53
@manupedrozo manupedrozo requested a review from a team as a code owner December 4, 2025 08:53

# setting projectName
projectName="cfn-bot-access-list-$((1 + RANDOM % 10000))"
projectName="cfn-bot-access-list-$(date +%s)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it in seconds or milliseconds? in case we need to add a random to timestamp.
thinking in case of publishing a resource to multiple regions, script would be executed multiple times at almost the same time

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Switching to ms here b7688b9

Copy link
Copy Markdown
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

fi

# setting projectName
projectName="cfn-bot-access-list-$((1 + RANDOM % 10000))"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from PR description was curious how we got to this work, is there any related CLOUDP or related PR in which we detected this issue?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw tests failing due to duplicated names while merging sdk updates. Need to re-run in those cases to roll the dice again.


# setting projectName
projectName="cfn-bot-access-list-$((1 + RANDOM % 10000))"
projectName="cfn-bot-access-list-$(date +%s%3N)"
Copy link
Copy Markdown
Member

@lantoli lantoli Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will work fine in Linux and GHA, but won't work in Mac:

# Expected: ct-alert-config-1733356800123
# Actual:   ct-alert-config-1733356800N
                                    ↑
                          literal "N", not milliseconds

The %3 part is ignored, and %N becomes a literal "N" character.

not sure if keep the random, maybe bigger 😅 or timestamp in seconds + random, e.g.:

 projectName="cfn-bot-access-list-$(date +%s)$(1 + RANDOM % 10000)"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad. Going with seconds + random. Thanks!

Copy link
Copy Markdown
Contributor

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty! However, would be awesome if we also supported reading the projectName from an env-var so it is simpler to debug and test locally

@manupedrozo manupedrozo added this pull request to the merge queue Dec 4, 2025
Merged via the queue into master with commit 482ea0b Dec 4, 2025
56 of 59 checks passed
@manupedrozo manupedrozo deleted the use-timestamp-in-test-names branch December 4, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants