Merge pull request #6235 from yujuhong/defaults_tests

defaults_tests: verify defaults when converting to an API object
This commit is contained in:
Tim Hockin 2015-03-31 12:13:23 -07:00
commit 0a8e2e0b1b
4 changed files with 29 additions and 10 deletions

View File

@ -1509,7 +1509,8 @@ type ContainerManifest struct {
Containers []Container `json:"containers"`
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
// 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.

View File

@ -20,6 +20,7 @@ import (
"reflect"
"testing"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t.Errorf("%v\n %#v", err, obj)
return nil
}
obj2 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = current.Codec.DecodeInto(data, obj2)
obj2, err := newer.Codec.Decode(data)
if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
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) {

View File

@ -20,6 +20,7 @@ import (
"reflect"
"testing"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t.Errorf("%v\n %#v", err, obj)
return nil
}
obj2 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = current.Codec.DecodeInto(data, obj2)
obj2, err := newer.Codec.Decode(data)
if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
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) {

View File

@ -20,6 +20,7 @@ import (
"reflect"
"testing"
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@ -31,13 +32,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t.Errorf("%v\n %#v", err, obj)
return nil
}
obj2 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
err = current.Codec.DecodeInto(data, obj2)
obj2, err := newer.Codec.Decode(data)
if err != nil {
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
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) {