Skip to content

Commit

Permalink
test: Customize test timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti committed Jun 23, 2023
1 parent 7533958 commit 89d763f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ jobs:
- name: Run e2e tests
run: |
export CODEFLARE_TEST_TIMEOUT_SHORT=1m
export CODEFLARE_TEST_TIMEOUT_MEDIUM=3m
export CODEFLARE_TEST_TIMEOUT_LONG=8m
make test-e2e
- name: Print CodeFlare operator logs
Expand Down
13 changes: 0 additions & 13 deletions test/support/gomega.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,11 @@ limitations under the License.
package support

import (
"time"

"github.com/onsi/gomega"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/gstruct"
"github.com/onsi/gomega/types"
)

func init() {
// Gomega settings
gomega.SetDefaultEventuallyTimeout(TestTimeoutShort)
gomega.SetDefaultEventuallyPollingInterval(1 * time.Second)
gomega.SetDefaultConsistentlyDuration(30 * time.Second)
gomega.SetDefaultConsistentlyPollingInterval(1 * time.Second)
// Disable object truncation on test results
format.MaxLength = 0
}

func EqualP(expected interface{}) types.GomegaMatcher {
return gstruct.PointTo(gomega.Equal(expected))
}
Expand Down
41 changes: 38 additions & 3 deletions test/support/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,52 @@ limitations under the License.
package support

import (
"fmt"
"os"
"time"

"github.com/onsi/gomega"
"github.com/onsi/gomega/format"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
var (
TestTimeoutShort = 1 * time.Minute
TestTimeoutMedium = 2 * time.Minute
TestTimeoutLong = 5 * time.Minute
)

var (
ApplyOptions = metav1.ApplyOptions{FieldManager: "codeflare-test", Force: true}
)

func init() {
if value, ok := os.LookupEnv("CODEFLARE_TEST_TIMEOUT_SHORT"); ok {
if duration, err := time.ParseDuration(value); err == nil {
TestTimeoutShort = duration
} else {
fmt.Printf("Error parsing CODEFLARE_TEST_TIMEOUT_SHORT. Using default value: %s", TestTimeoutShort)
}
}
if value, ok := os.LookupEnv("CODEFLARE_TEST_TIMEOUT_MEDIUM"); ok {
if duration, err := time.ParseDuration(value); err == nil {
TestTimeoutMedium = duration
} else {
fmt.Printf("Error parsing CODEFLARE_TEST_TIMEOUT_MEDIUM. Using default value: %s", TestTimeoutMedium)
}
}
if value, ok := os.LookupEnv("CODEFLARE_TEST_TIMEOUT_LONG"); ok {
if duration, err := time.ParseDuration(value); err == nil {
TestTimeoutLong = duration
} else {
fmt.Printf("Error parsing CODEFLARE_TEST_TIMEOUT_LONG. Using default value: %s", TestTimeoutLong)
}
}

// Gomega settings
gomega.SetDefaultEventuallyTimeout(TestTimeoutShort)
gomega.SetDefaultEventuallyPollingInterval(1 * time.Second)
gomega.SetDefaultConsistentlyDuration(30 * time.Second)
gomega.SetDefaultConsistentlyPollingInterval(1 * time.Second)
// Disable object truncation on test results
format.MaxLength = 0
}

0 comments on commit 89d763f

Please sign in to comment.