Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: follow-ups + fix flaky Windows http artifact tests. Fixes #12744 #13670

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading