From 8b7eeaae457b1c770c882426c7641b677aee2c3c Mon Sep 17 00:00:00 2001 From: RealAnna Date: Thu, 17 Nov 2022 12:22:16 +0100 Subject: [PATCH] test: renamed Signed-off-by: RealAnna --- operator/api/v1alpha1/common/common.go | 27 ------------------- .../controllers/keptnapp/controller_test.go | 2 +- .../keptnappversion/controller_test.go | 21 ++++++++++++--- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/operator/api/v1alpha1/common/common.go b/operator/api/v1alpha1/common/common.go index 6b191abcec..182975445b 100644 --- a/operator/api/v1alpha1/common/common.go +++ b/operator/api/v1alpha1/common/common.go @@ -2,8 +2,6 @@ package common import ( "fmt" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/sdk/metric" "math/rand" "go.opentelemetry.io/otel/attribute" @@ -175,28 +173,3 @@ type GaugeFloatValue struct { Value float64 Attributes []attribute.KeyValue } - -func InitKeptnMeters() KeptnMeters { - provider := metric.NewMeterProvider() - meter := provider.Meter("keptn/task") - deploymentCount, _ := meter.SyncInt64().Counter("keptn.deployment.count", instrument.WithDescription("a simple counter for Keptn Deployments")) - deploymentDuration, _ := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn Deployments"), instrument.WithUnit("s")) - taskCount, _ := meter.SyncInt64().Counter("keptn.task.count", instrument.WithDescription("a simple counter for Keptn Tasks")) - taskDuration, _ := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn Tasks"), instrument.WithUnit("s")) - appCount, _ := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) - appDuration, _ := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit("s")) - evaluationCount, _ := meter.SyncInt64().Counter("keptn.evaluation.count", instrument.WithDescription("a simple counter for Keptn Evaluations")) - evaluationDuration, _ := meter.SyncFloat64().Histogram("keptn.evaluation.duration", instrument.WithDescription("a histogram of duration for Keptn Evaluations"), instrument.WithUnit("s")) - - meters := KeptnMeters{ - TaskCount: taskCount, - TaskDuration: taskDuration, - DeploymentCount: deploymentCount, - DeploymentDuration: deploymentDuration, - AppCount: appCount, - AppDuration: appDuration, - EvaluationCount: evaluationCount, - EvaluationDuration: evaluationDuration, - } - return meters -} diff --git a/operator/controllers/keptnapp/controller_test.go b/operator/controllers/keptnapp/controller_test.go index bbd999201a..aea95e8a37 100644 --- a/operator/controllers/keptnapp/controller_test.go +++ b/operator/controllers/keptnapp/controller_test.go @@ -43,7 +43,7 @@ func TestKeptnAppReconciler_createAppVersionSuccess(t *testing.T) { } -func TestKeptnAppReconciler_Reconcile(t *testing.T) { +func TestKeptnAppReconciler_reconcile(t *testing.T) { r, eventChannel, tracer := setupReconciler(t) diff --git a/operator/controllers/keptnappversion/controller_test.go b/operator/controllers/keptnappversion/controller_test.go index 4c55398fcc..55ee489520 100644 --- a/operator/controllers/keptnappversion/controller_test.go +++ b/operator/controllers/keptnappversion/controller_test.go @@ -7,6 +7,8 @@ import ( keptncommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" "github.com/keptn/lifecycle-toolkit/operator/controllers/common/fake" "github.com/magiconair/properties/assert" + "go.opentelemetry.io/otel/metric/instrument" + "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/trace" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" @@ -20,7 +22,7 @@ import ( ) // this test checks if the chain of reconcile events is correct -func TestKeptnApVersionReconciler_Reconcile(t *testing.T) { +func TestKeptnApVersionReconciler_reconcile(t *testing.T) { r, eventChannel, tracer, _ := setupReconciler(t) @@ -160,12 +162,12 @@ func setupReconciler(t *testing.T) (*KeptnAppVersionReconciler, chan string, *fa Log: ctrl.Log.WithName("test-appVersionController"), Tracer: tr, SpanHandler: spanRecorder, - Meters: keptncommon.InitKeptnMeters(), + Meters: InitAppMeters(), } return r, recorder.Events, tr, spanRecorder } -func Test_setupSpansContexts(t *testing.T) { +func TestKeptnApVersionReconciler_setupSpansContexts(t *testing.T) { r, _, _, _ := setupReconciler(t) type args struct { @@ -201,3 +203,16 @@ func Test_setupSpansContexts(t *testing.T) { }) } } + +func InitAppMeters() keptncommon.KeptnMeters { + provider := metric.NewMeterProvider() + meter := provider.Meter("keptn/task") + appCount, _ := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) + appDuration, _ := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit("s")) + + meters := keptncommon.KeptnMeters{ + AppCount: appCount, + AppDuration: appDuration, + } + return meters +}