Skip to content

Commit c4bdbff

Browse files
authored
fix: set command instead of args in workload.test podspec (#725)
Rather than append args to a workload container's entrypoint, replace it when workloadTestCommand is set. Signed-off-by: Patrick J.P. Culp <[email protected]>
1 parent 4ea23f6 commit c4bdbff

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

test/cases/workload/workload_test.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ import (
2121
)
2222

2323
func createWorkloadJob(name, image, command string, resources map[string]string, timeout time.Duration) *batchv1.Job {
24+
container := corev1.Container{
25+
Name: name,
26+
Image: image,
27+
ImagePullPolicy: corev1.PullAlways,
28+
Resources: buildResourceRequirements(resources),
29+
}
30+
31+
// Override entrypoint if command is provided
32+
if command != "" {
33+
container.Command = strings.Fields(command)
34+
}
35+
36+
podSpec := corev1.PodSpec{
37+
RestartPolicy: corev1.RestartPolicyNever,
38+
ActiveDeadlineSeconds: ptr.Int64(int64(timeout.Seconds())),
39+
Containers: []corev1.Container{container},
40+
}
41+
2442
job := &batchv1.Job{
2543
ObjectMeta: metav1.ObjectMeta{
2644
Name: name,
@@ -33,19 +51,7 @@ func createWorkloadJob(name, image, command string, resources map[string]string,
3351
ObjectMeta: metav1.ObjectMeta{
3452
Labels: map[string]string{"app": name},
3553
},
36-
Spec: corev1.PodSpec{
37-
RestartPolicy: corev1.RestartPolicyNever,
38-
ActiveDeadlineSeconds: ptr.Int64(int64(timeout.Seconds())),
39-
Containers: []corev1.Container{
40-
{
41-
Name: name,
42-
Image: image,
43-
Args: strings.Fields(command),
44-
ImagePullPolicy: corev1.PullAlways,
45-
Resources: buildResourceRequirements(resources),
46-
},
47-
},
48-
},
54+
Spec: podSpec,
4955
},
5056
},
5157
}

0 commit comments

Comments
 (0)