From 6308382af9fb3dd36376dd0dd4df2ace3bc427fb Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 10:35:35 +0800 Subject: [PATCH 01/11] Test_imageToImage --- cri/v1alpha1/cri_utils_test.go | 251 +++++++++++++++++++++++++++++++-- 1 file changed, 240 insertions(+), 11 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 01f39c393..81610fe82 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -282,7 +282,7 @@ func Test_makeSandboxPouchConfig(t *testing.T) { want *apitypes.ContainerCreateConfig wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -342,7 +342,7 @@ func Test_toCriSandbox(t *testing.T) { want *runtime.PodSandbox wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -558,7 +558,7 @@ func Test_makeContainerName(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -579,7 +579,7 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { name string args args }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -600,7 +600,7 @@ func Test_applyContainerSecurityContext(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -628,7 +628,7 @@ func TestCriManager_updateCreateConfig(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -653,7 +653,7 @@ func Test_toCriContainer(t *testing.T) { want *runtime.Container wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -680,7 +680,236 @@ func Test_imageToCriImage(t *testing.T) { want *runtime.Image wantErr bool }{ - // TODO: Add test cases. + { + "case1", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "xiaoming", + }, + ID: "1", + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 1024, + }, + }, + &runtime.Image{ + Id: "1", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + Size_: 1024, + Uid: &runtime.Int64Value{Value: 0}, + Username: "xiaoming", + }, + false, + }, + { + "case2", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456", + }, + ID: "1", + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 1024, + }, + }, + &runtime.Image{ + Id: "1", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + Size_: 1024, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case3", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456:dev", + }, + ID: "1", + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 1024, + }, + }, + &runtime.Image{ + Id: "1", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + Size_: 1024, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case4", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456:dev", + }, + ID: "1", + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 1024, + }, + }, + &runtime.Image{ + Id: "1", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + Size_: 1024, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case5", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456:dev", + }, + ID: "1", + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 2048, + }, + }, + &runtime.Image{ + Id: "1", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + Size_: 2048, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case6", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456:dev", + }, + ID: "abc", + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 2048, + }, + }, + &runtime.Image{ + Id: "abc", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"asdlkfej", "vwoeifo"}, + Size_: 2048, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case7", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456:dev", + }, + ID: "abc", + RepoDigests: []string{"1238", "4820940"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 2048, + }, + }, + &runtime.Image{ + Id: "abc", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"1238", "4820940"}, + Size_: 2048, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case8", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "123456:dev", + }, + ID: "abc", + RepoDigests: []string{"1238", "4820940"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: -2048, + }, + }, + &runtime.Image{ + Id: "abc", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"1238", "4820940"}, + Size_: 18446744073709549568, + Uid: &runtime.Int64Value{Value: int64(123456)}, + Username: "", + }, + false, + }, + { + "case9", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "-123456:dev", + }, + ID: "abc", + RepoDigests: []string{"1238", "4820940"}, + RepoTags: []string{"sldkfeio", "civlme"}, + Size: 2048, + }, + }, + &runtime.Image{ + Id: "abc", + RepoTags: []string{"sldkfeio", "civlme"}, + RepoDigests: []string{"1238", "4820940"}, + Size_: 2048, + Uid: &runtime.Int64Value{Value: int64(-123456)}, + Username: "", + }, + false, + }, + { + "case10", + args{ + &apitypes.ImageInfo{ + Config: &apitypes.ContainerConfig{ + User: "", + }, + ID: "abc", + RepoDigests: []string{"1238", "4820940"}, + RepoTags: []string{"xcuvk23", "cuvkwej23095489"}, + Size: 2048, + }, + }, + &runtime.Image{ + Id: "abc", + RepoTags: []string{"xcuvk23", "cuvkwej23095489"}, + RepoDigests: []string{"1238", "4820940"}, + Size_: 2048, + Uid: &runtime.Int64Value{Value: int64(0)}, + Username: "", + }, + false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -711,7 +940,7 @@ func TestCriManager_ensureSandboxImageExists(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -736,7 +965,7 @@ func Test_getUserFromImageUser(t *testing.T) { want *int64 want1 string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -760,7 +989,7 @@ func Test_parseUserFromImageUser(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From cf50f5c24a62ea76b8216a2ed1c9be41a6188d08 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 11:08:15 +0800 Subject: [PATCH 02/11] Test_imageToCriImage --- cri/v1alpha1/cri_utils_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 81610fe82..1d25b058f 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -282,7 +282,7 @@ func Test_makeSandboxPouchConfig(t *testing.T) { want *apitypes.ContainerCreateConfig wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -342,7 +342,7 @@ func Test_toCriSandbox(t *testing.T) { want *runtime.PodSandbox wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -558,7 +558,7 @@ func Test_makeContainerName(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -579,7 +579,7 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { name string args args }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -600,7 +600,7 @@ func Test_applyContainerSecurityContext(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -628,7 +628,7 @@ func TestCriManager_updateCreateConfig(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -653,7 +653,7 @@ func Test_toCriContainer(t *testing.T) { want *runtime.Container wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -940,7 +940,7 @@ func TestCriManager_ensureSandboxImageExists(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -965,7 +965,7 @@ func Test_getUserFromImageUser(t *testing.T) { want *int64 want1 string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -989,7 +989,7 @@ func Test_parseUserFromImageUser(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From d7cd43a01775ab82413551b172fa2b8701a72154 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 11:41:18 +0800 Subject: [PATCH 03/11] Test_imageToCriImage Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 1d25b058f..019ef1c7a 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -896,13 +896,13 @@ func Test_imageToCriImage(t *testing.T) { }, ID: "abc", RepoDigests: []string{"1238", "4820940"}, - RepoTags: []string{"xcuvk23", "cuvkwej23095489"}, + RepoTags: []string{"xcuvk2", "cuvkwej23095489"}, Size: 2048, }, }, &runtime.Image{ Id: "abc", - RepoTags: []string{"xcuvk23", "cuvkwej23095489"}, + RepoTags: []string{"xcuvk2", "cuvkwej23095489"}, RepoDigests: []string{"1238", "4820940"}, Size_: 2048, Uid: &runtime.Int64Value{Value: int64(0)}, From 4f8b062ed7925bf5e95b99943487fe404b1cfad4 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 12:03:55 +0800 Subject: [PATCH 04/11] fix issue1905 Signed-off-by: shanbo.lkw --- apis/opts/portbindings_test.go | 136 ++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/apis/opts/portbindings_test.go b/apis/opts/portbindings_test.go index 2c0fa6f12..f944d9a04 100644 --- a/apis/opts/portbindings_test.go +++ b/apis/opts/portbindings_test.go @@ -17,7 +17,81 @@ func TestParsePortBinding(t *testing.T) { want types.PortMap wantErr bool }{ - // TODO: Add test cases. + + { + name: "normal test", + args: args{ports: []string{"192.168.0.1:8080:1010"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "8080"}, + }, + }), + wantErr: false, + }, + + { + name: "test small ip", + args: args{ports: []string{"0.0.0.0.:8080:1010"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "0.0.0.0", HostPort: "8080"}, + }, + }), + wantErr: false, + }, + + { + name: "test big ip", + args: args{ports: []string{"256.256.256.256:8080:1010"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "256.256.256.256", HostPort: "8080"}, + }, + }), + wantErr: false, + }, + { + name: "test host small port", + args: args{ports: []string{"192.168.0.1:0:1010"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "0"}, + }, + }), + wantErr: false, + }, + { + name: "test host big port", + args: args{ports: []string{"192.168.0.1:65536:1010"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "65535"}, + }, + }), + wantErr: false, + }, + + { + name: "test container small port", + args: args{ports: []string{"192.168.0.1:8080:0"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "0/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "8080"}, + }, + }), + wantErr: false, + }, + + { + name: "test container big port", + args: args{ports: []string{"192.168.0.1:8080:65536"}}, + want: types.PortMap(map[string][]types.PortBinding{ + "65536/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "8080"}, + }, + }), + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -42,7 +116,65 @@ func TestVerifyPortBinding(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + { + name: "test normal port", + args: args{ + types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "8080"}, + }, + }), + }, + wantErr: false, + }, + + { + name: "test small ip", + args: args{ + types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "0.0.0.0", HostPort: "8080"}, + }, + }), + }, + wantErr: false, + }, + + { + name: "test big ip", + args: args{ + types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "65536.65536.65536.65536", HostPort: "8080"}, + }, + }), + }, + wantErr: false, + }, + + { + name: "test small port", + args: args{ + types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "0"}, + }, + }), + }, + wantErr: false, + }, + + { + name: "test big port", + args: args{ + types.PortMap(map[string][]types.PortBinding{ + "1010/tcp": []types.PortBinding{ + types.PortBinding{HostIP: "192.168.0.1", HostPort: "65536"}, + }, + }), + }, + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 3e176fb9d0c4cbef5e3940d7b7de030bf7b6428a Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 12:14:39 +0800 Subject: [PATCH 05/11] issue1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 493 +++++++++++++++++---------------- 1 file changed, 253 insertions(+), 240 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 019ef1c7a..a65b89323 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -282,7 +282,7 @@ func Test_makeSandboxPouchConfig(t *testing.T) { want *apitypes.ContainerCreateConfig wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -342,7 +342,7 @@ func Test_toCriSandbox(t *testing.T) { want *runtime.PodSandbox wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -558,7 +558,7 @@ func Test_makeContainerName(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -570,16 +570,258 @@ func Test_makeContainerName(t *testing.T) { } func Test_modifyContainerNamespaceOptions(t *testing.T) { + type args struct { nsOpts *runtime.NamespaceOption podSandboxID string hostConfig *apitypes.HostConfig } + st := int64(1000) tests := []struct { name string args args }{ - // TODO: Add test cases. + // TODO: Add test cases. + {name: "test1", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{""}, + }, + }, + }, + {name: "test2", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test3", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: true, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test4", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: true, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test5", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: true}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test6", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: true, + HostPid: true, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test7", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: true, + HostIpc: true}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test8", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: true, + HostPid: false, + HostIpc: true}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test9", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: true, + HostPid: true, + HostIpc: true}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test10", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "aaa", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test11", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: true, + Binds: []string{""}, + }, + }, + }, + {name: "test12", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{"aaa"}, + }, + }, + }, + {name: "test13", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{}, + }, + }, + }, + + {name: "test14", + args: args{ + nsOpts: &runtime.NamespaceOption{ + HostNetwork: false, + HostPid: false, + HostIpc: false}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{}, + CapAdd: []string{}, + CapDrop: []string{}, + Cgroup: "", + ConsoleSize: []*int64{}, + ContainerIDFile: "", + DNS: []string{}, + DNSOptions: []string{}, + DNSSearch: []string{}, + EnableLxcfs: false, + ExtraHosts: []string{}, + GroupAdd: []string{}, + InitScript: "", + IpcMode: "", + Isolation: "", + Links: []string{}, + LogConfig: &apitypes.LogConfig{ + LogDriver: "", + LogOpts: map[string]string{"a": "b"}, + }, + NetworkMode: "", + OomScoreAdj: 1, + PidMode: "", + PortBindings: apitypes.PortMap(map[string][]apitypes.PortBinding{ + "101/tcp": []apitypes.PortBinding{ + apitypes.PortBinding{HostIP: "192.168.0.1", HostPort: "8080"}, + }, + }), + Privileged: false, + PublishAllPorts: false, + ReadonlyRootfs: false, + RestartPolicy: &apitypes.RestartPolicy{ + MaximumRetryCount: 1, + Name: "", + }, + Rich: false, + RichMode: "", + Runtime: "", + SecurityOpt: []string{}, + ShmSize: &st, + StorageOpt: map[string]string{"a": "b"}, + Sysctls: map[string]string{"a": "b"}, + Tmpfs: map[string]string{"a": "b"}, + UTSMode: "", + UsernsMode: "", + VolumeDriver: "", + VolumesFrom: []string{}, + Resources: apitypes.Resources{}, + }, + }, + }, + {name: "test15", + args: args{ + nsOpts: &runtime.NamespaceOption{}, + podSandboxID: "", + hostConfig: &apitypes.HostConfig{ + AutoRemove: false, + Binds: []string{""}, + }, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -600,7 +842,7 @@ func Test_applyContainerSecurityContext(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -628,7 +870,7 @@ func TestCriManager_updateCreateConfig(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -653,7 +895,7 @@ func Test_toCriContainer(t *testing.T) { want *runtime.Container wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -680,236 +922,7 @@ func Test_imageToCriImage(t *testing.T) { want *runtime.Image wantErr bool }{ - { - "case1", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "xiaoming", - }, - ID: "1", - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 1024, - }, - }, - &runtime.Image{ - Id: "1", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - Size_: 1024, - Uid: &runtime.Int64Value{Value: 0}, - Username: "xiaoming", - }, - false, - }, - { - "case2", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456", - }, - ID: "1", - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 1024, - }, - }, - &runtime.Image{ - Id: "1", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - Size_: 1024, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case3", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456:dev", - }, - ID: "1", - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 1024, - }, - }, - &runtime.Image{ - Id: "1", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - Size_: 1024, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case4", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456:dev", - }, - ID: "1", - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 1024, - }, - }, - &runtime.Image{ - Id: "1", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - Size_: 1024, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case5", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456:dev", - }, - ID: "1", - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 2048, - }, - }, - &runtime.Image{ - Id: "1", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - Size_: 2048, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case6", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456:dev", - }, - ID: "abc", - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 2048, - }, - }, - &runtime.Image{ - Id: "abc", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"asdlkfej", "vwoeifo"}, - Size_: 2048, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case7", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456:dev", - }, - ID: "abc", - RepoDigests: []string{"1238", "4820940"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 2048, - }, - }, - &runtime.Image{ - Id: "abc", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"1238", "4820940"}, - Size_: 2048, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case8", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "123456:dev", - }, - ID: "abc", - RepoDigests: []string{"1238", "4820940"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: -2048, - }, - }, - &runtime.Image{ - Id: "abc", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"1238", "4820940"}, - Size_: 18446744073709549568, - Uid: &runtime.Int64Value{Value: int64(123456)}, - Username: "", - }, - false, - }, - { - "case9", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "-123456:dev", - }, - ID: "abc", - RepoDigests: []string{"1238", "4820940"}, - RepoTags: []string{"sldkfeio", "civlme"}, - Size: 2048, - }, - }, - &runtime.Image{ - Id: "abc", - RepoTags: []string{"sldkfeio", "civlme"}, - RepoDigests: []string{"1238", "4820940"}, - Size_: 2048, - Uid: &runtime.Int64Value{Value: int64(-123456)}, - Username: "", - }, - false, - }, - { - "case10", - args{ - &apitypes.ImageInfo{ - Config: &apitypes.ContainerConfig{ - User: "", - }, - ID: "abc", - RepoDigests: []string{"1238", "4820940"}, - RepoTags: []string{"xcuvk2", "cuvkwej23095489"}, - Size: 2048, - }, - }, - &runtime.Image{ - Id: "abc", - RepoTags: []string{"xcuvk2", "cuvkwej23095489"}, - RepoDigests: []string{"1238", "4820940"}, - Size_: 2048, - Uid: &runtime.Int64Value{Value: int64(0)}, - Username: "", - }, - false, - }, + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -940,7 +953,7 @@ func TestCriManager_ensureSandboxImageExists(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -965,7 +978,7 @@ func Test_getUserFromImageUser(t *testing.T) { want *int64 want1 string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -989,7 +1002,7 @@ func Test_parseUserFromImageUser(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From fb0a5855229bb59222b84fab0a9a74999f1f70d1 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 12:19:10 +0800 Subject: [PATCH 06/11] fix issue1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 48 ++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index a65b89323..2498b0cc7 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -282,7 +282,7 @@ func Test_makeSandboxPouchConfig(t *testing.T) { want *apitypes.ContainerCreateConfig wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -342,7 +342,7 @@ func Test_toCriSandbox(t *testing.T) { want *runtime.PodSandbox wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -558,7 +558,7 @@ func Test_makeContainerName(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -660,7 +660,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test7", + { + name: "test7", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, @@ -673,7 +674,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test8", + { + name: "test8", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: true, @@ -686,7 +688,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test9", + { + name: "test9", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: true, @@ -699,7 +702,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test10", + { + name: "test10", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, @@ -712,7 +716,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test11", + { + name: "test11", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, @@ -725,7 +730,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test12", + { + name: "test12", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, @@ -738,7 +744,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test13", + { + name: "test13", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, @@ -751,8 +758,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - - {name: "test14", + { + name: "test14", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, @@ -812,7 +819,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test15", + { + name: "test15", args: args{ nsOpts: &runtime.NamespaceOption{}, podSandboxID: "", @@ -842,7 +850,7 @@ func Test_applyContainerSecurityContext(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -870,7 +878,7 @@ func TestCriManager_updateCreateConfig(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -895,7 +903,7 @@ func Test_toCriContainer(t *testing.T) { want *runtime.Container wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -922,7 +930,7 @@ func Test_imageToCriImage(t *testing.T) { want *runtime.Image wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -953,7 +961,7 @@ func TestCriManager_ensureSandboxImageExists(t *testing.T) { args args wantErr bool }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -978,7 +986,7 @@ func Test_getUserFromImageUser(t *testing.T) { want *int64 want1 string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -1002,7 +1010,7 @@ func Test_parseUserFromImageUser(t *testing.T) { args args want string }{ - // TODO: Add test cases. + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 62aa4d76792b9222a63ce74d0b14b21cd04c344e Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 12:26:11 +0800 Subject: [PATCH 07/11] fix issue 1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 60 ++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 2498b0cc7..4fa5f4b2d 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -582,12 +582,14 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { args args }{ // TODO: Add test cases. - {name: "test1", + { + name: "test1", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -595,12 +597,14 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test2", + { + name: "test2", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -608,12 +612,14 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test3", + { + name: "test3", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: true, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -621,12 +627,14 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test4", + { + name: "test4", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: true, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -634,12 +642,14 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test5", + { + name: "test5", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: true}, + HostIpc: true, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -647,12 +657,14 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - {name: "test6", + { + name: "test6", args: args{ nsOpts: &runtime.NamespaceOption{ HostNetwork: true, HostPid: true, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -666,7 +678,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: true, - HostIpc: true}, + HostIpc: true, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -680,7 +693,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: true, HostPid: false, - HostIpc: true}, + HostIpc: true, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -694,7 +708,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: true, HostPid: true, - HostIpc: true}, + HostIpc: true, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -708,7 +723,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "aaa", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -722,7 +738,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: true, @@ -736,7 +753,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -750,7 +768,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, @@ -764,7 +783,8 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { nsOpts: &runtime.NamespaceOption{ HostNetwork: false, HostPid: false, - HostIpc: false}, + HostIpc: false, + }, podSandboxID: "", hostConfig: &apitypes.HostConfig{ AutoRemove: false, From 2eef1ee65f80e24c9e1faeca628f2bc3928e5bf1 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 13:18:55 +0800 Subject: [PATCH 08/11] fix issue 1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 62 ---------------------------------- 1 file changed, 62 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 4fa5f4b2d..42d4920fb 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -777,68 +777,6 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - { - name: "test14", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{}, - CapAdd: []string{}, - CapDrop: []string{}, - Cgroup: "", - ConsoleSize: []*int64{}, - ContainerIDFile: "", - DNS: []string{}, - DNSOptions: []string{}, - DNSSearch: []string{}, - EnableLxcfs: false, - ExtraHosts: []string{}, - GroupAdd: []string{}, - InitScript: "", - IpcMode: "", - Isolation: "", - Links: []string{}, - LogConfig: &apitypes.LogConfig{ - LogDriver: "", - LogOpts: map[string]string{"a": "b"}, - }, - NetworkMode: "", - OomScoreAdj: 1, - PidMode: "", - PortBindings: apitypes.PortMap(map[string][]apitypes.PortBinding{ - "101/tcp": []apitypes.PortBinding{ - apitypes.PortBinding{HostIP: "192.168.0.1", HostPort: "8080"}, - }, - }), - Privileged: false, - PublishAllPorts: false, - ReadonlyRootfs: false, - RestartPolicy: &apitypes.RestartPolicy{ - MaximumRetryCount: 1, - Name: "", - }, - Rich: false, - RichMode: "", - Runtime: "", - SecurityOpt: []string{}, - ShmSize: &st, - StorageOpt: map[string]string{"a": "b"}, - Sysctls: map[string]string{"a": "b"}, - Tmpfs: map[string]string{"a": "b"}, - UTSMode: "", - UsernsMode: "", - VolumeDriver: "", - VolumesFrom: []string{}, - Resources: apitypes.Resources{}, - }, - }, - }, { name: "test15", args: args{ From 364bcd65cb98a93fdb2ab0a73b7804f1dbd2b662 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 13:25:24 +0800 Subject: [PATCH 09/11] fix issue 1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 192 --------------------------------- 1 file changed, 192 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 42d4920fb..f6684babc 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -576,7 +576,6 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { podSandboxID string hostConfig *apitypes.HostConfig } - st := int64(1000) tests := []struct { name string args args @@ -597,197 +596,6 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { }, }, }, - { - name: "test2", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test3", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: true, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test4", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: true, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test5", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: true, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test6", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: true, - HostPid: true, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test7", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: true, - HostIpc: true, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test8", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: true, - HostPid: false, - HostIpc: true, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test9", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: true, - HostPid: true, - HostIpc: true, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test10", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "aaa", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test11", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: true, - Binds: []string{""}, - }, - }, - }, - { - name: "test12", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{"aaa"}, - }, - }, - }, - { - name: "test13", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{}, - }, - }, - }, - { - name: "test15", - args: args{ - nsOpts: &runtime.NamespaceOption{}, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{""}, - }, - }, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From dc7f161f8291abca0c7c028af47a358256eeaf5c Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 13:31:04 +0800 Subject: [PATCH 10/11] fix issue 1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index f6684babc..8645a1794 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -580,7 +580,6 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { name string args args }{ - // TODO: Add test cases. { name: "test1", args: args{ From 783058f5fb1c7914080210933a6898efb6e5fd78 Mon Sep 17 00:00:00 2001 From: "shanbo.lkw" Date: Tue, 31 Jul 2018 13:33:42 +0800 Subject: [PATCH 11/11] fix issue 1911 Signed-off-by: shanbo.lkw --- cri/v1alpha1/cri_utils_test.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/cri/v1alpha1/cri_utils_test.go b/cri/v1alpha1/cri_utils_test.go index 8645a1794..f3ede5931 100644 --- a/cri/v1alpha1/cri_utils_test.go +++ b/cri/v1alpha1/cri_utils_test.go @@ -579,23 +579,7 @@ func Test_modifyContainerNamespaceOptions(t *testing.T) { tests := []struct { name string args args - }{ - { - name: "test1", - args: args{ - nsOpts: &runtime.NamespaceOption{ - HostNetwork: false, - HostPid: false, - HostIpc: false, - }, - podSandboxID: "", - hostConfig: &apitypes.HostConfig{ - AutoRemove: false, - Binds: []string{""}, - }, - }, - }, - } + }{} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { modifyContainerNamespaceOptions(tt.args.nsOpts, tt.args.podSandboxID, tt.args.hostConfig)