Skip to content

ci: split TestModule into multiple suites - #8212

Merged
gerhard merged 5 commits into
dagger:mainfrom
TomChv:feat/split-test-module-into-sub-suite
Aug 29, 2024
Merged

gerhard merged 5 commits into
dagger:mainfrom
TomChv:feat/split-test-module-into-sub-suite

Conversation

@TomChv

@TomChv TomChv commented Aug 22, 2024 •

Copy link
Copy Markdown
Member

Run a specific suite:

dagger -m .dagger call --source=.:default test specific --pkg="./core/integration" --run="^MySuite$"

New suite after the split

  • TypescriptSuite (Done in tests: move TypeScript test to its own suite #8185): Execute all module TypeScript tests (run in 8m)
  • PythonSuite: Execute all module Python tests (run in 8m30s)
  • GoSuite: Execute all module Go tests (run in 5m15s)
  • ElixirSuite: Execute all module Elixir tests (run in 2m15s
  • PHPSuite: Execute all module PhP tests (run in 1m40s)
  • DaggerCallSuite: Execute all tests from module_call_test.go (run in 10m)
  • DaggerConfigSuite: Run all tests from module_config_test.go (run in 13m)
  • DaggerCLISuite: Run all tests from module_cli_test.go (run in 4m30)
    This is the result of a rename of module_function and the move of some CLI related tests from module_config to module_cli
  • TestInterface: Run all test from module_iface_test.go (run in 2m)
  • TestDaggerType: Run all tests related to module’s type (run in 8m)

TestModule still exists but is much smaller.

💡 I think there are better way to split the tests, but this is a first draft to gather teams's opinion.

Now I think the ideal would be to run some suite together in the CI, for example having a function dagger call test sdks that run all SDK related suite etc...

Screenshot 2024-08-22 at 12 03 56

Some suites are still super expensive in compute resources but at least they are all runnable locally now :)

@gerhard let me know what I can do around the CI itself to improve it too!

@TomChv
TomChv requested review from gerhard, sipsma and vito August 22, 2024 14:23
@TomChv TomChv self-assigned this Aug 22, 2024
@TomChv

TomChv commented Aug 22, 2024

Copy link
Copy Markdown
Member Author

@gerhard The PR isn't mergeable in this state, but several changes need to happen in our GA to make it work.

I'll need your advice on this seems it might be counter-productive to spawn multiple engine as you explained

Each test run incurs a 3-5 minutes penalty since:
A new EC2 instance needs to be provisioned & join the EKS cluster
Dagger CLI + Engine need to be installed
Our dagger/dagger/.dagger module needs to be installed
A dev Engine needs to be built and spun up as a service

If the tests take up to 5 minutes to run, then we would be paying an extra 3-5 minutes penalty by splitting them out.

@gerhard gerhard mentioned this pull request Aug 22, 2024
2 of 5 tasks

@gerhard gerhard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I went through the code changes, looking good @TomChv 👍

I need to run this locally, and compare the test suites before and after to make sure that everything behaves correctly before approving & merging. Will do it right after the next meeting.

Super excited to see that big TestModule suite getting split into smaller suites. At least things are manageable now! The fact that you are able to run subsets of interest locally is most promising.

@gerhard

gerhard commented Aug 22, 2024

Copy link
Copy Markdown
Contributor

@gerhard The PR isn't mergeable in this state, but several changes need to happen in our GA to make it work. I'll need your advice on this seems it might be counter-productive to spawn multiple engine as you explained

Yes, indeed, that is the second part which should be done part of this PR too, for sure.

@TomChv

TomChv commented Aug 22, 2024

Copy link
Copy Markdown
Member Author

Yes, indeed, that is the second part which should be done part of this PR too, for sure.

Yes because right now I'm not sure all tests are actually run

@gerhard

gerhard commented Aug 23, 2024 •

Copy link
Copy Markdown
Contributor

@TomChv all tests are still running part of Engine & CLI / test

I am now going to run the test suites locally, and see how they compare before & after.

@gerhard

gerhard commented Aug 23, 2024 •

Copy link
Copy Markdown
Contributor

I ran dagger call --source=.:default test list | tee test-list.txt and then compared the two results:

diff dagger/test-list.txt dagger.TomChv/test-list.txt

11a12,15
> TestDaggerCLI
> TestDaggerCall
> TestDaggerConfig
> TestDaggerType
14a19
> TestElixir
23a29
> TestGo
30a37
> TestInterface
55a63
> TestPHP
66a75
> TestPython

This is exactly as expected. New test suites are showing in this branch, but otherwise all other tests are the same.

I am now going to run the various test suites and see how they compare. Will add links to all Dagger Cloud traces.

@gerhard

gerhard commented Aug 23, 2024 •

Copy link
Copy Markdown
Contributor

Given the following host gerhard-2024-08-23-c-32-intel-lon1-01:

One-by-one - how long does each take?

TEST SUITE DURATION GOMAXPROCS 32
TestDaggerCLI 1m 42s ✅
TestDaggerCall 2m 3s ✅
TestDaggerConfig 2m 18s ✅
TestDaggerType 1m 55s ✅
TestElixir 1m 8s ✅
TestGo 1m 38s ✅
TestInterface 58s ✅
TestPHP 56s ✅
TestPython 2m 14s ✅
TestModule 4m 10s ✅

Note

I noticed that all tests passed the first time. No flakes in sight.

Grouped - which groups make most sense?

TEST SUITES GROUP DURATION GOMAXPROCS 32
--run="TestGo,TestPython,TestTypescript,TestElixir,TestPHP" 5m 27s ✅
--skip="TestGo,TestPython,TestTypescript,TestElixir,TestPHP" 11m 36s ✅
--skip="TestGo,TestPython,TestTypescript,TestElixir,TestPHP,TestModule" 8m 48s ❌
--run="TestContainer,TestEngine" 3m 29s ✅
--run="TestEngine,TestDaggerCLI" 2m 3s ✅
--run="TestEngine,TestDaggerCLI,TestContainer,TestDirectory,TestFile" 7m 28s ✅
--run="TestEngine,TestDaggerCLI,TestModule" ~20m ⚠️

Tip

I am using , instead of | in the flags above so that it doesn't break the table markdown formatting.

Note

I've just hit my first flake. I am not going to re-run it since I want to finish this series of runs, but that combination of test suites is potentially worth investigating.

Caution

The following test suites combo is making the Engine stall: --run="TestEngine|TestDaggerCLI|TestModule". This is definitely worth investigating. Here is the cloud trace. Attaching the screenshots. I did not tee the CLI output, running it in tmux, cannot capture stdout / stderr. I also messed up the engine stderr capture. Will do it on the next run - at least this looks fairly straightforward to reproduce now.

image image image image

@TomChv

TomChv commented Aug 23, 2024

Copy link
Copy Markdown
Member Author

@gerhard Thanks for all these updates! Looks like it has a positive impact on the CI 🚀

@gerhard gerhard added this to the v0.12.6 milestone Aug 27, 2024
@gerhard gerhard changed the title feat: split TestModule into multiple suites ci: split TestModule into multiple suites Aug 27, 2024
@gerhard
gerhard force-pushed the feat/split-test-module-into-sub-suite branch from 5dbcbdc to 13eb2bf Compare August 27, 2024 14:21
@gerhard
gerhard force-pushed the feat/split-test-module-into-sub-suite branch from 13eb2bf to 1bed69d Compare August 27, 2024 14:44
@gerhard

gerhard commented Aug 27, 2024 •

Copy link
Copy Markdown
Contributor

As a recap, we started by splitting test into test-modules & test-everything-else - #7863

This was a good change since it confirmed that most of the test flakes were in test-modules:
image

This change goes one step further and extracts from test-modules:

  1. test-module-runtimes
  2. test-engine-cli

We now have the following pipelines / jobs split from test:

  1. test-module-runtimes
  2. test-engine-cli
  3. test-modules
  4. test-everything-else

Going forward, these are the things that we care about:

  • How often do these pipelines fail?
  • Which of these pipelines fails the most?
  • How long do these pipelines take to run?

Current state:

  1. test-module-runtimes succeeded in 6m 5s
  2. test-engine-cli succeeded in 3m 22s
  3. test-modules succeeded in 4m 46s
  4. test-everything-else succeeded in 7m 50s

While we could combine test-engine-cli & test-modules into a single pipeline, this combination is prone to failures (see this comment above).

Before merging, I have a question for @sipsma @jedevc: since TestModule now changed, which of the following top-level tests do we want to run in the context of testdev ?

TestBaseVersion
TestBasic
TestBuiltins
TestCLI
TestCache
TestCacheMapConcurrent
TestCacheMapErrors
TestCacheMapRecursiveCall
TestCall
TestCheckResponse
TestClient
TestConfig
TestContainer
TestCoreModTypeDefs
TestDefToDAG
TestDefaults
TestDirectory
TestElixir
TestEmptyID
TestEngine
TestEngineNameLabel
TestEnums
TestFile
TestFromDir
TestGPU
TestGit
TestGitModuleSourceSymbolic
TestGo
TestHTTP
TestHost
TestIDFormat
TestIDsDoNotContainSensitiveValues
TestIDsReflectQuery
TestImpureIDsReEvaluate
TestInputObjects
TestInterface
TestIntrospection
TestIsSemver
TestLegacy
TestLexicalRelativePath
TestListResults
TestLoadCircleCILabels
TestLoadClientLabels
TestLoadGitHubLabels
TestLoadGitLabLabels
TestLoadGitLabels
TestLoadGitRefEnvLabels
TestLoadJenkinsLabels
TestLoadSecretsToScrubFromEnv
TestLoadSecretsToScrubFromFiles
TestLoadServerLabels
TestLoadingFromID
TestMatchGoImport
TestMatchVersion
TestModule
TestNamespaceObjects
TestNormalizeVersion
TestNullableResults
TestObject
TestObjects
TestOriginToPath
TestPHP
TestParallelism
TestParallelismFlag
TestParseAuthAddress
TestParseDaggerToken
TestParseGit
TestParseMetaGoImports
TestParsePragmaComment
TestParseRefString
TestPassingObjectsAround
TestPlatform
TestPureIDsDoNotReEvaluate
TestPython
TestRegistryAuthProvider
TestRemoteCache
TestRepoRootForImportPath
TestScrubSecretLogLatency
TestScrubSecretWrite
TestSecret
TestSecretScrubWriterWrite
TestSecretStore
TestSecretStoreNotFound
TestService
TestServicesStartConcurrentHappy
TestServicesStartConcurrentSad
TestServicesStartConcurrentSadThenHappy
TestServicesStartHappy
TestServicesStartHappyDifferentServers
TestServicesStartSad
TestSortInputFields
TestSpanName
TestSplitRequiredOptionalArgs
TestTelemetry
TestTrie
TestTrieExtend
TestTrieReinsert
TestType
TestType
TestTypeDefConversions
TestTypescript
TestValidateRepoRoot
TestVersionCompatibility
TestViews
TestViewsCaching
TestViewsIntrospection

@jedevc

jedevc commented Aug 27, 2024 •

Copy link
Copy Markdown
Contributor

I think we should probably keep the same tests in testdev that were there before.

i.e. everything that TestModule has been split into as part of this PR can be included.


Something we should do at some point btw - we should make it easier to group suites together. We could do this with the idea of "embedded suites" - we just need to extend testctx to look into embedded structs and traverse those as well.

That way we can define the logic of "groups of tests" in the integration test code, instead of having the definition in GitHub YAML - which we're trying to move away from.

@gerhard

gerhard commented Aug 27, 2024 •

Copy link
Copy Markdown
Contributor

If we keep the same tests in testdev as before TestModule was split, we can't expect anything to change in terms of its stability.

In the interest of keeping the same test coverage, I will split testdev into:

  1. testdev-modules
  2. testdev-module-runtimes
  3. testdev-container

Of course, we will keep testdev as is, this change is additive, same as we did for test.

I think that we could provision smaller runners for this @matipan. Keeping this as is for now, but I want to revisit this since 32vCPUs seems excessive. Actually, looking at the metrics for various runs, 32vCPU is the right size:

image image image

@sipsma

sipsma commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

I generally think that we need to reconsider whether we even need separate test and testdev in the first place anymore. That split happened a long time ago and I think in the new world we probably can just get away with only testdev.

But given that, in the meantime keeping the coverage the same but splitting up testdev sounds fine.

@gerhard

gerhard commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

I really like that idea @sipsma!

Since test already builds and tests a dev Engine inside Dagger, could we instead remove testdev? That would remove our dependency on Docker, which has a bunch of complications that span the entire stack (including how we provision those CI runners).

@TomChv
TomChv force-pushed the feat/split-test-module-into-sub-suite branch from a2114fe to 45bc1f9 Compare August 27, 2024 19:51
@sipsma

sipsma commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

I really like that idea @sipsma!

Since test already builds and tests a dev Engine inside Dagger, could we instead remove testdev? That would remove our dependency on Docker, which has a bunch of complications that span the entire stack (including how we provision those CI runners).

The point of testdev is to run our CI code itself against the dev engine, which is important to catch any issues pre-release. Otherwise our CI gets broken only once we do the release. So if we only have one we need to have testdev.

@TomChv
TomChv force-pushed the feat/split-test-module-into-sub-suite branch from 45bc1f9 to d5e417c Compare August 27, 2024 22:04
@jedevc jedevc removed this from the v0.12.6 milestone Aug 28, 2024
@gerhard

gerhard commented Aug 28, 2024

Copy link
Copy Markdown
Contributor

The point of testdev is to run our CI code itself against the dev engine, which is important to catch any issues pre-release. Otherwise our CI gets broken only once we do the release. So if we only have one we need to have testdev.

Got it. Instead of building & running the dev engine in Docker, could we instead use dagger-g2-main-...? This is the last version built from main. WDYT @jedevc @sipsma ?

@jedevc

jedevc commented Aug 28, 2024 •

Copy link
Copy Markdown
Contributor

Potentially we can use this, but now we have an implicit dependency on main - testdev (or it's equivalent) would then need to run only after the publish step. This also means it can't be run in PR environments, so we wouldn't be able to make testdev (or equivalent) the default.

IMO, the way to do this properly would be to:

  • Build the engine and CLI, and upload them as a workflow artifact
  • Then each next test/lint/etc step should download the artifact and start the "dev" engine in docker based on this
  • Also, the publish step just becomes: download artifacts, publish artifacts.

This is a pretty substantial rework, but since we can't publish an image/cli from a PR, the default testing environment can't involve consuming the dagger-g2-main... env.

Just consuming main isn't great IMO, since then we just have the problem we're trying to avoid - where running a PR workflow gives different results from main.

Tom Chauveau and others added 4 commits August 28, 2024 14:34
This splits test-modules further because it's the test suite with the
most failures since the last split. The intention is to keep doing this
until:
- all test suites complete within 10 mins (95%)
- all tests suites succeed 99% of the runs

Also, since test-modules is now much smaller, and test-everything-else
is larger, we need to split test-everything-else into two parts:
- test-engine & test-cli
- everything else

This is an intermediary state until we figure out a better arrangement.
The thing that we care about now is stability & time-to-completion.
Ideally, all of these should be a single test suite.

I also dropped "Dagger" from a bunch of test suites: it's all Dagger.

Signed-off-by: Gerhard Lazu <[email protected]>

Squash -2

Signed-off-by: Gerhard Lazu <[email protected]>
Signed-off-by: Gerhard Lazu <[email protected]>
- testdev-modules
- testdev-module-runtimes
- testdev-container

So that tests are more likely to succeed. These instance sizes seem
excessive, should configure smaller ones as a follow-up.

Signed-off-by: Gerhard Lazu <[email protected]>
@TomChv
TomChv force-pushed the feat/split-test-module-into-sub-suite branch from d5e417c to 8ec2238 Compare August 28, 2024 12:35
@sipsma

sipsma commented Aug 28, 2024

Copy link
Copy Markdown
Contributor

@jedevc @gerhard Something like #7771 should avoid the dep on docker in the infra

Or if that isn't salvageable for whatever reason, we can try variations on it like:

  • build dev engine, proxy service to localhost and run CI against that
  • just straight-up run docker as a service in the engine, proxy to localhost (feels silly somehow, but also avoids the hard dep on infra and creates the same end effect as today, so 🤷‍♂️)

It was making the tests fail.

Signed-off-by: Gerhard Lazu <[email protected]>
@gerhard

gerhard commented Aug 29, 2024 •

Copy link
Copy Markdown
Contributor

I understand the importance of testdev over test, which means starting with an outer dev engine built from the PR source, rather than the latest released version.

I also understand why we can't use :main for this - we need an Engine built from the source in the PR.

Let me think about this some more, and see where we land with testdev.

The current change looks good enough for now, I am keen on merging this so that we can start answering:

  • How often do these new pipelines fail?
  • Which of these pipelines fails the most?
  • How long do these pipelines take to run?

Just to re-emphasize, test & testdev remained as they were before this split, we can compare the new, smaller pipelines against the original ones. Today's snapshot which shows the state of flakes after the first split:

image

As soon as this gets merged, we will start capturing the behaviour of these new pipelines.

@gerhard gerhard left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 🚀

@gerhard
gerhard merged commit 907c013 into dagger:main Aug 29, 2024
gerhard added a commit that referenced this pull request Sep 11, 2024
…8407)

So that we can compare the two different workflows side-by-side. This is
something that we have learned ~2 weeks after the last test suite split:
- #8212

We know that the split suites are faster & more reliable, but without
this change, we cannot compare the two workflows side-by-side. All that
we know is that the Engine & CLI workflow is failing more often (flakes
are now 2x as likely to happen). This change will show us how all the
tests, but split differently, compare.

This is part of a wider effort captured in:
- #8184

Signed-off-by: Gerhard Lazu <[email protected]>
gerhard added a commit that referenced this pull request Sep 12, 2024
During #8212, testdev was
refactored and I missed these important test suites. This puts them
back. We should expect it to get slower and more flaky, but at least the
coverage will be the same as before.

We were still running the same tests in the split
testdev-module-runtimes, so were not really missing on anything test
coverage-wise, just the comparison between the original testdev and the
split one was less accurate.

Signed-off-by: Gerhard Lazu <[email protected]>
gerhard added a commit that referenced this pull request Nov 21, 2024
We introduced an alternative workflow which splits the big test suites
into smaller ones that have appropriately-sized CI runners. Context:
- #7863
- #8212

Now that we have been running both workflows in parallel for 4 months
and have a long-term understanding of their behaviour, we are going to
**temporarily** pause the less reliable jobs and save on infra
costs. For more details on the two workflows see this original issue
description which has been kept up-to-date all these months:
- #8184

As a reminder, we are doing this change so that we:
- mark a new milestone in this saga which started 6 months ago, in
  May 2024: #7339
- make progress towards `All our jobs succeed 90% of the time and
  finish within 10 minutes` (this change effectively makes our longest
  job be ~11mins)
- make all contributors wait less for all PR checks to be green
  (including re-running jobs which fail intermittently)
- save on CI infra costs which have doubled since September and are on
  track to reach `$10k` just for November

Signed-off-by: Gerhard Lazu <[email protected]>
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.

4 participants