Skip to content

Commit

Permalink
Merge pull request #9029 from deads2k/cq-01
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Jun 16, 2016
2 parents 1367253 + 51a1e57 commit 24ae73e
Show file tree
Hide file tree
Showing 20 changed files with 1,050 additions and 65 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/api/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
_ "github.com/openshift/origin/pkg/image/api/install"
_ "github.com/openshift/origin/pkg/oauth/api/install"
_ "github.com/openshift/origin/pkg/project/api/install"
_ "github.com/openshift/origin/pkg/quota/api/install"
_ "github.com/openshift/origin/pkg/route/api/install"
_ "github.com/openshift/origin/pkg/sdn/api/install"
_ "github.com/openshift/origin/pkg/security/api/install"
Expand Down
62 changes: 38 additions & 24 deletions pkg/api/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ import (
image "github.com/openshift/origin/pkg/image/api"
"github.com/openshift/origin/pkg/image/api/docker10"
"github.com/openshift/origin/pkg/image/api/dockerpre012"
quotaapi "github.com/openshift/origin/pkg/quota/api"
quotaapiv1 "github.com/openshift/origin/pkg/quota/api/v1"
route "github.com/openshift/origin/pkg/route/api"
template "github.com/openshift/origin/pkg/template/api"
uservalidation "github.com/openshift/origin/pkg/user/api/validation"

// install all APIs
_ "github.com/openshift/origin/pkg/api/install"
_ "github.com/openshift/origin/pkg/quota/api/install"
_ "k8s.io/kubernetes/pkg/api/install"
)

Expand Down Expand Up @@ -522,36 +525,47 @@ var nonInternalRoundTrippableTypes = sets.NewString("List", "ListOptions")

// TestTypes will try to roundtrip all OpenShift and Kubernetes stable api types
func TestTypes(t *testing.T) {
for kind, reflectType := range kapi.Scheme.KnownTypes(osapi.SchemeGroupVersion) {
if !strings.Contains(reflectType.PkgPath(), "/origin/") && reflectType.PkgPath() != "k8s.io/kubernetes/pkg/api" {
continue
}
if nonInternalRoundTrippableTypes.Has(kind) {
continue
}
// Try a few times, since runTest uses random values.
for i := 0; i < fuzzIters; i++ {
item, err := kapi.Scheme.New(osapi.SchemeGroupVersion.WithKind(kind))
if err != nil {
t.Errorf("Couldn't make a %v? %v", kind, err)
internalVersionToExternalVersions := map[unversioned.GroupVersion][]unversioned.GroupVersion{
osapi.SchemeGroupVersion: {v1.SchemeGroupVersion},
quotaapi.SchemeGroupVersion: {quotaapiv1.SchemeGroupVersion},
}

for internalVersion, externalVersions := range internalVersionToExternalVersions {
for kind, reflectType := range kapi.Scheme.KnownTypes(internalVersion) {
if !strings.Contains(reflectType.PkgPath(), "/origin/") && reflectType.PkgPath() != "k8s.io/kubernetes/pkg/api" {
continue
}
if _, err := meta.TypeAccessor(item); err != nil {
t.Fatalf("%q is not a TypeMeta and cannot be tested - add it to nonRoundTrippableTypes: %v", kind, err)
if nonInternalRoundTrippableTypes.Has(kind) {
continue
}
seed := rand.Int63()

if versions, ok := skipStandardVersions[kind]; ok {
for _, v := range versions {
t.Logf("About to test %v with %q", kind, v)
fuzzInternalObject(t, v, item, seed)
roundTrip(t, kapi.Codecs.LegacyCodec(v), item)
for _, externalVersion := range externalVersions {
// Try a few times, since runTest uses random values.
for i := 0; i < fuzzIters; i++ {
item, err := kapi.Scheme.New(internalVersion.WithKind(kind))
if err != nil {
t.Errorf("Couldn't make a %v? %v", kind, err)
continue
}
if _, err := meta.TypeAccessor(item); err != nil {
t.Fatalf("%q is not a TypeMeta and cannot be tested - add it to nonRoundTrippableTypes: %v", kind, err)
}
seed := rand.Int63()

if versions, ok := skipStandardVersions[kind]; ok {
for _, v := range versions {
t.Logf("About to test %v with %q", kind, v)
fuzzInternalObject(t, v, item, seed)
roundTrip(t, kapi.Codecs.LegacyCodec(v), item)
}
continue
}
t.Logf(`About to test %v with "v1"`, kind)
fuzzInternalObject(t, externalVersion, item, seed)
roundTrip(t, kapi.Codecs.LegacyCodec(externalVersion), item)
}
continue
}
t.Logf(`About to test %v with "v1"`, kind)
fuzzInternalObject(t, v1.SchemeGroupVersion, item, seed)
roundTrip(t, kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), item)
}

}
}
5 changes: 5 additions & 0 deletions pkg/api/validation/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
imagevalidation "github.com/openshift/origin/pkg/image/api/validation"
oauthvalidation "github.com/openshift/origin/pkg/oauth/api/validation"
projectvalidation "github.com/openshift/origin/pkg/project/api/validation"
quotavalidation "github.com/openshift/origin/pkg/quota/api/validation"
routevalidation "github.com/openshift/origin/pkg/route/api/validation"
sdnvalidation "github.com/openshift/origin/pkg/sdn/api/validation"
securityvalidation "github.com/openshift/origin/pkg/security/api/validation"
Expand All @@ -22,6 +23,7 @@ import (
imageapi "github.com/openshift/origin/pkg/image/api"
oauthapi "github.com/openshift/origin/pkg/oauth/api"
projectapi "github.com/openshift/origin/pkg/project/api"
quotaapi "github.com/openshift/origin/pkg/quota/api"
routeapi "github.com/openshift/origin/pkg/route/api"
sdnapi "github.com/openshift/origin/pkg/sdn/api"
securityapi "github.com/openshift/origin/pkg/security/api"
Expand Down Expand Up @@ -94,4 +96,7 @@ func registerAll() {
Validator.MustRegister(&securityapi.PodSecurityPolicySubjectReview{}, securityvalidation.ValidatePodSecurityPolicySubjectReview, nil)
Validator.MustRegister(&securityapi.PodSecurityPolicySelfSubjectReview{}, securityvalidation.ValidatePodSecurityPolicySelfSubjectReview, nil)
Validator.MustRegister(&securityapi.PodSecurityPolicyReview{}, securityvalidation.ValidatePodSecurityPolicyReview, nil)

Validator.MustRegister(&quotaapi.ClusterResourceQuota{}, quotavalidation.ValidateClusterResourceQuota, quotavalidation.ValidateClusterResourceQuotaUpdate)

}
96 changes: 96 additions & 0 deletions pkg/quota/api/deep_copy_generated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// +build !ignore_autogenerated

// This file was autogenerated by deepcopy-gen. Do not edit it manually!

package api

import (
api "k8s.io/kubernetes/pkg/api"
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
conversion "k8s.io/kubernetes/pkg/conversion"
)

func init() {
if err := api.Scheme.AddGeneratedDeepCopyFuncs(
DeepCopy_api_ClusterResourceQuota,
DeepCopy_api_ClusterResourceQuotaList,
DeepCopy_api_ClusterResourceQuotaSpec,
DeepCopy_api_ClusterResourceQuotaStatus,
DeepCopy_api_ResourceQuotasStatusByNamespace,
); err != nil {
// if one of the deep copy functions is malformed, detect it immediately.
panic(err)
}
}

func DeepCopy_api_ClusterResourceQuota(in ClusterResourceQuota, out *ClusterResourceQuota, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := api.DeepCopy_api_ObjectMeta(in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := DeepCopy_api_ClusterResourceQuotaSpec(in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_api_ClusterResourceQuotaStatus(in.Status, &out.Status, c); err != nil {
return err
}
return nil
}

func DeepCopy_api_ClusterResourceQuotaList(in ClusterResourceQuotaList, out *ClusterResourceQuotaList, c *conversion.Cloner) error {
if err := unversioned.DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := unversioned.DeepCopy_unversioned_ListMeta(in.ListMeta, &out.ListMeta, c); err != nil {
return err
}
if in.Items != nil {
in, out := in.Items, &out.Items
*out = make([]ClusterResourceQuota, len(in))
for i := range in {
if err := DeepCopy_api_ClusterResourceQuota(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}

func DeepCopy_api_ClusterResourceQuotaSpec(in ClusterResourceQuotaSpec, out *ClusterResourceQuotaSpec, c *conversion.Cloner) error {
if in.Selector != nil {
in, out := in.Selector, &out.Selector
*out = new(unversioned.LabelSelector)
if err := unversioned.DeepCopy_unversioned_LabelSelector(*in, *out, c); err != nil {
return err
}
} else {
out.Selector = nil
}
if err := api.DeepCopy_api_ResourceQuotaSpec(in.Quota, &out.Quota, c); err != nil {
return err
}
return nil
}

func DeepCopy_api_ClusterResourceQuotaStatus(in ClusterResourceQuotaStatus, out *ClusterResourceQuotaStatus, c *conversion.Cloner) error {
if err := api.DeepCopy_api_ResourceQuotaStatus(in.Total, &out.Total, c); err != nil {
return err
}
if err := DeepCopy_api_ResourceQuotasStatusByNamespace(in.Namespaces, &out.Namespaces, c); err != nil {
return err
}
return nil
}

func DeepCopy_api_ResourceQuotasStatusByNamespace(in ResourceQuotasStatusByNamespace, out *ResourceQuotasStatusByNamespace, c *conversion.Cloner) error {
if newVal, err := c.DeepCopy(in.orderedMap); err != nil {
return err
} else {
out.orderedMap = newVal.(orderedMap)
}
return nil
}
Loading

0 comments on commit 24ae73e

Please sign in to comment.