Skip to content

ci: Test Engine provisioning on MacOS - #3774

Merged
gerhard merged 9 commits into
dagger:mainfrom
grouville:macos-runner
Nov 29, 2022
Merged

gerhard merged 9 commits into
dagger:mainfrom
grouville:macos-runner

Conversation

@grouville

@grouville grouville commented Nov 10, 2022 •

Copy link
Copy Markdown
Member

Closes #3225

cc @sipsma @gerhard

@grouville grouville changed the title test(macos): Implement native MacOS pipeline ci(macos): Implement native MacOS pipeline Nov 10, 2022
@sipsma

sipsma commented Nov 10, 2022

Copy link
Copy Markdown
Contributor

This is awesome! Will save us so much manual testing time


Currently triggered on PRs, but it is quite long (~1h), wdyt ?

I'm surprised by this as the specs of the machine aren't great but not so bad that I would have thought they should take an hour. From https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources

Hardware specification for macOS virtual machines:

    3-core CPU (x86_64)
    14 GB of RAM
    14 GB of SSD space

Looking at the actual run, it seems like by far the longest part is one of the multiplatform tests:

Thu, 10 Nov 2022 15:13:52 GMT #22 sh -c uname -m && goxx-go build -o /out/cloak /src/cmd/cloak
Thu, 10 Nov 2022 15:13:52 GMT #22 DONE 1273.6s
Thu, 10 Nov 2022 15:13:53 GMT
Thu, 10 Nov 2022 15:13:53 GMT #24 sh -c uname -m && goxx-go build -o /out/cloak /src/cmd/cloak
Thu, 10 Nov 2022 15:18:09 GMT #24 DONE 1530.2s

Wouldn't be surprised if it's the one where you are using emulation. Still weird though.


How about we only run the SDK tests on mac os? So just starting with go, that would mean we do something like cd sdk/go && go run -v test ./.... That will cover the codepaths that are unique to macos. The full engine integration tests mostly are testing behavior that happen inside the Linux VM (even when the client is on macos), so running them here isn't strictly needed.

@aluzzardi

Copy link
Copy Markdown
Contributor

Great idea!

No need to have a different workflow though, we can use a matrix instead.

Something like:

jobs:
  sdk-go:
    name: sdk / go
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:

@grouville
grouville force-pushed the macos-runner branch 3 times, most recently from da22a50 to 4a31c5b Compare November 11, 2022 17:29
@grouville

grouville commented Nov 11, 2022 •

Copy link
Copy Markdown
Member Author

@aluzzardi @sipsma. Since yesterday's rebase, I keep failing on (TestImageProvision) https://github.com/dagger/dagger/actions/runs/3446849441/jobs/5752237018#step:7:33.

I believe it is related to #3793

@sipsma
sipsma force-pushed the macos-runner branch 5 times, most recently from 99f191a to 46e30c5 Compare November 13, 2022 23:11
@sipsma

sipsma commented Nov 13, 2022

Copy link
Copy Markdown
Contributor

@grouville Took a look, the tests all pass on my macbook as is (starting from clean slate, no local images pulled or anything) and I found that if I decrease the parallelism of the test case (run 5 provisions in parallel instead of 30), then CI seems to pass too.

The strange part is that we should be getting more output from the logs showing an error. After you updated to use dagger.LogOutput the only thing shown are the messages expected when everything works, but we still end up with the EOF error.

My only guess (and it's very much just a guess at this point):

  1. The macos tests are really slow and timing out here
  2. We aren't seeing the error message from that even when setting LogOutput because we shutdown too quickly (here) and the sdk misses the last logs printed (either cause they weren't flushed to the pipe or the pipe gets closed by the parent before they are read)

For now, just pushed a commit that lowers the parallelism to 5, which I'm okay with merging for now since 30 was a pretty arbitrary choice before. I also have a separate commit that I'll send out in a different PR that makes it so those log messages are put in the error message even if LogOutput is not set. I'll also look into the missing error messages I mentioned above alongside that.

@aluzzardi

Copy link
Copy Markdown
Contributor

Great idea!

No need to have a different workflow though, we can use a matrix instead.

I still think we don't need a separate workflow. Is there a reason why we need custom tests for Mac?

@grouville
grouville force-pushed the macos-runner branch 2 times, most recently from 3df2b3b to 6973506 Compare November 15, 2022 23:53
@grouville

grouville commented Nov 16, 2022 •

Copy link
Copy Markdown
Member Author

Great idea!
No need to have a different workflow though, we can use a matrix instead.

I still think we don't need a separate workflow. Is there a reason why we need custom tests for Mac?

From what I understood, we want to natively run the tests to avoid relying on Dagger-in-Dagger, which skips the provisioning part of our tests: #3225 (comment)

There's a lot more very important testing we need to do on macos now (around provisioning done by SDKs+engine-session binaries), and it's currently totally manual, which is not great. So we should be sure to cover that when we set this up.

  1. Manual testing of the engine before releases:
  • our docs mentions manual tests of each SDKs
  • comment mentioning the need to test the provisioning natively
  1. Mention on Discord, from Erik

Afaik, there was an issue with the privileges of the home dir, only on MacOS ? (that touched SDKs?)

As MacOS minutes are quite expensive, I talked with Gerhard this morning. Maybe running it only on main branch, on changes affecting just the engine ? (current commented implementation).

Wdyt @aluzzardi @sipsma ?

@grouville grouville changed the title ci(macos): Implement native MacOS pipeline DNM: ci(macos): Implement native MacOS pipeline Nov 16, 2022
@grouville

grouville commented Nov 16, 2022 •

Copy link
Copy Markdown
Member Author

The action seems to be flaky (working ~50% of the time), or times out (indefinitely waits on Docker Desktop to be running). Forking the action (once my job on the scrapper is done), to tweak it and make it more sustainable

@grouville
grouville force-pushed the macos-runner branch 2 times, most recently from c45e72f to a76703d Compare November 17, 2022 12:41
@grouville grouville changed the title DNM: ci(macos): Implement native MacOS pipeline DNM: ci(automated-provisioning-test): Implement native provisioning tests Nov 17, 2022
@grouville grouville changed the title DNM: ci(automated-provisioning-test): Implement native provisioning tests DNM: ci(automated-provisioning-test): Implement native provisioning tests [ubuntu-macOS] Nov 17, 2022
@grouville

grouville commented Nov 17, 2022 •

Copy link
Copy Markdown
Member Author

@sipsma I talked with Andrea yesterday, we found an agreement on the future of this PR: make it a periodic check (once a day), and rename it as as automated-provisioning-test. We run the SDK tests natively on each host.

  1. Do you think testing natively the provisioning on macos + ubuntu is still necessary, even with your dagger-in-dagger coming ? I recall there were some permissions / path issues on MacOS.

  2. I'm getting a race condition, rarely, on our go test suite, when running from Colima:

=== RUN   TestImageProvision
failed to remove old container dagger-engine-gcme-1668698067402844000: Error response from daemon: removal of container dagger-engine-gcme-1668698067402844000 is already in progress
failed to remove old container dagger-engine-gcme-1668698067402844000: Error response from daemon: removal of container dagger-engine-gcme-1668698067402844000 is already in progress
Error: buildkit failed to respond
Error: buildkit failed to respond
Error: buildkit failed to respond
Error: buildkit failed to respond
Error: buildkit failed to respond
    provision_test.go:76:
        	Error Trace:	/Users/home/Documents/dagger-worktree/macos-runner/sdk/go/provision_test.go:76
        	Error:      	Received unexpected error:
        	            	failed to connect: failed to start engine session bin: failed to read port from engine-session: EOF
        	            	Please visit https://dagger.io/help#go for troubleshooting guidance.
        	Test:       	TestImageProvision
--- FAIL: TestImageProvision (16.39s)
=== CONT  TestErrorMessage
=== CONT  TestContainer
=== CONT  TestGit
=== CONT  TestConnectOption
=== CONT  TestDirectory
=== CONT  TestConnectOption
    client_test.go:109:
        	Error Trace:	/Users/home/Documents/dagger-worktree/macos-runner/sdk/go/client_test.go:109
        	Error:      	Received unexpected error:
        	            	failed to start engine session bin: failed to read port from engine-session: EOF
        	            	Please visit https://dagger.io/help#go for troubleshooting guidance.
        	Test:       	TestConnectOption
--- FAIL: TestConnectOption (13.33s)
=== CONT  TestErrorMessage
    client_test.go:144:
        	Error Trace:	/Users/home/Documents/dagger-worktree/macos-runner/sdk/go/client_test.go:144
        	Error:      	Received unexpected error:
        	            	failed to start engine session bin: failed to read port from engine-session: EOF
        	            	Please visit https://dagger.io/help#go for troubleshooting guidance.
        	Test:       	TestErrorMessage

I believe it is due due to a conflict between TestImageProvision and other tests. Do you think isolating the TestImageProvision might make sense ?

@sipsma

sipsma commented Nov 17, 2022

Copy link
Copy Markdown
Contributor

we found an agreement on the future of this PR: make it a periodic check (once a day), and rename it as as automated-provisioning-test.

SGTM!

Do you think testing natively the provisioning on macos + ubuntu is still necessary, even with your dagger-in-dagger coming

Yeah I think we should still do that. Dagger-in-dagger only allows us to run linux binaries so we can't test the macos specific behavior with that. Unfortunate but I don't see any way around it for now. We only need to run these provisioning tests on the macos host directly though; nothing else is needed.

I'm getting a race condition, rarely, on our go test suite, when running from Colima

It's not super clear immediately what would cause that error. Is it possible to add a step that prints the logs of the container to the workflow (similar to this)? The output you showed there makes me think the actual engine container is not running or is being very very slow to start, but it's hard to say without more info.

In general, it's not expected that those test cases would interfere with one another. The only thing I can think of is that TestImageProvision sets XDG_CACHE_HOME as an env var which could cause the other tests to use that too, but the test is not marked with t.Parallel() and it also unsets that env var at the end of the case, so I don't currently see how that could cause problems.

@aluzzardi

Copy link
Copy Markdown
Contributor

we found an agreement on the future of this PR: make it a periodic check (once a day), and rename it as as automated-provisioning-test.

I was originally confused by this PR because I thought the goal was to run the tests on macOS, and I didn't understand why we wouldn't just do a matrix on the tests we already have.

Turns out the goal is to test provisioning outside of dagger-in-dagger

So I suggested to just call these "provisioning-test". Right now macOS only (maybe Linux wouldn't hurt?) but someday Windows probably.

@gerhard

gerhard commented Nov 29, 2022

Copy link
Copy Markdown
Contributor

Started looking into this.

Comment thread sdk/go/provision_test.go Resolved
@gerhard

gerhard commented Nov 29, 2022 •

Copy link
Copy Markdown
Contributor

This is almost there:

grouville and others added 5 commits November 29, 2022 14:18
- Run our integration suite against a native MacOS pipeline, with the install of Docker Desktop in headless mode
- Multiple MacOS versions could easily be implemented.
- Currently triggered on PRs, but it is quite long (~1h), wdyt ?
- Runs our integration tests, as these are the currently manual steps required on Mac

Signed-off-by: Guillaume de Rouville <[email protected]>
- Test Python SDK
- Test Go SDK

Signed-off-by: Guillaume de Rouville <[email protected]>
Lowering it to 5 parallel tests (to keep it consistent with the Go SDK). We had to reduce the amount because virtualization on MacOS runners is very slow:
- it led to timeouts / inconsistencies
- MacOS minutes are 10x more expensive, this number was arbitrary, and 5 is ok. We will save a lot of CI minutes

Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville
grouville force-pushed the macos-runner branch 2 times, most recently from db9f3c5 to 16310d1 Compare November 29, 2022 14:35
- rebase on top of main
- Set parallelism in SDKs to amount of logical CPUs
- add workflow-dispatch

Signed-off-by: Guillaume de Rouville <[email protected]>
We want it as similar to test, lint & publish as possible.

Signed-off-by: Gerhard Lazu <[email protected]>
@gerhard gerhard changed the title DNM: ci(provisioning-test): test provisioning outside dagger-in-dagger ci: Test Engine provisioning on MacOS Nov 29, 2022
Gerhard Lazu added 2 commits November 29, 2022 16:34
Windows container support on hosted GitHub Actions runners is unlikely:
actions/runner#904

Linux we get for free via our existing tests.

For the time being, let's keep this one simple, remove the matrix, and
stick to macOS only.

Rework the steps so that they are grouped together:
- First: setup Docker
- Then: checkout repository
- Next: setup Go & run Go SDK tests
- Last: setup Python & run Python SDK tests

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

@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.

@gerhard
gerhard merged commit 571c8ae into dagger:main Nov 29, 2022
@gerhard

gerhard commented Nov 30, 2022 •

Copy link
Copy Markdown
Contributor

https://github.com/dagger/dagger/actions/runs/3583093358/jobs/6028108171 triggered https://github.com/dagger/dagger/actions/workflows/provision.yml, but 3x instead of just once 🤔

image

I think this is happening because we are publishing separate images at once:

image

I know that we are building & publishing linux/amd64 and linux/arm64 image variants:

Why do we publish a 3rd manifest @sipsma @vito @aluzzardi , the one that is tagged as main?


Does this failure make sense to you @helderco? https://github.com/dagger/dagger/actions/runs/3583149836/jobs/6028239131#step:9:98

image

Seems to have failed for the other 2 runs too:

@helderco

Copy link
Copy Markdown
Contributor

Is the provision workflow being triggered when a new engine is published? Shouldn't the tests be run against a DAGGER_HOST pointing to that new engine? Otherwise you can easily have breaking changes in main if testing against the un-bumped engine in the sdks.

Anyway, not sure why that module wasn't installed in this particular job.

@grouville

Copy link
Copy Markdown
Member Author

Re-ran locally on my fork: https://github.com/grouville/dagger/actions/runs/3583501774/jobs/6029004809 (To debug)

For the 1 vs 3x runs, I believe it is due to our:

 # We want to trigger this workflow when our engine package gets updated:
  # https://github.com/dagger/dagger/pkgs/container/engine
  registry_package:
    # ⚠️ Differs to the official docs:
    # ✅ https://github.com/orgs/community/discussions/25123
    # ❌ https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package
    action: ["updated"]

It gets triggered for each update, however, I wouldn't surprised if the last deployment impacted the package 3 times (the main + one for each architecture):
image

@gerhard

gerhard commented Nov 30, 2022

Copy link
Copy Markdown
Contributor

For the 1 vs 3x runs, I believe it is due to ...
It gets triggered for each update, however, I wouldn't surprised if the last deployment impacted the package 3 times (the main + one for each architecture)

Yes, that makes sense.

Do you know @grouville if the manifest which gets tagged as main is cross-platform, in the sense that it will reference all platform-specific manifests?

@gerhard

gerhard commented Nov 30, 2022

Copy link
Copy Markdown
Contributor

Is the provision workflow being triggered when a new engine is published? Shouldn't the tests be run against a DAGGER_HOST pointing to that new engine? Otherwise you can easily have breaking changes in main if testing against the un-bumped engine in the sdks.

I was under the impression that's what we were doing. Did we miss this @grouville?

Anyway, not sure why that module wasn't installed in this particular job.

This passed before we merged this PR: https://github.com/grouville/dagger/actions/runs/3576435891/jobs/6014239024#step:9:96

Did something change?

Have hit my time box for this, will need to leave it for another day.

@grouville

grouville commented Nov 30, 2022 •

Copy link
Copy Markdown
Member Author

I was under the impression that's what we were doing. Did we miss this @grouville?

We run it after the new engine is published, not before. But I thought this was what we wanted to do.

Did something change?

Breaks too on my fork. Whenever I run the code locally, againstthe latest main branch, it's the same issue. Currently exploring the root cause. It might be a package bump (as we're using latest)

@helderco

Copy link
Copy Markdown
Contributor

Did something change?

As I said in #4037 (comment), I think there's issues with dependabot so this may have been introduced by:

@gerhard

gerhard commented Dec 7, 2022

Copy link
Copy Markdown
Contributor

FWIW, there is a follow-up diagram here #4065 (comment)

We still need to add provisioning tests part of publishing, before we actually publish anything (potentially) broken. @grouville has the context.

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.

Automated tests on macos

5 participants