Skip to content

Commit

Permalink
test: renamed
Browse files Browse the repository at this point in the history
Signed-off-by: RealAnna <[email protected]>
  • Loading branch information
RealAnna committed Nov 21, 2022
1 parent 65cac8d commit 8b7eeaa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
27 changes: 0 additions & 27 deletions operator/api/v1alpha1/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion operator/controllers/keptnapp/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 18 additions & 3 deletions operator/controllers/keptnappversion/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

0 comments on commit 8b7eeaa

Please sign in to comment.