Skip to content

Commit

Permalink
test: fix more tests using invalid images
Browse files Browse the repository at this point in the history
Signed-off-by: Mason Malone <[email protected]>
  • Loading branch information
MasonM committed Jan 18, 2025
1 parent 66bf46c commit 4deb2ec
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 153 deletions.
5 changes: 2 additions & 3 deletions test/e2e/cron/basic-update-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ spec:
parameters:
- name: message
container:
image: python:alpine3.6
command: [ "sh", -c ]
args: [ "echo {{inputs.parameters.message}}" ]
image: argoproj/argosay:v2
args: [ "echo", "{{inputs.parameters.message}}" ]
5 changes: 2 additions & 3 deletions test/e2e/cron/cron-and-malformed-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ spec:
templates:
- name: whalesay
container:
image: python:alpine3.6
command: ["sh", -c]
args: ["echo hello"]
image: argoproj/argosay:v2
args: ["echo", "hello"]

---

Expand Down
5 changes: 2 additions & 3 deletions test/e2e/cron/param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ spec:
parameters:
- name: message
container:
image: python:alpine3.6
command: ["sh", -c]
args: ["echo {{inputs.parameters.message}}"]
image: argoproj/argosay:v2
args: ["echo", "{{inputs.parameters.message}}"]
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ spec:
valueFrom:
path: /tmp/hello_world.txt
container:
image: alpine:latest
image: argoproj/argosay:v2
command: ["sh", "-c"]
args: ["echo intentional failure; exit 1"]
- name: lifecycle-hook
inputs:
parameters:
- name: hello-param
container:
image: busybox
command: [echo]
args: ["Hello param: {{inputs.parameters.hello-param}}"]
image: argoproj/argosay:v2
args: ["echo", "Hello param: {{inputs.parameters.hello-param}}"]
10 changes: 4 additions & 6 deletions test/e2e/expectedfailures/parallelism-dag-fail-fast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ spec:
template: sleep
- name: fail
container:
image: alpine:latest
command: [ sh, -c ]
args: ["exit 1"]
image: argoproj/argosay:v2
args: ["exit", "1"]
- name: sleep
container:
image: alpine:latest
command: [sh, -c]
args: ["sleep 5"]
image: argoproj/argosay:v2
args: ["sleep", "5"]
10 changes: 4 additions & 6 deletions test/e2e/expectedfailures/parallelism-step-fail-fast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ spec:
template: sleep
- name: fail
container:
image: alpine:latest
command: [sh, -c]
args: ["exit 1"]
image: argoproj/argosay:v2
command: ["exit", "1"]
- name: sleep
container:
image: alpine:latest
command: [ sh, -c ]
args: [ "sleep 5" ]
image: argoproj/argosay:v2
command: ["sleep", "5"]
10 changes: 0 additions & 10 deletions test/e2e/fixtures/given.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package fixtures

import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"

"github.com/TwiN/go-color"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -120,16 +118,11 @@ func (g *Given) checkImages(wf interface{}, isExample bool) {
g.t.Fatalf("Unsupported checkImage workflow type: %s", wf)
}

// discouraged
discouraged := func(image string) bool {
return image == "python:alpine3.6" && !isExample
}
allowed := func(image string) bool {
return strings.Contains(image, "argoexec:") ||
image == "argoproj/argosay:v1" ||
image == "argoproj/argosay:v2" ||
image == "quay.io/argoproj/argocli:latest" ||
discouraged(image) ||
(isExample && (image == "busybox" || image == "python:alpine3.6"))
}
for _, t := range templates {
Expand All @@ -147,9 +140,6 @@ func (g *Given) checkImages(wf interface{}, isExample bool) {
// (⎈ |docker-desktop:argo)➜ ~ time docker run --rm argoproj/argosay:v2
// docker run --rm argoproj/argosay˜:v2 0.21s user 0.10s system 16% cpu 1.912 total
// docker run --rm argoproj/argosay:v1 0.17s user 0.08s system 31% cpu 0.784 total
if discouraged(image) {
_, _ = fmt.Println(color.Ize(color.Yellow, "DISCOURAGED IMAGE: "+g.t.Name()+" is using "+image))
}
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions test/e2e/functional/dag-empty-param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ spec:

- name: gen-number-list
script:
image: python:alpine3.6
command: [python]
source: |
import json
import sys
json.dump([i for i in range(0, -1)], sys.stdout)
image: argoproj/argosay:v2
args: ["echo", "[]"]

- name: sleep-n-sec
inputs:
Expand Down
8 changes: 2 additions & 6 deletions test/e2e/functional/loops-empty-param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ spec:

- name: gen-number-list
script:
image: python:alpine3.6
command: [python]
source: |
import json
import sys
json.dump([i for i in range(0, -1)], sys.stdout)
image: argoproj/argosay:v2
args: ["echo", "[]"]

- name: sleep-n-sec
inputs:
Expand Down
18 changes: 3 additions & 15 deletions test/e2e/functional/param-aggregation-fromoutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,9 @@ spec:
- name: output1
valueFrom:
path: /tmp/fan_out.json
script:
command:
- python3
image: python:3.11
source: |-
import os
import sys
sys.path.append(os.getcwd())
import json
try: param1 = json.loads(r'''{{inputs.parameters.param1}}''')
except: param1 = r'''{{inputs.parameters.param1}}'''
with open('/tmp/fan_out.json', 'w') as f:
json.dump(param1, f)
print(json.dumps(param1))
container:
image: argoproj/argosay:v2
args: ["echo", "{{inputs.parameters.param1}}", "/tmp/fan_out.json"]
- dag:
tasks:
- arguments:
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/functional/retry-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ spec:
retryStrategy:
limit: 10
script:
image: python:alpine3.6
command: ["python"]
image: argoproj/argosay:v2
command: ["bash", "-c"]
# fail with a 66% probability
source: |
import random;
import sys;
exit_code = random.choice([0, 1, 1]);
sys.exit(exit_code)
(( $RANDOM % 3 > 0 ))
11 changes: 4 additions & 7 deletions test/e2e/functional/sidecar-volumes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ spec:

- name: generate
script:
image: python:alpine3.6
command: [python]
source: |
import time
time.sleep(5)
image: argoproj/argosay:v2
args: ["sleep", "5"]
sidecars:
- name: sidevol
image: alpine:latest
image: argoproj/argosay:v2
command: [sh, -c]
args: ["echo 'it works' > /mnt/vol/test-art"]
volumeMounts:
Expand All @@ -39,7 +36,7 @@ spec:

- name: verify
container:
image: alpine:latest
image: argoproj/argosay:v2
command: [sh, -c]
args: ['[[ "$(cat /mnt/vol/test-art)" == "it works" ]]']
volumeMounts:
Expand Down
53 changes: 19 additions & 34 deletions test/e2e/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,18 +539,13 @@ spec:
synchronization:
mutexes:
- name: job
script:
image: alpine:latest
command: [/bin/sh]
source: |
sleep 4
container:
image: argoproj/argosay:v2
args: ["sleep", "4"]
- name: exit0
script:
image: alpine:latest
command: [/bin/sh]
source: |
sleep 2
exit 0
container:
image: argoproj/argosay:v2
args: ["sleep", "2"]
`).When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeSucceeded).
Expand Down Expand Up @@ -691,18 +686,12 @@ spec:
- name: output-artifact
script:
image: python:alpine3.6
command: [ python ]
image: argoproj/argosay:v2
command: [/bin/sh]
source: |
import time
import random
import sys
time.sleep(1) # lifecycle hook for running won't trigger unless it runs for more than "a few seconds"
with open("result.txt", "w") as f:
f.write("Welcome")
if {{retries}} == 2:
sys.exit(0)
sys.exit(1)
sleep 1
echo 'Welcome' > result.txt
[ "{{retries}}" != "2" ]
retryStrategy:
limit: 2
outputs:
Expand All @@ -712,31 +701,27 @@ spec:
- name: started
container:
image: python:alpine3.6
command: [sh, -c]
args: ["echo STARTED!"]
image: argoproj/argosay:v2
args: ["echo", "STARTED!"]
- name: success
container:
image: python:alpine3.6
command: [sh, -c]
args: ["echo SUCCEEDED!"]
image: argoproj/argosay:v2
args: ["echo", "SUCCEEDED!"]
- name: failed
container:
image: python:alpine3.6
command: [sh, -c]
args: ["echo FAILED or ERROR!"]
image: argoproj/argosay:v2
args: ["echo", "FAILED or ERROR!"]
- name: print-artifact
inputs:
artifacts:
- name: message
path: /tmp/message
container:
image: python:alpine3.6
command: [sh, -c]
args: ["cat /tmp/message"]
image: argoproj/argosay:v2
args: ["cat", "/tmp/message"]
`).When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeCompleted).
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/testdata/artifact-passing-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:

- name: create-message
container:
image: alpine:latest
image: argoproj/argosay:v2
command: [sh, -c]
args: ["echo ':) Hello Argo!' | tee /tmp/hello_world.txt"]
outputs:
Expand All @@ -40,6 +40,6 @@ spec:
- name: message
path: /tmp/message
container:
image: alpine:latest
image: argoproj/argosay:v2
command: [sh, -c]
args: ["cat /tmp/message"]
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
dependencies: [delay-stop-workflow]
- name: artgc-dag-delay-stop
container:
image: alpine:latest
image: argoproj/argosay:v2
volumeMounts:
- name: artifacts
mountPath: /mnt/vol
Expand Down Expand Up @@ -73,7 +73,7 @@ spec:
labels:
template: "artgc-dag-artifact-creator-1"
container:
image: alpine:latest
image: argoproj/argosay:v2
volumeMounts:
- name: artifacts
mountPath: /mnt/vol
Expand Down Expand Up @@ -104,7 +104,7 @@ spec:
labels:
template: "artgc-dag-artifact-creator-2"
container:
image: alpine:latest
image: argoproj/argosay:v2
volumeMounts:
- name: artifacts
mountPath: /mnt/vol
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/testdata/artifactgc/artgc-dag-wf-stopped.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
dependencies: [delay-stop-workflow]
- name: artgc-dag-delay-stop
container:
image: alpine:latest
image: argoproj/argosay:v2
volumeMounts:
- name: artifacts
mountPath: /mnt/vol
Expand Down Expand Up @@ -75,7 +75,7 @@ spec:
labels:
template: "artgc-dag-artifact-creator-1"
container:
image: alpine:latest
image: argoproj/argosay:v2
volumeMounts:
- name: artifacts
mountPath: /mnt/vol
Expand Down Expand Up @@ -106,7 +106,7 @@ spec:
labels:
template: "artgc-dag-artifact-creator-2"
container:
image: alpine:latest
image: argoproj/argosay:v2
volumeMounts:
- name: artifacts
mountPath: /mnt/vol
Expand Down
Loading

0 comments on commit 4deb2ec

Please sign in to comment.