Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-t committed Mar 20, 2015
1 parent 3b367f8 commit 9c4ef28
Showing 1 changed file with 62 additions and 9 deletions.
71 changes: 62 additions & 9 deletions pkg/kubelet/config/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func writeTestFile(t *testing.T, dir, name string, contents string) *os.File {
return file
}

func TestReadManifestFromFile(t *testing.T) {
func TestReadFromFile(t *testing.T) {
hostname, _ := os.Hostname()
hostname = strings.ToLower(hostname)

Expand All @@ -93,7 +93,15 @@ func TestReadManifestFromFile(t *testing.T) {
Namespace: kubelet.NamespaceDefault,
SelfLink: "/api/v1beta2/pods/test-" + hostname + "?namespace=default",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always"}},
},
}),
},
{
Expand All @@ -110,7 +118,15 @@ func TestReadManifestFromFile(t *testing.T) {
Namespace: kubelet.NamespaceDefault,
SelfLink: "/api/v1beta2/pods/12345-" + hostname + "?namespace=default",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always"}},
},
}),
},
{
Expand All @@ -128,7 +144,15 @@ func TestReadManifestFromFile(t *testing.T) {
Namespace: kubelet.NamespaceDefault,
SelfLink: "/api/v1beta2/pods/test-" + hostname + "?namespace=default",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always"}},
},
}),
},
{
Expand All @@ -152,7 +176,15 @@ func TestReadManifestFromFile(t *testing.T) {
Namespace: "mynamespace",
SelfLink: "/api/v1beta2/pods/test-" + hostname + "?namespace=mynamespace",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent"}},
},
}),
},
{
Expand All @@ -174,7 +206,15 @@ func TestReadManifestFromFile(t *testing.T) {
Namespace: kubelet.NamespaceDefault,
SelfLink: "/api/v1beta2/pods/12345-" + hostname + "?namespace=default",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent"}},
},
}),
},
{
Expand All @@ -197,7 +237,15 @@ func TestReadManifestFromFile(t *testing.T) {
Namespace: kubelet.NamespaceDefault,
SelfLink: "/api/v1beta2/pods/test-" + hostname + "?namespace=default",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent"}},
},
}),
},
}
Expand All @@ -212,7 +260,12 @@ func TestReadManifestFromFile(t *testing.T) {
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
if !api.Semantic.DeepDerivative(testCase.expected, update) {
for _, pod := range update.Pods {
if errs := validation.ValidatePod(&pod); len(errs) > 0 {
t.Errorf("%s: Invalid pod %#v, %#v", testCase.desc, pod, errs)
}
}
if !api.Semantic.DeepEqual(testCase.expected, update) {
t.Errorf("%s: Expected %#v, Got %#v", testCase.desc, testCase.expected, update)
}
case <-time.After(time.Second):
Expand Down Expand Up @@ -274,7 +327,7 @@ func TestExtractFromEmptyDir(t *testing.T) {

update := (<-ch).(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource)
if !api.Semantic.DeepDerivative(expected, update) {
if !api.Semantic.DeepEqual(expected, update) {
t.Errorf("Expected %#v, Got %#v", expected, update)
}
}
Expand Down

0 comments on commit 9c4ef28

Please sign in to comment.