@@ -32,18 +32,41 @@ func TestOperatorVersionMetrics(t *testing.T) {
3232 awaitilities := WaitForDeployments (t )
3333
3434 t .Run ("host-operator" , func (t * testing.T ) {
35+
3536 // given
3637 hostAwait := awaitilities .Host ()
37- // host metrics should be available at this point
38- hostAwait . InitMetrics (t , awaitilities . Member1 (). ClusterName , awaitilities . Member2 (). ClusterName )
38+ _ , err := hostAwait . WaitForRouteToBeAvailable ( t , hostAwait . Namespace , "host-operator-metrics-service" , "/metrics" )
39+ require . NoError (t , err )
3940
40- // when
41- labels := hostAwait .GetMetricLabels (t , wait .HostOperatorVersionMetric )
41+ t .Run ("commit" , func (t * testing.T ) {
42+ // when
43+ labels := hostAwait .GetMetricLabels (t , hostAwait .MetricsURL , wait .HostOperatorCommitMetric )
4244
43- // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
44- require .Len (t , labels , 1 )
45- commit := labels [0 ]["commit" ]
46- assert .Len (t , commit , 7 )
45+ // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
46+ require .Len (t , labels , 1 )
47+ commit := labels [0 ]["commit" ]
48+ assert .Len (t , commit , len ("e6a12a442a60dfd86d348a030ad2e789c79184b5" )) // example value: 40 characters
49+ })
50+
51+ t .Run ("short commit" , func (t * testing.T ) {
52+ // when
53+ labels := hostAwait .GetMetricLabels (t , hostAwait .MetricsURL , wait .HostOperatorShortCommitMetric )
54+
55+ // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
56+ require .Len (t , labels , 1 )
57+ commit := labels [0 ]["commit" ]
58+ assert .Len (t , commit , 7 )
59+ })
60+
61+ t .Run ("version" , func (t * testing.T ) {
62+ // when
63+ labels := hostAwait .GetMetricLabels (t , hostAwait .MetricsURL , wait .HostOperatorVersionMetric )
64+
65+ // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
66+ require .Len (t , labels , 1 )
67+ commit := labels [0 ]["commit" ]
68+ assert .Len (t , commit , 7 )
69+ })
4770 })
4871
4972 t .Run ("member-operators" , func (t * testing.T ) {
@@ -56,7 +79,7 @@ func TestOperatorVersionMetrics(t *testing.T) {
5679
5780 // --- member1 ---
5881 // when
59- labels := member1Await .GetMetricLabels (t , wait .MemberOperatorVersionMetric )
82+ labels := member1Await .GetMetricLabels (t , member1Await . MetricsURL , wait .MemberOperatorVersionMetric )
6083
6184 // verify that the "version" metric exists for the first Member Operator and that it has a non-empty `commit` label
6285 require .Len (t , labels , 1 )
@@ -65,7 +88,7 @@ func TestOperatorVersionMetrics(t *testing.T) {
6588
6689 // --- member2 ---
6790 // when
68- labels = member2Await .GetMetricLabels (t , wait .MemberOperatorVersionMetric )
91+ labels = member2Await .GetMetricLabels (t , member2Await . MetricsURL , wait .MemberOperatorVersionMetric )
6992
7093 // verify that the "version" metric exists for the second Member Operator and that it has a non-empty `commit` label
7194 require .Len (t , labels , 1 )
@@ -75,6 +98,35 @@ func TestOperatorVersionMetrics(t *testing.T) {
7598 // expect the same version on member1 and member2
7699 assert .Equal (t , commit1 , commit2 )
77100 })
101+
102+ t .Run ("registration-service" , func (t * testing.T ) {
103+
104+ // given
105+ hostAwait := awaitilities .Host ()
106+ _ , err := hostAwait .WaitForRouteToBeAvailable (t , hostAwait .Namespace , "host-operator-metrics-service" , "/metrics" )
107+ require .NoError (t , err )
108+
109+ t .Run ("commit" , func (t * testing.T ) {
110+ // when
111+ labels := hostAwait .GetMetricLabels (t , hostAwait .RegistrationServiceMetricsURL , wait .RegistrationServiceCommitMetric )
112+
113+ // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
114+ require .Len (t , labels , 1 )
115+ commit := labels [0 ]["commit" ]
116+ assert .Len (t , commit , len ("da3f54634cc65075d51d067a157831d44bf1413e" )) // example value: 40 characters
117+ })
118+
119+ t .Run ("short commit" , func (t * testing.T ) {
120+ // when
121+ labels := hostAwait .GetMetricLabels (t , hostAwait .RegistrationServiceMetricsURL , wait .RegistrationServiceShortCommitMetric )
122+
123+ // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
124+ require .Len (t , labels , 1 )
125+ commit := labels [0 ]["commit" ]
126+ assert .Len (t , commit , 7 )
127+ })
128+ })
129+
78130}
79131
80132// TestMetricsWhenUsersManuallyApproved verifies that `UserSignupsApprovedMetric` and `UserSignupsApprovedWithMethodMetric` counters are increased when users are approved
0 commit comments