Commit 0a8e2e0b authored by Tim Hockin's avatar Tim Hockin

Merge pull request #6235 from yujuhong/defaults_tests

defaults_tests: verify defaults when converting to an API object
parents 903fb42a 7b0e45a5
...@@ -1509,7 +1509,8 @@ type ContainerManifest struct { ...@@ -1509,7 +1509,8 @@ type ContainerManifest struct {
Containers []Container `json:"containers"` Containers []Container `json:"containers"`
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"` RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
// Required: Set DNS policy. // Required: Set DNS policy.
DNSPolicy DNSPolicy `json:"dnsPolicy"` DNSPolicy DNSPolicy `json:"dnsPolicy"`
HostNetwork bool `json:"hostNetwork,omitempty"`
} }
// ContainerManifestList is used to communicate container manifests to kubelet. // ContainerManifestList is used to communicate container manifests to kubelet.
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
) )
...@@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { ...@@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t.Errorf("%v\n %#v", err, obj) t.Errorf("%v\n %#v", err, obj)
return nil return nil
} }
obj2 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object) obj2, err := newer.Codec.Decode(data)
err = current.Codec.DecodeInto(data, obj2)
if err != nil { if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj) t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
return nil return nil
} }
return obj2 obj3 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = newer.Scheme.Convert(obj2, obj3)
if err != nil {
t.Errorf("%v\nSource: %#v", err, obj2)
return nil
}
return obj3
} }
func TestSetDefaultService(t *testing.T) { func TestSetDefaultService(t *testing.T) {
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2" current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
) )
...@@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { ...@@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t.Errorf("%v\n %#v", err, obj) t.Errorf("%v\n %#v", err, obj)
return nil return nil
} }
obj2 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object) obj2, err := newer.Codec.Decode(data)
err = current.Codec.DecodeInto(data, obj2)
if err != nil { if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj) t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
return nil return nil
} }
return obj2 obj3 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = newer.Scheme.Convert(obj2, obj3)
if err != nil {
t.Errorf("%v\nSource: %#v", err, obj2)
return nil
}
return obj3
} }
func TestSetDefaultService(t *testing.T) { func TestSetDefaultService(t *testing.T) {
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3" current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...@@ -31,13 +32,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { ...@@ -31,13 +32,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t.Errorf("%v\n %#v", err, obj) t.Errorf("%v\n %#v", err, obj)
return nil return nil
} }
obj2 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object) obj2, err := newer.Codec.Decode(data)
err = current.Codec.DecodeInto(data, obj2)
if err != nil { if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj) t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
return nil return nil
} }
return obj2 obj3 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = newer.Scheme.Convert(obj2, obj3)
if err != nil {
t.Errorf("%v\nSource: %#v", err, obj2)
return nil
}
return obj3
} }
func TestSetDefaultService(t *testing.T) { func TestSetDefaultService(t *testing.T) {
......
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