diff --git a/test/performance/framework/service/scale_up.go b/test/performance/framework/service/scale_up.go index aa666e39aed..bf2acaba8f5 100644 --- a/test/performance/framework/service/scale_up.go +++ b/test/performance/framework/service/scale_up.go @@ -129,11 +129,16 @@ func ScaleUp(ctx context.Context, provider providers.ProviderInterface, controlP // for _, ip := range reservedIPs { // parsedIPs = append(parsedIPs, net.ParseIP(ip)) // } - allocator, err := ipallocator.NewCIDRAllocator(ipNet, nil) + allocator, err := ipallocator.NewCIDRAllocator(ipNet, []net.IP{net.ParseIP("10.96.0.1"), net.ParseIP("10.96.0.10")}) - testPodIndex := 0 for _, ns := range nss { klog.InfoS("Scale up Services", "Namespace", ns) + testPodIndex := 0 + var podList *corev1.PodList + podList, err = cs.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{}) + if err != nil { + return + } for _, svc := range generateService(ns, numPerNs) { if ipv6 { ipFamily := corev1.IPv6Protocol @@ -146,11 +151,6 @@ func ScaleUp(ctx context.Context, provider providers.ProviderInterface, controlP return fmt.Errorf("allocate IP from ServiceCIDR error: %+v", err) } - var podList *corev1.PodList - podList, err = cs.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{}) - if err != nil { - return fmt.Errorf("list test Pod error: %+v", err) - } var fromPod *corev1.Pod if testPodIndex < len(podList.Items) { fromPod = &podList.Items[testPodIndex] diff --git a/test/performance/utils/exec.go b/test/performance/utils/exec.go index 452d5c9f688..e638b7155ae 100644 --- a/test/performance/utils/exec.go +++ b/test/performance/utils/exec.go @@ -101,8 +101,7 @@ func PingIP(ctx context.Context, kubeConfig *rest.Config, kc kubernetes.Interfac } func extractNanoseconds(logEntry string) (int, error) { - // 1709005058989452190 Status changed from unknown to up after 30217985 seconds - re := regexp.MustCompile(`(\d+) Status changed from`) + re := regexp.MustCompile(`(\d+)\s+Status changed from (unknown|down)? to up after`) matches := re.FindStringSubmatch(logEntry) if len(matches) < 2 { @@ -134,8 +133,8 @@ func FetchTimestampFromLog(ctx context.Context, kc kubernetes.Interface, namespa if _, err := io.Copy(&b, podLogs); err != nil { return false, fmt.Errorf("error when copying logs for Pod '%s/%s': %w", namespace, podName, err) } - klog.InfoS("GetLogs from probe container", "logs", b.String()) - if strings.Contains(b.String(), "Status changed from unknown to up") { + klog.InfoS("GetLogs from probe container", "podName", podName, "namespace", namespace, "logs", b.String()) + if strings.Contains(b.String(), "to up") { changedTimeStamp, err := extractNanoseconds(b.String()) if err != nil { return false, err diff --git a/test/performance/utils/exec_test.go b/test/performance/utils/exec_test.go index 1f840a56722..ae6902f9150 100644 --- a/test/performance/utils/exec_test.go +++ b/test/performance/utils/exec_test.go @@ -6,9 +6,25 @@ import ( ) func TestExtractSeconds(t *testing.T) { - res, err := extractSeconds("Fri Feb 23 06:52:14 UTC 2024 Status changed from unknown to up after 100 seconds") - if err != nil { - fmt.Println(err) + testCases := []struct { + name string + log string + }{ + { + name: "", + log: "1234567 Status changed from unknown to up after 100 seconds", + }, + { + name: "", + log: "12345678 Status changed from down to up after 100 seconds", + }, } - fmt.Println(res) + for _, tc := range testCases { + res, err := extractNanoseconds(tc.log) + if err != nil { + fmt.Println(err) + } + fmt.Println(res) + } + }