@@ -75,15 +75,15 @@ var _ = Describe("Metrics are generated for OLM managed resources", func() {
75
75
Expect (getMetricsFromPod (c , getPodWithLabel (c , "app=olm-operator" ), "8081" )).To (And (
76
76
ContainElement (LikeMetric (
77
77
WithFamily ("csv_abnormal" ),
78
- WithLabel ( "name" , failingCSV .Name ),
79
- WithLabel ( "phase" , "Failed" ),
80
- WithLabel ( "reason" , "UnsupportedOperatorGroup" ),
81
- WithLabel ( "version" , "0.0.0" ),
78
+ WithName ( failingCSV .Name ),
79
+ WithPhase ( "Failed" ),
80
+ WithReason ( "UnsupportedOperatorGroup" ),
81
+ WithVersion ( "0.0.0" ),
82
82
)),
83
83
ContainElement (LikeMetric (
84
84
WithFamily ("csv_succeeded" ),
85
85
WithValue (0 ),
86
- WithLabel ( "name" , failingCSV .Name ),
86
+ WithName ( failingCSV .Name ),
87
87
)),
88
88
))
89
89
@@ -101,8 +101,8 @@ var _ = Describe("Metrics are generated for OLM managed resources", func() {
101
101
It ("deletes its associated CSV metrics" , func () {
102
102
// Verify that when the csv has been deleted, it deletes the corresponding CSV metrics
103
103
Expect (getMetricsFromPod (c , getPodWithLabel (c , "app=olm-operator" ), "8081" )).ToNot (And (
104
- ContainElement (LikeMetric (WithFamily ("csv_abnormal" ), WithLabel ( "name" , failingCSV .Name ))),
105
- ContainElement (LikeMetric (WithFamily ("csv_succeeded" ), WithLabel ( "name" , failingCSV .Name ))),
104
+ ContainElement (LikeMetric (WithFamily ("csv_abnormal" ), WithName ( failingCSV .Name ))),
105
+ ContainElement (LikeMetric (WithFamily ("csv_succeeded" ), WithName ( failingCSV .Name ))),
106
106
))
107
107
})
108
108
})
@@ -133,9 +133,9 @@ var _ = Describe("Metrics are generated for OLM managed resources", func() {
133
133
return getMetricsFromPod (c , getPodWithLabel (c , "app=catalog-operator" ), "8081" )
134
134
}).Should (ContainElement (LikeMetric (
135
135
WithFamily ("subscription_sync_total" ),
136
- WithLabel ( "name" , "metric-subscription-for-create" ),
137
- WithLabel ( "channel" , stableChannel ),
138
- WithLabel ( "package" , testPackageName ),
136
+ WithName ( "metric-subscription-for-create" ),
137
+ WithChannel ( stableChannel ),
138
+ WithPackage ( testPackageName ),
139
139
)))
140
140
})
141
141
})
@@ -152,7 +152,7 @@ var _ = Describe("Metrics are generated for OLM managed resources", func() {
152
152
if err != nil {
153
153
return err
154
154
}
155
- s .Spec .Channel = "beta"
155
+ s .Spec .Channel = betaChannel
156
156
_ , err = crc .OperatorsV1alpha1 ().Subscriptions (s .GetNamespace ()).Update (context .TODO (), s , metav1.UpdateOptions {})
157
157
return err
158
158
}).Should (Succeed ())
@@ -170,17 +170,55 @@ var _ = Describe("Metrics are generated for OLM managed resources", func() {
170
170
}).Should (And (
171
171
Not (ContainElement (LikeMetric (
172
172
WithFamily ("subscription_sync_total" ),
173
- WithLabel ("name" , "metric-subscription-for-update" ),
174
- WithLabel ("channel" , stableChannel ),
173
+ WithName ("metric-subscription-for-update" ),
174
+ WithChannel (stableChannel ),
175
+ WithPackage (testPackageName ),
175
176
))),
176
177
ContainElement (LikeMetric (
177
178
WithFamily ("subscription_sync_total" ),
178
- WithLabel ( "name" , "metric-subscription-for-update" ),
179
- WithLabel ( "channel" , "beta" ),
180
- WithLabel ( "package" , testPackageName ),
179
+ WithName ( "metric-subscription-for-update" ),
180
+ WithChannel ( betaChannel ),
181
+ WithPackage ( testPackageName ),
181
182
)),
182
183
))
183
184
})
185
+ When ("The subscription object is updated again" , func () {
186
+
187
+ BeforeEach (func () {
188
+ Eventually (func () error {
189
+ s , err := crc .OperatorsV1alpha1 ().Subscriptions (subscription .GetNamespace ()).Get (context .TODO (), subscription .GetName (), metav1.GetOptions {})
190
+ if err != nil {
191
+ return err
192
+ }
193
+ s .Spec .Channel = alphaChannel
194
+ _ , err = crc .OperatorsV1alpha1 ().Subscriptions (s .GetNamespace ()).Update (context .TODO (), s , metav1.UpdateOptions {})
195
+ return err
196
+ }).Should (Succeed ())
197
+ })
198
+
199
+ It ("deletes the old subscription metric and emits the new metric(there is only one metric for the subscription)" , func () {
200
+ Eventually (func () []Metric {
201
+ return getMetricsFromPod (c , getPodWithLabel (c , "app=catalog-operator" ), "8081" )
202
+ }).Should (And (
203
+ Not (ContainElement (LikeMetric (
204
+ WithFamily ("subscription_sync_total" ),
205
+ WithName ("metric-subscription-for-update" ),
206
+ WithChannel (stableChannel ),
207
+ ))),
208
+ Not (ContainElement (LikeMetric (
209
+ WithFamily ("subscription_sync_total" ),
210
+ WithName ("metric-subscription-for-update" ),
211
+ WithChannel (betaChannel ),
212
+ WithPackage (testPackageName ),
213
+ ))),
214
+ ContainElement (LikeMetric (
215
+ WithFamily ("subscription_sync_total" ),
216
+ WithName ("metric-subscription-for-update" ),
217
+ WithChannel (alphaChannel ),
218
+ WithPackage (testPackageName ),
219
+ ))))
220
+ })
221
+ })
184
222
})
185
223
186
224
When ("A subscription object is deleted after emitting metrics" , func () {
@@ -205,7 +243,7 @@ var _ = Describe("Metrics are generated for OLM managed resources", func() {
205
243
It ("deletes the Subscription metric" , func () {
206
244
Eventually (func () []Metric {
207
245
return getMetricsFromPod (c , getPodWithLabel (c , "app=catalog-operator" ), "8081" )
208
- }).ShouldNot (ContainElement (LikeMetric (WithFamily ("subscription_sync_total" ), WithLabel ( "name" , "metric-subscription-for-delete" ))))
246
+ }).ShouldNot (ContainElement (LikeMetric (WithFamily ("subscription_sync_total" ), WithName ( "metric-subscription-for-delete" ))))
209
247
})
210
248
})
211
249
})
0 commit comments