@@ -36,7 +36,6 @@ import (
36
36
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
37
37
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
38
38
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/projection"
39
- "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison"
40
39
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
41
40
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
42
41
registryapi "github.com/operator-framework/operator-registry/pkg/api"
@@ -1035,6 +1034,7 @@ var _ = Describe("Subscription", func() {
1035
1034
// - Wait for sub to have status condition SubscriptionInstallPlanMissing true
1036
1035
// - Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
1037
1036
It ("can reconcile InstallPlan status" , func () {
1037
+ By (`TestSubscriptionInstallPlanStatus ensures that a Subscription has the appropriate status conditions for possible referenced InstallPlan states.` )
1038
1038
c := newKubeClient ()
1039
1039
crc := newCRClient ()
1040
1040
@@ -1081,6 +1081,7 @@ var _ = Describe("Subscription", func() {
1081
1081
ref := sub .Status .InstallPlanRef
1082
1082
Expect (ref ).ToNot (BeNil ())
1083
1083
1084
+ By (`Get the InstallPlan` )
1084
1085
plan := & operatorsv1alpha1.InstallPlan {}
1085
1086
plan .SetNamespace (ref .Namespace )
1086
1087
plan .SetName (ref .Name )
@@ -1192,16 +1193,13 @@ var _ = Describe("Subscription", func() {
1192
1193
Expect (err ).ToNot (HaveOccurred ())
1193
1194
Expect (sub ).ToNot (BeNil ())
1194
1195
1195
- // Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
1196
- hashEqual := comparison .NewHashEqualitor ()
1196
+ By (`Ensure InstallPlan-related status conditions match what we're expecting` )
1197
1197
for _ , cond := range conds {
1198
1198
switch condType := cond .Type ; condType {
1199
1199
case operatorsv1alpha1 .SubscriptionInstallPlanPending , operatorsv1alpha1 .SubscriptionInstallPlanFailed :
1200
1200
require .FailNowf (GinkgoT (), "failed" , "subscription contains unexpected installplan condition: %v" , cond )
1201
1201
case operatorsv1alpha1 .SubscriptionInstallPlanMissing :
1202
1202
require .Equal (GinkgoT (), operatorsv1alpha1 .ReferencedInstallPlanNotFound , cond .Reason )
1203
- default :
1204
- require .True (GinkgoT (), hashEqual (cond , sub .Status .GetCondition (condType )), "non-installplan status condition changed" )
1205
1203
}
1206
1204
}
1207
1205
})
@@ -2825,14 +2823,53 @@ func subscriptionHasCurrentCSV(currentCSV string) subscriptionStateChecker {
2825
2823
}
2826
2824
2827
2825
func subscriptionHasCondition (condType operatorsv1alpha1.SubscriptionConditionType , status corev1.ConditionStatus , reason , message string ) subscriptionStateChecker {
2826
+ var lastCond operatorsv1alpha1.SubscriptionCondition
2827
+ lastTime := time .Now ()
2828
+ // if status/reason/message meet expectations, then subscription state is considered met/true
2829
+ // IFF this is the result of a recent change of status/reason/message
2830
+ // else, cache the current status/reason/message for next loop/comparison
2828
2831
return func (subscription * operatorsv1alpha1.Subscription ) bool {
2829
2832
cond := subscription .Status .GetCondition (condType )
2830
2833
if cond .Status == status && cond .Reason == reason && cond .Message == message {
2831
- fmt .Printf ("subscription condition met %v\n " , cond )
2834
+ if lastCond .Status != cond .Status && lastCond .Reason != cond .Reason && lastCond .Message == cond .Message {
2835
+ GinkgoT ().Logf ("waited %s subscription condition met %v\n " , time .Since (lastTime ), cond )
2836
+ lastTime = time .Now ()
2837
+ lastCond = cond
2838
+ }
2839
+ return true
2840
+ }
2841
+
2842
+ if lastCond .Status != cond .Status && lastCond .Reason != cond .Reason && lastCond .Message == cond .Message {
2843
+ GinkgoT ().Logf ("waited %s subscription condition not met: %v\n " , time .Since (lastTime ), cond )
2844
+ lastTime = time .Now ()
2845
+ lastCond = cond
2846
+ }
2847
+ return false
2848
+ }
2849
+ }
2850
+
2851
+ func subscriptionDoesNotHaveCondition (condType operatorsv1alpha1.SubscriptionConditionType ) subscriptionStateChecker {
2852
+ var lastStatus corev1.ConditionStatus
2853
+ lastTime := time .Now ()
2854
+ // if status meets expectations, then subscription state is considered met/true
2855
+ // IFF this is the result of a recent change of status
2856
+ // else, cache the current status for next loop/comparison
2857
+ return func (subscription * operatorsv1alpha1.Subscription ) bool {
2858
+ cond := subscription .Status .GetCondition (condType )
2859
+ if cond .Status == corev1 .ConditionUnknown {
2860
+ if cond .Status != lastStatus {
2861
+ GinkgoT ().Logf ("waited %s subscription condition not found\n " , time .Since (lastTime ))
2862
+ lastStatus = cond .Status
2863
+ lastTime = time .Now ()
2864
+ }
2832
2865
return true
2833
2866
}
2834
2867
2835
- fmt .Printf ("subscription condition not met: %v\n " , cond )
2868
+ if cond .Status != lastStatus {
2869
+ GinkgoT ().Logf ("waited %s subscription condition found: %v\n " , time .Since (lastTime ), cond )
2870
+ lastStatus = cond .Status
2871
+ lastTime = time .Now ()
2872
+ }
2836
2873
return false
2837
2874
}
2838
2875
}
0 commit comments