Skip to content

Commit cab86d5

Browse files
committed
nodelaytest
1 parent d1fc4df commit cab86d5

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
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

+13-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,16 @@ 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) {
186+
func logLineTime(t *testing.T, pattern string) time.Time {
187+
str := checkPodsLogs(t, clientset, `\d+:\d+:\d+\.\d+.*`+pattern)
188+
str = strings.Split(str, ".")[0]
189+
time1, err := time.Parse("15:04:05", str)
190+
e(t, err, "time parsing fail")
191+
return time1
192+
193+
}
194+
195+
func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogsOnly ...bool) string {
187196
r, _ := regexp.Compile(message)
188197
newPods, err := kubeClient.CoreV1().Pods("openshift-insights").List(metav1.ListOptions{})
189198
if err != nil {
@@ -194,6 +203,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
194203
if len(newLogsOnly)==1 && newLogsOnly[0] {
195204
logOptions = &corev1.PodLogOptions{SinceTime:&timeNow}
196205
}
206+
result := ""
197207
for _, newPod := range newPods.Items {
198208
pod, err := kubeClient.CoreV1().Pods("openshift-insights").Get(newPod.Name, metav1.GetOptions{})
199209
if err != nil {
@@ -214,7 +224,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
214224
}
215225
log := buf.String()
216226

217-
result := r.FindString(log) //strings.Contains(log, message)
227+
result = r.FindString(log) //strings.Contains(log, message)
218228
if result == "" {
219229
t.Logf("No %s in logs\n", message)
220230
t.Logf("Logs for verification: ****\n%s", log)
@@ -228,6 +238,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
228238
t.Error(errLog)
229239
}
230240
}
241+
return result
231242
}
232243

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

0 commit comments

Comments
 (0)