From ba1c8a2ac552bf3c213948a30a3dc69b42fa4f0c Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Fri, 10 Jun 2016 16:22:04 +0200 Subject: [PATCH] Revert "ScheduledJob tests" --- hack/test-go.sh | 2 +- hack/test-integration.sh | 2 +- pkg/api/testapi/testapi.go | 118 +++++++++++++++++++++---------------- pkg/api/testing/fuzzer.go | 4 -- pkg/master/master_test.go | 22 +++---- 5 files changed, 79 insertions(+), 69 deletions(-) diff --git a/hack/test-go.sh b/hack/test-go.sh index 94c4fa390cc7b..f87b16559e5d4 100755 --- a/hack/test-go.sh +++ b/hack/test-go.sh @@ -58,7 +58,7 @@ KUBE_GOVERALLS_BIN=${KUBE_GOVERALLS_BIN:-} # Lists of API Versions of each groups that should be tested, groups are # separated by comma, lists are separated by semicolon. e.g., # "v1,compute/v1alpha1,experimental/v1alpha2;v1,compute/v2,experimental/v1alpha3" -KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"batch/v1;batch/v2alpha1"} +KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,extensions/v1beta1,federation/v1alpha1;v1,autoscaling/v1,batch/v1,batch/v2alpha1,extensions/v1beta1,apps/v1alpha1,federation/v1alpha1,policy/v1alpha1,rbac.authorization.k8s.io/v1alpha1"} # once we have multiple group supports # Run tests with the standard (registry) etcd prefix. KUBE_TEST_ETCD_PREFIXES=${KUBE_TEST_ETCD_PREFIXES:-"registry"} diff --git a/hack/test-integration.sh b/hack/test-integration.sh index 10c8a8139c931..9f47d1e257a9c 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -29,7 +29,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh" # "v1,compute/v1alpha1,experimental/v1alpha2;v1,compute/v2,experimental/v1alpha3" # TODO: It's going to be: # KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,extensions/v1beta1"} -KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"batch/v1;batch/v2alpha1"} +KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,extensions/v1beta1;v1,autoscaling/v1,batch/v1,apps/v1alpha1,policy/v1alpha1,extensions/v1beta1,rbac.authorization.k8s.io/v1alpha1"} # Give integration tests longer to run # TODO: allow a larger value to be passed in diff --git a/pkg/api/testapi/testapi.go b/pkg/api/testapi/testapi.go index 518dddbfff120..1c6319b7f2955 100644 --- a/pkg/api/testapi/testapi.go +++ b/pkg/api/testapi/testapi.go @@ -65,9 +65,10 @@ var ( ) type TestGroup struct { - externalGroupVersion unversioned.GroupVersion - internalGroupVersion unversioned.GroupVersion - internalTypes map[string]reflect.Type + // the first element in the group is meant to be the preferred version + externalGroupVersions []unversioned.GroupVersion + internalGroupVersion unversioned.GroupVersion + internalTypes map[string]reflect.Type } func init() { @@ -105,26 +106,31 @@ func init() { } internalGroupVersion := unversioned.GroupVersion{Group: groupVersion.Group, Version: runtime.APIVersionInternal} - Groups[groupVersion.Group] = TestGroup{ - externalGroupVersion: groupVersion, - internalGroupVersion: internalGroupVersion, - internalTypes: api.Scheme.KnownTypes(internalGroupVersion), + if group, ok := Groups[groupVersion.Group]; !ok { + Groups[groupVersion.Group] = TestGroup{ + externalGroupVersions: []unversioned.GroupVersion{groupVersion}, + internalGroupVersion: internalGroupVersion, + internalTypes: api.Scheme.KnownTypes(internalGroupVersion), + } + } else { + group.externalGroupVersions = append(group.externalGroupVersions, groupVersion) + Groups[groupVersion.Group] = group } } } if _, ok := Groups[api.GroupName]; !ok { Groups[api.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: api.GroupName, Version: registered.GroupOrDie(api.GroupName).GroupVersion.Version}, - internalGroupVersion: api.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(api.SchemeGroupVersion), + externalGroupVersions: []unversioned.GroupVersion{{Group: api.GroupName, Version: registered.GroupOrDie(api.GroupName).GroupVersion.Version}}, + internalGroupVersion: api.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(api.SchemeGroupVersion), } } if _, ok := Groups[extensions.GroupName]; !ok { Groups[extensions.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: extensions.GroupName, Version: registered.GroupOrDie(extensions.GroupName).GroupVersion.Version}, - internalGroupVersion: extensions.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(extensions.SchemeGroupVersion), + externalGroupVersions: []unversioned.GroupVersion{{Group: extensions.GroupName, Version: registered.GroupOrDie(extensions.GroupName).GroupVersion.Version}}, + internalGroupVersion: extensions.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(extensions.SchemeGroupVersion), } } if _, ok := Groups[autoscaling.GroupName]; !ok { @@ -136,9 +142,9 @@ func init() { internalTypes[k] = t } Groups[autoscaling.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: autoscaling.GroupName, Version: registered.GroupOrDie(autoscaling.GroupName).GroupVersion.Version}, - internalGroupVersion: extensions.SchemeGroupVersion, - internalTypes: internalTypes, + externalGroupVersions: []unversioned.GroupVersion{{Group: autoscaling.GroupName, Version: registered.GroupOrDie(autoscaling.GroupName).GroupVersion.Version}}, + internalGroupVersion: extensions.SchemeGroupVersion, + internalTypes: internalTypes, } } if _, ok := Groups[autoscaling.GroupName+"IntraGroup"]; !ok { @@ -150,44 +156,48 @@ func init() { } } Groups[autoscaling.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: autoscaling.GroupName, Version: registered.GroupOrDie(autoscaling.GroupName).GroupVersion.Version}, - internalGroupVersion: autoscaling.SchemeGroupVersion, - internalTypes: internalTypes, + externalGroupVersions: []unversioned.GroupVersion{{Group: autoscaling.GroupName, Version: registered.GroupOrDie(autoscaling.GroupName).GroupVersion.Version}}, + internalGroupVersion: autoscaling.SchemeGroupVersion, + internalTypes: internalTypes, } } if _, ok := Groups[batch.GroupName]; !ok { + var gvs []unversioned.GroupVersion + for _, gv := range registered.GroupOrDie(batch.GroupName).GroupVersions { + gvs = append(gvs, gv) + } Groups[batch.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: batch.GroupName, Version: registered.GroupOrDie(batch.GroupName).GroupVersion.Version}, - internalGroupVersion: batch.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(batch.SchemeGroupVersion), + externalGroupVersions: gvs, + internalGroupVersion: batch.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(batch.SchemeGroupVersion), } } if _, ok := Groups[apps.GroupName]; !ok { Groups[apps.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: apps.GroupName, Version: registered.GroupOrDie(apps.GroupName).GroupVersion.Version}, - internalGroupVersion: extensions.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(extensions.SchemeGroupVersion), + externalGroupVersions: []unversioned.GroupVersion{{Group: apps.GroupName, Version: registered.GroupOrDie(apps.GroupName).GroupVersion.Version}}, + internalGroupVersion: extensions.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(extensions.SchemeGroupVersion), } } if _, ok := Groups[policy.GroupName]; !ok { Groups[policy.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: policy.GroupName, Version: registered.GroupOrDie(policy.GroupName).GroupVersion.Version}, - internalGroupVersion: policy.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(policy.SchemeGroupVersion), + externalGroupVersions: []unversioned.GroupVersion{{Group: policy.GroupName, Version: registered.GroupOrDie(policy.GroupName).GroupVersion.Version}}, + internalGroupVersion: policy.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(policy.SchemeGroupVersion), } } if _, ok := Groups[federation.GroupName]; !ok { Groups[federation.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: federation.GroupName, Version: registered.GroupOrDie(federation.GroupName).GroupVersion.Version}, - internalGroupVersion: federation.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(federation.SchemeGroupVersion), + externalGroupVersions: []unversioned.GroupVersion{{Group: federation.GroupName, Version: registered.GroupOrDie(federation.GroupName).GroupVersion.Version}}, + internalGroupVersion: federation.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(federation.SchemeGroupVersion), } } if _, ok := Groups[rbac.GroupName]; !ok { Groups[rbac.GroupName] = TestGroup{ - externalGroupVersion: unversioned.GroupVersion{Group: rbac.GroupName, Version: registered.GroupOrDie(rbac.GroupName).GroupVersion.Version}, - internalGroupVersion: rbac.SchemeGroupVersion, - internalTypes: api.Scheme.KnownTypes(rbac.SchemeGroupVersion), + externalGroupVersions: []unversioned.GroupVersion{{Group: rbac.GroupName, Version: registered.GroupOrDie(rbac.GroupName).GroupVersion.Version}}, + internalGroupVersion: rbac.SchemeGroupVersion, + internalTypes: api.Scheme.KnownTypes(rbac.SchemeGroupVersion), } } @@ -206,10 +216,14 @@ func (g TestGroup) ContentConfig() (string, *unversioned.GroupVersion, runtime.C } func (g TestGroup) GroupVersion() *unversioned.GroupVersion { - copyOfGroupVersion := g.externalGroupVersion + copyOfGroupVersion := g.externalGroupVersions[0] return ©OfGroupVersion } +func (g TestGroup) GroupVersions() []unversioned.GroupVersion { + return append([]unversioned.GroupVersion{}, g.externalGroupVersions...) +} + // InternalGroupVersion returns the group,version used to identify the internal // types for this API func (g TestGroup) InternalGroupVersion() unversioned.GroupVersion { @@ -225,9 +239,9 @@ func (g TestGroup) InternalTypes() map[string]reflect.Type { // KUBE_TEST_API_TYPE env var. func (g TestGroup) Codec() runtime.Codec { if serializer.Serializer == nil { - return api.Codecs.LegacyCodec(g.externalGroupVersion) + return api.Codecs.LegacyCodec(g.externalGroupVersions[0]) } - return api.Codecs.CodecForVersions(serializer, api.Codecs.UniversalDeserializer(), []unversioned.GroupVersion{g.externalGroupVersion}, nil) + return api.Codecs.CodecForVersions(serializer, api.Codecs.UniversalDeserializer(), g.externalGroupVersions, nil) } // NegotiatedSerializer returns the negotiated serializer for the server. @@ -245,7 +259,7 @@ func (g TestGroup) StorageCodec() runtime.Codec { s := storageSerializer.Serializer if s == nil { - return api.Codecs.LegacyCodec(g.externalGroupVersion) + return api.Codecs.LegacyCodec(g.externalGroupVersions[0]) } // etcd2 only supports string data - we must wrap any result before returning @@ -255,13 +269,13 @@ func (g TestGroup) StorageCodec() runtime.Codec { } ds := recognizer.NewDecoder(s, api.Codecs.UniversalDeserializer()) - return api.Codecs.CodecForVersions(s, ds, []unversioned.GroupVersion{g.externalGroupVersion}, nil) + return api.Codecs.CodecForVersions(s, ds, g.externalGroupVersions, nil) } // Converter returns the api.Scheme for the API version to test against, as set by the // KUBE_TEST_API env var. func (g TestGroup) Converter() runtime.ObjectConvertor { - interfaces, err := registered.GroupOrDie(g.externalGroupVersion.Group).InterfacesFor(g.externalGroupVersion) + interfaces, err := registered.GroupOrDie(g.externalGroupVersions[0].Group).InterfacesFor(g.externalGroupVersions[0]) if err != nil { panic(err) } @@ -271,7 +285,7 @@ func (g TestGroup) Converter() runtime.ObjectConvertor { // MetadataAccessor returns the MetadataAccessor for the API version to test against, // as set by the KUBE_TEST_API env var. func (g TestGroup) MetadataAccessor() meta.MetadataAccessor { - interfaces, err := registered.GroupOrDie(g.externalGroupVersion.Group).InterfacesFor(g.externalGroupVersion) + interfaces, err := registered.GroupOrDie(g.externalGroupVersions[0].Group).InterfacesFor(g.externalGroupVersions[0]) if err != nil { panic(err) } @@ -282,18 +296,18 @@ func (g TestGroup) MetadataAccessor() meta.MetadataAccessor { // 'resource' should be the resource path, e.g. "pods" for the Pod type. 'name' should be // empty for lists. func (g TestGroup) SelfLink(resource, name string) string { - if g.externalGroupVersion.Group == api.GroupName { + if g.externalGroupVersions[0].Group == api.GroupName { if name == "" { - return fmt.Sprintf("/api/%s/%s", g.externalGroupVersion.Version, resource) + return fmt.Sprintf("/api/%s/%s", g.externalGroupVersions[0].Version, resource) } - return fmt.Sprintf("/api/%s/%s/%s", g.externalGroupVersion.Version, resource, name) + return fmt.Sprintf("/api/%s/%s/%s", g.externalGroupVersions[0].Version, resource, name) } else { // TODO: will need a /apis prefix once we have proper multi-group // support if name == "" { - return fmt.Sprintf("/apis/%s/%s/%s", g.externalGroupVersion.Group, g.externalGroupVersion.Version, resource) + return fmt.Sprintf("/apis/%s/%s/%s", g.externalGroupVersions[0].Group, g.externalGroupVersions[0].Version, resource) } - return fmt.Sprintf("/apis/%s/%s/%s/%s", g.externalGroupVersion.Group, g.externalGroupVersion.Version, resource, name) + return fmt.Sprintf("/apis/%s/%s/%s/%s", g.externalGroupVersions[0].Group, g.externalGroupVersions[0].Version, resource, name) } } @@ -302,12 +316,12 @@ func (g TestGroup) SelfLink(resource, name string) string { // /api/v1/watch/namespaces/foo/pods/pod0 for v1. func (g TestGroup) ResourcePathWithPrefix(prefix, resource, namespace, name string) string { var path string - if g.externalGroupVersion.Group == api.GroupName { - path = "/api/" + g.externalGroupVersion.Version + if g.externalGroupVersions[0].Group == api.GroupName { + path = "/api/" + g.externalGroupVersions[0].Version } else { // TODO: switch back once we have proper multiple group support // path = "/apis/" + g.Group + "/" + Version(group...) - path = "/apis/" + g.externalGroupVersion.Group + "/" + g.externalGroupVersion.Version + path = "/apis/" + g.externalGroupVersions[0].Group + "/" + g.externalGroupVersions[0].Version } if prefix != "" { @@ -377,5 +391,9 @@ func GetCodecForObject(obj runtime.Object) (runtime.Codec, error) { } func NewTestGroup(external, internal unversioned.GroupVersion, internalTypes map[string]reflect.Type) TestGroup { - return TestGroup{external, internal, internalTypes} + return TestGroup{ + externalGroupVersions: []unversioned.GroupVersion{external}, + internalGroupVersion: internal, + internalTypes: internalTypes, + } } diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index dfd15fec3ee26..8e3094ad825d0 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -169,10 +169,6 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source) j.ManualSelector = nil } }, - func(cp *batch.ConcurrencyPolicy, c fuzz.Continue) { - policies := []batch.ConcurrencyPolicy{batch.AllowConcurrent, batch.ForbidConcurrent, batch.ReplaceConcurrent} - *cp = policies[c.Rand.Intn(len(policies))] - }, func(j *api.List, c fuzz.Continue) { c.FuzzNoCustom(j) // fuzz self without calling this function again // TODO: uncomment when round trip starts from a versioned object diff --git a/pkg/master/master_test.go b/pkg/master/master_test.go index 4fece62aed381..57b1b930ca71a 100644 --- a/pkg/master/master_test.go +++ b/pkg/master/master_test.go @@ -430,19 +430,6 @@ func TestDiscoveryAtAPIS(t *testing.T) { Version: testapi.Autoscaling.GroupVersion().Version, }, }, - // batch is using its pkg/apis/batch/ types here since during installation - // both versions get installed and testapi.go currently does not support - // multi-versioned clients - batch.GroupName: { - { - GroupVersion: batchapiv1.SchemeGroupVersion.String(), - Version: batchapiv1.SchemeGroupVersion.Version, - }, - { - GroupVersion: batchapiv2alpha1.SchemeGroupVersion.String(), - Version: batchapiv2alpha1.SchemeGroupVersion.Version, - }, - }, apps.GroupName: { { GroupVersion: testapi.Apps.GroupVersion().String(), @@ -456,6 +443,15 @@ func TestDiscoveryAtAPIS(t *testing.T) { }, }, } + var batchVersions []unversioned.GroupVersionForDiscovery + for _, gv := range testapi.Batch.GroupVersions() { + batchVersions = append(batchVersions, unversioned.GroupVersionForDiscovery{ + GroupVersion: gv.String(), + Version: gv.Version, + }) + } + expectVersions[batch.GroupName] = batchVersions + expectPreferredVersion := map[string]unversioned.GroupVersionForDiscovery{ autoscaling.GroupName: { GroupVersion: registered.GroupOrDie(autoscaling.GroupName).GroupVersion.String(),