@@ -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,53 @@ 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
175
))),
176
176
ContainElement (LikeMetric (
177
177
WithFamily ("subscription_sync_total" ),
178
- WithLabel ( "name" , "metric-subscription-for-update" ),
179
- WithLabel ( "channel" , "beta" ),
180
- WithLabel ( "package" , testPackageName ),
178
+ WithName ( "metric-subscription-for-update" ),
179
+ WithChannel ( betaChannel ),
180
+ WithPackage ( testPackageName ),
181
181
)),
182
182
))
183
183
})
184
+ When ("The subscription object is updated again" , func () {
185
+
186
+ BeforeEach (func () {
187
+ Eventually (func () error {
188
+ s , err := crc .OperatorsV1alpha1 ().Subscriptions (subscription .GetNamespace ()).Get (context .TODO (), subscription .GetName (), metav1.GetOptions {})
189
+ if err != nil {
190
+ return err
191
+ }
192
+ s .Spec .Channel = alphaChannel
193
+ _ , err = crc .OperatorsV1alpha1 ().Subscriptions (s .GetNamespace ()).Update (context .TODO (), s , metav1.UpdateOptions {})
194
+ return err
195
+ }).Should (Succeed ())
196
+ })
197
+
198
+ It ("deletes the old subscription metric and emits the new metric(there is only one metric for the subscription)" , func () {
199
+ Eventually (func () []Metric {
200
+ return getMetricsFromPod (c , getPodWithLabel (c , "app=catalog-operator" ), "8081" )
201
+ }).Should (And (
202
+ Not (ContainElement (LikeMetric (
203
+ WithFamily ("subscription_sync_total" ),
204
+ WithName ("metric-subscription-for-update" ),
205
+ WithChannel (stableChannel ),
206
+ ))),
207
+ Not (ContainElement (LikeMetric (
208
+ WithFamily ("subscription_sync_total" ),
209
+ WithName ("metric-subscription-for-update" ),
210
+ WithChannel (betaChannel ),
211
+ ))),
212
+ ContainElement (LikeMetric (
213
+ WithFamily ("subscription_sync_total" ),
214
+ WithName ("metric-subscription-for-update" ),
215
+ WithChannel (alphaChannel ),
216
+ WithPackage (testPackageName ),
217
+ ))))
218
+ })
219
+ })
184
220
})
185
221
186
222
When ("A subscription object is deleted after emitting metrics" , func () {
0 commit comments