From 28239d4676c73500efeee6850e8fe7c510793a6a Mon Sep 17 00:00:00 2001 From: akashshinde Date: Mon, 29 Apr 2019 18:26:30 +0530 Subject: [PATCH 1/7] add e2e tests for gitsource and gitsourceanalysis --- test/e2e/gitsource_test.go | 81 +++++++++++++++++++ test/e2e/gitsourceanalysis_test.go | 120 +++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 test/e2e/gitsource_test.go create mode 100644 test/e2e/gitsourceanalysis_test.go diff --git a/test/e2e/gitsource_test.go b/test/e2e/gitsource_test.go new file mode 100644 index 0000000..c95b6bf --- /dev/null +++ b/test/e2e/gitsource_test.go @@ -0,0 +1,81 @@ +package e2e + +import ( + "context" + "fmt" + "os" + "testing" + + framework "github.com/operator-framework/operator-sdk/pkg/test" + "github.com/operator-framework/operator-sdk/pkg/test/e2eutil" + + devconsole "github.com/redhat-developer/devconsole-api/pkg/apis" + devconsoleapi "github.com/redhat-developer/devconsole-api/pkg/apis/devconsole/v1alpha1" + + "github.com/stretchr/testify/require" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// ComponentTest does e2e test as per operator-sdk documentation +// https://github.com/operator-framework/operator-sdk/blob/cc7b175/doc/test-framework/writing-e2e-tests.md +func TestGitsource(t *testing.T) { + var err error + gitSourceList := &devconsoleapi.GitSourceList{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSource", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + } + + err = framework.AddToFrameworkScheme(devconsole.AddToScheme, gitSourceList) + if err != nil { + t.Fatalf("failed to add custom resource scheme to framework: %v", err) + } + + ctx := framework.NewTestCtx(t) + defer ctx.Cleanup() + err = ctx.InitializeClusterResources(&framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to initialize cluster resources") + t.Log("Initialized cluster resources") + + namespace, err := ctx.GetNamespace() + require.NoError(t, err, "failed to get namespace where operator needs to run") + + // get global framework variables + f := framework.Global + t.Log(fmt.Sprintf("namespace: %s", namespace)) + + // wait for component-operator to be ready + err = e2eutil.WaitForOperatorDeployment(t, f.KubeClient, os.Getenv("DEPLOYED_NAMESPACE"), "devconsole-operator", 1, retryInterval, timeout) + require.NoError(t, err, "failed while waiting for operator deployment") + + t.Log("operator is ready and running") + + gs := &devconsoleapi.GitSource{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSource", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "my-git-source-2", + Namespace: namespace, + }, + Spec: devconsoleapi.GitSourceSpec{ + URL: "https://somegit.con/myrepo", + Ref: "master", + }, + } + // use TestCtx's create helper to create the object and add a cleanup function for the new object + err = f.Client.Create(context.TODO(), gs, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to create custom resource of kind `GitSource`") + + t.Run("retrieve component and verify related resources are created", func(t *testing.T) { + outputCR := &devconsoleapi.GitSource{} + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}, outputCR) + require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") + require.Equal(t, "my-git-source-2", outputCR.ObjectMeta.Name) + require.Equal(t, namespace, outputCR.ObjectMeta.Namespace) + }) +} diff --git a/test/e2e/gitsourceanalysis_test.go b/test/e2e/gitsourceanalysis_test.go new file mode 100644 index 0000000..4c425f8 --- /dev/null +++ b/test/e2e/gitsourceanalysis_test.go @@ -0,0 +1,120 @@ +package e2e + +import ( + "context" + "fmt" + "os" + "testing" + + framework "github.com/operator-framework/operator-sdk/pkg/test" + "github.com/operator-framework/operator-sdk/pkg/test/e2eutil" + + devconsole "github.com/redhat-developer/devconsole-api/pkg/apis" + devconsoleapi "github.com/redhat-developer/devconsole-api/pkg/apis/devconsole/v1alpha1" + + "github.com/stretchr/testify/require" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +// ComponentTest does e2e test as per operator-sdk documentation +// https://github.com/operator-framework/operator-sdk/blob/cc7b175/doc/test-framework/writing-e2e-tests.md +func TestGitsourceAnalysis(t *testing.T) { + var err error + gitSourceList := &devconsoleapi.GitSourceList{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSource", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + } + + gitSourceAnalysisList := &devconsoleapi.GitSourceAnalysisList{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSourceAnalysis", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + } + + err = framework.AddToFrameworkScheme(devconsole.AddToScheme, gitSourceList) + if err != nil { + t.Fatalf("failed to add custom resource scheme to framework: %v", err) + } + + err = framework.AddToFrameworkScheme(devconsole.AddToScheme, gitSourceAnalysisList) + if err != nil { + t.Fatalf("failed to add custom resource scheme to framework: %v", err) + } + + ctx := framework.NewTestCtx(t) + defer ctx.Cleanup() + err = ctx.InitializeClusterResources(&framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to initialize cluster resources") + t.Log("Initialized cluster resources") + + namespace, err := ctx.GetNamespace() + require.NoError(t, err, "failed to get namespace where operator needs to run") + + // get global framework variables + f := framework.Global + t.Log(fmt.Sprintf("namespace: %s", namespace)) + + // wait for component-operator to be ready + err = e2eutil.WaitForOperatorDeployment(t, f.KubeClient, os.Getenv("DEPLOYED_NAMESPACE"), "devconsole-operator", 1, retryInterval, timeout) + require.NoError(t, err, "failed while waiting for operator deployment") + + t.Log("operator is ready and running") + + gs := &devconsoleapi.GitSource{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSource", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "my-git-source-analysis", + Namespace: namespace, + }, + Spec: devconsoleapi.GitSourceSpec{ + URL: "https://somegit.con/myrepo", + Ref: "master", + }, + } + + gsa := &devconsoleapi.GitSourceAnalysis{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSourceAnanlysis", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "gitsource-analysis", + Namespace: namespace, + }, + Spec: devconsoleapi.GitSourceAnalysisSpec{ + GitSourceRef: devconsoleapi.GitSourceRef{ + Name: "my-git-source-analysis", + }, + }, + } + + // use TestCtx's create helper to create the object and add a cleanup function for the new object + err = f.Client.Create(context.TODO(), gs, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to create custom resource of kind `GitSource`") + + // use TestCtx's create helper to create the object and add a cleanup function for the new object + err = f.Client.Create(context.TODO(), gsa, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to create custom resource of kind `GitSourceAnalysis`") + + t.Run("retrieve component and verify related resources are created", func(t *testing.T) { + outputCR := &devconsoleapi.GitSource{} + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}, outputCR) + require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") + require.Equal(t, "my-git-source-2", outputCR.ObjectMeta.Name) + require.Equal(t, namespace, outputCR.ObjectMeta.Namespace) + }) + + t.Run("check if gitsourceanalysis has referrence to gitsource", func(t *testing.T) { + outputGsa := &devconsoleapi.GitSourceAnalysis{} + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "gitsource-analysis", Namespace: namespace}, outputGsa) + require.NoError(t, err, "failed to retrieve custom resource of kind `GitSourceAnalysis`") + }) +} From 14365baf385408230ed977261b1a41036b69241e Mon Sep 17 00:00:00 2001 From: akashshinde Date: Tue, 30 Apr 2019 15:15:45 +0530 Subject: [PATCH 2/7] fix gitsourceanalysis test --- test/e2e/gitsourceanalysis_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/gitsourceanalysis_test.go b/test/e2e/gitsourceanalysis_test.go index 4c425f8..8d73f15 100644 --- a/test/e2e/gitsourceanalysis_test.go +++ b/test/e2e/gitsourceanalysis_test.go @@ -71,7 +71,7 @@ func TestGitsourceAnalysis(t *testing.T) { APIVersion: "devconsole.openshift.io/v1alpha1", }, ObjectMeta: metav1.ObjectMeta{ - Name: "my-git-source-analysis", + Name: "my-git-source", Namespace: namespace, }, Spec: devconsoleapi.GitSourceSpec{ @@ -91,7 +91,7 @@ func TestGitsourceAnalysis(t *testing.T) { }, Spec: devconsoleapi.GitSourceAnalysisSpec{ GitSourceRef: devconsoleapi.GitSourceRef{ - Name: "my-git-source-analysis", + Name: "my-git-source", }, }, } @@ -106,9 +106,9 @@ func TestGitsourceAnalysis(t *testing.T) { t.Run("retrieve component and verify related resources are created", func(t *testing.T) { outputCR := &devconsoleapi.GitSource{} - err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}, outputCR) + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source", Namespace: namespace}, outputCR) require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") - require.Equal(t, "my-git-source-2", outputCR.ObjectMeta.Name) + require.Equal(t, "my-git-source", outputCR.ObjectMeta.Name) require.Equal(t, namespace, outputCR.ObjectMeta.Namespace) }) From cabdab072466e5cc75b2979e0ad443268cadf708 Mon Sep 17 00:00:00 2001 From: akashshinde Date: Thu, 2 May 2019 14:27:23 +0530 Subject: [PATCH 3/7] add wait utils and gitsource tests --- test/e2e/e2eutils.go | 26 ++++++++++ test/e2e/gitsource_test.go | 83 +++++++++++++++++++++--------- test/e2e/gitsourceanalysis_test.go | 8 ++- 3 files changed, 93 insertions(+), 24 deletions(-) create mode 100644 test/e2e/e2eutils.go diff --git a/test/e2e/e2eutils.go b/test/e2e/e2eutils.go new file mode 100644 index 0000000..a259f77 --- /dev/null +++ b/test/e2e/e2eutils.go @@ -0,0 +1,26 @@ +package e2e + +import ( + goctx "context" + "time" + + "github.com/operator-framework/operator-sdk/pkg/test" + devconsoleapi "github.com/redhat-developer/devconsole-api/pkg/apis/devconsole/v1alpha1" + + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/wait" +) + +// WaitUntilGitSourceReconcile waits execution until controller finishes reconciling. +func WaitUntilGitSourceReconcile(t *test.Framework, nsd types.NamespacedName) error { + var err error + err = wait.Poll(time.Second*5, time.Minute*1, func() (bool, error) { + var gitSource devconsoleapi.GitSource + err = t.Client.Get(goctx.TODO(), nsd, &gitSource) + if err != nil { + return false, err + } + return (gitSource.Status.Connection.State != ""), nil + }) + return err +} diff --git a/test/e2e/gitsource_test.go b/test/e2e/gitsource_test.go index c95b6bf..594ce70 100644 --- a/test/e2e/gitsource_test.go +++ b/test/e2e/gitsource_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/types" ) -// ComponentTest does e2e test as per operator-sdk documentation +// GitSourceTest does e2e test as per operator-sdk documentation // https://github.com/operator-framework/operator-sdk/blob/cc7b175/doc/test-framework/writing-e2e-tests.md func TestGitsource(t *testing.T) { var err error @@ -53,29 +53,66 @@ func TestGitsource(t *testing.T) { t.Log("operator is ready and running") - gs := &devconsoleapi.GitSource{ - TypeMeta: metav1.TypeMeta{ - Kind: "GitSource", - APIVersion: "devconsole.openshift.io/v1alpha1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "my-git-source-2", - Namespace: namespace, - }, - Spec: devconsoleapi.GitSourceSpec{ - URL: "https://somegit.con/myrepo", - Ref: "master", - }, - } - // use TestCtx's create helper to create the object and add a cleanup function for the new object - err = f.Client.Create(context.TODO(), gs, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) - require.NoError(t, err, "failed to create custom resource of kind `GitSource`") + t.Run("check exisiting repo connection should yield OK", func(t *testing.T) { + gs := &devconsoleapi.GitSource{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSource", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "my-git-source-1", + Namespace: namespace, + }, + Spec: devconsoleapi.GitSourceSpec{ + URL: "https://github.com/fabric8-services/build-tool-detector", + Ref: "master", + }, + } + // use TestCtx's create helper to create the object and add a cleanup function for the new object + err = f.Client.Create(context.TODO(), gs, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to create custom resource of kind `GitSource`") + + err = WaitUntilGitSourceReconcile(f, types.NamespacedName{Name: "my-git-source-1", Namespace: namespace}) + if err != nil { + t.Log("Failed to wait for gitsource reconcile") + } + outputGS := &devconsoleapi.GitSource{} + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-1", Namespace: namespace}, outputGS) + require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") + require.Equal(t, "my-git-source-1", outputGS.ObjectMeta.Name) + require.Equal(t, devconsoleapi.OK, outputGS.Status.Connection.State) + require.Equal(t, namespace, outputGS.ObjectMeta.Namespace) + }) + + t.Run("check non-existing repo connection should yield FAILED", func(t *testing.T) { + gs := &devconsoleapi.GitSource{ + TypeMeta: metav1.TypeMeta{ + Kind: "GitSource", + APIVersion: "devconsole.openshift.io/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "my-git-source-2", + Namespace: namespace, + }, + Spec: devconsoleapi.GitSourceSpec{ + URL: "https://example.abc/non-exisiting-repo", + Ref: "master", + }, + } + // use TestCtx's create helper to create the object and add a cleanup function for the new object + err = f.Client.Create(context.TODO(), gs, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) + require.NoError(t, err, "failed to create custom resource of kind `GitSource`") - t.Run("retrieve component and verify related resources are created", func(t *testing.T) { - outputCR := &devconsoleapi.GitSource{} - err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}, outputCR) + err = WaitUntilGitSourceReconcile(f, types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}) + if err != nil { + t.Log("Failed to wait for gitsource reconcile") + } + outputGS := &devconsoleapi.GitSource{} + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}, outputGS) require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") - require.Equal(t, "my-git-source-2", outputCR.ObjectMeta.Name) - require.Equal(t, namespace, outputCR.ObjectMeta.Namespace) + require.Equal(t, "my-git-source-2", outputGS.ObjectMeta.Name) + require.Equal(t, devconsoleapi.Failed, outputGS.Status.Connection.State) + require.Equal(t, namespace, outputGS.ObjectMeta.Namespace) }) + } diff --git a/test/e2e/gitsourceanalysis_test.go b/test/e2e/gitsourceanalysis_test.go index 8d73f15..2bd7883 100644 --- a/test/e2e/gitsourceanalysis_test.go +++ b/test/e2e/gitsourceanalysis_test.go @@ -75,7 +75,7 @@ func TestGitsourceAnalysis(t *testing.T) { Namespace: namespace, }, Spec: devconsoleapi.GitSourceSpec{ - URL: "https://somegit.con/myrepo", + URL: "https://github.com/fabric8-services/build-tool-detector", Ref: "master", }, } @@ -104,9 +104,15 @@ func TestGitsourceAnalysis(t *testing.T) { err = f.Client.Create(context.TODO(), gsa, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval}) require.NoError(t, err, "failed to create custom resource of kind `GitSourceAnalysis`") + err = WaitUntilGitSourceReconcile(f, types.NamespacedName{Name: "my-git-source", Namespace: namespace}) + if err != nil { + t.Log("Failed to wait for gitsource reconciel") + } + t.Run("retrieve component and verify related resources are created", func(t *testing.T) { outputCR := &devconsoleapi.GitSource{} err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source", Namespace: namespace}, outputCR) + t.Logf("gitsource %+v", outputCR) require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") require.Equal(t, "my-git-source", outputCR.ObjectMeta.Name) require.Equal(t, namespace, outputCR.ObjectMeta.Namespace) From 74a2b054cb5c1857cd12475b15c0f768f6f83100 Mon Sep 17 00:00:00 2001 From: akashshinde Date: Thu, 2 May 2019 15:38:58 +0530 Subject: [PATCH 4/7] Add gitsourceananlysis tests --- test/e2e/e2eutils.go | 14 ++++++++++++++ test/e2e/gitsource_test.go | 1 - test/e2e/gitsourceanalysis_test.go | 16 +++++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/e2e/e2eutils.go b/test/e2e/e2eutils.go index a259f77..5406c36 100644 --- a/test/e2e/e2eutils.go +++ b/test/e2e/e2eutils.go @@ -24,3 +24,17 @@ func WaitUntilGitSourceReconcile(t *test.Framework, nsd types.NamespacedName) er }) return err } + +// WaitUntilGitSourceAnalyzeReconcile waits execution until controller finishes reconciling. +func WaitUntilGitSourceAnalyzeReconcile(t *test.Framework, nsd types.NamespacedName) error { + var err error + err = wait.Poll(time.Second*5, time.Minute*1, func() (bool, error) { + var gitSourceAnalysis devconsoleapi.GitSourceAnalysis + err = t.Client.Get(goctx.TODO(), nsd, &gitSourceAnalysis) + if err != nil { + return false, err + } + return gitSourceAnalysis.Status.Analyzed, nil + }) + return err +} diff --git a/test/e2e/gitsource_test.go b/test/e2e/gitsource_test.go index 594ce70..ebf6ecf 100644 --- a/test/e2e/gitsource_test.go +++ b/test/e2e/gitsource_test.go @@ -114,5 +114,4 @@ func TestGitsource(t *testing.T) { require.Equal(t, devconsoleapi.Failed, outputGS.Status.Connection.State) require.Equal(t, namespace, outputGS.ObjectMeta.Namespace) }) - } diff --git a/test/e2e/gitsourceanalysis_test.go b/test/e2e/gitsourceanalysis_test.go index 2bd7883..a2eca71 100644 --- a/test/e2e/gitsourceanalysis_test.go +++ b/test/e2e/gitsourceanalysis_test.go @@ -106,21 +106,31 @@ func TestGitsourceAnalysis(t *testing.T) { err = WaitUntilGitSourceReconcile(f, types.NamespacedName{Name: "my-git-source", Namespace: namespace}) if err != nil { - t.Log("Failed to wait for gitsource reconciel") + t.Log("Failed to wait for gitsource reconcile") + t.Fail() + } + + err = WaitUntilGitSourceAnalyzeReconcile(f, types.NamespacedName{Name: "gitsource-analysis", Namespace: namespace}) + if err != nil { + t.Log("Failed to wait for gitsource analyze reconcile") + t.Fail() } t.Run("retrieve component and verify related resources are created", func(t *testing.T) { outputCR := &devconsoleapi.GitSource{} err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source", Namespace: namespace}, outputCR) - t.Logf("gitsource %+v", outputCR) require.NoError(t, err, "failed to retrieve custom resource of kind `GitSource`") require.Equal(t, "my-git-source", outputCR.ObjectMeta.Name) require.Equal(t, namespace, outputCR.ObjectMeta.Namespace) }) - t.Run("check if gitsourceanalysis has referrence to gitsource", func(t *testing.T) { + t.Run("check if gitsourceanalysis has referrence to gitsource and if build env stats are correct", func(t *testing.T) { outputGsa := &devconsoleapi.GitSourceAnalysis{} err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "gitsource-analysis", Namespace: namespace}, outputGsa) require.NoError(t, err, "failed to retrieve custom resource of kind `GitSourceAnalysis`") + require.Equal(t, "my-git-source", outputGsa.Spec.GitSourceRef.Name) + require.Equal(t, true, outputGsa.Status.Analyzed) + require.NotZero(t, len(outputGsa.Status.BuildEnvStatistics.DetectedBuildTypes), "build type has not been detected") + require.Equal(t, "go", outputGsa.Status.BuildEnvStatistics.DetectedBuildTypes[0].Language) }) } From d8a600188506bf7b6ef91800c0c8a7ea113fbcac Mon Sep 17 00:00:00 2001 From: akashshinde Date: Fri, 3 May 2019 16:37:32 +0530 Subject: [PATCH 5/7] add logs to test --- test/e2e/gitsource_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/gitsource_test.go b/test/e2e/gitsource_test.go index ebf6ecf..7783b75 100644 --- a/test/e2e/gitsource_test.go +++ b/test/e2e/gitsource_test.go @@ -75,6 +75,7 @@ func TestGitsource(t *testing.T) { err = WaitUntilGitSourceReconcile(f, types.NamespacedName{Name: "my-git-source-1", Namespace: namespace}) if err != nil { t.Log("Failed to wait for gitsource reconcile") + require.NoError(t, err, "Failed to wait for gitsource reconcile") } outputGS := &devconsoleapi.GitSource{} err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-1", Namespace: namespace}, outputGS) @@ -105,7 +106,8 @@ func TestGitsource(t *testing.T) { err = WaitUntilGitSourceReconcile(f, types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}) if err != nil { - t.Log("Failed to wait for gitsource reconcile") + t.Log("Failed to wait for gitsource reconcile ", err) + require.NoError(t, err, "Failed to wait for gitsource reconcile") } outputGS := &devconsoleapi.GitSource{} err = f.Client.Get(context.TODO(), types.NamespacedName{Name: "my-git-source-2", Namespace: namespace}, outputGS) From 0363d3bcb72a61a285701bf59434f838d148070d Mon Sep 17 00:00:00 2001 From: akashshinde Date: Mon, 6 May 2019 13:26:30 +0530 Subject: [PATCH 6/7] debug test failure --- test/e2e/e2eutils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/e2e/e2eutils.go b/test/e2e/e2eutils.go index 5406c36..0a0cebb 100644 --- a/test/e2e/e2eutils.go +++ b/test/e2e/e2eutils.go @@ -2,6 +2,7 @@ package e2e import ( goctx "context" + "fmt" "time" "github.com/operator-framework/operator-sdk/pkg/test" @@ -14,9 +15,10 @@ import ( // WaitUntilGitSourceReconcile waits execution until controller finishes reconciling. func WaitUntilGitSourceReconcile(t *test.Framework, nsd types.NamespacedName) error { var err error - err = wait.Poll(time.Second*5, time.Minute*1, func() (bool, error) { + err = wait.Poll(time.Second*5, time.Minute*5, func() (bool, error) { var gitSource devconsoleapi.GitSource err = t.Client.Get(goctx.TODO(), nsd, &gitSource) + fmt.Printf("\nGitSource is %+v and error is %+v", gitSource, err) if err != nil { return false, err } @@ -28,9 +30,10 @@ func WaitUntilGitSourceReconcile(t *test.Framework, nsd types.NamespacedName) er // WaitUntilGitSourceAnalyzeReconcile waits execution until controller finishes reconciling. func WaitUntilGitSourceAnalyzeReconcile(t *test.Framework, nsd types.NamespacedName) error { var err error - err = wait.Poll(time.Second*5, time.Minute*1, func() (bool, error) { + err = wait.Poll(time.Second*5, time.Minute*5, func() (bool, error) { var gitSourceAnalysis devconsoleapi.GitSourceAnalysis err = t.Client.Get(goctx.TODO(), nsd, &gitSourceAnalysis) + fmt.Printf("\nGitSource is %+v and error is %+v", gitSourceAnalysis, err) if err != nil { return false, err } From ba8b0e7a291884c9460200973d8b7270264549d0 Mon Sep 17 00:00:00 2001 From: akashshinde Date: Tue, 7 May 2019 14:48:30 +0530 Subject: [PATCH 7/7] reduce timeout in wait utils --- test/e2e/e2eutils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/e2eutils.go b/test/e2e/e2eutils.go index 0a0cebb..119b777 100644 --- a/test/e2e/e2eutils.go +++ b/test/e2e/e2eutils.go @@ -15,7 +15,7 @@ import ( // WaitUntilGitSourceReconcile waits execution until controller finishes reconciling. func WaitUntilGitSourceReconcile(t *test.Framework, nsd types.NamespacedName) error { var err error - err = wait.Poll(time.Second*5, time.Minute*5, func() (bool, error) { + err = wait.Poll(time.Second*5, time.Minute*2, func() (bool, error) { var gitSource devconsoleapi.GitSource err = t.Client.Get(goctx.TODO(), nsd, &gitSource) fmt.Printf("\nGitSource is %+v and error is %+v", gitSource, err) @@ -30,7 +30,7 @@ func WaitUntilGitSourceReconcile(t *test.Framework, nsd types.NamespacedName) er // WaitUntilGitSourceAnalyzeReconcile waits execution until controller finishes reconciling. func WaitUntilGitSourceAnalyzeReconcile(t *test.Framework, nsd types.NamespacedName) error { var err error - err = wait.Poll(time.Second*5, time.Minute*5, func() (bool, error) { + err = wait.Poll(time.Second*5, time.Minute*2, func() (bool, error) { var gitSourceAnalysis devconsoleapi.GitSourceAnalysis err = t.Client.Get(goctx.TODO(), nsd, &gitSourceAnalysis) fmt.Printf("\nGitSource is %+v and error is %+v", gitSourceAnalysis, err)