@@ -183,8 +183,19 @@ func deleteAllPods(t *testing.T, namespace string) {
183
183
t .Log (errPod )
184
184
}
185
185
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
+ str = strings .Split (strings .Split (str , "." )[0 ], " " )[1 ]
190
+ time1 , err := time .Parse ("15:04:05" , str )
191
+ e (t , err , "time parsing fail" )
192
+ return time1
193
+
194
+ }
195
+
196
+ func checkPodsLogs (t * testing.T , kubeClient * kubernetes.Clientset , message string , newLogsOnly ... bool ) string {
197
+ r , err := regexp .Compile (`(?m)` + message )
198
+ e (t , err ,"Regex compilation failed" )
188
199
newPods , err := kubeClient .CoreV1 ().Pods ("openshift-insights" ).List (metav1.ListOptions {})
189
200
if err != nil {
190
201
t .Fatal (err .Error ())
@@ -194,6 +205,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
194
205
if len (newLogsOnly )== 1 && newLogsOnly [0 ] {
195
206
logOptions = & corev1.PodLogOptions {SinceTime :& timeNow }
196
207
}
208
+ result := ""
197
209
for _ , newPod := range newPods .Items {
198
210
pod , err := kubeClient .CoreV1 ().Pods ("openshift-insights" ).Get (newPod .Name , metav1.GetOptions {})
199
211
if err != nil {
@@ -214,7 +226,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
214
226
}
215
227
log := buf .String ()
216
228
217
- result : = r .FindString (log ) //strings.Contains(log, message)
229
+ result = r .FindString (log ) //strings.Contains(log, message)
218
230
if result == "" {
219
231
t .Logf ("No %s in logs\n " , message )
220
232
t .Logf ("Logs for verification: ****\n %s" , log )
@@ -228,6 +240,7 @@ func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message strin
228
240
t .Error (errLog )
229
241
}
230
242
}
243
+ return result
231
244
}
232
245
233
246
func forceUpdateSecret (ns string , secretName string , secret * v1.Secret ) error {
0 commit comments