Skip to content

Add docker image provisioner test. - #3763

Merged
helderco merged 3 commits into
dagger:mainfrom
sipsma:py-provision-test
Nov 14, 2022
Merged

helderco merged 3 commits into
dagger:mainfrom
sipsma:py-provision-test

Conversation

@sipsma

@sipsma sipsma commented Nov 10, 2022

Copy link
Copy Markdown
Contributor

Signed-off-by: Erik Sipsma [email protected]

Same thing as for Go, but in Python now: #3761


NOTE: this test won't yet run in CI because when we use dagger-in-dagger DAGGER_HOST gets overridden, so right now this test is only useful for us when running manually directly on hosts. I'm gonna fix this for both go+python+future-sdks in a follow up so it can also run in CI.


Also note: the ETXTBSY issue hit in Go (golang/go#22315) is not an issue here yet because our provisioner implementation is fully sync (and thus closes all file descriptors before they could end up in a forked process). However, that issue is a general Linux flaw and you can find people using pretty much any language hitting+complaining about it eventually across the internet, python example here.

So I think we will hit it if we update the provisioner to use async code, in which case this test case will start flaking and we can apply a similar fix that we did in Go (afaict doing a few retries after etxtbsy is where most people land as a solution).

@sipsma
sipsma requested a review from helderco November 10, 2022 03:37
@sipsma

sipsma commented Nov 10, 2022

Copy link
Copy Markdown
Contributor Author

I'm not sure what the linting error is, all I see it saying is:


#21 poe lint
#21 0.224 Poe => flake8 .
Error: input:1: container.from.exec.withEnvVariable.withEnvVariable.withEnvVariable.withEnvVariable.exec.exec.withEnvVariable.withEnvVariable.withEnvVariable.withMountedDirectory.withWorkdir.exec.exec.exitCode process "/_shim poe lint" did not complete successfully: exit code: 1

@helderco

helderco commented Nov 10, 2022 •

Copy link
Copy Markdown
Contributor

Hope you don't mind that I modernized it a bit.

You should do a poetry run poe fmt when changing python code so lint passes afterwards.

@helderco

helderco commented Nov 10, 2022 •

Copy link
Copy Markdown
Contributor

How is the docker provisioner adding to that temporary cache? Looks like the concurrency stuff isn't doing anything to affect cache_dir.

Did you mean to set XDG_CACHE_HOME to it?

diff --git a/sdk/python/tests/connectors/test_docker.py b/sdk/python/tests/connectors/test_docker.py
index d19c4dcb..a845afac 100644
--- a/sdk/python/tests/connectors/test_docker.py
+++ b/sdk/python/tests/connectors/test_docker.py
@@ -15,7 +15,9 @@ pytestmark = [
     dagger.Config().host.scheme != "docker-image",
     reason="DAGGER_HOST is not docker-image",
 )
-async def test_docker_image_provision(tmp_path: Path):
+async def test_docker_image_provision(tmp_path: Path, monkeypatch):
+    monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path))
+
     cache_dir = tmp_path / "dagger"
     cache_dir.mkdir()

sipsma and others added 3 commits November 13, 2022 17:06
- By using dagger.Config() instead of just os.environ we can test using the default value for DAGGER_HOST;
- Temporary dirs should be created by a pytest fixture;
- Use anyio instead of asyncio for compat with other backends like trio;

Signed-off-by: Helder Correia <[email protected]>
@sipsma

sipsma commented Nov 14, 2022

Copy link
Copy Markdown
Contributor Author

Did you mean to set XDG_CACHE_HOME to it?

Yes! Thank you for noticing that and for the other cleanup commit @helderco ! I rebased, it should be good to go now.

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