Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Nov 27, 2024
1 parent 7dead3d commit c808528
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
15 changes: 11 additions & 4 deletions test/e2e/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ func waitResource(ctx context.Context, t *testing.T, kwokctlPath, name, resource
defer func() {
cancel()
}()
cmd := exec.CommandContext(watchCtx, kwokctlPath, "--name", name, "kubectl", "get", "--no-headers", "--watch", resource)
args := []string{
"--name", name,
"kubectl", "get", resource,
"--watch", "--output-watch-events",
"-o", "template",
"--template", `{{.object.metadata.name}} {{.type}} {{.object.status.phase}} {{ "\n" }}`,
}
cmd := exec.CommandContext(watchCtx, kwokctlPath, args...)

Check failure on line 47 in test/e2e/benchmark.go

View workflow job for this annotation

GitHub Actions / lint (macos-latest)

G204: Subprocess launched with variable (gosec)
cmd.Stderr = os.Stderr
pr, err := cmd.StdoutPipe()
if err != nil {
Expand Down Expand Up @@ -70,7 +77,7 @@ func waitResource(ctx context.Context, t *testing.T, kwokctlPath, name, resource
}
cancel()
watchCtx, cancel = context.WithCancel(ctx)

Check failure on line 79 in test/e2e/benchmark.go

View workflow job for this annotation

GitHub Actions / lint (macos-latest)

lostcancel: the cancel function is not used on all paths (possible context leak) (govet)
cmd = exec.CommandContext(watchCtx, kwokctlPath, "--name", name, "kubectl", "get", "--no-headers", "--watch", resource)
cmd = exec.CommandContext(watchCtx, kwokctlPath, args...)

Check failure on line 80 in test/e2e/benchmark.go

View workflow job for this annotation

GitHub Actions / lint (macos-latest)

G204: Subprocess launched with variable (gosec)
cmd.Stderr = os.Stderr
pr, err = cmd.StdoutPipe()
if err != nil {
Expand Down Expand Up @@ -149,7 +156,7 @@ func scaleDeletePod(ctx context.Context, t *testing.T, kwokctlPath string, name
scaleCmd.Stdout = os.Stderr
scaleCmd.Stderr = os.Stderr

if err := waitResource(ctx, t, kwokctlPath, name, "Pod", "Terminating", size, 0, 0, scaleCmd.Start); err != nil {
if err := waitResource(ctx, t, kwokctlPath, name, "Pod", "DELETED", size, 0, 0, scaleCmd.Start); err != nil {
return fmt.Errorf("failed to wait for resource: %w", err)
}
return nil
Expand All @@ -160,7 +167,7 @@ func scaleCreateNode(ctx context.Context, t *testing.T, kwokctlPath string, name
scaleCmd.Stdout = os.Stderr
scaleCmd.Stderr = os.Stderr

if err := waitResource(ctx, t, kwokctlPath, name, "Node", "Ready", size, 10, 30, scaleCmd.Start); err != nil {
if err := waitResource(ctx, t, kwokctlPath, name, "Node", "Running", size, 10, 30, scaleCmd.Start); err != nil {
return fmt.Errorf("failed to wait for resource: %w", err)
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/benchmark_hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func scaleDeletePodWithHack(ctx context.Context, t *testing.T, kwokctlPath strin
scaleCmd := exec.CommandContext(ctx, kwokctlPath, "--name", name, "hack", "put", "--path", "-")
scaleCmd.Stdin = readerPodDeleteYaml(size)

if err := waitResource(ctx, t, kwokctlPath, name, "Pod", "Terminating", size, 0, 0, scaleCmd.Start); err != nil {
if err := waitResource(ctx, t, kwokctlPath, name, "Pod", "DELETED", size, 0, 0, scaleCmd.Start); err != nil {
return fmt.Errorf("failed to wait for resource: %w", err)
}
return nil
Expand Down Expand Up @@ -152,7 +152,7 @@ func scaleCreateNodeWithHack(ctx context.Context, t *testing.T, kwokctlPath stri
scaleCmd := exec.CommandContext(ctx, kwokctlPath, "--name", name, "hack", "put", "--path", "-")
scaleCmd.Stdin = readerNodeYaml(size)

if err := waitResource(ctx, t, kwokctlPath, name, "Node", "Ready", size, 10, 20, scaleCmd.Start); err != nil {
if err := waitResource(ctx, t, kwokctlPath, name, "Node", "Running", size, 10, 20, scaleCmd.Start); err != nil {
return fmt.Errorf("failed to wait for resource: %w", err)
}
return nil
Expand Down
1 change: 1 addition & 0 deletions test/e2e/kwokctl/benchmark-hack/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
"--disable-kube-scheduler",
"--disable-qps-limits",
"--controller-port=10247",
"--node-lease-duration-seconds=3600",
}
)

Expand Down
1 change: 1 addition & 0 deletions test/e2e/kwokctl/benchmark/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
"--disable-kube-scheduler",
"--disable-qps-limits",
"--controller-port=10247",
"--node-lease-duration-seconds=3600",
}
)

Expand Down

0 comments on commit c808528

Please sign in to comment.