diff --git a/.github/workflows/ci-build.yaml b/.github/workflows/ci-build.yaml index 541c93aab38a..ab80c6fd8304 100644 --- a/.github/workflows/ci-build.yaml +++ b/.github/workflows/ci-build.yaml @@ -240,10 +240,11 @@ jobs: profile: minimal use-api: false steps: - - name: Free up disk space + - name: Free up unused disk space run: | printf "==> Available space before cleanup\n" df -h + # these directories are not used by E2E tests sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/.ghcup /opt/hostedtoolcache/CodeQL printf "==> Available space after cleanup\n" df -h @@ -275,14 +276,10 @@ jobs: export INSTALL_K3S_VERSION=${{ matrix.install_k3s_version }} fi - cat >/tmp/kubelet.config <> $KUBECONFIG diff --git a/test/e2e/manifests/kubelet-configuration.yaml b/test/e2e/manifests/kubelet-configuration.yaml new file mode 100644 index 000000000000..1c9b1902deee --- /dev/null +++ b/test/e2e/manifests/kubelet-configuration.yaml @@ -0,0 +1,11 @@ +# The E2E CI workflow passes this file to k3s using "--kubelet-arg=config=". +# Docs: https://docs.k3s.io/cli/agent?_highlight=kubelet&_highlight=arg#customized-flags + +# API reference: https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/ +apiVersion: kubelet.config.k8s.io/v1beta1 +kind: KubeletConfiguration +# Prevent images from being GC'd during a test run (which will lead to ErrImageNeverPull errors) by +# raising the minimum age to 1 hour and the disk usage threshold to 100%. +# We probably don't need to specify both, but it doesn't hurt. +imageMinimumGCAge: 1h +imageGCHighThresholdPercent: 100 \ No newline at end of file diff --git a/workflow/artifacts/http/http_test.go b/workflow/artifacts/http/http_test.go index 66a913748eba..eb055f6bb521 100644 --- a/workflow/artifacts/http/http_test.go +++ b/workflow/artifacts/http/http_test.go @@ -5,7 +5,7 @@ import ( "net/http" "net/http/httptest" "os" - "path" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -20,32 +20,37 @@ func TestHTTPArtifactDriver_Load(t *testing.T) { a := &wfv1.HTTPArtifact{ URL: "https://github.com/argoproj/argo-workflows", } + tempDir := t.TempDir() + t.Run("Found", func(t *testing.T) { + tempFile := filepath.Join(tempDir, "found") err := driver.Load(&wfv1.Artifact{ ArtifactLocation: wfv1.ArtifactLocation{HTTP: a}, - }, "/tmp/found") + }, tempFile) require.NoError(t, err) - _, err = os.Stat("/tmp/found") + _, err = os.Stat(tempFile) require.NoError(t, err) }) t.Run("FoundWithRequestHeaders", func(t *testing.T) { + tempFile := filepath.Join(tempDir, "found-with-request-headers") h1 := wfv1.Header{Name: "Accept", Value: "application/json"} h2 := wfv1.Header{Name: "Authorization", Value: "Bearer foo-bar"} a.Headers = []wfv1.Header{h1, h2} err := driver.Load(&wfv1.Artifact{ ArtifactLocation: wfv1.ArtifactLocation{HTTP: a}, - }, "/tmp/found-with-request-headers") + }, tempFile) require.NoError(t, err) - _, err = os.Stat("/tmp/found-with-request-headers") + _, err = os.Stat(tempFile) require.NoError(t, err) - assert.FileExists(t, "/tmp/found-with-request-headers") + assert.FileExists(t, tempFile) }) t.Run("NotFound", func(t *testing.T) { + tempFile := filepath.Join(tempDir, "not-found") err := driver.Load(&wfv1.Artifact{ ArtifactLocation: wfv1.ArtifactLocation{ HTTP: &wfv1.HTTPArtifact{URL: "https://github.com/argoproj/argo-workflows/not-found"}, }, - }, "/tmp/not-found") + }, tempFile) require.Error(t, err) argoError, ok := err.(errors.ArgoError) require.True(t, ok) @@ -55,25 +60,29 @@ func TestHTTPArtifactDriver_Load(t *testing.T) { func TestArtifactoryArtifactDriver_Load(t *testing.T) { driver := &ArtifactDriver{Client: http.DefaultClient} + tempDir := t.TempDir() + t.Run("NotFound", func(t *testing.T) { + tempFile := filepath.Join(tempDir, "not-found") err := driver.Load(&wfv1.Artifact{ ArtifactLocation: wfv1.ArtifactLocation{ Artifactory: &wfv1.ArtifactoryArtifact{URL: "https://github.com/argoproj/argo-workflows/not-found"}, }, - }, "/tmp/not-found") + }, tempFile) require.Error(t, err) argoError, ok := err.(errors.ArgoError) require.True(t, ok) assert.Equal(t, errors.CodeNotFound, argoError.Code()) }) t.Run("Found", func(t *testing.T) { + tempFile := filepath.Join(tempDir, "found") err := driver.Load(&wfv1.Artifact{ ArtifactLocation: wfv1.ArtifactLocation{ Artifactory: &wfv1.ArtifactoryArtifact{URL: "https://github.com/argoproj/argo-workflows"}, }, - }, "/tmp/found") + }, tempFile) require.NoError(t, err) - _, err = os.Stat("/tmp/found") + _, err = os.Stat(tempFile) require.NoError(t, err) }) } @@ -85,7 +94,7 @@ func TestSaveHTTPArtifactRedirect(t *testing.T) { } defer os.RemoveAll(tempDir) // clean up - tempFile := path.Join(tempDir, "tmpfile") + tempFile := filepath.Join(tempDir, "tmpfile") content := "temporary file's content" if err := os.WriteFile(tempFile, []byte(content), 0o600); err != nil { panic(err)