Skip to content

Commit

Permalink
optional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
psimovec committed Jul 14, 2020
1 parent f1087cf commit a2d9e51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/integration/bugs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestPodLogsCollected(t *testing.T) {
defer ChangeReportTimeInterval(t, 1)()
pod := findPod(t, clientset, "openshift-monitoring", "cluster-monitoring-operator")
defer degradeOperator(t, clientset, pod)()
checkNewPodsLogs(t, clientset, "Writing \\d+ records to")//|No status update necessary, objects are identical)")
checkPodsLogs(t, clientset, "Writing \\d+ records to", true)//|No status update necessary, objects are identical)")
if !LatestArchiveContainsPodLogs(t, clientset, pod) {
t.Fatal("There are no logs!")
}
Expand Down
18 changes: 5 additions & 13 deletions test/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,17 @@ func restartInsightsOperator(t *testing.T) {
t.Log(errPod)
}

func CheckPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogs bool) {
// TODO -> change this function to camel case and most of functions in this file to PascalCase in follow-up PR
func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string, newLogsOnly ...bool) {
// TODO -> change this function to to PascalCase in follow-up PR
r, _ := regexp.Compile(message)
newPods, err := kubeClient.CoreV1().Pods("openshift-insights").List(metav1.ListOptions{})
if err != nil {
t.Fatal(err.Error())
}
tajm := metav1.NewTime(time.Now())
timeNow := metav1.NewTime(time.Now())
logOptions := &corev1.PodLogOptions{}
if newLogs {
logOptions = &corev1.PodLogOptions{SinceTime:&tajm}
if len(newLogsOnly)==1 && newLogsOnly[0] {
logOptions = &corev1.PodLogOptions{SinceTime:&timeNow}
}
for _, newPod := range newPods.Items {
pod, err := kubeClient.CoreV1().Pods("openshift-insights").Get(newPod.Name, metav1.GetOptions{})
Expand Down Expand Up @@ -253,14 +253,6 @@ func forceUpdateSecret(ns string, secretName string, secret *v1.Secret) error {
return nil
}

func checkPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string) {
CheckPodsLogs(t, kubeClient, message, false)
}

func checkNewPodsLogs(t *testing.T, kubeClient *kubernetes.Clientset, message string) {
CheckPodsLogs(t, kubeClient, message, true)
}

func ExecCmd(t *testing.T, client kubernetes.Interface, podName string, namespace string,
command string, stdin io.Reader) (string, string, error) {
cmd := []string{
Expand Down

0 comments on commit a2d9e51

Please sign in to comment.