diff --git a/integration-tests/pkg/collector/collector.go b/integration-tests/pkg/collector/collector.go index 676baee07f..233fbd37ef 100644 --- a/integration-tests/pkg/collector/collector.go +++ b/integration-tests/pkg/collector/collector.go @@ -16,7 +16,7 @@ type Manager interface { Launch() error TearDown() error IsRunning() (bool, error) - ContainerID() string + ContainerID() executor.ContainerID TestName() string } diff --git a/integration-tests/pkg/collector/collector_docker.go b/integration-tests/pkg/collector/collector_docker.go index b0d3df86ab..5a0f51f767 100644 --- a/integration-tests/pkg/collector/collector_docker.go +++ b/integration-tests/pkg/collector/collector_docker.go @@ -8,7 +8,6 @@ import ( "golang.org/x/exp/maps" "github.com/hashicorp/go-multierror" - "github.com/stackrox/collector/integration-tests/pkg/common" "github.com/stackrox/collector/integration-tests/pkg/config" "github.com/stackrox/collector/integration-tests/pkg/executor" ) @@ -22,7 +21,7 @@ type DockerCollectorManager struct { testName string CollectorOutput string - containerID string + containerID executor.ContainerID } func NewDockerCollectorManager(e executor.Executor, name string) *DockerCollectorManager { @@ -91,7 +90,7 @@ func (c *DockerCollectorManager) TearDown() error { // Check if collector container segfaulted or exited with error exitCode, err := c.executor.ExitCode(executor.ContainerFilter{ - Name: "collector", + Id: executor.ContainerID("collector"), }) if err != nil || exitCode != 0 { logsEnd := "" @@ -145,24 +144,22 @@ func (c *DockerCollectorManager) launchCollector() error { if err != nil { return err } - output, err := c.executor.StartContainer(startConfig) - c.CollectorOutput = output + id, err := c.executor.StartContainer(startConfig) if err != nil { return err } - outLines := strings.Split(output, "\n") - c.containerID = common.ContainerShortID(string(outLines[len(outLines)-1])) - return err + c.containerID = id + return nil } func (c *DockerCollectorManager) captureLogs(containerName string) (string, error) { - return c.executor.CaptureLogs(c.testName, containerName) + return c.executor.CaptureLogs(c.testName, executor.ContainerID(containerName)) } func (c *DockerCollectorManager) killContainer(name string) error { - _, err1 := c.executor.KillContainer(name) + _, err1 := c.executor.KillContainer(executor.ContainerID(name)) _, err2 := c.executor.RemoveContainer(executor.ContainerFilter{ - Name: name, + Id: executor.ContainerID(name), }) var result error @@ -177,11 +174,11 @@ func (c *DockerCollectorManager) killContainer(name string) error { } func (c *DockerCollectorManager) stopContainer(name string) error { - _, err := c.executor.StopContainer(name) + _, err := c.executor.StopContainer(executor.ContainerID(name)) return err } -func (c *DockerCollectorManager) ContainerID() string { +func (c *DockerCollectorManager) ContainerID() executor.ContainerID { return c.containerID } diff --git a/integration-tests/pkg/collector/collector_k8s.go b/integration-tests/pkg/collector/collector_k8s.go index 74c29a4e3c..b9dfb1684c 100644 --- a/integration-tests/pkg/collector/collector_k8s.go +++ b/integration-tests/pkg/collector/collector_k8s.go @@ -32,7 +32,7 @@ type K8sCollectorManager struct { eventWatcher watch.Interface - containerID string + containerID executor.ContainerID ip string } @@ -165,7 +165,7 @@ func (k *K8sCollectorManager) TearDown() error { if !isRunning { exitCode, err := k.executor.ExitCode(executor.ContainerFilter{ - Name: "collector", + Id: executor.ContainerID("collector"), Namespace: TEST_NAMESPACE, }) if err != nil { @@ -185,7 +185,7 @@ func (k *K8sCollectorManager) TearDown() error { } return k.executor.WaitPodRemoved(executor.ContainerFilter{ - Name: "collector", + Id: executor.ContainerID("collector"), Namespace: TEST_NAMESPACE, }) } @@ -199,10 +199,10 @@ func (k *K8sCollectorManager) IsRunning() (bool, error) { return *pod.Status.ContainerStatuses[0].Started, nil } -func (k *K8sCollectorManager) ContainerID() string { +func (k *K8sCollectorManager) ContainerID() executor.ContainerID { if k.containerID == "" { cf := executor.ContainerFilter{ - Name: "collector", + Id: executor.ContainerID("collector"), Namespace: TEST_NAMESPACE, } diff --git a/integration-tests/pkg/common/container_id.go b/integration-tests/pkg/common/container_id.go new file mode 100644 index 0000000000..56b9716489 --- /dev/null +++ b/integration-tests/pkg/common/container_id.go @@ -0,0 +1,16 @@ +package common + +// ContainerID is an identifier for a container. It can +// be a container name *OR* a hex ID +type ContainerID string + +// Long returns the whole containerID as a string +func (c ContainerID) Long() string { + return string(c) +} + +// Short returns the first twelve character of a containerID +// to match the shortened IDs returned by docker. +func (c ContainerID) Short() string { + return string(c)[:12] +} diff --git a/integration-tests/pkg/common/utils.go b/integration-tests/pkg/common/utils.go index cd3a39427d..3d771ed727 100644 --- a/integration-tests/pkg/common/utils.go +++ b/integration-tests/pkg/common/utils.go @@ -15,12 +15,6 @@ import ( "k8s.io/utils/strings/slices" ) -// containerShortID returns the first twelve character of a containerID -// to match the shortened IDs returned by docker. -func ContainerShortID(containerID string) string { - return containerID[0:12] -} - // quoteArgs will add quotes around any arguments require it for the shell. func QuoteArgs(args []string) []string { quotedArgs := []string{} diff --git a/integration-tests/pkg/executor/executor.go b/integration-tests/pkg/executor/executor.go index 01a50ab23d..31462f3cfb 100644 --- a/integration-tests/pkg/executor/executor.go +++ b/integration-tests/pkg/executor/executor.go @@ -6,8 +6,23 @@ import ( "github.com/stackrox/collector/integration-tests/pkg/config" ) +// ContainerID is an identifier for a container. It can +// be a container name *OR* a hex ID +type ContainerID string + +// Long returns the whole containerID as a string +func (c ContainerID) Long() string { + return string(c) +} + +// Short returns the first twelve character of a containerID +// to match the shortened IDs returned by docker. +func (c ContainerID) Short() string { + return string(c)[:12] +} + type ContainerFilter struct { - Name string + Id ContainerID Namespace string } @@ -32,20 +47,20 @@ func (l *ContainerLogs) GetSingleLog() string { type Executor interface { PullImage(image string) error - IsContainerRunning(container string) (bool, error) + IsContainerRunning(container ContainerID) (bool, error) ContainerExists(filter ContainerFilter) (bool, error) ExitCode(filter ContainerFilter) (int, error) - ExecContainer(containerName string, command []string) (string, error) - KillContainer(name string) (string, error) + ExecContainer(container ContainerID, command []string) (string, error) + KillContainer(container ContainerID) (string, error) RemoveContainer(filter ContainerFilter) (string, error) - StopContainer(name string) (string, error) - StartContainer(config config.ContainerStartConfig) (string, error) - GetContainerHealthCheck(containerID string) (string, error) - GetContainerIP(containerID string) (string, error) - GetContainerLogs(containerID string) (ContainerLogs, error) - CaptureLogs(testName, containerName string) (string, error) - GetContainerPort(containerID string) (string, error) - IsContainerFoundFiltered(containerID, filter string) (bool, error) + StopContainer(container ContainerID) (string, error) + StartContainer(config config.ContainerStartConfig) (ContainerID, error) + GetContainerHealthCheck(container ContainerID) (string, error) + GetContainerIP(container ContainerID) (string, error) + GetContainerLogs(container ContainerID) (ContainerLogs, error) + CaptureLogs(testName string, container ContainerID) (string, error) + GetContainerPort(container ContainerID) (string, error) + IsContainerFoundFiltered(container ContainerID, filter string) (bool, error) } type CommandBuilder interface { diff --git a/integration-tests/pkg/executor/executor_docker_api.go b/integration-tests/pkg/executor/executor_docker_api.go index 2e3d799f93..6998568e37 100644 --- a/integration-tests/pkg/executor/executor_docker_api.go +++ b/integration-tests/pkg/executor/executor_docker_api.go @@ -48,7 +48,7 @@ func convertMapToSlice(env map[string]string) []string { return result } -func (d *dockerAPIExecutor) IsContainerFoundFiltered(containerID, filter string) (bool, error) { +func (d *dockerAPIExecutor) IsContainerFoundFiltered(containerID ContainerID, filter string) (bool, error) { parts := strings.SplitN(filter, "=", 2) if len(parts) != 2 { return false, fmt.Errorf("filter format is invalid") @@ -57,7 +57,7 @@ func (d *dockerAPIExecutor) IsContainerFoundFiltered(containerID, filter string) filterArgs := filters.NewArgs() filterArgs.Add(filterKey, filterValue) if containerID != "" { - filterArgs.Add("id", containerID) + filterArgs.Add("id", containerID.Long()) } containers, err := d.client.ContainerList(context.Background(), container.ListOptions{ @@ -70,15 +70,15 @@ func (d *dockerAPIExecutor) IsContainerFoundFiltered(containerID, filter string) found := false for _, c := range containers { - if common.ContainerShortID(containerID) == common.ContainerShortID(c.ID) { + if containerID.Short() == ContainerID(c.ID).Short() { found = true } } - log.Debug("checked %s for filter %s (%t)\n", common.ContainerShortID(containerID), filter, found) + log.Debug("checked %s for filter %s (%t)\n", containerID.Short(), filter, found) return found, nil } -func (d *dockerAPIExecutor) GetContainerHealthCheck(containerID string) (string, error) { +func (d *dockerAPIExecutor) GetContainerHealthCheck(containerID ContainerID) (string, error) { inspectResp, err := d.inspectContainer(containerID) if err != nil { return "", fmt.Errorf("error inspecting container: %w", err) @@ -91,7 +91,7 @@ func (d *dockerAPIExecutor) GetContainerHealthCheck(containerID string) (string, return strings.Join(inspectResp.Config.Healthcheck.Test, " "), nil } -func (d *dockerAPIExecutor) StartContainer(startConfig config.ContainerStartConfig) (string, error) { +func (d *dockerAPIExecutor) StartContainer(startConfig config.ContainerStartConfig) (ContainerID, error) { ctx := context.Background() var binds []string volumes := map[string]struct{}{} @@ -152,12 +152,12 @@ func (d *dockerAPIExecutor) StartContainer(startConfig config.ContainerStartConf return "", err } - log.Info("start %s with %s (%s)\n", - startConfig.Name, startConfig.Image, common.ContainerShortID(resp.ID)) - return resp.ID, nil + id := ContainerID(resp.ID) + log.Info("start %s with %s (%s)\n", startConfig.Name, startConfig.Image, id) + return id, nil } -func (d *dockerAPIExecutor) ExecContainer(containerName string, command []string) (string, error) { +func (d *dockerAPIExecutor) ExecContainer(containerID ContainerID, command []string) (string, error) { ctx := context.Background() execConfig := types.ExecConfig{ AttachStdout: true, @@ -165,7 +165,7 @@ func (d *dockerAPIExecutor) ExecContainer(containerName string, command []string Cmd: command, } - resp, err := d.client.ContainerExecCreate(ctx, containerName, execConfig) + resp, err := d.client.ContainerExecCreate(ctx, containerID.Long(), execConfig) if err != nil { return "", fmt.Errorf("error creating Exec: %w", err) } @@ -188,14 +188,14 @@ func (d *dockerAPIExecutor) ExecContainer(containerName string, command []string return "", fmt.Errorf("error inspecting Exec: %w", err) } log.Info("exec %s %v (exitCode=%d, outBytes=%d)\n", - containerName, command, execInspect.ExitCode, stdoutBuf.Len()) + containerID, command, execInspect.ExitCode, stdoutBuf.Len()) return stdoutBuf.String(), nil } -func (d *dockerAPIExecutor) GetContainerLogs(containerID string) (ContainerLogs, error) { +func (d *dockerAPIExecutor) GetContainerLogs(containerID ContainerID) (ContainerLogs, error) { timeoutContext, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() - logsReader, err := d.client.ContainerLogs(timeoutContext, containerID, + logsReader, err := d.client.ContainerLogs(timeoutContext, containerID.Long(), container.LogsOptions{ShowStdout: true, ShowStderr: true}) if err != nil { return ContainerLogs{}, fmt.Errorf("error getting container logs: %w", err) @@ -214,11 +214,11 @@ func (d *dockerAPIExecutor) GetContainerLogs(containerID string) (ContainerLogs, }, nil } -func (c *dockerAPIExecutor) CaptureLogs(testName, containerName string) (string, error) { - log.Info("%s: Gathering logs for %q", testName, containerName) - logs, err := c.GetContainerLogs(containerName) +func (c *dockerAPIExecutor) CaptureLogs(testName string, containerID ContainerID) (string, error) { + log.Info("%s: Gathering logs for %q", testName, containerID) + logs, err := c.GetContainerLogs(containerID) if err != nil { - return "", log.Error("logs error (%v) for container %s\n", err, containerName) + return "", log.Error("logs error (%v) for container %s\n", err, containerID) } type logFile = struct { @@ -230,21 +230,21 @@ func (c *dockerAPIExecutor) CaptureLogs(testName, containerName string) (string, if logs.Empty() { // Nothing to log, still we create an empty file for awareness logFiles = []logFile{{ - name: fmt.Sprintf("%s.log", containerName), + name: fmt.Sprintf("%s.log", containerID), }} } else if logs.Stderr == "" || logs.Stdout == "" { // We only have stdout OR stderr to log logFiles = []logFile{{ - name: fmt.Sprintf("%s.log", containerName), + name: fmt.Sprintf("%s.log", containerID), content: logs.GetSingleLog(), }} } else { // We need to log both stdout and stderr, do so on separate files logFiles = []logFile{{ - name: fmt.Sprintf("%s-stderr.log", containerName), + name: fmt.Sprintf("%s-stderr.log", containerID), content: logs.Stderr, }, { - name: fmt.Sprintf("%s-stdout.log", containerName), + name: fmt.Sprintf("%s-stdout.log", containerID), content: logs.Stdout, }} } @@ -262,10 +262,10 @@ func (c *dockerAPIExecutor) CaptureLogs(testName, containerName string) (string, return logFiles[0].content, nil } -func (d *dockerAPIExecutor) KillContainer(containerID string) (string, error) { +func (d *dockerAPIExecutor) KillContainer(containerID ContainerID) (string, error) { timeoutContext, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - err := d.client.ContainerKill(timeoutContext, containerID, "KILL") + err := d.client.ContainerKill(timeoutContext, containerID.Long(), "KILL") if err != nil { return "", fmt.Errorf("error killing container: %w", err) } @@ -273,18 +273,18 @@ func (d *dockerAPIExecutor) KillContainer(containerID string) (string, error) { return "", nil } -func (d *dockerAPIExecutor) StopContainer(name string) (string, error) { +func (d *dockerAPIExecutor) StopContainer(containerID ContainerID) (string, error) { stopOptions := container.StopOptions{ Signal: "SIGTERM", Timeout: nil, // 10 secs } timeoutContext, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - err := d.client.ContainerStop(timeoutContext, name, stopOptions) + err := d.client.ContainerStop(timeoutContext, containerID.Long(), stopOptions) if err != nil { return "", fmt.Errorf("error stopping container: %w", err) } - log.Debug("stop %s\n", name) + log.Debug("stop %s\n", containerID) return "", nil } @@ -296,16 +296,16 @@ func (d *dockerAPIExecutor) RemoveContainer(cf ContainerFilter) (string, error) RemoveVolumes: true, Force: true, } - err := d.client.ContainerRemove(timeoutContext, cf.Name, removeOptions) + err := d.client.ContainerRemove(timeoutContext, cf.Id.Long(), removeOptions) if err != nil { return "", fmt.Errorf("error removing container: %w", err) } - log.Debug("remove %s\n", cf.Name) + log.Debug("remove %s\n", cf.Id) return "", nil } -func (d *dockerAPIExecutor) inspectContainer(containerID string) (types.ContainerJSON, error) { - containerJSON, err := d.client.ContainerInspect(context.Background(), containerID) +func (d *dockerAPIExecutor) inspectContainer(containerID ContainerID) (types.ContainerJSON, error) { + containerJSON, err := d.client.ContainerInspect(context.Background(), containerID.Long()) if err != nil { return types.ContainerJSON{}, fmt.Errorf("error inspecting container: %w", err) } @@ -314,15 +314,15 @@ func (d *dockerAPIExecutor) inspectContainer(containerID string) (types.Containe } func (d *dockerAPIExecutor) ExitCode(cf ContainerFilter) (int, error) { - inspectResp, err := d.inspectContainer(cf.Name) + inspectResp, err := d.inspectContainer(cf.Id) if err != nil { return -1, err } - log.Info("%s exitcode=%s\n", cf.Name, inspectResp.State.ExitCode) + log.Info("%s exitcode=%s\n", cf.Id, inspectResp.State.ExitCode) return inspectResp.State.ExitCode, nil } -func (d *dockerAPIExecutor) GetContainerIP(containerID string) (string, error) { +func (d *dockerAPIExecutor) GetContainerIP(containerID ContainerID) (string, error) { inspectResp, err := d.inspectContainer(containerID) if err != nil { return "", err @@ -332,7 +332,7 @@ func (d *dockerAPIExecutor) GetContainerIP(containerID string) (string, error) { return inspectResp.NetworkSettings.DefaultNetworkSettings.IPAddress, nil } -func (d *dockerAPIExecutor) GetContainerPort(containerID string) (string, error) { +func (d *dockerAPIExecutor) GetContainerPort(containerID ContainerID) (string, error) { containerPort := "-1" containerJSON, err := d.inspectContainer(containerID) if err != nil { @@ -351,7 +351,7 @@ func (d *dockerAPIExecutor) GetContainerPort(containerID string) (string, error) return containerPort, nil } -func (d *dockerAPIExecutor) CheckContainerHealthy(containerID string) (bool, error) { +func (d *dockerAPIExecutor) CheckContainerHealthy(containerID ContainerID) (bool, error) { containerJSON, err := d.inspectContainer(containerID) if err != nil { return false, err @@ -360,7 +360,7 @@ func (d *dockerAPIExecutor) CheckContainerHealthy(containerID string) (bool, err return containerJSON.State.Health.Status == "healthy", nil } -func (d *dockerAPIExecutor) IsContainerRunning(containerID string) (bool, error) { +func (d *dockerAPIExecutor) IsContainerRunning(containerID ContainerID) (bool, error) { containerJSON, err := d.inspectContainer(containerID) if err != nil { return false, err @@ -370,12 +370,12 @@ func (d *dockerAPIExecutor) IsContainerRunning(containerID string) (bool, error) } func (d *dockerAPIExecutor) ContainerExists(cf ContainerFilter) (bool, error) { - _, err := d.inspectContainer(cf.Name) + _, err := d.inspectContainer(cf.Id) if err != nil { - log.Trace("%s does not exist\n", cf.Name) + log.Trace("%s does not exist\n", cf.Id) return false, err } - log.Trace("%s exists\n", cf.Name) + log.Trace("%s exists\n", cf.Id) return true, nil } diff --git a/integration-tests/pkg/executor/executor_k8s.go b/integration-tests/pkg/executor/executor_k8s.go index e6c7b38da4..5c6761c5ac 100644 --- a/integration-tests/pkg/executor/executor_k8s.go +++ b/integration-tests/pkg/executor/executor_k8s.go @@ -56,10 +56,10 @@ func (e *K8sExecutor) IsPodRunning(podName string) (bool, error) { return pod.Status.ContainerStatuses[0].Ready, nil } -func (e *K8sExecutor) PodContainerID(podFilter ContainerFilter) string { - pod, err := e.ClientSet().CoreV1().Pods(podFilter.Namespace).Get(context.Background(), podFilter.Name, metaV1.GetOptions{}) +func (e *K8sExecutor) PodContainerID(podFilter ContainerFilter) ContainerID { + pod, err := e.ClientSet().CoreV1().Pods(podFilter.Namespace).Get(context.Background(), podFilter.Id.Long(), metaV1.GetOptions{}) if err != nil { - log.Error("namespace: %s pod: %s error: %s\n", podFilter.Namespace, podFilter.Name, err) + log.Error("namespace: %s pod: %s error: %s\n", podFilter.Namespace, podFilter.Id.Long(), err) return "" } @@ -71,23 +71,23 @@ func (e *K8sExecutor) PodContainerID(podFilter ContainerFilter) string { * The format extracted from the following line looks something like this: * containerd://01e8c0454972a6b22b2e8ff7bf5a7d011e7dc7c0cde95c468a823b7085669a36 */ - containerID := pod.Status.ContainerStatuses[0].ContainerID - if len(containerID) < 12 { - log.Error("Invalid container ID: %q", containerID) + id := pod.Status.ContainerStatuses[0].ContainerID + if len(id) < 12 { + log.Error("Invalid container ID: %q", id) return "" } - i := strings.LastIndex(containerID, "/") + i := strings.LastIndex(id, "/") if i == -1 { - log.Error("Invalid container ID: %q", containerID) + log.Error("Invalid container ID: %q", id) return "" } - return common.ContainerShortID(containerID[i+1:]) + return ContainerID(id) } func (e *K8sExecutor) PodExists(podFilter ContainerFilter) (bool, error) { - pod, err := e.clientset.CoreV1().Pods(podFilter.Namespace).Get(context.Background(), podFilter.Name, metaV1.GetOptions{}) + pod, err := e.clientset.CoreV1().Pods(podFilter.Namespace).Get(context.Background(), podFilter.Id.Long(), metaV1.GetOptions{}) if err != nil { return false, err } @@ -96,7 +96,7 @@ func (e *K8sExecutor) PodExists(podFilter ContainerFilter) (bool, error) { } func (e *K8sExecutor) ExitCode(podFilter ContainerFilter) (int, error) { - pod, err := e.clientset.CoreV1().Pods(podFilter.Namespace).Get(context.Background(), podFilter.Name, metaV1.GetOptions{}) + pod, err := e.clientset.CoreV1().Pods(podFilter.Namespace).Get(context.Background(), podFilter.Id.Long(), metaV1.GetOptions{}) if err != nil { return -1, err } @@ -114,13 +114,13 @@ func (e *K8sExecutor) ExitCode(podFilter ContainerFilter) (int, error) { } func (e *K8sExecutor) RemovePod(podFilter ContainerFilter) (string, error) { - err := e.clientset.CoreV1().Pods(podFilter.Namespace).Delete(context.Background(), podFilter.Name, metaV1.DeleteOptions{}) + err := e.clientset.CoreV1().Pods(podFilter.Namespace).Delete(context.Background(), podFilter.Id.Long(), metaV1.DeleteOptions{}) return "", err } func (e *K8sExecutor) WaitPodRemoved(podFilter ContainerFilter) error { ctx := context.Background() - opts := metaV1.ListOptions{LabelSelector: "app=" + podFilter.Name} + opts := metaV1.ListOptions{LabelSelector: "app=" + podFilter.Id.Long()} w, err := e.clientset.CoreV1().Pods(podFilter.Namespace).Watch(ctx, opts) if err != nil { return err diff --git a/integration-tests/pkg/mock_sensor/expect_conn.go b/integration-tests/pkg/mock_sensor/expect_conn.go index 9411197f88..0b72a41d1f 100644 --- a/integration-tests/pkg/mock_sensor/expect_conn.go +++ b/integration-tests/pkg/mock_sensor/expect_conn.go @@ -8,6 +8,7 @@ import ( "github.com/thoas/go-funk" collectorAssert "github.com/stackrox/collector/integration-tests/pkg/assert" + "github.com/stackrox/collector/integration-tests/pkg/executor" "github.com/stackrox/collector/integration-tests/pkg/types" ) @@ -15,7 +16,7 @@ import ( // the list of expected Connections. It will first check to see if the connections // have been received already, and then monitor the live feed of connections // until timeout or until all the events have been received. -func (s *MockSensor) ExpectConnections(t *testing.T, containerID string, timeout time.Duration, expected ...types.NetworkInfo) bool { +func (s *MockSensor) ExpectConnections(t *testing.T, containerID executor.ContainerID, timeout time.Duration, expected ...types.NetworkInfo) bool { to_find := funk.Filter(expected, func(x types.NetworkInfo) bool { return !s.HasConnection(containerID, x) @@ -35,7 +36,7 @@ loop: // ElementsMatch we get much better logging about the differences return assert.ElementsMatch(t, expected, s.Connections(containerID), "timed out waiting for network connections") case network := <-s.LiveConnections(): - if network.GetContainerId() != containerID { + if network.GetContainerId() != containerID.Short() { continue loop } @@ -57,7 +58,7 @@ loop: // // It does not consider the content of the events, just that a certain number // have been received -func (s *MockSensor) ExpectConnectionsN(t *testing.T, containerID string, timeout time.Duration, n int) []types.NetworkInfo { +func (s *MockSensor) ExpectConnectionsN(t *testing.T, containerID executor.ContainerID, timeout time.Duration, n int) []types.NetworkInfo { if len(s.Connections(containerID)) == n { return s.Connections(containerID) } @@ -69,7 +70,7 @@ loop: case <-timer: assert.FailNowf(t, "timed out", "found %d connections (expected %d)", len(s.Connections(containerID)), n) case conn := <-s.LiveConnections(): - if conn.GetContainerId() != containerID { + if conn.GetContainerId() != containerID.Short() { continue loop } if len(s.Connections(containerID)) == n { @@ -82,7 +83,7 @@ loop: // ExpectSameElementsConnections compares a list of expected connections to the observed connections. This comparison is done at the beginning, when a new // connection arrives, and after a timeout period. The number of connections must match and the expected and observed connections must match, but the order // does not matter. -func (s *MockSensor) ExpectSameElementsConnections(t *testing.T, containerID string, timeout time.Duration, expected ...types.NetworkInfo) bool { +func (s *MockSensor) ExpectSameElementsConnections(t *testing.T, containerID executor.ContainerID, timeout time.Duration, expected ...types.NetworkInfo) bool { types.SortConnections(expected) equal := func(c1, c2 types.NetworkInfo) bool { @@ -102,7 +103,7 @@ func (s *MockSensor) ExpectSameElementsConnections(t *testing.T, containerID str connections := s.Connections(containerID) return collectorAssert.AssertElementsMatchFunc(t, expected, connections, equal) case conn := <-s.LiveConnections(): - if conn.GetContainerId() != containerID { + if conn.GetContainerId() != containerID.Short() { continue } connections := s.Connections(containerID) @@ -117,7 +118,7 @@ func (s *MockSensor) ExpectSameElementsConnections(t *testing.T, containerID str // the list of expected Endpoints. It will first check to see if the endpoints // have been received already, and then monitor the live feed of endpoints // until timeout or until all the events have been received. -func (s *MockSensor) ExpectEndpoints(t *testing.T, containerID string, timeout time.Duration, expected ...types.EndpointInfo) bool { +func (s *MockSensor) ExpectEndpoints(t *testing.T, containerID executor.ContainerID, timeout time.Duration, expected ...types.EndpointInfo) bool { to_find := funk.Filter(expected, func(x types.EndpointInfo) bool { return !s.HasEndpoint(containerID, x) @@ -137,7 +138,7 @@ loop: // ElementsMatch we get much better logging about the differences return assert.ElementsMatch(t, expected, s.Endpoints(containerID), "timed out waiting for endpoints") case network := <-s.LiveEndpoints(): - if network.GetContainerId() != containerID { + if network.GetContainerId() != containerID.Short() { continue loop } @@ -159,7 +160,7 @@ loop: // // It does not consider the content of the events, just that a certain number // have been received -func (s *MockSensor) ExpectEndpointsN(t *testing.T, containerID string, timeout time.Duration, n int) []types.EndpointInfo { +func (s *MockSensor) ExpectEndpointsN(t *testing.T, containerID executor.ContainerID, timeout time.Duration, n int) []types.EndpointInfo { return s.waitEndpointsN(t, func() { assert.FailNowf(t, "timed out", "found %d endpoints (expected %d)", len(s.Endpoints(containerID)), n) }, containerID, timeout, n) @@ -167,13 +168,13 @@ func (s *MockSensor) ExpectEndpointsN(t *testing.T, containerID string, timeout // WaitEndpointsN is a non-fatal version of ExpectEndpointsN. It waits for a given timeout // until n Endpoints have been receieved. On timeout it returns false. -func (s *MockSensor) WaitEndpointsN(t *testing.T, containerID string, timeout time.Duration, n int) bool { +func (s *MockSensor) WaitEndpointsN(t *testing.T, containerID executor.ContainerID, timeout time.Duration, n int) bool { return len(s.waitEndpointsN(t, func() {}, containerID, timeout, n)) == n } // waitEndpointsN is a helper function for waiting for a set number of endpoints. // the timeoutFn function can be used to control error behaviour on timeout. -func (s *MockSensor) waitEndpointsN(t *testing.T, timeoutFn func(), containerID string, timeout time.Duration, n int) []types.EndpointInfo { +func (s *MockSensor) waitEndpointsN(t *testing.T, timeoutFn func(), containerID executor.ContainerID, timeout time.Duration, n int) []types.EndpointInfo { seen := len(s.Endpoints(containerID)) if seen == n { @@ -190,7 +191,7 @@ loop: timeoutFn() return make([]types.EndpointInfo, 0) case ep := <-s.LiveEndpoints(): - if ep.GetContainerId() != containerID { + if ep.GetContainerId() != containerID.Short() { continue loop } diff --git a/integration-tests/pkg/mock_sensor/expect_proc.go b/integration-tests/pkg/mock_sensor/expect_proc.go index 374f11fd69..e5dd231649 100644 --- a/integration-tests/pkg/mock_sensor/expect_proc.go +++ b/integration-tests/pkg/mock_sensor/expect_proc.go @@ -8,21 +8,22 @@ import ( "github.com/stretchr/testify/assert" "github.com/thoas/go-funk" + "github.com/stackrox/collector/integration-tests/pkg/executor" "github.com/stackrox/collector/integration-tests/pkg/types" ) -func (s *MockSensor) ExpectProcessesN(t *testing.T, containerID string, timeout time.Duration, n int) []types.ProcessInfo { +func (s *MockSensor) ExpectProcessesN(t *testing.T, containerID executor.ContainerID, timeout time.Duration, n int) []types.ProcessInfo { return s.waitProcessesN(func() { assert.FailNowf(t, "timed out", "found %d processes (expected %d)", len(s.Processes(containerID)), n) }, containerID, timeout, n, 0, func() {}) } -func (s *MockSensor) WaitProcessesN(containerID string, timeout time.Duration, n int, tickFn func()) bool { +func (s *MockSensor) WaitProcessesN(containerID executor.ContainerID, timeout time.Duration, n int, tickFn func()) bool { return len(s.waitProcessesN(func() {}, containerID, timeout, n, 0, tickFn)) >= n } func (s *MockSensor) ExpectProcesses( - t *testing.T, containerID string, timeout time.Duration, expected ...types.ProcessInfo) bool { + t *testing.T, containerID executor.ContainerID, timeout time.Duration, expected ...types.ProcessInfo) bool { // might have already seen some of the events to_find := funk.Filter(expected, func(x types.ProcessInfo) bool { @@ -42,7 +43,7 @@ loop: case <-timer: return assert.ElementsMatch(t, expected, s.Processes(containerID), "Not all processes received") case process := <-s.LiveProcesses(): - if process.GetContainerId() != containerID { + if process.GetContainerId() != containerID.Short() { continue loop } @@ -66,7 +67,7 @@ loop: } } -func (s *MockSensor) ExpectLineages(t *testing.T, containerID string, timeout time.Duration, processName string, expected ...types.ProcessLineage) bool { +func (s *MockSensor) ExpectLineages(t *testing.T, containerID executor.ContainerID, timeout time.Duration, processName string, expected ...types.ProcessLineage) bool { to_find := funk.Filter(expected, func(x types.ProcessLineage) bool { return s.HasLineage(containerID, x) }).([]types.ProcessLineage) @@ -110,7 +111,7 @@ func (s *MockSensor) ExpectLineages(t *testing.T, containerID string, timeout ti // of processes func (s *MockSensor) waitProcessesN( timeoutFn func(), - containerID string, + containerID executor.ContainerID, timeout time.Duration, n int, tickSeconds time.Duration, @@ -136,7 +137,7 @@ loop: timeoutFn() return make([]types.ProcessInfo, 0) case proc := <-s.LiveProcesses(): - if proc.GetContainerId() != containerID { + if proc.GetContainerId() != containerID.Short() { continue loop } diff --git a/integration-tests/pkg/mock_sensor/server.go b/integration-tests/pkg/mock_sensor/server.go index f8e1e66be3..26f03f075e 100644 --- a/integration-tests/pkg/mock_sensor/server.go +++ b/integration-tests/pkg/mock_sensor/server.go @@ -18,6 +18,7 @@ import ( "google.golang.org/grpc/keepalive" "github.com/stackrox/collector/integration-tests/pkg/common" + "github.com/stackrox/collector/integration-tests/pkg/executor" "github.com/stackrox/collector/integration-tests/pkg/types" ) @@ -78,11 +79,11 @@ func (m *MockSensor) LiveProcesses() <-chan *storage.ProcessSignal { // Processes returns a list of all processes that have been receieved for // a given container ID -func (m *MockSensor) Processes(containerID string) []types.ProcessInfo { +func (m *MockSensor) Processes(containerID executor.ContainerID) []types.ProcessInfo { m.processMutex.Lock() defer m.processMutex.Unlock() - if processes, ok := m.processes[containerID]; ok { + if processes, ok := m.processes[containerID.Short()]; ok { keys := make([]types.ProcessInfo, 0, len(processes)) for k := range processes { keys = append(keys, k) @@ -94,11 +95,11 @@ func (m *MockSensor) Processes(containerID string) []types.ProcessInfo { // HasProcess returns whether a given process has been seen for a given // container ID. -func (m *MockSensor) HasProcess(containerID string, process types.ProcessInfo) bool { +func (m *MockSensor) HasProcess(containerID executor.ContainerID, process types.ProcessInfo) bool { m.processMutex.Lock() defer m.processMutex.Unlock() - if processes, ok := m.processes[containerID]; ok { + if processes, ok := m.processes[containerID.Short()]; ok { _, exists := processes[process] return exists } @@ -114,11 +115,11 @@ func (m *MockSensor) LiveLineages() <-chan *storage.ProcessSignal_LineageInfo { // ProcessLineages returns a list of all processes that have been received for // a given container ID -func (m *MockSensor) ProcessLineages(containerID string) []types.ProcessLineage { +func (m *MockSensor) ProcessLineages(containerID executor.ContainerID) []types.ProcessLineage { m.processMutex.Lock() defer m.processMutex.Unlock() - if lineages, ok := m.processLineages[containerID]; ok { + if lineages, ok := m.processLineages[containerID.Short()]; ok { keys := make([]types.ProcessLineage, 0, len(lineages)) for k := range lineages { keys = append(keys, k) @@ -130,11 +131,11 @@ func (m *MockSensor) ProcessLineages(containerID string) []types.ProcessLineage // HasLineage returns whether a given process lineage has been seen for a given // container ID -func (m *MockSensor) HasLineage(containerID string, lineage types.ProcessLineage) bool { +func (m *MockSensor) HasLineage(containerID executor.ContainerID, lineage types.ProcessLineage) bool { m.processMutex.Lock() defer m.processMutex.Unlock() - if lineages, ok := m.processLineages[containerID]; ok { + if lineages, ok := m.processLineages[containerID.Short()]; ok { _, exists := lineages[lineage] return exists } @@ -150,11 +151,11 @@ func (m *MockSensor) LiveConnections() <-chan *sensorAPI.NetworkConnection { // Connections returns a list of all connections that have been received for // a given container ID -func (m *MockSensor) Connections(containerID string) []types.NetworkInfo { +func (m *MockSensor) Connections(containerID executor.ContainerID) []types.NetworkInfo { m.networkMutex.Lock() defer m.networkMutex.Unlock() - if connections, ok := m.connections[containerID]; ok { + if connections, ok := m.connections[containerID.Short()]; ok { conns := make([]types.NetworkInfo, len(connections)) copy(conns, connections) types.SortConnections(conns) @@ -165,11 +166,11 @@ func (m *MockSensor) Connections(containerID string) []types.NetworkInfo { // HasConnection returns whether a given connection has been seen for a given // container ID -func (m *MockSensor) HasConnection(containerID string, conn types.NetworkInfo) bool { +func (m *MockSensor) HasConnection(containerID executor.ContainerID, conn types.NetworkInfo) bool { m.networkMutex.Lock() defer m.networkMutex.Unlock() - if conns, ok := m.connections[containerID]; ok { + if conns, ok := m.connections[containerID.Short()]; ok { return slices.ContainsFunc(conns, func(c types.NetworkInfo) bool { return c.Equal(conn) }) @@ -186,11 +187,11 @@ func (m *MockSensor) LiveEndpoints() <-chan *sensorAPI.NetworkEndpoint { // Endpoints returns a list of all endpoints that have been received for // a given container ID -func (m *MockSensor) Endpoints(containerID string) []types.EndpointInfo { +func (m *MockSensor) Endpoints(containerID executor.ContainerID) []types.EndpointInfo { m.networkMutex.Lock() defer m.networkMutex.Unlock() - if endpoints, ok := m.endpoints[containerID]; ok { + if endpoints, ok := m.endpoints[containerID.Short()]; ok { keys := make([]types.EndpointInfo, 0, len(endpoints)) for k := range endpoints { keys = append(keys, k) @@ -202,11 +203,11 @@ func (m *MockSensor) Endpoints(containerID string) []types.EndpointInfo { // HasEndpoint returns whether a given endpoint has been seen for a given // container ID -func (m *MockSensor) HasEndpoint(containerID string, endpoint types.EndpointInfo) bool { +func (m *MockSensor) HasEndpoint(containerID executor.ContainerID, endpoint types.EndpointInfo) bool { m.networkMutex.Lock() defer m.networkMutex.Unlock() - if endpoints, ok := m.endpoints[containerID]; ok { + if endpoints, ok := m.endpoints[containerID.Short()]; ok { for ep := range endpoints { if ep.Equal(endpoint) { return true diff --git a/integration-tests/suites/async_connections.go b/integration-tests/suites/async_connections.go index 26032b4445..f7ed7eb421 100644 --- a/integration-tests/suites/async_connections.go +++ b/integration-tests/suites/async_connections.go @@ -10,6 +10,7 @@ import ( "github.com/stackrox/collector/integration-tests/pkg/collector" "github.com/stackrox/collector/integration-tests/pkg/common" "github.com/stackrox/collector/integration-tests/pkg/config" + "github.com/stackrox/collector/integration-tests/pkg/executor" ) type AsyncConnectionTestSuite struct { @@ -18,8 +19,8 @@ type AsyncConnectionTestSuite struct { BlockConnection bool ExpectToSeeTheConnection bool - clientContainer string - serverContainer string + clientContainer executor.ContainerID + serverContainer executor.ContainerID serverIP string } @@ -53,7 +54,7 @@ func (s *AsyncConnectionTestSuite) SetupSuite() { containerID, err := s.Executor().StartContainer(config.ContainerStartConfig{Name: "server", Image: image_store.ImageByKey("nginx")}) s.Require().NoError(err) - s.serverContainer = common.ContainerShortID(containerID) + s.serverContainer = containerID s.serverIP, err = s.getIPAddress("server") s.Require().NoError(err) @@ -73,7 +74,7 @@ func (s *AsyncConnectionTestSuite) SetupSuite() { Command: []string{"curl", "--connect-timeout", "5", fmt.Sprintf("http://%s/", target)}, }) s.Require().NoError(err) - s.clientContainer = common.ContainerShortID(containerID) + s.clientContainer = containerID common.Sleep(10 * time.Second) // give some time to the connection to fail } diff --git a/integration-tests/suites/base.go b/integration-tests/suites/base.go index 32e5afa1ac..7ae685e0cb 100644 --- a/integration-tests/suites/base.go +++ b/integration-tests/suites/base.go @@ -175,7 +175,7 @@ func (s *IntegrationTestSuiteBase) RegisterCleanup(containers ...string) { // StopCollector is safe when collector isn't running, but the container must exist. // This will ensure that logs are still written even when test setup fails - exists, _ := s.Executor().ContainerExists(executor.ContainerFilter{Name: "collector"}) + exists, _ := s.Executor().ContainerExists(executor.ContainerFilter{Id: executor.ContainerID("collector")}) if exists { s.StopCollector() } @@ -311,7 +311,7 @@ func (s *IntegrationTestSuiteBase) AssertProcessInfoEqual(expected, actual types // - filter -- description of the desired status func (s *IntegrationTestSuiteBase) waitForContainerStatus( containerName string, - containerID string, + containerID executor.ContainerID, tickSeconds time.Duration, timeoutThreshold time.Duration, filter string) (bool, error) { @@ -354,9 +354,9 @@ func (s *IntegrationTestSuiteBase) waitForContainerStatus( // certain. func (s *IntegrationTestSuiteBase) findContainerHealthCheck( containerName string, - containerID string) (bool, error) { + containerID executor.ContainerID) (bool, error) { - healthcheck, err := s.Executor().GetContainerHealthCheck(containerName) + healthcheck, err := s.Executor().GetContainerHealthCheck(containerID) if err != nil { return false, err } @@ -372,7 +372,7 @@ func (s *IntegrationTestSuiteBase) findContainerHealthCheck( func (s *IntegrationTestSuiteBase) waitForContainerToBecomeHealthy( containerName string, - containerID string, + containerID executor.ContainerID, tickSeconds time.Duration, timeoutThreshold time.Duration) (bool, error) { @@ -382,7 +382,7 @@ func (s *IntegrationTestSuiteBase) waitForContainerToBecomeHealthy( func (s *IntegrationTestSuiteBase) waitForContainerToExit( containerName string, - containerID string, + containerID executor.ContainerID, tickSeconds time.Duration, timeoutThreshold time.Duration) (bool, error) { @@ -391,49 +391,49 @@ func (s *IntegrationTestSuiteBase) waitForContainerToExit( } func (s *IntegrationTestSuiteBase) execContainer(containerName string, command []string) (string, error) { - return s.Executor().ExecContainer(containerName, command) + return s.Executor().ExecContainer(executor.ContainerID(containerName), command) } func (s *IntegrationTestSuiteBase) execContainerShellScript(containerName string, shell string, script string, args ...string) (string, error) { cmd := []string{shell, "-s"} cmd = append(cmd, args...) - return s.Executor().ExecContainer(containerName, cmd) + return s.Executor().ExecContainer(executor.ContainerID(containerName), cmd) } -func (s *IntegrationTestSuiteBase) cleanupContainers(containers ...string) { +func (s *IntegrationTestSuiteBase) cleanupContainers(containers ...executor.ContainerID) { for _, container := range containers { - exists, _ := s.Executor().ContainerExists(executor.ContainerFilter{Name: container}) + exists, _ := s.Executor().ContainerExists(executor.ContainerFilter{Id: container}) if exists { s.Executor().KillContainer(container) s.Executor().CaptureLogs(s.T().Name(), container) - s.Executor().RemoveContainer(executor.ContainerFilter{Name: container}) + s.Executor().RemoveContainer(executor.ContainerFilter{Id: container}) } } } -func (s *IntegrationTestSuiteBase) stopContainers(containers ...string) { +func (s *IntegrationTestSuiteBase) stopContainers(containers ...executor.ContainerID) { for _, container := range containers { s.Executor().StopContainer(container) } } -func (s *IntegrationTestSuiteBase) removeContainers(containers ...string) { +func (s *IntegrationTestSuiteBase) removeContainers(containers ...executor.ContainerID) { for _, container := range containers { - s.Executor().RemoveContainer(executor.ContainerFilter{Name: container}) + s.Executor().RemoveContainer(executor.ContainerFilter{Id: container}) } } -func (s *IntegrationTestSuiteBase) containerLogs(containerName string) (executor.ContainerLogs, error) { - return s.Executor().GetContainerLogs(containerName) +func (s *IntegrationTestSuiteBase) containerLogs(container executor.ContainerID) (executor.ContainerLogs, error) { + return s.Executor().GetContainerLogs(container) } -func (s *IntegrationTestSuiteBase) getIPAddress(containerName string) (string, error) { - return s.Executor().GetContainerIP(containerName) +func (s *IntegrationTestSuiteBase) getIPAddress(container executor.ContainerID) (string, error) { + return s.Executor().GetContainerIP(container) } -func (s *IntegrationTestSuiteBase) getPort(containerName string) (string, error) { - return s.Executor().GetContainerPort(containerName) +func (s *IntegrationTestSuiteBase) getPort(container executor.ContainerID) (string, error) { + return s.Executor().GetContainerPort(container) } func (s *IntegrationTestSuiteBase) StartContainerStats() { diff --git a/integration-tests/suites/benchmark.go b/integration-tests/suites/benchmark.go index 2c06a5713a..4006d24fec 100644 --- a/integration-tests/suites/benchmark.go +++ b/integration-tests/suites/benchmark.go @@ -12,6 +12,7 @@ import ( "github.com/stackrox/collector/integration-tests/pkg/common" "github.com/stackrox/collector/integration-tests/pkg/config" + "github.com/stackrox/collector/integration-tests/pkg/executor" ) type BenchmarkBaselineTestSuite struct { @@ -25,8 +26,8 @@ type BenchmarkCollectorTestSuite struct { type BenchmarkTestSuiteBase struct { IntegrationTestSuiteBase - perfContainers []string - loadContainers []string + perfContainers []executor.ContainerID + loadContainers []executor.ContainerID } func (b *BenchmarkTestSuiteBase) StartPerfTools() { @@ -148,7 +149,7 @@ func (s *BenchmarkCollectorTestSuite) SetupSuite() { s.StartCollector(false, nil) } -func (s *BenchmarkTestSuiteBase) SpinBerserker(workload string) (string, error) { +func (s *BenchmarkTestSuiteBase) SpinBerserker(workload string) (executor.ContainerID, error) { benchmarkImage := config.Images().QaImageByKey("performance-berserker") err := s.Executor().PullImage(benchmarkImage) if err != nil { diff --git a/integration-tests/suites/connections_and_endpoints.go b/integration-tests/suites/connections_and_endpoints.go index ddbd096387..db10ed57e3 100644 --- a/integration-tests/suites/connections_and_endpoints.go +++ b/integration-tests/suites/connections_and_endpoints.go @@ -8,6 +8,7 @@ import ( "github.com/stackrox/collector/integration-tests/pkg/collector" "github.com/stackrox/collector/integration-tests/pkg/common" "github.com/stackrox/collector/integration-tests/pkg/config" + "github.com/stackrox/collector/integration-tests/pkg/executor" "github.com/stackrox/collector/integration-tests/pkg/log" "github.com/stackrox/collector/integration-tests/pkg/types" "github.com/stretchr/testify/assert" @@ -16,7 +17,7 @@ import ( type Container struct { Name string Cmd string - ContainerID string + ContainerID executor.ContainerID IP string ExpectedNetwork []types.NetworkInfo ExpectedEndpoints []types.EndpointInfo @@ -51,23 +52,23 @@ func (s *ConnectionsAndEndpointsTestSuite) SetupSuite() { serverName := s.Server.Name clientName := s.Client.Name - longContainerID, err := s.Executor().StartContainer( + containerID, err := s.Executor().StartContainer( config.ContainerStartConfig{Name: serverName, Entrypoint: []string{"/bin/sh"}, Image: socatImage, Command: []string{"-c", "/bin/sleep 300"}, }) s.Require().NoError(err) - s.Server.ContainerID = common.ContainerShortID(longContainerID) + s.Server.ContainerID = containerID - longContainerID, err = s.Executor().StartContainer( + containerID, err = s.Executor().StartContainer( config.ContainerStartConfig{Name: clientName, Entrypoint: []string{"/bin/sh"}, Image: socatImage, Command: []string{"-c", "/bin/sleep 300"}, }) s.Require().NoError(err) - s.Client.ContainerID = common.ContainerShortID(longContainerID) + s.Client.ContainerID = containerID s.Server.IP, err = s.getIPAddress(serverName) s.Require().NoError(err) @@ -88,7 +89,7 @@ func (s *ConnectionsAndEndpointsTestSuite) SetupSuite() { func (s *ConnectionsAndEndpointsTestSuite) TearDownSuite() { s.StopCollector() - s.cleanupContainers(s.Server.Name, s.Client.Name) + s.cleanupContainers(s.Server.ContainerID, s.Client.ContainerID) s.WritePerfResults() } diff --git a/integration-tests/suites/k8s/namespace.go b/integration-tests/suites/k8s/namespace.go index 5b94df3a5e..a8cf227cf0 100644 --- a/integration-tests/suites/k8s/namespace.go +++ b/integration-tests/suites/k8s/namespace.go @@ -13,7 +13,7 @@ import ( ) type NamespaceTest struct { - containerID string + containerID executor.ContainerID expectecNamespace string } @@ -85,7 +85,7 @@ func (k *K8sNamespaceTestSuite) TestK8sNamespace() { } } -func (k *K8sNamespaceTestSuite) launchNginxPod() string { +func (k *K8sNamespaceTestSuite) launchNginxPod() executor.ContainerID { pod := &coreV1.Pod{ ObjectMeta: metaV1.ObjectMeta{ Name: "nginx", @@ -106,7 +106,7 @@ func (k *K8sNamespaceTestSuite) launchNginxPod() string { // Wait for nginx pod to start up pf := executor.ContainerFilter{ - Name: "nginx", + Id: executor.ContainerID("nginx"), Namespace: NAMESPACE, } @@ -120,7 +120,7 @@ func (k *K8sNamespaceTestSuite) launchNginxPod() string { func (k *K8sNamespaceTestSuite) teardownNginxPod() { nginxPodFilter := executor.ContainerFilter{ - Name: "nginx", + Id: executor.ContainerID("nginx"), Namespace: NAMESPACE, } exists, _ := k.Executor().PodExists(nginxPodFilter)