Skip to content

Commit 35fb271

Browse files
authored
fix(tests): Fix ginkgo compiler tests for disabled cache (#12304)
Signed-off-by: mprahl <[email protected]>
1 parent 51ab5e6 commit 35fb271

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ Notes:
189189
ginkgo -v ./backend/test/compiler
190190

191191
# Update compiled workflow goldens when intended
192-
ginkgo -v -args -updateCompiledFiles=true ./backend/test/compiler
192+
ginkgo -v ./backend/test/compiler -- -updateCompiledFiles=true
193193

194194
# Auto-create missing goldens (default true); disable with:
195-
ginkgo -v -args -createGoldenFiles=false ./backend/test/compiler
195+
ginkgo -v ./backend/test/compiler -- -createGoldenFiles=false
196196
```
197197

198198
- v2 API integration tests (label-filterable):

backend/test/compiler/utils/workflow_utils.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,42 @@ func ConfigureCacheSettings(workflow *v1alpha1.Workflow, remove bool) *v1alpha1.
9696
for _, template := range configuredWorkflow.Spec.Templates {
9797
if template.Container != nil {
9898
if len(template.Container.Args) > 0 {
99-
if remove && slices.Contains(template.Container.Args, cacheDisabledArg) {
100-
containerArgs := make([]string, len(template.Container.Args)-1)
101-
for index, arg := range template.Container.Args {
102-
if arg == cacheDisabledArg {
103-
containerArgs = append(template.Container.Args[:index], template.Container.Args[index+1:]...)
104-
break
99+
if remove {
100+
// Remove cache_disabled arg if it exists
101+
if slices.Contains(template.Container.Args, cacheDisabledArg) {
102+
for index, arg := range template.Container.Args {
103+
if arg == cacheDisabledArg {
104+
template.Container.Args = append(template.Container.Args[:index], template.Container.Args[index+1:]...)
105+
break
106+
}
105107
}
106108
}
107-
template.Container.Args = containerArgs
108109
} else {
109-
if slices.Contains(template.Container.Args, "--run_id") {
110+
// Add cache_disabled arg if it doesn't exist and this is a driver container
111+
if slices.Contains(template.Container.Args, "--run_id") && !slices.Contains(template.Container.Args, cacheDisabledArg) {
110112
template.Container.Args = append(template.Container.Args, cacheDisabledArg)
111113
}
112114
}
113115
}
114116
for index, userContainer := range template.InitContainers {
115117
if remove {
116-
userArgs := make([]string, len(userContainer.Args)-1)
117-
for userArgsIndex, arg := range userContainer.Args {
118-
if arg == cacheDisabledArg {
119-
userArgs = append(userContainer.Args[:userArgsIndex], userContainer.Args[userArgsIndex+1:]...)
120-
break
118+
// Remove cache_disabled arg if it exists
119+
if slices.Contains(userContainer.Args, cacheDisabledArg) {
120+
for userArgsIndex, arg := range userContainer.Args {
121+
if arg == cacheDisabledArg {
122+
userContainer.Args = append(userContainer.Args[:userArgsIndex], userContainer.Args[userArgsIndex+1:]...)
123+
break
124+
}
121125
}
122126
}
123-
userContainer.Args = userArgs
124127
} else {
125-
if len(userContainer.Args) > 0 {
126-
userContainer.Args = append(userContainer.Args, cacheDisabledArg)
127-
} else {
128-
userContainer.Args = []string{cacheDisabledArg}
128+
// Add cache_disabled arg if it doesn't exist
129+
if !slices.Contains(userContainer.Args, cacheDisabledArg) {
130+
if len(userContainer.Args) > 0 {
131+
userContainer.Args = append(userContainer.Args, cacheDisabledArg)
132+
} else {
133+
userContainer.Args = []string{cacheDisabledArg}
134+
}
129135
}
130136
}
131137
template.InitContainers[index].Args = userContainer.Args

0 commit comments

Comments
 (0)