Skip to content

Commit 40bc008

Browse files
committed
nodelaytest
1 parent d1fc4df commit 40bc008

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

test/integration/bugs_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ const knownFileSuffixesInsideArchiveRegex string = `(`+
2020
`(\/|^)(config|id|invoker|metrics|version)` +
2121
`)$`
2222

23+
//https://bugzilla.redhat.com/show_bug.cgi?id=1841057
24+
func TestUploadNotDelayedAfterStart(t *testing.T) {
25+
time1:=logLineTime(t, `Reporting status periodically to .* every`)
26+
time2:=logLineTime(t, `Successfully reported id=`)
27+
delay := time2.Sub(time1)
28+
allowedDelay := time.Minute
29+
t.Logf("Archive upload delay was %d seconds", delay/time.Second)
30+
if delay > allowedDelay && delay < time.Hour*24-allowedDelay {
31+
t.Fatal("Upload after start took too much time")
32+
}
33+
}
34+
2335
// https://bugzilla.redhat.com/show_bug.cgi?id=1750665
2436
// https://bugzilla.redhat.com/show_bug.cgi?id=1753755
2537
func TestDefaultUploadFrequency(t *testing.T) {

test/integration/main_test.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,23 @@ func deleteAllPods(t *testing.T, namespace string) {
183183
t.Log(errPod)
184184
}
185185

186-
func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogsOnly ...bool) {
187-
r, _ := regexp.Compile(message)
186+
func logLineTime(t *testing.T, pattern string) time.Time {
187+
startOfLine := `\S\d{2}\d{2}\s\d{2}:\d{2}:\d{2}\.\d{6}\s*\d+\s\S+\.go:\d+]\s`
188+
str := checkPodsLogs(t, clientset, startOfLine+pattern)
189+
lineStart := regexp.MustCompile(startOfLine)
190+
if lineStart.MatchString(str[22:]) {
191+
t.Fatal("invalid logLineTime pattern, it matched more lines")
192+
}
193+
str = strings.Split(strings.Split(str, ".")[0], " ")[1]
194+
time1, err := time.Parse("15:04:05", str)
195+
e(t, err, "time parsing fail")
196+
return time1
197+
198+
}
199+
200+
func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogsOnly ...bool) string {
201+
r, err := regexp.Compile(message)
202+
e(t, err,"Regex compilation failed")
188203
newPods, err := kubeClient.CoreV1().Pods("openshift-insights").List(metav1.ListOptions{})
189204
if err != nil {
190205
t.Fatal(err.Error())
@@ -194,6 +209,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
194209
if len(newLogsOnly)==1 && newLogsOnly[0] {
195210
logOptions = &corev1.PodLogOptions{SinceTime:&timeNow}
196211
}
212+
result := ""
197213
for _, newPod := range newPods.Items {
198214
pod, err := kubeClient.CoreV1().Pods("openshift-insights").Get(newPod.Name, metav1.GetOptions{})
199215
if err != nil {
@@ -214,7 +230,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
214230
}
215231
log := buf.String()
216232

217-
result := r.FindString(log) //strings.Contains(log, message)
233+
result = r.FindString(log) //strings.Contains(log, message)
218234
if result == "" {
219235
t.Logf("No %s in logs\n", message)
220236
t.Logf("Logs for verification: ****\n%s", log)
@@ -228,6 +244,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
228244
t.Error(errLog)
229245
}
230246
}
247+
return result
231248
}
232249

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

0 commit comments

Comments
 (0)