Skip to content

Engine & CLI tests are reliable & fast #8184

Closed

Description

@gerhard

badgen.net

Reliable = pass 99% of the time.
Fast = < 10mins to pass.

Dagger version Engine & CLI main branch reliability Pass duration (P95) Fail duration (P95)
v0.15.3 5 days, 18 runs 17% 20m 23m
v0.15.2 19 days, 64 runs 50% 22m 32m
v0.15.[0-1] 35 days, 140 runs 56% 22m 32m
v0.14.0 20 days, 66 runs 46% 22m 22m
v0.13.7 7 days, 38 runs 57% 20m 32m
v0.13.6 11 days, 27 runs 77% 18m 35m
v0.13.[4-5] 16 days, 62 runs 72% 26m 32m
v0.13.[2-3] 15 days, 57 runs 70% 36m 39m
v0.13.1 5 days, 19 runs 60% 29m 18m
v0.13.0 6 days, 38 runs 70% 36m 39m
Image

👆 #8998 merged Engine & CLI split into Engine & CLI, only showing the split variant above:


Engine & CLI + Engine & CLI split

Dagger version Engine & CLI main reliability Pass duration (P95) Fail duration (P95)
v0.14.0
9 days, 56 runs
38%
(split) 67%
33m
(split) 23m
34m
(split) 35m
v0.13.7
7 days, 38 runs
34%
(split) 57%
32m
(split) 20m
33m
(split) 32m
v0.13.6
11 days, 27 runs
70%
(split) 77%
29m
(split) 18m
49m
(split) 35m
v0.13.[4-5]
16 days, 62 runs
68%
(split) 72%
34m
(split) 26m
41m
(split) 32m
v0.13.[2-3]
15 days, 57 runs
62%
(split) 70%
44m
(split) 36m
32m
(split) 39m
v0.13.1
5 days, 19 runs
58%
(split) 60%
30m
(split) 29m
32m
(split) 18m
v0.13.0
6 days, 38 runs
67%
(split) 70%
41m
(split) 36m
32m
(split) 39m

All the data above in one graph:

image


This is how past versions behaved:

Dagger version Engine & CLI main reliability Pass duration (P95) Fail duration (P95)
v0.12.[6-7]13 days, 67 runs 33% 37m 41m
v0.12.514 days, 51 runs 29% 22m 32m
v0.12.410 days, 40 runs 48% 16m 32m
v0.12.37 days, 40 runs 60% 18m 18m
v0.12.26 days, 23 runs 43% 25m 19m
v0.12.[0-1]6 days, 46 runs 20% 23m 33m
v0.11.922 days, 129 runs 42% 41m 26m
v0.11.86 days, 22 runs 72% 26m 18m

All the data above in one graph:

image


This is a checkpoint in our attempt to make our Engine & CLI tests reliable & fast. It is meant to:

  • remind us why we are doing this (after months with many distractions, it's easy to forget)
  • collect & share observations in a single place (we've been doing this ad-hoc, mostly private)
  • tie other related issues and pull requests

Why are we doing this?

We want the dagger/dagger Engine & CLI test suite to show off the most advanced & polished Dagger use case. We would like to have the most robust implementation - think production-ready - so that anyone is able to see what that means long-term. Looking at commits on main, there should be a sea of green checks.

The goal that we are aiming for is: 99% of runs on the main branch will succeed and complete within 10 minutes. We acknowledge that:

  • During weeks with lots of churn, 99% may not be possible (we merge incomplete code, external dependencies fail, etc.)
  • While 10 minutes is a good starting point, if no code changes, this should be a few minutes at most with everything (queueing time, reporting, etc.)

What is the problem?

There are several:

  • We cannot run all Engine & CLI tests locally, on regular hardware. dagger call --source=.:default test all will timeout after 30 minutes (default timeout).
    • Increasing the timeout to 180m does not help. Even if we would try with 240m / 360m and get it to work, it is impractical to wait 4h-6h for the entire test suite to complete.
  • We need server-grade machines to run all Engine & CLI tests
    • Minimum 32vCPUs (and --parallel=16, otherwise it may fail depending on the NVMe disk quality & contention)
    • Top-end user grade NVMe disk (Samsung 990PRO) is not fast enough
    • Minimum 192GB of RAM if we want to use TMPFS (a.k.a. ramdisk)
  • As each full test run generates 90GB of data, we need to prune storage after ~10 runs
  • Some tests are failing intermittently only in our CI
    • I am yet to see this happen in DigitalOcean, where Dagger runs in Docker (32vCPU compute optimised instances)
    • We are able to run all tests locally if we --skip=TestModule
  • If nothing changes, running dagger call --source=.:default test all the second time takes almost as long as it did the first time (there is a 3mins or 20% difference). This means that caching does not work as expected in this context.

Related items (most recent first)

What's next?

How does this run locally, on a 16vCPU Linux host?

Given the following host:

This is the outcome of running dagger call --source=.:default test specific --run=TestModule:

image

You can find the Dagger Cloud trace here: https://dagger.cloud/dagger/traces/af42de097bc7e417f1af560d17fa4b42

image

These are all the test runs on this host using #7863:

TEST SUITE GOMAXPROCS 16 --parallel=8
test all --race=true 74G ❌ 33m 26s ❌ 33m 22s
test specific --run=TestModule 60G ❌ 32m 56s ❌ 33m 8s
test specific --skip=TestModule 38GB ✅ 9m 59s ✅ 9m 55s

I then configured a 100GB ramdisk and ran the same tests again. TL;DR 100GB RAM is not enough.

TEST SUITE GOMAXPROCS 16 --parallel=8
test all --race=true 63G ❌ 32m 20s (OOM) ❌ 32m 14s (OOM)
test specific --run=TestModule 60G ❌ 32m 7s (OOM) ❌ 32m 16s (OOM)
test specific --skip=TestModule 37GB ✅ 7m 8s ✅ 7m 6s

Key take aways

  • Consumer grade-hardware is not powerful enough to run these tests
  • 🤔 Would it work with 32vCPU?

How does this run on a 32vCPU DO CPU-optimized instance?

Given the following host perf-party-2024-08-20-c-32-intel-tor1-01:

And the following setup:

curl -fsSL https://get.docker.com | sh
docker login

curl https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sh

(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) && sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && sudo apt update && sudo apt install gh -y

apt install tmux atop btop htop dstat

tmux

git clone https://github.com/gerhard/dagger
cd dagger
git checkout split-engine-test-all

dagger login dagger
dagger call --source=.:default test specific --skip="32C-6548N|64GB-DDR5|VIRTIO-NVME"

This is the outcome from various runs:

TEST SUITE GOMAXPROCS 32 --parallel=16 --parallel=8
test all --race=true 90G ❌ 25m 35s

❌ 25m 52s
❌ 17m 11s
✅ 14m 32s module cached | ✅ 18m 8s
✅ 15m 35s module cached | ✅ 23m 44s
✅ 21m 21s module cached |
| test specific --run=TestModule 60G | ✅ 10m 41s | ✅ 11m 53s | |
| test specific --skip=TestModule | | | |

And this is what the instance resources looked like during one of the test all --race=true run & test parallelism left at the default GOMAXPROCS 32 (notice that this fails consistently with an empty state):

image

Screenshot 2024-08-20 at 17 15 08

Screenshot 2024-08-20 at 17 15 12

Screenshot 2024-08-20 at 17 15 16

Screenshot 2024-08-20 at 17 15 21

This is the instance metrics view across all 3 failed runs:

image

Key take aways

  • Each run uses an additional 60GB - 90GB of disk space
  • Having the .dagger module cached makes the run 10-15% quicker
  • When running all tests with -race, GOMAXPROCS 32 and no previous state (rm -rf * in /var/run/docker before each run), the tests fail consistently

As discussed with @shykes @samalba & others on August 15, 2024

Activity

  1. self-assigned this
    on Aug 19, 2024
  2. jedevc commented on Aug 20, 2024

    @jedevc
    Contributor

    note - some of the runtimes of tests may not be accurately reported - see #8120.

  3. gerhard commented on Aug 20, 2024

    @gerhard
    ContributorAuthor

    This is where I got to today:

    • I am able to consistently reproduce failures when running test all --race=true with an empty state (3 failed runs in a row) and not setting any test parallelism (effectively GOMAXPROCS 32)
    • If there is some previous state (especially the module cache), this always passes

    This is what the instance resources looked like during those 3 runs:
    image

    I have reworked:

    I will appreciate your reviews since in all my manual runs I have confirmed that running TestModule separately from everything else does not fail intermittnetly or timeout if there are sufficient system resources.

    That PR splits the tests on top of what we have currently. If we confirm that the split makes things more reliable, we should keep all tests together as we investigate that further. I propose that we timebox that activity and pick the reliable and pragmatic solution so that:

    • our main becomes greener
    • PRs flow quicker

    My next step is to finish the remaining runs on the 32vCPU DigitalOcean CPU-optimized instance, and then move onto the matrix with:

    1. 32vCPU GitHub Runner
    2. 32vCPU Depot Runner
    3. 32vCPU Dagger Runner
  4. TomChv commented on Aug 20, 2024

    @TomChv
    Member

    Thanks for this amazing issue @gerhard

    I think #8185 should also be include to the effort and then spread globally to other test suite.
    Moving TypeScript related test from TestModule into its own suites had multiple benefits:

    • Actually let me tests only what I need locally (because as we'll know, running the full test suite isn't possible)
    • Let me dig more into what happens with each tests and identify the slowest to do some tests.

    I think this is related to #7863 but instead of CI, changes are at the codebase level.

    Right now, TypeScript tests takes around 7 minutes to executes https://dagger.cloud/Quartz/traces/a2c3a4a24346f31efac7dc52f23b6137#1fc4089edfc38818 (around 4 minutes setup).
    Cool things: tests are run in parallel and successfully pass.

    I couldn't find any active optimization for now, there's something strange in the trace.

    Slowest Typescript tests

    Note: Tests are linked to their traces and I only selected tests that are slower than 5m
    Note: Theses tests are run locally on my Mac M1 Max (32GB, 500Go NVMI, 16core)

    • TestInit 5m17.
      It's quite strange because even if these tests are run in parallel, it doesn't seem they start at the same point. The longest sub test in that one took 3m20s so where are the extra 2minutes spent?
      Question: is there a limit of the number of tests than can run in parallel?

    • TestSignaturesBuildinTypes 5m24s.
      This one is also quite strange, if I sum up the time of each steps, I end up with around 3m30s with subtests ([1m24 + 43s + 33s + (12s + 9s + 20s + 10s) ]). so again, where are the extra 2 minutes spent? And in that case, there's no parallelization, so I'm not sure the extra time spent is because of that.
      I spotted a typo in the test name btw, will fix it in tests: move TypeScript test to its own suite #8185

    • TestSignatures 5m38s.
      Same as TestInit, longest tests is 1m46s but even here if we sum up all tests durations, it's still less than 5 minutes.

    • TestWithOtherModuleTypes 7m7s.
      Strange again here, even the tests are run in parallel (and I verified it by trying to add t.Parallel but this ended in an Go error saying it was already parallelized), each of them takes 2m56s. However, the total test time is 7m7s.

    • TestRuntimeDetection 5m43s.
      Still the same issue, tests are all run in parallel and the longest is 1m24s. It's up to 3m30s time spent in that case.

    Deeper research

    If we take as reference TestRuntimeDetection trace (it's the same on all other TS tests, I didn't check for other's languages), we see this:

    Screenshot 2024-08-20 at 20 43 43

    Note: I only included the 2 first tests to keep it short

    What's surprising me is that the traces seems to start long after the dagger cli has been started.
    If you look closely, there's a gap big gap between the beginning of the session traces and other's tests. Question: Why that gap? Where does it come from? Normally the sum of all trace lenght should be as long as the parent trace?

    So we got the step /.dagger-cli session... that always as long as the test's time, however if we open the trace, we see nothing in. Question: Is it normal?

    Screenshot 2024-08-20 at 20 45 48

    Some hypothesys

    It's mostly theory, I'm not 100% sure but hopefully it will be useful to find the answers to our questions

    Theses traces highlight that the tests slowness might not be from the tests themselves but from the setup, speciallty the session. As we see in the first session, there is plenty of extra times spent inside the session (however we don't know what's happening there).
    So maybe there's a deeper issue with the session setup that creates this slowness, is it because we have so many connection happening in parallel?

    It seems there's also some traces or piece of information missing in dagger cloud, is it because of a bug? Is it because these traces are ignored? It might be interested to dig into that too.

    Potential things to continue the research

    • Testing how the number of parallel connection impact the engine: it would be interesting to creates 1, 10, 100, 500 dagger sessions in parallel to execute a simple task and see if it actually impacts the overall time, normally it shouldn't but I'm not sure we ever tried that.
    • Digging into engine traces to understand what's happening, maybe adding extra logs or traces inside session.
  5. gerhard commented on Aug 21, 2024

    @gerhard
    ContributorAuthor

    That's a nice addition @TomChv 💪

    As mentioned elsewhere, we cannot trust the test span durations yet. There is a known issue with them, @vito is on it.

    In the interim, I have added -v to go test part of #7863 . As this is now merged, if you rebase on top of main, you will be able to download the following files from GitHub Actions Artifacts:

    Screenshot 2024-08-21 at 11 31 34

    I then filter for the following: rg PASS: ~/Downloads/call.log | rg -v 0.00s | less -r

    image
  6. vito commented on Aug 21, 2024

    @vito
    Contributor

    @TomChv

    What's surprising me is that the traces seems to start long after the dagger cli has been started. If you look closely, there's a gap big gap between the beginning of the session traces and other's tests. Question: Why that gap? Where does it come from? Normally the sum of all trace lenght should be as long as the parent trace?

    Here's what's happening:

    1. TestRuntimeDetection runs and likely has a c := connect(ctx) line pretty early on, which is what starts the Dagger session.
    2. TestRuntimeDetection then calls t.Run to create sub-tests. Each of these sub-tests call t.Parallel via testctx middleware, since we want to run all of our tests in parallel.
    3. t.Parallel blocks until the Go test runtime tells it to wake up, meaning we hold the Dagger session open this entire time.

    There are a some potential improvements here:

    1. Our test telemetry shouldn't inflate test runtime - TestRuntimeDetection shouldn't be "charged" for the time it spends waiting on t.Parallel in a subtest.
    2. Tests probably shouldn't be opening a session so early - ideally it would be moved into each sub-test. I wouldn't worry too much about this yet, but it's something to keep an eye on, and some tests might be doing it intentionally.
      • Maybe we could move client initialization to middleware somehow.

    So we got the step /.dagger-cli session... that always as long as the test's time, however if we open the trace, we see nothing in. Question: Is it normal?

    Also normal. dagger session no longer shows spans beneath itself - that would "steal" them from their original call paths. For example, if I create a client (dagger.Connect(ctx)), and later on create a span foo, and use the client beneath that foo span, the telemetry should show up beneath foo, not beneath the place where we connected to Dagger.

  7. sipsma commented on Aug 21, 2024

    @sipsma
    Contributor

    Gonna be focusing on this until we reach our goals for CI in terms of de-flaking and test execution time.

    I will personally first focus on de-flaking so that we can get our CI consistently green and then hold it to that standard going forward. After that I can join the efforts to improve the performance.

    General plan for the test flakes:

    1. Do more deep dives into individual flakes to see if we can root cause them. In particular flaky test: TestPythonProjectLayout - The "main" module could not be found #7662 and Tests require disabling go mod index pending upstream bug fix #8031 since they are the most persistent and mysterious
      • I'm timeboxing me making progress on this to this week.
    2. If no meaningful progress on the above after this week, I'm okay falling back to seeing if we can just refactor how we approach integ testing modules.
      • As much as I'd like to avoid this, an extremely important fact is that no users have reported most of these problems.
      • While it's still highly likely these are genuine bugs, they may be specific to the ways in which we test modules through lots of nested execs. That approach is not something users do in the real world. So if we update our test suite to be closer to what users do (i.e. initialize and call modules from the CLI executing on the host rather than nested execs) and these flakes disappear, that's acceptable IMO.

    For the performance aspects, I think the hardest part right now is that the metrics we have are machine wide, which leaves us having to guess or painfully debug what specific parts are performance bottlenecks.

    What I'd really like to see is for us to have the ability to gather fine-grain performance profiles in the engine and use those to quickly identify the precise places that are introducing bottlenecks, using excessive CPU/memory/io, etc. There's many possible approaches here which are not mutually exclusive:

    1. Profilers like parca (but on the engine)
    2. Putting more debug OTEL spans all over the codebase
    3. pprof sampling
    4. Using cgroup sampling (buildkit has an implementation here, cc @vito)

    One question for you @gerhard: I remember you mentioned that we can now get fine-grain profiles for the CLI. Is there progress on being able to get the same thing for the engine container too? And if not, curious to know if there's any technical problem blockers that we could help with. Having those profiles for the engine could potentially be extremely helpful.

  8. sipsma commented on Aug 21, 2024

    @sipsma
    Contributor

    Just chatted with @gerhard who set me up with access to the CI eks cluster, which is going to make the deflaking infinitely simpler since I can go crazy debugging the flakes same as I do when problems are reproducible locally (which most of the remaining flakes are not, unfortunately) 🙏

    He also mentioned that the problem with parca integration on the engine is most likely a configuration one as opposed to some deep technical issue, which is great since should be easier to get going. However, with eks access I can also just pprof my way through that for now, which is great in the meantime.

  9. gerhard commented on Sep 2, 2024

    @gerhard
    ContributorAuthor

    5 days & 19 runs later, we have the first results for:

    How reliable are the new pipelines?

    Pipeline Success rate
    test-module-runtimes 74%
    test-modules 100%
    test-cli-engine 100%
    test-everything-else 79%
    testdev-module-runtimes 85%
    testdev-container 100%

    How long do these pipelines take to run?

    Pipeline Pass (P95) Fail (P95)
    test-module-runtimes 7m 40s 7m30s
    test-modules 7m N/A
    test-cli-engine 4m 40s N/A
    test-everything-else 9m 25s 9m 5s
    testdev-module-runtimes 9m 8m 55s
    testdev-container 7m 20s N/A

    How does test & testdev compare for reliability?

    Pipeline Success rate
    test 52%
    testdev 89%

    How does test & testdev compare for duration?

    Pipeline Pass (P95) Fail (P95)
    test 18m 55s 30m
    testdev 9m 35s 9m 10s

    Some additional insights worth sharing:

    • 59% is the success rate before the split for test & testdev only
    • 71% is the success rate after the split for test & testdev only

    Attacking those flakes seems to be working! It will be interesting to see if this holds up next week too.

    As for the new pipelines which have been split out:

    • 91% is the success rate after the split for all the new pipelines

    Before the split: 5 days from Aug. 24th - Aug. 29th

    After the split: 5 days: Aug. 29th - Sep. 3rd

  10. TomChv commented on Sep 5, 2024

    @TomChv
    Member

    What is the meaning of the 13% in the table? This comment seems to show that it's actually doing better that ever?

  11. gerhard commented on Sep 5, 2024

    @gerhard
    ContributorAuthor

    13% is the Engine & CLI workflow as a whole, which includes both test suites:

    • the split suites
    • the suites which are not split

    We are basically running tests twice now, which makes the overall workflow fail more, since there are 2x as many opportunities for flakes to happen.

    The key take away is that:

    • if we only had the split suites, the Engine & CLI workflow would be 91% successful
    • if we only had the unsplit suites, the Engine & CLI workflow would be 71% successful

    The most important thing right now is to keep tracking both suites to see if they remain consistently reliably. The problem with test & testdev is that this has been inconsistent over the various Dagger versions, which is why we now have a different types of suites to track.

  12. sipsma commented on Sep 20, 2024

    @sipsma
    Contributor

    Just noting for posterity, ephemeral errors downloading go deps with error messages along the lines of:

    • protocol error: received DATA before a HEADERS frame
    • stream error: stream ID 19; PROTOCOL_ERROR

    Appear to be golang/go#69544, so not an "us" problem it seems

  13. rajatjindal commented on Nov 21, 2024

    @rajatjindal
    Contributor

    Hi @gerhard

    I was reading through this issue, and one of the line item specifically interests me

    Integrate https://github.com/vakenbolt/go-test-report (export the resulting file to the GHA result)

    while having an HTML report for a specific run is great, in my experience what really helps (especially with high flake test repository like ours) is to have trends of these results. In one of my past job I developed a dashboard specifically for this (for a large monolithic app with several days of automated test executions per build) which helped me answer a few questions:

    • how frequently the tests are failing.
    • how frequently a specific test case is failing
    • how long the test executions are taking. is the execution time trend looking upwards or downwards
    • what are the top x number of slow tests. Identify the root cause for those, fix them, move to the next x number of slow tests
    • found a flake? great, lets search for this particular testcase across last x number of builds and see if they were failing on a specific combination of variables e.g. specific region, host machine, sdk, version of dagger etc. what was the memory/cpu profile of the host machine around the time of that failure.
    • search for a specific log msg across executions from last x number of builds. This helps identify which build it started with and then identify which commit it started with. greatly helps time-to-identify-fix.

    I have been building a similar dashboard as one of my side project (https://github.com/rajatjindal/tests-dashboard) and since last few weeks I occassionally inject test results from our CI into the system to glance through the results. (https://tests-dashboard.rajatjindal.com)

    As part of the same effort I opened #9011 to start archiving the test results from our CI as an artifact as the first step. The next step I was thinking was to start injecting these test results into the dashboard and build some analytics out of that.

    if that is something that sounds like a useful addition, please let me know. and I can get the basic dashboard setup and ready for consumption quickly.

    cc @marcosnils

  14. gerhard commented on Nov 25, 2024

    @gerhard
    ContributorAuthor

    That is an excellent idea @rajatjindal ! I really like this view & I'm keen to visualise these tests through it:

    image

    I would very much like us to have this for our own CI. I will take a look at #9011 next.

    I was excited to see you using Spin for this. I would be keen to test this on our experimental K8s cluster which has Spin runtime support. Will DM about sync-ing on the next steps.

    cc @marcosnils

  15. locked and limited conversation to collaborators on Mar 24, 2026
  16. converted this issue into a discussion #12253 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions