Skip to content

Commit

Permalink
ci: follow-up changes and fix flaky Windows tests. Fixes #12744 (#13670)
Browse files Browse the repository at this point in the history
Signed-off-by: Mason Malone <mmalone@adobe.com>
  • Loading branch information
MasonM authored Sep 27, 2024
1 parent 5c1b97f commit 7f14810
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -275,14 +276,10 @@ jobs:
export INSTALL_K3S_VERSION=${{ matrix.install_k3s_version }}
fi
cat >/tmp/kubelet.config <<EOT
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
imageMinimumGCAge: 1h
imageGCHighThresholdPercent: 100
EOT
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=stable INSTALL_K3S_EXEC='--docker --kubelet-arg=config=/tmp/kubelet.config' K3S_KUBECONFIG_MODE=644 sh -
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=stable \
INSTALL_K3S_EXEC="--docker --kubelet-arg=config=${GITHUB_WORKSPACE}/test/e2e/manifests/kubelet-configuration.yaml" \
K3S_KUBECONFIG_MODE=644 \
sh -
until kubectl --kubeconfig=/etc/rancher/k3s/k3s.yaml cluster-info ; do sleep 10s ; done
cp /etc/rancher/k3s/k3s.yaml /home/runner/.kubeconfig
echo "- name: fake_token_user" >> $KUBECONFIG
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/manifests/kubelet-configuration.yaml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 20 additions & 11 deletions workflow/artifacts/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -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)
Expand All @@ -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)
})
}
Expand All @@ -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)
Expand Down

0 comments on commit 7f14810

Please sign in to comment.