Skip to content

Commit 3c21143

Browse files
astefanuttiopenshift-merge-robot
authored andcommitted
test: Customize test timeouts
1 parent 4fb8a6f commit 3c21143

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

.github/workflows/e2e_tests.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ jobs:
165165
166166
- name: Run e2e tests
167167
run: |
168+
export CODEFLARE_TEST_TIMEOUT_SHORT=1m
169+
export CODEFLARE_TEST_TIMEOUT_MEDIUM=3m
170+
export CODEFLARE_TEST_TIMEOUT_LONG=8m
171+
168172
make test-e2e
169173
170174
- name: Print CodeFlare operator logs

test/support/gomega.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,11 @@ limitations under the License.
1717
package support
1818

1919
import (
20-
"time"
21-
2220
"github.com/onsi/gomega"
23-
"github.com/onsi/gomega/format"
2421
"github.com/onsi/gomega/gstruct"
2522
"github.com/onsi/gomega/types"
2623
)
2724

28-
func init() {
29-
// Gomega settings
30-
gomega.SetDefaultEventuallyTimeout(TestTimeoutShort)
31-
gomega.SetDefaultEventuallyPollingInterval(1 * time.Second)
32-
gomega.SetDefaultConsistentlyDuration(30 * time.Second)
33-
gomega.SetDefaultConsistentlyPollingInterval(1 * time.Second)
34-
// Disable object truncation on test results
35-
format.MaxLength = 0
36-
}
37-
3825
func EqualP(expected interface{}) types.GomegaMatcher {
3926
return gstruct.PointTo(gomega.Equal(expected))
4027
}

test/support/support.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,52 @@ limitations under the License.
1717
package support
1818

1919
import (
20+
"fmt"
21+
"os"
2022
"time"
2123

24+
"github.com/onsi/gomega"
25+
"github.com/onsi/gomega/format"
26+
2227
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2328
)
2429

25-
const (
30+
var (
2631
TestTimeoutShort = 1 * time.Minute
2732
TestTimeoutMedium = 2 * time.Minute
2833
TestTimeoutLong = 5 * time.Minute
29-
)
3034

31-
var (
3235
ApplyOptions = metav1.ApplyOptions{FieldManager: "codeflare-test", Force: true}
3336
)
37+
38+
func init() {
39+
if value, ok := os.LookupEnv("CODEFLARE_TEST_TIMEOUT_SHORT"); ok {
40+
if duration, err := time.ParseDuration(value); err == nil {
41+
TestTimeoutShort = duration
42+
} else {
43+
fmt.Printf("Error parsing CODEFLARE_TEST_TIMEOUT_SHORT. Using default value: %s", TestTimeoutShort)
44+
}
45+
}
46+
if value, ok := os.LookupEnv("CODEFLARE_TEST_TIMEOUT_MEDIUM"); ok {
47+
if duration, err := time.ParseDuration(value); err == nil {
48+
TestTimeoutMedium = duration
49+
} else {
50+
fmt.Printf("Error parsing CODEFLARE_TEST_TIMEOUT_MEDIUM. Using default value: %s", TestTimeoutMedium)
51+
}
52+
}
53+
if value, ok := os.LookupEnv("CODEFLARE_TEST_TIMEOUT_LONG"); ok {
54+
if duration, err := time.ParseDuration(value); err == nil {
55+
TestTimeoutLong = duration
56+
} else {
57+
fmt.Printf("Error parsing CODEFLARE_TEST_TIMEOUT_LONG. Using default value: %s", TestTimeoutLong)
58+
}
59+
}
60+
61+
// Gomega settings
62+
gomega.SetDefaultEventuallyTimeout(TestTimeoutShort)
63+
gomega.SetDefaultEventuallyPollingInterval(1 * time.Second)
64+
gomega.SetDefaultConsistentlyDuration(30 * time.Second)
65+
gomega.SetDefaultConsistentlyPollingInterval(1 * time.Second)
66+
// Disable object truncation on test results
67+
format.MaxLength = 0
68+
}

0 commit comments

Comments
 (0)