mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Add Annotations from the deviceplugin to the runtime
This commit is contained in:
@@ -156,6 +156,11 @@ func TestContainerAnnotations(t *testing.T) {
|
||||
restartCount := 5
|
||||
deletionGracePeriod := int64(10)
|
||||
terminationGracePeriod := int64(10)
|
||||
opts := &kubecontainer.RunContainerOptions{
|
||||
Annotations: []kubecontainer.Annotation{
|
||||
{Name: "Foo", Value: "bar"},
|
||||
},
|
||||
}
|
||||
lifecycle := &v1.Lifecycle{
|
||||
// Left PostStart as nil
|
||||
PreStop: &v1.Handler{
|
||||
@@ -216,11 +221,14 @@ func TestContainerAnnotations(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test whether we can get right information from label
|
||||
annotations := newContainerAnnotations(container, pod, restartCount)
|
||||
annotations := newContainerAnnotations(container, pod, restartCount, opts)
|
||||
containerInfo := getContainerInfoFromAnnotations(annotations)
|
||||
if !reflect.DeepEqual(containerInfo, expected) {
|
||||
t.Errorf("expected %v, got %v", expected, containerInfo)
|
||||
}
|
||||
if v, ok := annotations[opts.Annotations[0].Name]; !ok || v != opts.Annotations[0].Value {
|
||||
t.Errorf("expected annotation %s to exist got %v, %v", opts.Annotations[0].Name, ok, v)
|
||||
}
|
||||
|
||||
// Test when DeletionGracePeriodSeconds, TerminationGracePeriodSeconds and Lifecycle are nil,
|
||||
// the information got from annotations should also be nil
|
||||
@@ -232,11 +240,14 @@ func TestContainerAnnotations(t *testing.T) {
|
||||
expected.PreStopHandler = nil
|
||||
// Because container is changed, the Hash should be updated
|
||||
expected.Hash = kubecontainer.HashContainer(container)
|
||||
annotations = newContainerAnnotations(container, pod, restartCount)
|
||||
annotations = newContainerAnnotations(container, pod, restartCount, opts)
|
||||
containerInfo = getContainerInfoFromAnnotations(annotations)
|
||||
if !reflect.DeepEqual(containerInfo, expected) {
|
||||
t.Errorf("expected %v, got %v", expected, containerInfo)
|
||||
}
|
||||
if v, ok := annotations[opts.Annotations[0].Name]; !ok || v != opts.Annotations[0].Value {
|
||||
t.Errorf("expected annotation %s to exist got %v, %v", opts.Annotations[0].Name, ok, v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPodLabels(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user