Skip to content

Commit fbb600c

Browse files
committed
e2e: increase test timeout to 20m
TestTagResolution adds ~5m to the suite, pushing past the old 10m limit. Signed-off-by: Alice Frosi <afrosi@redhat.com>
1 parent 23aac50 commit fbb600c

3 files changed

Lines changed: 83 additions & 13 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ e2e: ## Run e2e tests (requires: make deploy-bink). V=1 for verbose. RUN=<regex>
6969
ARTIFACTS=$(ARTIFACTS) \
7070
BINK_NODE_IMAGE_DIGEST=$$(skopeo inspect --tls-verify=false --format '{{.Digest}}' docker://localhost:5000/node:latest) \
7171
BINK_NODE_IMAGE_UPDATE_DIGEST=$$(skopeo inspect --tls-verify=false docker://localhost:5000/node:update | jq -r '.Digest') \
72-
go test -timeout 10m -count=1 $(if $(V),-v) $(if $(RUN),-run $(RUN)) .
72+
go test -timeout 20m -count=1 $(if $(V),-v) $(if $(RUN),-run $(RUN)) .
7373

7474
##@ Build
7575

test/e2e/e2eutil/env.go

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -398,34 +398,74 @@ const (
398398
)
399399

400400
// argName returns the flag name from a --key or --key=value argument.
401+
// Returns "" for bare values that don't start with --.
401402
func argName(arg string) string {
403+
if !strings.HasPrefix(arg, "--") {
404+
return ""
405+
}
402406
arg = strings.TrimPrefix(arg, "--")
403407
if i := strings.Index(arg, "="); i >= 0 {
404408
return arg[:i]
405409
}
406410
return arg
407411
}
408412

413+
type flagGroup struct {
414+
name string
415+
elems []string
416+
}
417+
418+
// parseArgs groups a flat argument list into logical flags.
419+
// "--key=val" is one group; "--key val" (space-separated) is one group;
420+
// "--bool-flag" is one group.
421+
func parseArgs(args []string) []flagGroup {
422+
var groups []flagGroup
423+
for i := 0; i < len(args); i++ {
424+
n := argName(args[i])
425+
if n == "" {
426+
continue
427+
}
428+
g := flagGroup{name: n, elems: []string{args[i]}}
429+
// --key value: flag without "=" whose next element is a value, not another flag
430+
if !strings.Contains(args[i], "=") && i+1 < len(args) && !strings.HasPrefix(args[i+1], "--") {
431+
g.elems = append(g.elems, args[i+1])
432+
i++
433+
}
434+
// --key=value or --bool-flag: single-element group (no special handling needed)
435+
groups = append(groups, g)
436+
}
437+
return groups
438+
}
439+
409440
// mergeArgs merges newArgs into oldArgs. Existing flags whose name
410441
// matches a new flag are replaced; unmatched new flags are appended.
442+
// Handles both --key=value and --key value forms.
411443
func mergeArgs(oldArgs, newArgs []string) []string {
412-
newByName := make(map[string]string, len(newArgs))
413-
for _, a := range newArgs {
414-
newByName[argName(a)] = a
444+
newGroups := parseArgs(newArgs)
445+
newByName := make(map[string]flagGroup, len(newGroups))
446+
for _, g := range newGroups {
447+
if g.name != "" {
448+
newByName[g.name] = g
449+
}
415450
}
416451

452+
oldGroups := parseArgs(oldArgs)
417453
var result []string
418-
for _, a := range oldArgs {
419-
if replacement, ok := newByName[argName(a)]; ok {
420-
result = append(result, replacement)
421-
delete(newByName, argName(a))
422-
} else {
423-
result = append(result, a)
454+
for _, g := range oldGroups {
455+
if g.name != "" {
456+
if replacement, ok := newByName[g.name]; ok {
457+
result = append(result, replacement.elems...)
458+
delete(newByName, g.name)
459+
continue
460+
}
424461
}
462+
result = append(result, g.elems...)
425463
}
426-
for _, a := range newArgs {
427-
if _, ok := newByName[argName(a)]; ok {
428-
result = append(result, a)
464+
for _, g := range newGroups {
465+
if g.name != "" {
466+
if _, ok := newByName[g.name]; ok {
467+
result = append(result, g.elems...)
468+
}
429469
}
430470
}
431471
return result

test/e2e/e2eutil/env_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,36 @@ func TestMergeArgs(t *testing.T) {
5555
newArgs: []string{"--interval=10s"},
5656
want: []string{"--interval=10s"},
5757
},
58+
{
59+
name: "space-separated flag replaced",
60+
oldArgs: []string{"--interval", "5m", "--foo=bar"},
61+
newArgs: []string{"--interval", "10s"},
62+
want: []string{"--interval", "10s", "--foo=bar"},
63+
},
64+
{
65+
name: "equals form replaces space-separated",
66+
oldArgs: []string{"--interval", "5m"},
67+
newArgs: []string{"--interval=10s"},
68+
want: []string{"--interval=10s"},
69+
},
70+
{
71+
name: "space-separated replaces equals form",
72+
oldArgs: []string{"--interval=5m"},
73+
newArgs: []string{"--interval", "10s"},
74+
want: []string{"--interval", "10s"},
75+
},
76+
{
77+
name: "space-separated new arg appended",
78+
oldArgs: []string{"--foo=bar"},
79+
newArgs: []string{"--interval", "10s"},
80+
want: []string{"--foo=bar", "--interval", "10s"},
81+
},
82+
{
83+
name: "mixed forms multiple flags",
84+
oldArgs: []string{"--foo", "bar", "--enable-feature", "--baz=qux"},
85+
newArgs: []string{"--foo=newbar", "--baz", "newqux"},
86+
want: []string{"--foo=newbar", "--enable-feature", "--baz", "newqux"},
87+
},
5888
}
5989

6090
for _, tt := range tests {

0 commit comments

Comments
 (0)