Unverified Commit d51962e1 authored by Jess Frazelle's avatar Jess Frazelle Committed by Jess Frazelle

vet fixes

parent 3803fee9
......@@ -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))
}
}
......
......@@ -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.
}
}
......
......@@ -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 {
......
......@@ -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",
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment