Skip to content

Commit 3a5fa54

Browse files
Tests
1 parent 235f26d commit 3a5fa54

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

knowledge/internal/datasources/monitor_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ func TestMonitorDescribe(t *testing.T) {
8282

8383
func TestMonitorCollect(t *testing.T) {
8484
monitor := NewSyncMonitor()
85+
86+
// Add some data to the metrics so they will be collected
87+
monitor.PipelineRunTimer.WithLabelValues("test").Observe(1.0)
88+
monitor.PipelineObjectsGauge.WithLabelValues("test").Set(10)
89+
monitor.PipelineRequestTimer.WithLabelValues("test").Observe(0.5)
90+
monitor.PipelineRequestProcessedCounter.WithLabelValues("test").Inc()
91+
8592
ch := make(chan prometheus.Metric, 20)
8693

8794
go func() {
@@ -281,6 +288,12 @@ func TestMultipleDatasourceLabels(t *testing.T) {
281288
func TestMonitorMetricNames(t *testing.T) {
282289
monitor := NewSyncMonitor()
283290

291+
// Add some data to the metrics so they will show up in the registry
292+
monitor.PipelineRunTimer.WithLabelValues("test").Observe(1.0)
293+
monitor.PipelineObjectsGauge.WithLabelValues("test").Set(10)
294+
monitor.PipelineRequestTimer.WithLabelValues("test").Observe(0.5)
295+
monitor.PipelineRequestProcessedCounter.WithLabelValues("test").Inc()
296+
284297
// Test that all metrics have the expected names by checking metric families
285298
registry := prometheus.NewRegistry()
286299
registry.MustRegister(&monitor)

knowledge/internal/datasources/openstack/controller_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ func TestPlacementDatasourceTypeConstants(t *testing.T) {
131131
func TestOpenStackDatasourceSpec(t *testing.T) {
132132
// Test creating a complete Nova datasource spec
133133
spec := v1alpha1.DatasourceSpec{
134-
Operator: "test-operator",
135-
Type: v1alpha1.DatasourceTypeOpenStack,
134+
Type: v1alpha1.DatasourceTypeOpenStack,
136135
OpenStack: v1alpha1.OpenStackDatasource{
137136
Type: v1alpha1.OpenStackDatasourceTypeNova,
138137
Nova: v1alpha1.NovaDatasource{
@@ -173,7 +172,6 @@ func TestOpenStackDatasourceSpec(t *testing.T) {
173172

174173
func TestManilaDatasourceSpec(t *testing.T) {
175174
spec := v1alpha1.DatasourceSpec{
176-
Type: v1alpha1.DatasourceTypeOpenStack,
177175
OpenStack: v1alpha1.OpenStackDatasource{
178176
Type: v1alpha1.OpenStackDatasourceTypeManila,
179177
Manila: v1alpha1.ManilaDatasource{
@@ -198,7 +196,6 @@ func TestManilaDatasourceSpec(t *testing.T) {
198196

199197
func TestPlacementDatasourceSpec(t *testing.T) {
200198
spec := v1alpha1.DatasourceSpec{
201-
Type: v1alpha1.DatasourceTypeOpenStack,
202199
OpenStack: v1alpha1.OpenStackDatasource{
203200
Type: v1alpha1.OpenStackDatasourceTypePlacement,
204201
Placement: v1alpha1.PlacementDatasource{
@@ -223,7 +220,6 @@ func TestPlacementDatasourceSpec(t *testing.T) {
223220

224221
func TestIdentityDatasourceSpec(t *testing.T) {
225222
spec := v1alpha1.DatasourceSpec{
226-
Type: v1alpha1.DatasourceTypeOpenStack,
227223
OpenStack: v1alpha1.OpenStackDatasource{
228224
Type: v1alpha1.OpenStackDatasourceTypeIdentity,
229225
Identity: v1alpha1.IdentityDatasource{
@@ -248,7 +244,6 @@ func TestIdentityDatasourceSpec(t *testing.T) {
248244

249245
func TestLimesDatasourceSpec(t *testing.T) {
250246
spec := v1alpha1.DatasourceSpec{
251-
Type: v1alpha1.DatasourceTypeOpenStack,
252247
OpenStack: v1alpha1.OpenStackDatasource{
253248
Type: v1alpha1.OpenStackDatasourceTypeLimes,
254249
Limes: v1alpha1.LimesDatasource{
@@ -273,7 +268,6 @@ func TestLimesDatasourceSpec(t *testing.T) {
273268

274269
func TestCinderDatasourceSpec(t *testing.T) {
275270
spec := v1alpha1.DatasourceSpec{
276-
Type: v1alpha1.DatasourceTypeOpenStack,
277271
OpenStack: v1alpha1.OpenStackDatasource{
278272
Type: v1alpha1.OpenStackDatasourceTypeCinder,
279273
Cinder: v1alpha1.CinderDatasource{

0 commit comments

Comments
 (0)