Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 40a60b1

Browse files
authored
Merge pull request #25 from parul5sahoo/logging
Added granular logging for the existing provider upgrade test
2 parents e4a5fd7 + 99e5c89 commit 40a60b1

3 files changed

Lines changed: 40 additions & 19 deletions

File tree

config/provider/conformance.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ providers:
33
upgrade:
44
- initial: "v0.21.0"
55
final: "master"
6-
- package: crossplane/provider-aws
7-
upgrade:
8-
- initial: "v0.29.0"
9-
final: "master"
106
- package: crossplane/provider-azure
117
upgrade:
128
- initial: "v0.19.0"
13-
final: "master"
14-
9+
final: "master"
10+
- package: crossplane/provider-aws
11+
upgrade:
12+
- initial: "v0.29.0"
13+
final: "master"

test/framework/provider/wait.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package provider
1818

1919
import (
2020
"context"
21+
"testing"
2122
"time"
2223

2324
v1 "github.com/crossplane/crossplane/apis/pkg/v1"
@@ -27,20 +28,28 @@ import (
2728
)
2829

2930
// Wait for Provider to be successfully installed.
30-
func WaitForAllProvidersInstalled(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration) error {
31+
func WaitForAllProvidersInstalled(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration, t *testing.T) error {
3132
if err := wait.PollImmediate(interval, timeout, func() (bool, error) {
3233
l := &v1.ProviderList{}
3334
if err := c.List(ctx, l); err != nil {
3435
return false, err
3536
}
37+
3638
if len(l.Items) != 1 {
39+
t.Log("The no. of providers installed is not equal to 1")
40+
for i, item := range l.Items{
41+
t.Logf("Provider %v : %v", i, item.Name)
42+
}
3743
return false, nil
3844
}
39-
for _, p := range l.Items {
40-
if p.GetCondition(v1.TypeInstalled).Status != corev1.ConditionTrue {
45+
46+
for _, item := range l.Items {
47+
if item.GetCondition(v1.TypeInstalled).Status != corev1.ConditionTrue {
48+
t.Logf("The type of provider %v installed is %v", item.Name, item.TypeMeta)
4149
return false, nil
4250
}
43-
if p.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue {
51+
if item.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue {
52+
t.Logf("The status of provider %v installed is %v", item.Name, item.Status)
4453
return false, nil
4554
}
4655
}
@@ -52,27 +61,35 @@ func WaitForAllProvidersInstalled(ctx context.Context, c client.Client, interval
5261
}
5362

5463
// Wait for Provider to be successfully updated.
55-
func WaitForRevisionTransition(ctx context.Context, c client.Client, p2 string, p1 string, interval time.Duration, timeout time.Duration) error {
64+
func WaitForRevisionTransition(ctx context.Context, c client.Client, p2 string, p1 string, interval time.Duration, timeout time.Duration, t *testing.T) error {
5665
if err := wait.PollImmediate(interval, timeout, func() (bool, error) {
5766
l := &v1.ProviderRevisionList{}
5867
if err := c.List(ctx, l); err != nil {
5968
return false, err
6069
}
70+
6171
// There should be a revision present for the initial revision and the upgrade.
6272
if len(l.Items) != 2 {
73+
t.Log("The no. of provider revisions is not equal to 2")
74+
for i, item := range l.Items{
75+
t.Logf("Provider revision %v : %v uses package %v", i, item.Name, item.Spec.Package)
76+
}
6377
return false, nil
6478
}
65-
for _, p := range l.Items {
79+
for _, item := range l.Items {
6680
// New ProviderRevision should be Active.
67-
if p.Spec.Package == p2 && p.GetDesiredState() != v1.PackageRevisionActive {
81+
if item.Spec.Package == p2 && item.GetDesiredState() != v1.PackageRevisionActive {
82+
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)
6883
return false, nil
6984
}
7085
// Old ProviderRevision should be Inactive.
71-
if p.Spec.Package == p1 && p.GetDesiredState() != v1.PackageRevisionInactive {
86+
if item.Spec.Package == p1 && item.GetDesiredState() != v1.PackageRevisionInactive {
87+
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)
7288
return false, nil
7389
}
7490
// Both ProviderRevisions should be healthy.
75-
if p.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue {
91+
if item.GetCondition(v1.TypeHealthy).Status != corev1.ConditionTrue {
92+
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)
7693
return false, nil
7794
}
7895
}
@@ -84,12 +101,17 @@ func WaitForRevisionTransition(ctx context.Context, c client.Client, p2 string,
84101
}
85102

86103
// Wait for Provider to be successfully deleted.
87-
func WaitForAllProvidersDeleted(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration) error {
104+
func WaitForAllProvidersDeleted(ctx context.Context, c client.Client, interval time.Duration, timeout time.Duration, t *testing.T) error {
88105
return wait.PollImmediate(interval, timeout, func() (bool, error) {
89106
l := &v1.ProviderList{}
90107
if err := c.List(ctx, l); err != nil {
91108
return false, err
92109
}
110+
for _, item := range l.Items {
111+
t.Log("Undeleted providers :")
112+
t.Logf("Name: %v \t Type: %v \t Uses Package: %v", item.Name, item.Kind, item.Spec.Package)
113+
}
114+
93115
return len(l.Items) == 0, nil
94116
})
95117
}

test/provider/upgrade/upgrade_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestProviderUpgrade(t *testing.T) {
7878
}
7979

8080
// Wait for Provider to be successfully installed.
81-
if err := provider.WaitForAllProvidersInstalled(ctx, c, 5*time.Second, 2*time.Minute); err != nil {
81+
if err := provider.WaitForAllProvidersInstalled(ctx, c, 5*time.Second, 2*time.Minute, t); err != nil {
8282
return err
8383
}
8484

@@ -89,7 +89,7 @@ func TestProviderUpgrade(t *testing.T) {
8989
}
9090

9191
// Wait for Provider to be successfully updated.
92-
if err := provider.WaitForRevisionTransition(ctx, c, upgradeProviderPackage, initialProviderPackage, 5*time.Second, 2*time.Minute); err != nil {
92+
if err := provider.WaitForRevisionTransition(ctx, c, upgradeProviderPackage, initialProviderPackage, 5*time.Second, 2*time.Minute, t); err != nil {
9393
return err
9494
}
9595

@@ -99,7 +99,7 @@ func TestProviderUpgrade(t *testing.T) {
9999
}
100100

101101
// Wait for Provider to be successfully deleted.
102-
return provider.WaitForAllProvidersDeleted(ctx, c, 5*time.Second, 30*time.Second)
102+
return provider.WaitForAllProvidersDeleted(ctx, c, 5*time.Second, 30*time.Second, t)
103103
},
104104
},
105105
}

0 commit comments

Comments
 (0)