Skip to content

Commit

Permalink
Fix timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Feb 27, 2024
1 parent 79a8667 commit b08105e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
8 changes: 2 additions & 6 deletions test/performance/framework/service/scale_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ func ScaleUp(ctx context.Context, provider providers.ProviderInterface, controlP
klog.InfoS("retrieveCIDRs", "svcCIDRs", svcCIDRs)
svcCIDRIPv4 = svcCIDRs[0]
_, ipNet, _ := net.ParseCIDR(svcCIDRIPv4)
// var parsedIPs []net.IP
// for _, ip := range reservedIPs {
// parsedIPs = append(parsedIPs, net.ParseIP(ip))
// }
allocator, err := ipallocator.NewCIDRAllocator(ipNet, []net.IP{net.ParseIP("10.96.0.1"), net.ParseIP("10.96.0.10")})

for _, ns := range nss {
Expand All @@ -152,7 +148,7 @@ func ScaleUp(ctx context.Context, provider providers.ProviderInterface, controlP
}

var fromPod *corev1.Pod
if testPodIndex < len(podList.Items) {
if testPodIndex < len(podList.Items) && actualCheckNum < cap(ch) {
fromPod = &podList.Items[testPodIndex]
testPodIndex++

Expand All @@ -166,7 +162,7 @@ func ScaleUp(ctx context.Context, provider providers.ProviderInterface, controlP
var newSvc *corev1.Service
var err error
svc.Spec.ClusterIP = clusterIP.String()
startTimeStamp := time.Now().Nanosecond()
startTimeStamp := time.Now().UnixNano()
newSvc, err = cs.CoreV1().Services(ns).Create(ctx, svc, metav1.CreateOptions{})
if err != nil {
if errors.IsAlreadyExists(err) {
Expand Down
6 changes: 3 additions & 3 deletions test/performance/utils/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func PingIP(ctx context.Context, kubeConfig *rest.Config, kc kubernetes.Interfac
return nil
}

func extractNanoseconds(logEntry string) (int, error) {
func extractNanoseconds(logEntry string) (int64, error) {
re := regexp.MustCompile(`(\d+)\s+Status changed from (unknown|down)? to up after`)
matches := re.FindStringSubmatch(logEntry)

Expand All @@ -114,10 +114,10 @@ func extractNanoseconds(logEntry string) (int, error) {
return 0, fmt.Errorf("error converting nanoseconds to integer: %v", err)
}

return nanoseconds, nil
return int64(nanoseconds), nil
}

func FetchTimestampFromLog(ctx context.Context, kc kubernetes.Interface, namespace, podName, containerName string, ch chan time.Duration, startTime int) error {
func FetchTimestampFromLog(ctx context.Context, kc kubernetes.Interface, namespace, podName, containerName string, ch chan time.Duration, startTime int64) error {
return wait.Poll(defaultInterval, defaultTimeout, func() (done bool, err error) {
req := kc.CoreV1().Pods(namespace).GetLogs(podName, &corev1.PodLogOptions{
Container: containerName,
Expand Down
1 change: 0 additions & 1 deletion test/performance/utils/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ func TestExtractSeconds(t *testing.T) {
}
fmt.Println(res)
}

}

0 comments on commit b08105e

Please sign in to comment.