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

script and function for cleaning roots #2401

Merged
merged 6 commits into from
Sep 11, 2024

Conversation

scytacki
Copy link
Member

@scytacki scytacki commented Sep 11, 2024

The Firebase function runs at midnight (UTC) and cleans out QA roots that are older than 24 hours. So that means it will run at 8pm/7pm ET time. And will delete any roots that were used before 8pm/7pm ET the previous day. The reason to wait 24 hours before deleting a root is that there might be some benefit to debugging a root that was created during a test run. The schedule above will give the developer between 24 and 48 hours to debug a root before it gets deleted. The amount of time depends on when the root was used. A root used at 8:01pm will not get deleted until 2 days later at 8pm.

The script can be used to manually clear out roots on a whatever schedule seems best. Also there is a default timeout on Firebase functions of 60s. So if too many roots have built up the function might timeout. The script will have no timeout so can be used to fix that situation if it happens.

This also refactors out the initialization code from the 2 tests.
It took a while to figure out the right configuration so Jest would not pick up two versions of firebase-admin dependency since it also exists in the parent node_modules.

The Jest tests of the functions now have to run serially because they share the same Firebase emulator resources.

Future work:

  • also delete old dev roots. I think they should be deleted after a few months of inactivity.
  • clean out all of the dev and qa roots that don't have the lastLaunchedTime field.

This also refactors out the initialization code from the 2 tests.
It took a while to figure out the right configuration so Jest would not pick up two versions of firebase-admin dependency since it also exists in the parent node_modules.
Copy link

cypress bot commented Sep 11, 2024

collaborative-learning    Run #13698

Run Properties:  status check passed Passed #13698  •  git commit 6c92170fa0: address PR comments
Project collaborative-learning
Branch Review 188211348-fb-function-clean-roots
Run status status check passed Passed #13698
Run duration 01m 45s
Commit git commit 6c92170fa0: address PR comments
Committer Scott Cytacki
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 1
View all changes introduced in this branch ↗︎

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.64%. Comparing base (813b3d8) to head (6c92170).
Report is 7 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (813b3d8) and HEAD (6c92170). Click for more details.

HEAD has 5 uploads less than BASE
Flag BASE (813b3d8) HEAD (6c92170)
cypress-regression 5 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2401       +/-   ##
===========================================
- Coverage   85.98%   54.64%   -31.34%     
===========================================
  Files         738      729        -9     
  Lines       37855    37704      -151     
  Branches     9635     9612       -23     
===========================================
- Hits        32548    20605    -11943     
- Misses       5004    16072    +11068     
- Partials      303     1027      +724     
Flag Coverage Δ
cypress-regression ?
cypress-smoke 28.07% <ø> (ø)
jest 48.73% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@bgoldowsky bgoldowsky left a comment

Choose a reason for hiding this comment

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

This looks good other than a couple of comments.

I didn't test it but the logic seems straightforward (the test configuration and dependencies linking, not so straightforward!)

functions-v2/src/at-midnight.ts Outdated Show resolved Hide resolved
shared/clean-firebase-roots.ts Outdated Show resolved Hide resolved
scripts/clean-firebase-roots.ts Outdated Show resolved Hide resolved
@scytacki scytacki merged commit 62e0a3b into master Sep 11, 2024
11 of 12 checks passed
@scytacki scytacki deleted the 188211348-fb-function-clean-roots branch September 11, 2024 19:21
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.

2 participants