Skip to content

Commit

Permalink
Merge pull request kubernetes#27184 from kubernetes/revert-25737-sche…
Browse files Browse the repository at this point in the history
…duledjob_test

Revert "ScheduledJob tests"
  • Loading branch information
wojtek-t authored Jun 10, 2016
2 parents 701b6c7 + ba1c8a2 commit 60c1ec8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 69 deletions.
2 changes: 1 addition & 1 deletion hack/test-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
118 changes: 68 additions & 50 deletions pkg/api/testapi/testapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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),
}
}

Expand All @@ -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 &copyOfGroupVersion
}

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 {
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
}

Expand All @@ -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 != "" {
Expand Down Expand Up @@ -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,
}
}
4 changes: 0 additions & 4 deletions pkg/api/testing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 9 additions & 13 deletions pkg/master/master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down

0 comments on commit 60c1ec8

Please sign in to comment.