[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #135 from My-pleasure/e2e-patch
Browse files Browse the repository at this point in the history
Fix unstable e2e test of dependency engine
  • Loading branch information
hongchaodeng committed Jul 23, 2020
2 parents a3dd782 + 62ac819 commit 977dce0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/e2e-test/appconfig_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() {
Expand Down
30 changes: 22 additions & 8 deletions test/e2e-test/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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{
Expand Down Expand Up @@ -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{}))
Expand All @@ -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"},
Expand Down

0 comments on commit 977dce0

Please sign in to comment.