Skip to content

Commit aa2c0c0

Browse files
committed
refactor: remove duplicate tests from api package and add missing CRI-O tests
- Remove attributes_test.go, machine_test.go, machinestats_test.go from api package (now in common package) - Add TestGetAllCrioContainers to match TestGetAllDockerContainers - Add TestCrioHealthState (skipped - Docker health checks not supported by CRI-O) - Update sanityCheck to validate container aliases Test coverage is now consistent between Docker and CRI-O: - Docker: api.test (12 tests) + common.test (4 tests) - CRI-O: crio.test (12 tests) + common.test (4 tests) Signed-off-by: Davanum Srinivas <davanum@gmail.com>
1 parent 1e4adf8 commit aa2c0c0

File tree

4 files changed

+47
-162
lines changed

4 files changed

+47
-162
lines changed

integration/tests/api/attributes_test.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

integration/tests/api/machine_test.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

integration/tests/api/machinestats_test.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

integration/tests/crio/crio_test.go

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ func findSubstring(s, substr string) bool {
7272
}
7373

7474
// Sanity check the container by:
75-
// - Checking that the specified ID is associated with this container.
75+
// - Checking that the specified ID is a valid alias for this container.
7676
// - Verifying that stats are not empty.
7777
func sanityCheck(containerID string, containerInfo info.ContainerInfo, t *testing.T) {
78-
// Check that the container has stats
78+
assert.Contains(t, containerInfo.Aliases, containerID, "Alias %q should be in list of aliases %v", containerID, containerInfo.Aliases)
7979
assert.NotEmpty(t, containerInfo.Stats, "Expected container to have stats")
8080
}
8181

@@ -149,6 +149,43 @@ func TestCrioContainerByName(t *testing.T) {
149149
assert.True(t, found, "Container with ID %q should be found in cAdvisor", containerID)
150150
}
151151

152+
// TestGetAllCrioContainers tests that cAdvisor can find multiple CRI-O containers.
153+
func TestGetAllCrioContainers(t *testing.T) {
154+
fm := framework.New(t)
155+
defer fm.Cleanup()
156+
157+
// Start two containers
158+
containerID1 := fm.Crio().RunPause()
159+
containerID2 := fm.Crio().RunPause()
160+
161+
// Wait for both containers to show up
162+
waitForCrioContainer(containerID1, fm)
163+
waitForCrioContainer(containerID2, fm)
164+
165+
// Query all containers via SubcontainersInfo
166+
allInfo, err := fm.Cadvisor().Client().SubcontainersInfo("/", &info.ContainerInfoRequest{
167+
NumStats: 1,
168+
})
169+
require.NoError(t, err)
170+
171+
// Find both containers
172+
var found1, found2 bool
173+
for _, container := range allInfo {
174+
for _, alias := range container.Aliases {
175+
if alias == containerID1 {
176+
sanityCheck(containerID1, container, t)
177+
found1 = true
178+
}
179+
if alias == containerID2 {
180+
sanityCheck(containerID2, container, t)
181+
found2 = true
182+
}
183+
}
184+
}
185+
assert.True(t, found1, "Container %q should be found in cAdvisor", containerID1)
186+
assert.True(t, found2, "Container %q should be found in cAdvisor", containerID2)
187+
}
188+
152189
// TestBasicCrioContainer tests basic container properties.
153190
func TestBasicCrioContainer(t *testing.T) {
154191
fm := framework.New(t)
@@ -422,6 +459,14 @@ func TestCrioContainerDeletionExitCode(t *testing.T) {
422459
}
423460
}
424461

462+
// TestCrioHealthState tests health state reporting for CRI-O containers.
463+
// Docker-style health checks (HEALTHCHECK instruction) are not supported by CRI-O.
464+
// CRI-O containers rely on Kubernetes liveness/readiness probes instead,
465+
// which are managed by the kubelet, not the container runtime.
466+
func TestCrioHealthState(t *testing.T) {
467+
t.Skip("Skipping: Docker-style health checks are not supported by CRI-O (use Kubernetes probes instead)")
468+
}
469+
425470
// TestCrioFilesystemStats tests filesystem statistics collection for CRI-O containers.
426471
func TestCrioFilesystemStats(t *testing.T) {
427472
fm := framework.New(t)

0 commit comments

Comments
 (0)