From 835541d8466d8bcd114599ae64bbf775bbaf9b1f Mon Sep 17 00:00:00 2001 From: parul5sahoo Date: Wed, 20 Jul 2022 19:32:13 +0530 Subject: [PATCH] added granular logging Signed-off-by: parul5sahoo --- .github/workflows/crossplane-upgrade.yml | 10 +++--- .github/workflows/periodic.yml | 8 ++--- .github/workflows/provider-upgrade.yml | 6 ++-- config/provider/conformance.yml | 11 +++---- test/framework/provider/wait.go | 42 ++++++++++++++++++------ test/provider/upgrade/upgrade_test.go | 6 ++-- 6 files changed, 52 insertions(+), 31 deletions(-) diff --git a/.github/workflows/crossplane-upgrade.yml b/.github/workflows/crossplane-upgrade.yml index 0612560..8fdb1ff 100644 --- a/.github/workflows/crossplane-upgrade.yml +++ b/.github/workflows/crossplane-upgrade.yml @@ -7,18 +7,18 @@ on: workflow_dispatch: {} env: - GO_VERSION: '1.16' - KIND_VERSION: 'v0.11.1' + GO_VERSION: '1.18' + KIND_VERSION: 'v0.14.0' jobs: crossplane-upgrade-test: runs-on: ubuntu-latest steps: - - name: Checkout Crossplane Release 1.1 + - name: Checkout Crossplane Release 1.9 uses: actions/checkout@v2 with: repository: crossplane/crossplane - ref: release-1.1 + ref: release-1.9 - name: Setup Go uses: actions/setup-go@v2 with: @@ -33,7 +33,7 @@ jobs: run: kubectl create namespace crossplane-system shell: bash - name: Install Crossplane from Stable - run: helm repo add crossplane-stable https://charts.crossplane.io/stable && helm repo update && helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --version 1.1.0 --wait + run: helm repo add crossplane-stable https://charts.crossplane.io/stable && helm repo update && helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --version 1.9.0 --wait shell: bash - name: Run E2E Tests for stable run: go test -p 1 -timeout 10m -v --tags=e2e ./test/e2e/... diff --git a/.github/workflows/periodic.yml b/.github/workflows/periodic.yml index eb2e374..383a7b5 100644 --- a/.github/workflows/periodic.yml +++ b/.github/workflows/periodic.yml @@ -7,8 +7,8 @@ on: workflow_dispatch: {} env: - GO_VERSION: '1.16' - KIND_VERSION: 'v0.11.1' + GO_VERSION: '1.18' + KIND_VERSION: 'v0.14.0' jobs: e2e-tests-latest: @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v2 with: repository: crossplane/crossplane - ref: release-1.0 + ref: release-1.9 - name: Setup Go uses: actions/setup-go@v2 with: @@ -63,7 +63,7 @@ jobs: run: kubectl create namespace crossplane-system shell: bash - name: Install Crossplane from Stable - run: helm repo add crossplane-stable https://charts.crossplane.io/stable && helm repo update && helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --wait + run: helm repo add crossplane-stable https://charts.crossplane.io/stable && helm repo update && helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --version 1.9.0 --wait shell: bash - name: Run E2E Tests run: go test -p 1 -timeout 10m -v --tags=e2e ./test/e2e/... diff --git a/.github/workflows/provider-upgrade.yml b/.github/workflows/provider-upgrade.yml index 9ecc287..4b462b1 100644 --- a/.github/workflows/provider-upgrade.yml +++ b/.github/workflows/provider-upgrade.yml @@ -7,8 +7,8 @@ on: workflow_dispatch: {} env: - GO_VERSION: '1.16' - KIND_VERSION: 'v0.11.1' + GO_VERSION: '1.18' + KIND_VERSION: 'v0.14.0' jobs: provider-upgrade-crossplane-stable: @@ -32,7 +32,7 @@ jobs: run: kubectl create namespace crossplane-system shell: bash - name: Install Crossplane from Stable - run: helm repo add crossplane-stable https://charts.crossplane.io/stable && helm repo update && helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --wait + run: helm repo add crossplane-stable https://charts.crossplane.io/stable && helm repo update && helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --version 1.9.0 --wait shell: bash - name: Run Provider Upgrade Tests run: go test -timeout 10m -v --tags=e2e_provider ./test/... diff --git a/config/provider/conformance.yml b/config/provider/conformance.yml index 4994734..2c57621 100644 --- a/config/provider/conformance.yml +++ b/config/provider/conformance.yml @@ -3,12 +3,11 @@ providers: upgrade: - initial: "v0.21.0" final: "master" -- package: crossplane/provider-aws - upgrade: - - initial: "v0.29.0" - final: "master" - package: crossplane/provider-azure upgrade: - initial: "v0.19.0" - final: "master" - \ No newline at end of file + final: "master" +- package: crossplane/provider-aws + upgrade: + - initial: "v0.29.0" + final: "master" \ No newline at end of file diff --git a/test/framework/provider/wait.go b/test/framework/provider/wait.go index 370341f..c6747fb 100644 --- a/test/framework/provider/wait.go +++ b/test/framework/provider/wait.go @@ -18,6 +18,7 @@ package provider import ( "context" + "testing" "time" v1 "github.com/crossplane/crossplane/apis/pkg/v1" @@ -27,20 +28,28 @@ import ( ) // Wait for Provider to be successfully installed. -func WaitForAllProvidersInstalled(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration) error { +func WaitForAllProvidersInstalled(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration, t *testing.T) error { if err := wait.PollImmediate(interval, timeout, func() (bool, error) { l := &v1.ProviderList{} if err := c.List(ctx, l); err != nil { return false, err } + if len(l.Items) != 1 { + t.Log("The no. of providers installed is not equal to 1") + for i, item := range l.Items{ + t.Logf("Provider %v : %v", i, item.Name) + } return false, nil } - for _, p := range l.Items { - if p.GetCondition(v1.TypeInstalled).Status != corev1.ConditionTrue { + + for _, item := range l.Items { + if item.GetCondition(v1.TypeInstalled).Status != corev1.ConditionTrue { + t.Logf("The type of provider %v installed is %v", item.Name, item.TypeMeta) return false, nil } - if p.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue { + if item.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue { + t.Logf("The status of provider %v installed is %v", item.Name, item.Status) return false, nil } } @@ -52,27 +61,35 @@ func WaitForAllProvidersInstalled(ctx context.Context, c client.Client, interval } // Wait for Provider to be successfully updated. -func WaitForRevisionTransition(ctx context.Context, c client.Client, p2 string, p1 string, interval time.Duration, timeout time.Duration) error { +func WaitForRevisionTransition(ctx context.Context, c client.Client, p2 string, p1 string, interval time.Duration, timeout time.Duration, t *testing.T) error { if err := wait.PollImmediate(interval, timeout, func() (bool, error) { l := &v1.ProviderRevisionList{} if err := c.List(ctx, l); err != nil { return false, err } + // There should be a revision present for the initial revision and the upgrade. if len(l.Items) != 2 { + t.Log("The no. of provider revisions is not equal to 2") + for i, item := range l.Items{ + t.Logf("Provider revision %v : %v uses package %v", i, item.Name, item.Spec.Package) + } return false, nil } - for _, p := range l.Items { + for _, item := range l.Items { // New ProviderRevision should be Active. - if p.Spec.Package == p2 && p.GetDesiredState() != v1.PackageRevisionActive { + if item.Spec.Package == p2 && item.GetDesiredState() != v1.PackageRevisionActive { + t.Logf("The state of new provider revision %v built from package %v and having version %v is %v", item.Name, item.Spec.Package, item.Spec.Revision, item.Status) return false, nil } // Old ProviderRevision should be Inactive. - if p.Spec.Package == p1 && p.GetDesiredState() != v1.PackageRevisionInactive { + if item.Spec.Package == p1 && item.GetDesiredState() != v1.PackageRevisionInactive { + t.Logf("The state of old provider revision %v built from package %v and having version %v is %v", item.Name, item.Spec.Package, item.Spec.Revision, item.Status) return false, nil } // Both ProviderRevisions should be healthy. - if p.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue { + if item.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue { + t.Logf("The condition of provider revision %v built from package %v and having version %v is %v", item.Name, item.Spec.Package, item.Spec.Revision, item.Status.ConditionedStatus) return false, nil } } @@ -84,12 +101,17 @@ func WaitForRevisionTransition(ctx context.Context, c client.Client, p2 string, } // Wait for Provider to be successfully deleted. -func WaitForAllProvidersDeleted(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration) error { +func WaitForAllProvidersDeleted(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration, t *testing.T) error { return wait.PollImmediate(interval, timeout, func() (bool, error) { l := &v1.ProviderList{} if err := c.List(ctx, l); err != nil { return false, err } + for _, item := range l.Items { + t.Log("Undeleted providers :") + t.Logf("Name: %v \t Type: %v \t Uses Package: %v", item.Name, item.Kind, item.Spec.Package) + } + return len(l.Items) == 0, nil }) } diff --git a/test/provider/upgrade/upgrade_test.go b/test/provider/upgrade/upgrade_test.go index 61afa5a..07c54fc 100644 --- a/test/provider/upgrade/upgrade_test.go +++ b/test/provider/upgrade/upgrade_test.go @@ -78,7 +78,7 @@ func TestProviderUpgrade(t *testing.T) { } // Wait for Provider to be successfully installed. - if err := provider.WaitForAllProvidersInstalled(ctx, c, 5*time.Second, 2*time.Minute); err != nil { + if err := provider.WaitForAllProvidersInstalled(ctx, c, 5*time.Second, 2*time.Minute, t); err != nil { return err } @@ -89,7 +89,7 @@ func TestProviderUpgrade(t *testing.T) { } // Wait for Provider to be successfully updated. - if err := provider.WaitForRevisionTransition(ctx, c, upgradeProviderPackage, initialProviderPackage, 5*time.Second, 2*time.Minute); err != nil { + if err := provider.WaitForRevisionTransition(ctx, c, upgradeProviderPackage, initialProviderPackage, 5*time.Second, 2*time.Minute, t); err != nil { return err } @@ -99,7 +99,7 @@ func TestProviderUpgrade(t *testing.T) { } // Wait for Provider to be successfully deleted. - return provider.WaitForAllProvidersDeleted(ctx, c, 5*time.Second, 30*time.Second) + return provider.WaitForAllProvidersDeleted(ctx, c, 5*time.Second, 30*time.Second, t) }, }, }