mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	
				
					committed by
					
						
						Jess Frazelle
					
				
			
			
				
	
			
			
			
						parent
						
							3803fee972
						
					
				
				
					commit
					d51962e1bb
				
			@@ -705,7 +705,7 @@ func TestValidateContainerLogStatus(t *testing.T) {
 | 
				
			|||||||
		podStatus := &api.PodStatus{ContainerStatuses: tc.statuses}
 | 
							podStatus := &api.PodStatus{ContainerStatuses: tc.statuses}
 | 
				
			||||||
		_, err := kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
 | 
							_, err := kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
 | 
				
			||||||
		if !tc.success {
 | 
							if !tc.success {
 | 
				
			||||||
			assert.Error(t, err, "[case %d] error", i)
 | 
								assert.Error(t, err, fmt.Sprintf("[case %d] error", i))
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			assert.NoError(t, err, "[case %d] error", i)
 | 
								assert.NoError(t, err, "[case %d] error", i)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -713,13 +713,13 @@ func TestValidateContainerLogStatus(t *testing.T) {
 | 
				
			|||||||
		previous = true
 | 
							previous = true
 | 
				
			||||||
		_, err = kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
 | 
							_, err = kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
 | 
				
			||||||
		if !tc.pSuccess {
 | 
							if !tc.pSuccess {
 | 
				
			||||||
			assert.Error(t, err, "[case %d] error", i)
 | 
								assert.Error(t, err, fmt.Sprintf("[case %d] error", i))
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			assert.NoError(t, err, "[case %d] error", i)
 | 
								assert.NoError(t, err, "[case %d] error", i)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Access the log of a container that's not in the pod
 | 
							// Access the log of a container that's not in the pod
 | 
				
			||||||
		_, err = kubelet.validateContainerLogStatus("podName", podStatus, "blah", false)
 | 
							_, 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 (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
@@ -73,7 +74,7 @@ func TestValidateProfile(t *testing.T) {
 | 
				
			|||||||
		if test.expectValid {
 | 
							if test.expectValid {
 | 
				
			||||||
			assert.NoError(t, err, "Profile %s should be valid", test.profile)
 | 
								assert.NoError(t, err, "Profile %s should be valid", test.profile)
 | 
				
			||||||
		} else {
 | 
							} 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 {
 | 
							if test.expectValid {
 | 
				
			||||||
			assert.NoError(t, err, "Pod with profile %q should be valid", test.profile)
 | 
								assert.NoError(t, err, "Pod with profile %q should be valid", test.profile)
 | 
				
			||||||
		} else {
 | 
							} 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")
 | 
						assert.NoError(t, v.Validate(pod), "Multi-container pod should validate")
 | 
				
			||||||
	for k, val := range pod.Annotations {
 | 
						for k, val := range pod.Annotations {
 | 
				
			||||||
		pod.Annotations[k] = val + "-bad"
 | 
							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.
 | 
							pod.Annotations[k] = val // Restore.
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,7 @@ func TestValidate(t *testing.T) {
 | 
				
			|||||||
		testDisallowed := func(key string, category string) {
 | 
							testDisallowed := func(key string, category string) {
 | 
				
			||||||
			for _, s := range v.disallowed {
 | 
								for _, s := range v.disallowed {
 | 
				
			||||||
				pod.Annotations = map[string]string{
 | 
									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)
 | 
									errs = strategy.Validate(pod)
 | 
				
			||||||
				if len(errs) == 0 {
 | 
									if len(errs) == 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -382,7 +382,7 @@ func TestMostRequested(t *testing.T) {
 | 
				
			|||||||
			*/
 | 
								*/
 | 
				
			||||||
			pod:          &api.Pod{Spec: noResources},
 | 
								pod:          &api.Pod{Spec: noResources},
 | 
				
			||||||
			nodes:        []*api.Node{makeNode("machine1", 4000, 10000), makeNode("machine2", 4000, 10000)},
 | 
								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",
 | 
								test:         "nothing scheduled, nothing requested",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -399,7 +399,7 @@ func TestMostRequested(t *testing.T) {
 | 
				
			|||||||
			*/
 | 
								*/
 | 
				
			||||||
			pod:          &api.Pod{Spec: cpuAndMemory},
 | 
								pod:          &api.Pod{Spec: cpuAndMemory},
 | 
				
			||||||
			nodes:        []*api.Node{makeNode("machine1", 4000, 10000), makeNode("machine2", 6000, 10000)},
 | 
								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",
 | 
								test:         "nothing scheduled, resources requested, differently sized machines",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -416,7 +416,7 @@ func TestMostRequested(t *testing.T) {
 | 
				
			|||||||
			*/
 | 
								*/
 | 
				
			||||||
			pod:          &api.Pod{Spec: noResources},
 | 
								pod:          &api.Pod{Spec: noResources},
 | 
				
			||||||
			nodes:        []*api.Node{makeNode("machine1", 10000, 20000), makeNode("machine2", 10000, 20000)},
 | 
								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",
 | 
								test:         "no resources requested, pods scheduled with resources",
 | 
				
			||||||
			pods: []*api.Pod{
 | 
								pods: []*api.Pod{
 | 
				
			||||||
				{Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels2}},
 | 
									{Spec: cpuOnly, ObjectMeta: api.ObjectMeta{Labels: labels2}},
 | 
				
			||||||
@@ -439,7 +439,7 @@ func TestMostRequested(t *testing.T) {
 | 
				
			|||||||
			*/
 | 
								*/
 | 
				
			||||||
			pod:          &api.Pod{Spec: cpuAndMemory},
 | 
								pod:          &api.Pod{Spec: cpuAndMemory},
 | 
				
			||||||
			nodes:        []*api.Node{makeNode("machine1", 10000, 20000), makeNode("machine2", 10000, 20000)},
 | 
								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",
 | 
								test:         "resources requested, pods scheduled with resources",
 | 
				
			||||||
			pods: []*api.Pod{
 | 
								pods: []*api.Pod{
 | 
				
			||||||
				{Spec: cpuOnly},
 | 
									{Spec: cpuOnly},
 | 
				
			||||||
@@ -1142,7 +1142,7 @@ func TestNodePreferAvoidPriority(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			nodes:        testNodes,
 | 
								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",
 | 
								test:         "pod managed by ReplicaSet should avoid a node, this node get lowest priority score",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user