@@ -18,6 +18,7 @@ package provider
1818
1919import (
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}
0 commit comments