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

TestUploadNotDelayedAfterStart #157

Merged
merged 2 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/integration/bugs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ const knownFileSuffixesInsideArchiveRegex string = `(`+
`(\/|^)(config|id|invoker|metrics|version)` +
`)$`

//https://bugzilla.redhat.com/show_bug.cgi?id=1841057
func TestUploadNotDelayedAfterStart(t *testing.T) {
time1:=logLineTime(t, `Reporting status periodically to .* every`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, Could we please just for sure check that IO operator is healthy at the beginning of TC, because that is precondition for fast upload mode.
Also, at the beginning of Log file should be It is safe to use fast upload and not Not safe for fast upload, but I guess checking health of operator should be good enough fot test. (To not to have investigate ccases when AWS or OCP itself failed).

time2:=logLineTime(t, `Successfully reported id=`)
delay := time2.Sub(time1)
allowedDelay := time.Minute
t.Logf("Archive upload delay was %d seconds", delay/time.Second)
if delay > allowedDelay && delay < time.Hour*24-allowedDelay {
t.Fatal("Upload after start took too much time")
}
}

// https://bugzilla.redhat.com/show_bug.cgi?id=1750665
// https://bugzilla.redhat.com/show_bug.cgi?id=1753755
func TestDefaultUploadFrequency(t *testing.T) {
Expand Down
19 changes: 16 additions & 3 deletions test/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,19 @@ func deleteAllPods(t *testing.T, namespace string) {
t.Log(errPod)
}

func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogsOnly ...bool) {
r, _ := regexp.Compile(message)
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`
str := checkPodsLogs(t, clientset, startOfLine+pattern)
str = strings.Split(strings.Split(str, ".")[0], " ")[1]
time1, err := time.Parse("15:04:05", str)
e(t, err, "time parsing fail")
return time1

}

func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogsOnly ...bool) string {
r, err := regexp.Compile(`(?m)`+message)
e(t, err,"Regex compilation failed")
newPods, err := kubeClient.CoreV1().Pods("openshift-insights").List(metav1.ListOptions{})
if err != nil {
t.Fatal(err.Error())
Expand All @@ -194,6 +205,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
if len(newLogsOnly)==1 && newLogsOnly[0] {
logOptions = &corev1.PodLogOptions{SinceTime:&timeNow}
}
result := ""
for _, newPod := range newPods.Items {
pod, err := kubeClient.CoreV1().Pods("openshift-insights").Get(newPod.Name, metav1.GetOptions{})
if err != nil {
Expand All @@ -214,7 +226,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
}
log := buf.String()

result := r.FindString(log) //strings.Contains(log, message)
result = r.FindString(log) //strings.Contains(log, message)
if result == "" {
t.Logf("No %s in logs\n", message)
t.Logf("Logs for verification: ****\n%s", log)
Expand All @@ -228,6 +240,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
t.Error(errLog)
}
}
return result
}

func forceUpdateSecret(ns string, secretName string, secret *v1.Secret) error {
Expand Down