From d51962e1bb45a54163f3479e47922b6ec5dea3eb Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Mon, 15 Aug 2016 14:02:47 -0700 Subject: [PATCH] vet fixes Signed-off-by: Jess Frazelle --- pkg/kubelet/kubelet_test.go | 6 +++--- pkg/security/apparmor/validate_test.go | 7 ++++--- .../podsecuritypolicy/sysctl/mustmatchpatterns_test.go | 2 +- .../scheduler/algorithm/priorities/priorities_test.go | 10 +++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index d64503f89aa..c9787a885bf 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -705,7 +705,7 @@ func TestValidateContainerLogStatus(t *testing.T) { podStatus := &api.PodStatus{ContainerStatuses: tc.statuses} _, err := kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous) if !tc.success { - assert.Error(t, err, "[case %d] error", i) + assert.Error(t, err, fmt.Sprintf("[case %d] error", i)) } else { assert.NoError(t, err, "[case %d] error", i) } @@ -713,13 +713,13 @@ func TestValidateContainerLogStatus(t *testing.T) { previous = true _, err = kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous) if !tc.pSuccess { - assert.Error(t, err, "[case %d] error", i) + assert.Error(t, err, fmt.Sprintf("[case %d] error", i)) } else { assert.NoError(t, err, "[case %d] error", i) } // Access the log of a container that's not in the pod _, err = kubelet.validateContainerLogStatus("podName", podStatus, "blah", false) - assert.Error(t, err, "[case %d] invalid container name should cause an error", i) + assert.Error(t, err, fmt.Sprintf("[case %d] invalid container name should cause an error", i)) } } diff --git a/pkg/security/apparmor/validate_test.go b/pkg/security/apparmor/validate_test.go index 46536dd20e7..5085b6ab4e8 100644 --- a/pkg/security/apparmor/validate_test.go +++ b/pkg/security/apparmor/validate_test.go @@ -18,6 +18,7 @@ package apparmor import ( "errors" + "fmt" "testing" "k8s.io/kubernetes/pkg/api" @@ -73,7 +74,7 @@ func TestValidateProfile(t *testing.T) { if test.expectValid { assert.NoError(t, err, "Profile %s should be valid", test.profile) } else { - assert.Error(t, err, "Profile %s should not be valid", test.profile) + assert.Error(t, err, fmt.Sprintf("Profile %s should not be valid", test.profile)) } } } @@ -127,7 +128,7 @@ func TestValidateValidHost(t *testing.T) { if test.expectValid { assert.NoError(t, err, "Pod with profile %q should be valid", test.profile) } else { - assert.Error(t, err, "Pod with profile %q should trigger a validation error", test.profile) + assert.Error(t, err, fmt.Sprintf("Pod with profile %q should trigger a validation error", test.profile)) } } @@ -154,7 +155,7 @@ func TestValidateValidHost(t *testing.T) { assert.NoError(t, v.Validate(pod), "Multi-container pod should validate") for k, val := range pod.Annotations { pod.Annotations[k] = val + "-bad" - assert.Error(t, v.Validate(pod), "Multi-container pod with invalid profile %s:%s", k, pod.Annotations[k]) + assert.Error(t, v.Validate(pod), fmt.Sprintf("Multi-container pod with invalid profile %s:%s", k, pod.Annotations[k])) pod.Annotations[k] = val // Restore. } } diff --git a/pkg/security/podsecuritypolicy/sysctl/mustmatchpatterns_test.go b/pkg/security/podsecuritypolicy/sysctl/mustmatchpatterns_test.go index 6716175bc46..6ae87ada9fd 100644 --- a/pkg/security/podsecuritypolicy/sysctl/mustmatchpatterns_test.go +++ b/pkg/security/podsecuritypolicy/sysctl/mustmatchpatterns_test.go @@ -85,7 +85,7 @@ func TestValidate(t *testing.T) { testDisallowed := func(key string, category string) { for _, s := range v.disallowed { pod.Annotations = map[string]string{ - key: api.PodAnnotationsFromSysctls([]api.Sysctl{{s, "dummy"}}), + key: api.PodAnnotationsFromSysctls([]api.Sysctl{{Name: s, Value: "dummy"}}), } errs = strategy.Validate(pod) if len(errs) == 0 { diff --git a/plugin/pkg/scheduler/algorithm/priorities/priorities_test.go b/plugin/pkg/scheduler/algorithm/priorities/priorities_test.go index 7ec0f6f211e..668a044656f 100644 --- a/plugin/pkg/scheduler/algorithm/priorities/priorities_test.go +++ b/plugin/pkg/scheduler/algorithm/priorities/priorities_test.go @@ -382,7 +382,7 @@ func TestMostRequested(t *testing.T) { */ pod: &api.Pod{Spec: noResources}, nodes: []*api.Node{makeNode("machine1", 4000, 10000), makeNode("machine2", 4000, 10000)}, - expectedList: []schedulerapi.HostPriority{{"machine1", 0}, {"machine2", 0}}, + expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 0}, {Host: "machine2", Score: 0}}, test: "nothing scheduled, nothing requested", }, { @@ -399,7 +399,7 @@ func TestMostRequested(t *testing.T) { */ pod: &api.Pod{Spec: cpuAndMemory}, nodes: []*api.Node{makeNode("machine1", 4000, 10000), makeNode("machine2", 6000, 10000)}, - expectedList: []schedulerapi.HostPriority{{"machine1", 6}, {"machine2", 5}}, + expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 6}, {Host: "machine2", Score: 5}}, test: "nothing scheduled, resources requested, differently sized machines", }, { @@ -416,7 +416,7 @@ func TestMostRequested(t *testing.T) { */ pod: &api.Pod{Spec: noResources}, nodes: []*api.Node{makeNode("machine1", 10000, 20000), makeNode("machine2", 10000, 20000)}, - expectedList: []schedulerapi.HostPriority{{"machine1", 3}, {"machine2", 4}}, + expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 3}, {Host: "machine2", Score: 4}}, test: "no resources requested, pods scheduled with resources", pods: []*api.Pod{ {Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels2}}, @@ -439,7 +439,7 @@ func TestMostRequested(t *testing.T) { */ pod: &api.Pod{Spec: cpuAndMemory}, nodes: []*api.Node{makeNode("machine1", 10000, 20000), makeNode("machine2", 10000, 20000)}, - expectedList: []schedulerapi.HostPriority{{"machine1", 4}, {"machine2", 5}}, + expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 4}, {Host: "machine2", Score: 5}}, test: "resources requested, pods scheduled with resources", pods: []*api.Pod{ {Spec: cpuOnly}, @@ -1142,7 +1142,7 @@ func TestNodePreferAvoidPriority(t *testing.T) { }, }, nodes: testNodes, - expectedList: []schedulerapi.HostPriority{{"machine1", 10}, {"machine2", 0}, {"machine3", 10}}, + expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 10}, {Host: "machine2", Score: 0}, {Host: "machine3", Score: 10}}, test: "pod managed by ReplicaSet should avoid a node, this node get lowest priority score", }, }