Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1908400:tests-e2e, increase timeouts, re-add TestArchiveUploadedAndResultsReceived #298

Merged
merged 3 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test-unit:
test-e2e:
go test ./test/integration -v -run ^\(TestIsIOHealthy\)$$ ^\(TestPullSecretExists\)$$ -timeout 6m30s
test/integration/resource_samples/apply.sh
go test ./test/integration -v -timeout 40m $(TEST_OPTIONS)
go test ./test/integration -v -timeout 45m $(TEST_OPTIONS)
.PHONY: test-e2e

vet:
Expand Down
12 changes: 7 additions & 5 deletions test/integration/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ func TestIsIOHealthy(t *testing.T) {
// Check if an archive is uploaded and insights results retrieved in a reasonable amount of time
// This test can be performed on OCP 4.7 and newer
func TestArchiveUploadedAndResultReceived(t *testing.T) {
t.Skip("Test makes CI fail and should be checked manually for now")
start := logLineTime(t, `Reporting status periodically to .* every`)
end := logLineTime(t, `Successfully reported id=`)
//t.Skip("Test makes CI fail and should be checked manually for now")
checker := LogChecker(t)
start := checker.Timeout(15 * time.Minute).logLineTime(`Reporting status periodically to .* every`)
end := checker.Timeout(10 * time.Minute).logLineTime(`Successfully reported id=`)
uploadingTime := duration(t, start, end)
t.Logf("Archive upload time is %v seconds", uploadingTime)
start = logLineTime(t, `Successfully reported id=`)
end = logLineTime(t, `Report retrieved correctly`)
checker.Timeout(2 * time.Minute)
start = checker.logLineTime(`Successfully reported id=`)
end = checker.logLineTime(`Report retrieved correctly`)
retrievingTime := duration(t, start, end)
t.Logf("Insights results retrieving time is %v seconds", retrievingTime)
}
Expand Down
16 changes: 16 additions & 0 deletions test/integration/log_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"regexp"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -122,6 +123,21 @@ func (lc *LogCheck) CheckPodLogs(podName string, logOptions *corev1.PodLogOption
})
}

func (lc *LogCheck) logLineTime(pattern string) time.Time {
// for IO logs
startOfLine := `^\S\d{2}\d{2}\s\d{2}:\d{2}:\d{2}\.\d{6}\s*\d+\s\S+\.go:\d+]\s`
lc.Search(startOfLine + pattern)
if lc.Err != nil {
lc.test.Fatalf("Couldn't find \"%s\"", pattern)
}
str := strings.Split(strings.Split(lc.Result, ".")[0], " ")[1]
time1, err := time.Parse("15:04:05", str)
if err != nil {
lc.test.Fatal(err, "time parsing fail")
}
return time1
}

func (lc *LogCheck) Execute() *LogCheck {
t := lc.test
kubeClient := lc.clientset
Expand Down
10 changes: 1 addition & 9 deletions test/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,7 @@ func deleteAllPods(t *testing.T, namespace string) {
}

func logLineTime(t *testing.T, pattern string) time.Time {
startOfLine := `^\S\d{2}\d{2}\s\d{2}:\d{2}:\d{2}\.\d{6}\s*\d+\s\S+\.go:\d+]\s`
lc := checkPodsLogs(t, startOfLine+pattern)
if lc.Err != nil {
t.Fatalf("Couldn't find \"%s\"", pattern)
}
str := strings.Split(strings.Split(lc.Result, ".")[0], " ")[1]
time1, err := time.Parse("15:04:05", str)
e(t, err, "time parsing fail")
return time1
return LogChecker(t).logLineTime(pattern)
}

func duration(t *testing.T, start time.Time, end time.Time) float64 {
Expand Down