From 4d3b7a460d67ecbbf3f6bfa9d41eb774c0cd4a66 Mon Sep 17 00:00:00 2001 From: Javier Romero Date: Tue, 30 Nov 2021 13:49:32 +0000 Subject: [PATCH] Configure gitpod test execution out-of-the-box The GitPod environment requires the docker socket to be chmoded to allow for in-container access. Additionally, there are some networking nuances that make certain tests problematic. Signed-off-by: Javier Romero --- .gitpod.yml | 8 ++++++-- internal/build/phase_test.go | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 15c2e1f9ab..b716e56cd5 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,6 +1,10 @@ tasks: - - init: make build + - name: Setup + before: chmod ugo+w /var/run/docker.sock + init: make build + command: chmod ugo+w /var/run/docker.sock + github: prebuilds: master: true @@ -11,4 +15,4 @@ github: vscode: extensions: - - golang.go \ No newline at end of file + - golang.go diff --git a/internal/build/phase_test.go b/internal/build/phase_test.go index d347ba89b8..3c0fa70e54 100644 --- a/internal/build/phase_test.go +++ b/internal/build/phase_test.go @@ -297,6 +297,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) { it.Before(func() { h.SkipIf(t, runtime.GOOS != "linux", "Skipped on non-linux") }) + it("allows daemon access inside the container", func() { tmp, err := ioutil.TempDir("", "testSocketDir") if err != nil { @@ -320,7 +321,12 @@ func testPhase(t *testing.T, when spec.G, it spec.S) { when("with TCP docker-host", func() { it.Before(func() { h.SkipIf(t, runtime.GOOS != "linux", "Skipped on non-linux") + + // this test is problematic in GitPod due to the special networking used + // see: https://github.com/gitpod-io/gitpod/issues/6446 + h.SkipIf(t, os.Getenv("GITPOD_WORKSPACE_ID") != "", "Skipped on GitPod") }) + it("allows daemon access inside the container", func() { forwardCtx, cancelForward := context.WithCancel(context.Background()) defer cancelForward() @@ -331,6 +337,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) { forwardUnix2TCP(forwardCtx, t, portChan) forwardExited <- struct{}{} }() + dockerHost := fmt.Sprintf("tcp://127.0.0.1:%d", <-portChan) configProvider := build.NewPhaseConfigProvider(phaseName, lifecycleExec, build.WithArgs("daemon"),