Skip to content

Commit

Permalink
cri/server: Add userns tests in PodSandboxStatus
Browse files Browse the repository at this point in the history
The cherry-pick has been amended to duplicate the tests in cri/sbserver and
cri/server.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit 06ed897)
  • Loading branch information
rata committed Feb 28, 2024
1 parent 6e809ef commit b57dc9f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/cri/sbserver/sandbox_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func TestPodSandboxStatus(t *testing.T) {
id = "test-id"
ip = "10.10.10.10"
)
idmap := []*runtime.IDMapping{
{
ContainerId: 0,
HostId: 100,
Length: 1,
},
}

additionalIPs := []string{"8.8.8.8", "2001:db8:85a3::8a2e:370:7334"}
createdAt := time.Now()
config := &runtime.PodSandboxConfig{
Expand All @@ -46,6 +54,11 @@ func TestPodSandboxStatus(t *testing.T) {
Network: runtime.NamespaceMode_NODE,
Pid: runtime.NamespaceMode_CONTAINER,
Ipc: runtime.NamespaceMode_POD,
UsernsOptions: &runtime.UserNamespace{
Uids: idmap,
Gids: idmap,
Mode: runtime.NamespaceMode_POD,
},
},
},
},
Expand Down Expand Up @@ -80,6 +93,11 @@ func TestPodSandboxStatus(t *testing.T) {
Network: runtime.NamespaceMode_NODE,
Pid: runtime.NamespaceMode_CONTAINER,
Ipc: runtime.NamespaceMode_POD,
UsernsOptions: &runtime.UserNamespace{
Uids: idmap,
Gids: idmap,
Mode: runtime.NamespaceMode_POD,
},
},
},
},
Expand Down
17 changes: 17 additions & 0 deletions pkg/cri/server/sandbox_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ func TestPodSandboxStatus(t *testing.T) {
id = "test-id"
ip = "10.10.10.10"
)
idmap := []*runtime.IDMapping{
{
ContainerId: 0,
HostId: 100,
Length: 1,
},
}
additionalIPs := []string{"8.8.8.8", "2001:db8:85a3::8a2e:370:7334"}
createdAt := time.Now()
config := &runtime.PodSandboxConfig{
Expand All @@ -46,6 +53,11 @@ func TestPodSandboxStatus(t *testing.T) {
Network: runtime.NamespaceMode_NODE,
Pid: runtime.NamespaceMode_CONTAINER,
Ipc: runtime.NamespaceMode_POD,
UsernsOptions: &runtime.UserNamespace{
Uids: idmap,
Gids: idmap,
Mode: runtime.NamespaceMode_POD,
},
},
},
},
Expand Down Expand Up @@ -80,6 +92,11 @@ func TestPodSandboxStatus(t *testing.T) {
Network: runtime.NamespaceMode_NODE,
Pid: runtime.NamespaceMode_CONTAINER,
Ipc: runtime.NamespaceMode_POD,
UsernsOptions: &runtime.UserNamespace{
Uids: idmap,
Gids: idmap,
Mode: runtime.NamespaceMode_POD,
},
},
},
},
Expand Down

0 comments on commit b57dc9f

Please sign in to comment.