From 62ac8198c9ae75aeb2bc32269a0e4309e7966746 Mon Sep 17 00:00:00 2001 From: My-pleasure Date: Thu, 23 Jul 2020 20:12:31 +0800 Subject: [PATCH] fix unstable e2e test Signed-off-by: My-pleasure --- test/e2e-test/appconfig_dependency_test.go | 4 +-- test/e2e-test/suite_test.go | 30 ++++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/test/e2e-test/appconfig_dependency_test.go b/test/e2e-test/appconfig_dependency_test.go index a585eaec..7b010cd1 100644 --- a/test/e2e-test/appconfig_dependency_test.go +++ b/test/e2e-test/appconfig_dependency_test.go @@ -204,7 +204,7 @@ var _ = Describe("Resource Dependency in an ApplicationConfiguration", func() { func() error { return k8sClient.Get(ctx, inFooKey, inFoo) }, - time.Second*15, time.Millisecond*500).Should(BeNil()) + time.Second*60, time.Second*5).Should(BeNil()) By("Verify the appconfig's dependency is satisfied") appconfig = &v1alpha2.ApplicationConfiguration{} logf.Log.Info("Checking on appconfig", "Key", appconfigKey) @@ -213,7 +213,7 @@ var _ = Describe("Resource Dependency in an ApplicationConfiguration", func() { k8sClient.Get(ctx, appconfigKey, appconfig) return appconfig.Status.Dependency.Unsatisfied }, - time.Second*15, time.Millisecond*500).Should(BeNil()) + time.Second*60, time.Second*5).Should(BeNil()) } It("trait depends on another trait", func() { diff --git a/test/e2e-test/suite_test.go b/test/e2e-test/suite_test.go index 13937eba..dc0afddd 100644 --- a/test/e2e-test/suite_test.go +++ b/test/e2e-test/suite_test.go @@ -23,7 +23,7 @@ import ( . "github.com/onsi/gomega" rbac "k8s.io/api/rbac/v1" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -46,7 +46,7 @@ var k8sClient client.Client var scheme = runtime.NewScheme() var manualscalertrait v1alpha2.TraitDefinition var roleBindingName = "oam-role-binding" -var crd v1beta1.CustomResourceDefinition +var crd crdv1.CustomResourceDefinition func TestAPIs(t *testing.T) { RegisterFailHandler(Fail) @@ -63,7 +63,7 @@ var _ = BeforeSuite(func(done Done) { Expect(err).Should(BeNil()) err = core.AddToScheme(scheme) Expect(err).Should(BeNil()) - err = v1beta1.AddToScheme(scheme) + err = crdv1.AddToScheme(scheme) Expect(err).Should(BeNil()) depExample := &unstructured.Unstructured{} depExample.SetGroupVersionKind(schema.GroupVersionKind{ @@ -120,26 +120,40 @@ var _ = BeforeSuite(func(done Done) { Expect(k8sClient.Create(context.Background(), &adminRoleBinding)).Should(BeNil()) By("Created cluster role bind for the test service account") // Create a crd for appconfig dependency test - crd = v1beta1.CustomResourceDefinition{ + crd = crdv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "foo.example.com", Labels: map[string]string{"crd": "dependency"}, }, - Spec: v1beta1.CustomResourceDefinitionSpec{ + Spec: crdv1.CustomResourceDefinitionSpec{ Group: "example.com", - Names: v1beta1.CustomResourceDefinitionNames{ + Names: crdv1.CustomResourceDefinitionNames{ Kind: "Foo", ListKind: "FooList", Plural: "foo", Singular: "foo", }, - Versions: []v1beta1.CustomResourceDefinitionVersion{ + Versions: []crdv1.CustomResourceDefinitionVersion{ { Name: "v1", Served: true, Storage: true, + Schema: &crdv1.CustomResourceValidation{ + OpenAPIV3Schema: &crdv1.JSONSchemaProps{ + Type: "object", + Properties: map[string]crdv1.JSONSchemaProps{ + "status": { + Type: "object", + Properties: map[string]crdv1.JSONSchemaProps{ + "key": {Type: "string"}, + }, + }, + }, + }, + }, }, }, + Scope: crdv1.NamespaceScoped, }, } Expect(k8sClient.Create(context.Background(), &crd)).Should(SatisfyAny(BeNil(), &util.AlreadyExistMatcher{})) @@ -165,7 +179,7 @@ var _ = AfterSuite(func() { } Expect(k8sClient.Delete(context.Background(), &manualscalertrait)).Should(BeNil()) By("Deleted the manual scalertrait definition") - crd = v1beta1.CustomResourceDefinition{ + crd = crdv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "foo.example.com", Labels: map[string]string{"crd": "dependency"},