mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #100424 from yangjunmyfm192085/run-test30
Add test cases of kubelet_pods_test.go.
This commit is contained in:
commit
ba1c42892f
@ -2865,28 +2865,43 @@ func TestGetExec(t *testing.T) {
|
|||||||
)
|
)
|
||||||
var (
|
var (
|
||||||
podFullName = kubecontainer.GetPodFullName(podWithUIDNameNs(podUID, podName, podNamespace))
|
podFullName = kubecontainer.GetPodFullName(podWithUIDNameNs(podUID, podName, podNamespace))
|
||||||
command = []string{"ls"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
testcases := []struct {
|
testcases := []struct {
|
||||||
description string
|
description string
|
||||||
podFullName string
|
podFullName string
|
||||||
container string
|
container string
|
||||||
|
command []string
|
||||||
expectError bool
|
expectError bool
|
||||||
}{{
|
}{{
|
||||||
description: "success case",
|
description: "success case",
|
||||||
podFullName: podFullName,
|
podFullName: podFullName,
|
||||||
container: containerID,
|
container: containerID,
|
||||||
|
command: []string{"ls"},
|
||||||
|
expectError: false,
|
||||||
}, {
|
}, {
|
||||||
description: "no such pod",
|
description: "no such pod",
|
||||||
podFullName: "bar" + podFullName,
|
podFullName: "bar" + podFullName,
|
||||||
container: containerID,
|
container: containerID,
|
||||||
|
command: []string{"ls"},
|
||||||
expectError: true,
|
expectError: true,
|
||||||
}, {
|
}, {
|
||||||
description: "no such container",
|
description: "no such container",
|
||||||
podFullName: podFullName,
|
podFullName: podFullName,
|
||||||
container: "containerBar",
|
container: "containerBar",
|
||||||
|
command: []string{"ls"},
|
||||||
expectError: true,
|
expectError: true,
|
||||||
|
}, {
|
||||||
|
description: "null exec command",
|
||||||
|
podFullName: podFullName,
|
||||||
|
container: containerID,
|
||||||
|
expectError: false,
|
||||||
|
}, {
|
||||||
|
description: "multi exec commands",
|
||||||
|
podFullName: podFullName,
|
||||||
|
container: containerID,
|
||||||
|
command: []string{"bash", "-c", "ls"},
|
||||||
|
expectError: false,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
@ -2911,7 +2926,7 @@ func TestGetExec(t *testing.T) {
|
|||||||
kubelet.containerRuntime = fakeRuntime
|
kubelet.containerRuntime = fakeRuntime
|
||||||
kubelet.streamingRuntime = fakeRuntime
|
kubelet.streamingRuntime = fakeRuntime
|
||||||
|
|
||||||
redirect, err := kubelet.GetExec(tc.podFullName, podUID, tc.container, command, remotecommand.Options{})
|
redirect, err := kubelet.GetExec(tc.podFullName, podUID, tc.container, tc.command, remotecommand.Options{})
|
||||||
if tc.expectError {
|
if tc.expectError {
|
||||||
assert.Error(t, err, description)
|
assert.Error(t, err, description)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user