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

Test sharding #2810

Open
wants to merge 5 commits into
base: vvm/refactor_sdkv2_detailed_diff_tests
Choose a base branch
from

Conversation

VenelinMartinov
Copy link
Contributor

@VenelinMartinov VenelinMartinov commented Jan 6, 2025

This PR implements a test sharding strategy to speed up the bridge tests from 1 hour 30 minutes to under 15 minutes.

It uses https://github.com/VenelinMartinov/sharder which is a package for generating regexes to plug into go test based on the test profile data. The script is based on the previous work by @blampe in https://github.com/pulumi/shard.

This PR also adds two new make commands:

  • make test_profile this regenerates the test profile data, so that shard partitioning can be more fair
  • make test_shard. This is only run in CI. This command picks up the SHARD_CMD env var to determine which tests to run. SHARD_CMD is populated in CI by the sharder package and contains a regex which should match the correct tests to run.

Sharding is only done for ubuntu tests as they take the longest.

Example run: https://github.com/pulumi/pulumi-terraform-bridge/actions/runs/12656374664

@VenelinMartinov VenelinMartinov marked this pull request as draft January 6, 2025 13:19
@VenelinMartinov VenelinMartinov force-pushed the vvm/test_sharding branch 5 times, most recently from bce5fde to fef033d Compare January 6, 2025 13:54
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.62%. Comparing base (2c18440) to head (138e1d0).

Additional details and impacted files
@@                            Coverage Diff                             @@
##           vvm/refactor_sdkv2_detailed_diff_tests    #2810      +/-   ##
==========================================================================
- Coverage                                   68.63%   68.62%   -0.02%     
==========================================================================
  Files                                         325      325              
  Lines                                       41550    41550              
==========================================================================
- Hits                                        28518    28513       -5     
- Misses                                      11425    11430       +5     
  Partials                                     1607     1607              

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

@VenelinMartinov VenelinMartinov force-pushed the vvm/test_sharding branch 12 times, most recently from a542264 to 6a4085f Compare January 6, 2025 15:00
@VenelinMartinov VenelinMartinov changed the base branch from master to vvm/refactor_pf_detailed_diff_tests January 7, 2025 14:41
@VenelinMartinov VenelinMartinov force-pushed the vvm/test_sharding branch 5 times, most recently from 3b22893 to c3b2b2c Compare January 7, 2025 15:30
@VenelinMartinov VenelinMartinov changed the base branch from vvm/refactor_pf_detailed_diff_tests to vvm/refactor_sdkv2_detailed_diff_tests January 7, 2025 16:13
@VenelinMartinov VenelinMartinov force-pushed the vvm/test_sharding branch 2 times, most recently from e7dd711 to 223f70f Compare January 7, 2025 17:07
@VenelinMartinov VenelinMartinov force-pushed the vvm/refactor_sdkv2_detailed_diff_tests branch from a381fb5 to 817019b Compare January 7, 2025 17:13
@VenelinMartinov VenelinMartinov force-pushed the vvm/refactor_sdkv2_detailed_diff_tests branch from 817019b to 2c18440 Compare January 7, 2025 17:16
@VenelinMartinov VenelinMartinov requested a review from a team January 7, 2025 18:54
@VenelinMartinov VenelinMartinov marked this pull request as ready for review January 7, 2025 18:54
@VenelinMartinov VenelinMartinov changed the title test sharding Test sharding Jan 7, 2025
PULUMI_TERRAFORM_BRIDGE_TEST_PROVIDER=$(shell pwd)/bin/pulumi-terraform-bridge-test-provider \
go test -count=1 -coverprofile="coverage.txt" -coverpkg=./... -timeout 2h -parallel ${TESTPARALLELISM} ./... ${SHARD_CMD}

test_profile:: install_plugins
Copy link
Member

Choose a reason for hiding this comment

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

This needs a comment explaining what it does.

@@ -33,6 +33,20 @@ test:: install_plugins
PULUMI_TERRAFORM_BRIDGE_TEST_PROVIDER=$(shell pwd)/bin/pulumi-terraform-bridge-test-provider \
go test -count=1 -coverprofile="coverage.txt" -coverpkg=./... -timeout 2h -parallel ${TESTPARALLELISM} ./...

test_shard:: install_plugins
Copy link
Member

Choose a reason for hiding this comment

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

This also needs a comment explaining what it does, and that it is provided for CI.

pulumi-hcl-lint

schema-tpsdkv2.json
Copy link
Member

Choose a reason for hiding this comment

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

Why are we adding this. We should fix the test that erroneously generates this file instead of ignoring it.

Comment on lines +31 to +32
- platform: windows-latest
shard: 1
Copy link
Member

Choose a reason for hiding this comment

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

Is the idea that every OS runs shard 0, and only ubuntu runs the rest of the shards? If so, that needs a comment explaining so.

Also, why don't we shard all OSs?

feature-flags: "PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW"
- platform: macos-latest
feature-flags: "PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW"
- platform: windows-latest
Copy link
Member

Choose a reason for hiding this comment

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

Instead of defining shard as [0, 1, 2, 3, ...], then excluding each option we don't want, can we define shard as [0] and then add explicit includes for other shard options. That will reduce the length of the shard list by half.

- name: Build
run: make build
- name: Build PF
run: cd pkg/pf && make build
- name: Shard tests
run: echo "SHARD_CMD=$(go run github.com/VenelinMartinov/sharder@9d09afeb1c053b4a0263fbaa5c3c9da1ca2d10e7 --total ${{ env.TOTAL_SHARDS }} --index ${{ matrix.shard }} --output testoutput.txt --format make)" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

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

How is github.com/VenelinMartinov/sharder different from github.com/pulumi/shard? Why can't we use github.com/pulumi/shard?

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