diff --git a/test/cri-containerd/helper_sandbox_test.go b/test/cri-containerd/helper_sandbox_test.go index 3976b57026..984b53d522 100644 --- a/test/cri-containerd/helper_sandbox_test.go +++ b/test/cri-containerd/helper_sandbox_test.go @@ -66,24 +66,6 @@ func removePodSandbox(tb testing.TB, client runtime.RuntimeServiceClient, ctx co } } -func getPodSandboxStatus(tb testing.TB, client runtime.RuntimeServiceClient, ctx context.Context, podID string) *runtime.PodSandboxStatus { - tb.Helper() - status, err := client.PodSandboxStatus(ctx, &runtime.PodSandboxStatusRequest{ - PodSandboxId: podID, - }) - if err != nil { - tb.Fatalf("failed PodSandboxStatus for sandbox: %s, request with: %v", podID, err) - } - return status.Status -} - -func assertPodSandboxState(tb testing.TB, client runtime.RuntimeServiceClient, ctx context.Context, podID string, state runtime.PodSandboxState) { - tb.Helper() - if st := getPodSandboxStatus(tb, client, ctx, podID).State; st != state { - tb.Fatalf("got pod sandbox %q state %q; wanted %v", podID, st.String(), state.String()) - } -} - func getTestSandboxConfig(tb testing.TB, opts ...SandboxConfigOpt) *runtime.PodSandboxConfig { tb.Helper() c := &runtime.PodSandboxConfig{ diff --git a/test/cri-containerd/helper_service_test.go b/test/cri-containerd/helper_service_test.go deleted file mode 100644 index 5ac7a34acd..0000000000 --- a/test/cri-containerd/helper_service_test.go +++ /dev/null @@ -1,94 +0,0 @@ -//go:build windows && functional - -package cri_containerd - -import ( - "fmt" - "sync" - "testing" - "time" - - "golang.org/x/sys/windows/svc" - "golang.org/x/sys/windows/svc/mgr" -) - -// Implements functionality so tests can start/stop the containerd service. -// Tests assume containerd will be running when they start, since this -// matches with the state a dev box will usually be in. A test that stops containerd should -// therefore ensure it starts it again. - -var ( - svcMgr *mgr.Mgr - svcMgrConnectOnce sync.Once - svcMgrConnectErr error -) - -func getSvcMgr() (*mgr.Mgr, error) { - svcMgrConnectOnce.Do(func() { - s, err := mgr.Connect() - if err != nil { - err = fmt.Errorf("failed to connect to service manager: %w", err) - } - svcMgr, svcMgrConnectErr = s, err - }) - return svcMgr, svcMgrConnectErr -} - -func startService(serviceName string) error { - m, err := getSvcMgr() - if err != nil { - return err - } - s, err := m.OpenService(serviceName) - if err != nil { - return fmt.Errorf("failed to open service %s: %w", serviceName, err) - } - if err := s.Start(); err != nil { - return fmt.Errorf("failed to start service %s: %w", serviceName, err) - } - return nil -} - -func stopService(serviceName string) error { - m, err := getSvcMgr() - if err != nil { - return err - } - s, err := m.OpenService(serviceName) - if err != nil { - return fmt.Errorf("failed to open service %s: %w", serviceName, err) - } - status, err := s.Control(svc.Stop) - if err != nil { - return fmt.Errorf("failed to send stop control to service %s: %w", serviceName, err) - } - tc := time.NewTimer(10 * time.Second) - defer tc.Stop() - for status.State != svc.Stopped { - time.Sleep(1 * time.Second) - select { - case <-tc.C: - return fmt.Errorf("service %s did not stop in time", serviceName) - default: - status, err = s.Query() - if err != nil { - return fmt.Errorf("failed to query service %s status: %w", serviceName, err) - } - } - } - return nil -} - -func startContainerd(tb testing.TB) { - tb.Helper() - if err := startService(*flagContainerdServiceName); err != nil { - tb.Fatal(err) - } -} - -func stopContainerd(tb testing.TB) { - tb.Helper() - if err := stopService(*flagContainerdServiceName); err != nil { - tb.Fatal(err) - } -} diff --git a/test/cri-containerd/main_test.go b/test/cri-containerd/main_test.go index 5ac2b070b3..f19f7d185f 100644 --- a/test/cri-containerd/main_test.go +++ b/test/cri-containerd/main_test.go @@ -88,11 +88,10 @@ var ( // Flags var ( - flagFeatures = testflag.NewFeatureFlag(allFeatures) - flagCRIEndpoint = flag.String("cri-endpoint", "tcp://127.0.0.1:2376", "Address of CRI runtime and image service.") - flagVirtstack = flag.String("virtstack", "", "Virtstack to use for hypervisor isolated containers") - flagVMServiceBinary = flag.String("vmservice-binary", "", "Path to a binary implementing the vmservice ttrpc service") - flagContainerdServiceName = flag.String("containerd-service-name", "containerd", "Name of the containerd Windows service") + flagFeatures = testflag.NewFeatureFlag(allFeatures) + flagCRIEndpoint = flag.String("cri-endpoint", "tcp://127.0.0.1:2376", "Address of CRI runtime and image service.") + flagVirtstack = flag.String("virtstack", "", "Virtstack to use for hypervisor isolated containers") + flagVMServiceBinary = flag.String("vmservice-binary", "", "Path to a binary implementing the vmservice ttrpc service") ) // Features