Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
update tests for operator
patcher93e3a11135a8d
diff --git a/.github/workflows/operator-tests.yml b/.github/workflows/operator-tests.ymlindex 5eeb4931..10a69984 100644--- a/.github/workflows/operator-tests.yml+++ b/.github/workflows/operator-tests.yml@@ -1,4 +1,4 @@-name: Operator Tests+name: Test Operatoron:push:diff --git a/operator/internal/testing/edge_cases_test.go b/operator/internal/testing/edge_cases_test.goindex eddd0973..9c10299d 100644--- a/operator/internal/testing/edge_cases_test.go+++ b/operator/internal/testing/edge_cases_test.go@@ -11,15 +11,17 @@ import ("github.com/stretchr/testify/suite"admissionv1 "k8s.io/api/admission/v1"corev1 "k8s.io/api/core/v1"+ "k8s.io/apimachinery/pkg/api/resource"metav1 "k8s.io/apimachinery/pkg/apis/meta/v1""k8s.io/apimachinery/pkg/runtime""k8s.io/apimachinery/pkg/types"+ dynamicfake "k8s.io/client-go/dynamic/fake""sigs.k8s.io/controller-runtime/pkg/client/fake""sigs.k8s.io/controller-runtime/pkg/webhook/admission"autoinstrumentationv1alpha1 "github.com/openlit/openlit/operator/api/v1alpha1"+ "github.com/openlit/openlit/operator/internal/config""github.com/openlit/openlit/operator/internal/injector"- "github.com/openlit/openlit/operator/internal/observability""github.com/openlit/openlit/operator/internal/webhook")@@ -47,14 +49,20 @@ func (suite *EdgeCasesTestSuite) TestExtremeConfigurationValues() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "test"},},- Environment: map[string]string{- "VERY_LONG_VARIABLE": string(make([]byte, 10000)), // 10KB value- "NORMAL_VARIABLE": "normal-value",+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },+ Resource: &autoinstrumentationv1alpha1.ResourceConfig{+ Environment: "test",},},},@@ -69,11 +77,18 @@ func (suite *EdgeCasesTestSuite) TestExtremeConfigurationValues() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: generateManyLabels(100), // 100 label selectors},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},},expectValid: true,@@ -87,8 +102,6 @@ func (suite *EdgeCasesTestSuite) TestExtremeConfigurationValues() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app.kubernetes.io/name": "my-app",@@ -96,6 +109,15 @@ func (suite *EdgeCasesTestSuite) TestExtremeConfigurationValues() {"custom.domain.com/component": "web-server",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},},expectValid: true,@@ -126,15 +148,14 @@ func (suite *EdgeCasesTestSuite) TestPodResourceExtremes() {scheme := runtime.NewScheme()_ = corev1.AddToScheme(scheme)_ = autoinstrumentationv1alpha1.AddToScheme(scheme)- fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build()- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",+ // Create mock config and dynamic client+ cfg := &config.OperatorConfig{+ Namespace: "test-namespace",}+ dynamicClient := dynamicfake.NewSimpleDynamicClient(scheme)- handler := webhook.NewHandler(fakeClient, loggerProvider)+ handler := webhook.NewHandler(cfg, scheme, dynamicClient)tests := []struct {name string@@ -271,20 +292,18 @@ func (suite *EdgeCasesTestSuite) TestPodResourceExtremes() {}func (suite *EdgeCasesTestSuite) TestInjectorEdgeCases() {- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }-config := &injector.InjectorConfig{+ Provider: "openlit",+ OTLPEndpoint: "http://test:4318",+ InitContainerImage: "ghcr.io/openlit/openlit-ai-instrumentation:latest",+ ImagePullPolicy: "IfNotPresent",ServiceName: "test-service",ServiceNamespace: "default",SharedVolumeName: "test-volume",SharedVolumePath: "/test/path",}- inj := injector.NewOpenLitInjector(config, loggerProvider)+ inj := injector.New(config)tests := []struct {name string@@ -409,13 +428,13 @@ func (suite *EdgeCasesTestSuite) TestConcurrencyAndRaceConditions() {_ = autoinstrumentationv1alpha1.AddToScheme(scheme)fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build()- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",+ // Create mock config and dynamic client+ cfg := &config.OperatorConfig{+ Namespace: "test-namespace",}+ dynamicClient := dynamicfake.NewSimpleDynamicClient(scheme)- handler := webhook.NewHandler(fakeClient, loggerProvider)+ handler := webhook.NewHandler(cfg, scheme, dynamicClient)// Create AutoInstrumentation for concurrent testsautoInstr := &autoinstrumentationv1alpha1.AutoInstrumentation{@@ -424,13 +443,20 @@ func (suite *EdgeCasesTestSuite) TestConcurrencyAndRaceConditions() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"test": "concurrent",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -509,11 +535,6 @@ func (suite *EdgeCasesTestSuite) TestConcurrencyAndRaceConditions() {func (suite *EdgeCasesTestSuite) TestMemoryAndResourceUsage() {// Test operations under resource constraints- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }suite.Run("Large object processing", func() {// Create very large pod specification@@ -536,7 +557,7 @@ func (suite *EdgeCasesTestSuite) TestMemoryAndResourceUsage() {SharedVolumePath: "/test/path",}- inj := injector.NewOpenLitInjector(config, loggerProvider)+ inj := injector.New(config)// This should not cause memory issues or crasheserr := inj.InjectOpenLIT(largePod)@@ -572,7 +593,7 @@ func (suite *EdgeCasesTestSuite) TestMemoryAndResourceUsage() {SharedVolumePath: "/test/path",}- inj := injector.NewOpenLitInjector(config, loggerProvider)+ inj := injector.New(config)// Should fail due to security constraints but not leak memoryerr := inj.InjectOpenLIT(pod)@@ -592,12 +613,7 @@ func (suite *EdgeCasesTestSuite) TestBoundaryConditions() {// Should handle empty configuration gracefullysuite.NotPanics(func() {- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }- _ = injector.NewOpenLitInjector(config, loggerProvider)+ _ = injector.New(config)})})@@ -621,19 +637,17 @@ func (suite *EdgeCasesTestSuite) TestBoundaryConditions() {}config := &injector.InjectorConfig{+ Provider: "openlit",+ OTLPEndpoint: "http://test:4318",+ InitContainerImage: "ghcr.io/openlit/openlit-ai-instrumentation:latest",+ ImagePullPolicy: "IfNotPresent",ServiceName: "test-service",ServiceNamespace: "default",SharedVolumeName: "test-volume",SharedVolumePath: "/test/path",}- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }-- inj := injector.NewOpenLitInjector(config, loggerProvider)+ inj := injector.New(config)_ = inj.InjectOpenLIT(pod)})})@@ -676,34 +690,27 @@ func generateManyEnvVars(count int) []corev1.EnvVar {return envVars}-func mustParseQuantity(s string) *metav1.Quantity {- q := &metav1.Quantity{}- *q = *mustParseQuantityHelper(s)- return q-}--func mustParseQuantityHelper(s string) *metav1.Quantity {- q, err := metav1.ParseQuantity(s)+func mustParseQuantity(s string) resource.Quantity {+ q, err := resource.ParseQuantity(s)if err != nil {panic(err)}- return &q+ return q}// Additional edge case tests for specific scenariosfunc TestCircuitBreakerEdgeCases(t *testing.T) {// Test circuit breaker under extreme conditions- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }-scheme := runtime.NewScheme()_ = corev1.AddToScheme(scheme)- fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build()- handler := webhook.NewHandler(fakeClient, loggerProvider)+ // Create mock config and dynamic client+ cfg := &config.OperatorConfig{+ Namespace: "test-namespace",+ }+ dynamicClient := dynamicfake.NewSimpleDynamicClient(scheme)++ handler := webhook.NewHandler(cfg, scheme, dynamicClient)// Test rapid failure recoveryfor i := 0; i < 100; i++ {@@ -747,22 +754,20 @@ func TestCircuitBreakerEdgeCases(t *testing.T) {func TestContextCancellationHandling(t *testing.T) {// Test behavior when context is cancelled during operations- ctx, cancel := context.WithCancel(context.Background())-- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }+ _, cancel := context.WithCancel(context.Background())config := &injector.InjectorConfig{+ Provider: "openlit",+ OTLPEndpoint: "http://test:4318",+ InitContainerImage: "ghcr.io/openlit/openlit-ai-instrumentation:latest",+ ImagePullPolicy: "IfNotPresent",ServiceName: "test-service",ServiceNamespace: "default",SharedVolumeName: "test-volume",SharedVolumePath: "/test/path",}- inj := injector.NewOpenLitInjector(config, loggerProvider)+ inj := injector.New(config)// Cancel context before injectioncancel()diff --git a/operator/internal/testing/integration_test.go b/operator/internal/testing/integration_test.goindex 83783cd8..3a44ab20 100644--- a/operator/internal/testing/integration_test.go+++ b/operator/internal/testing/integration_test.go@@ -12,15 +12,13 @@ import (metav1 "k8s.io/apimachinery/pkg/apis/meta/v1""k8s.io/apimachinery/pkg/runtime""k8s.io/apimachinery/pkg/types"- "sigs.k8s.io/controller-runtime/pkg/client"+ dynamicfake "k8s.io/client-go/dynamic/fake""sigs.k8s.io/controller-runtime/pkg/reconcile""sigs.k8s.io/controller-runtime/pkg/webhook/admission"autoinstrumentationv1alpha1 "github.com/openlit/openlit/operator/api/v1alpha1"+ "github.com/openlit/openlit/operator/internal/config""github.com/openlit/openlit/operator/internal/controller"- "github.com/openlit/openlit/operator/internal/injector"- "github.com/openlit/openlit/operator/internal/observability"- "github.com/openlit/openlit/operator/internal/validation""github.com/openlit/openlit/operator/internal/webhook")@@ -36,21 +34,15 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {testSuite = SetupTestSuite()ctx = testSuite.Ctx- // Create mock logger provider- loggerProvider := MockLoggerProvider()-- // Create validator- validator := validation.NewAutoInstrumentationValidator()-- // Create controller- reconciler = &controller.AutoInstrumentationReconciler{- Client: testSuite.Client,- Scheme: testSuite.Client.Scheme(),- Validator: validator,- }+ // Create controller - use the proper constructor+ reconciler = controller.NewAutoInstrumentationReconciler(testSuite.Client, testSuite.Client.Scheme())// Create webhook handler- webhookHandler = webhook.NewHandler(testSuite.Client, loggerProvider)+ cfg := &config.OperatorConfig{+ Namespace: "test-namespace",+ }+ dynamicClient := dynamicfake.NewSimpleDynamicClient(testSuite.Client.Scheme())+ webhookHandler = webhook.NewHandler(cfg, testSuite.Client.Scheme(), dynamicClient)})AfterEach(func() {@@ -66,16 +58,22 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "python-web-app",},},- Environment: map[string]string{- "OTEL_EXPORTER_OTLP_ENDPOINT": "http://openlit.default.svc.cluster.local:4318",- "OPENLIT_APPLICATION_NAME": "e2e-test-app",+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://openlit.default.svc.cluster.local:4318",+ },+ Resource: &autoinstrumentationv1alpha1.ResourceConfig{+ Environment: "e2e-test",},},}@@ -99,7 +97,7 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {retrieved := &autoinstrumentationv1alpha1.AutoInstrumentation{}err = testSuite.Client.Get(ctx, req.NamespacedName, retrieved)Expect(err).NotTo(HaveOccurred())- Expect(retrieved.Spec.Provider).To(Equal("openlit"))+ Expect(retrieved.Spec.Python.Instrumentation.Provider).To(Equal("openlit"))By("Creating a pod that matches the selector")pod := &corev1.Pod{@@ -180,13 +178,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "python-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },Ignore: &autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"instrumentation": "skip",@@ -263,13 +268,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"language": "python",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -279,13 +291,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"type": "web-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -362,13 +381,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:v1.0.0",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "test-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:v1.0.0",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -390,10 +416,11 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {err = testSuite.Client.Get(ctx, req.NamespacedName, retrieved)Expect(err).NotTo(HaveOccurred())- retrieved.Spec.Image = "openlit-instrumentation:v2.0.0"- retrieved.Spec.Environment = map[string]string{- "NEW_CONFIG": "updated-value",+ retrieved.Spec.Python.Instrumentation.CustomInitImage = "openlit-instrumentation:v2.0.0"+ if retrieved.Spec.Resource == nil {+ retrieved.Spec.Resource = &autoinstrumentationv1alpha1.ResourceConfig{}}+ retrieved.Spec.Resource.Environment = "updated-env"err = testSuite.Client.Update(ctx, retrieved)Expect(err).NotTo(HaveOccurred())@@ -406,8 +433,8 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {final := &autoinstrumentationv1alpha1.AutoInstrumentation{}err = testSuite.Client.Get(ctx, req.NamespacedName, final)Expect(err).NotTo(HaveOccurred())- Expect(final.Spec.Image).To(Equal("openlit-instrumentation:v2.0.0"))- Expect(final.Spec.Environment["NEW_CONFIG"]).To(Equal("updated-value"))+ Expect(final.Spec.Python.Instrumentation.CustomInitImage).To(Equal("openlit-instrumentation:v2.0.0"))+ Expect(final.Spec.Resource.Environment).To(Equal("updated-env"))})It("should handle AutoInstrumentation deletion", func() {@@ -418,13 +445,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "temp-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -466,9 +500,16 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",- // Missing selector+ // Missing selector - this should cause validation errors+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -571,13 +612,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "multi-container-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -655,13 +703,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "secure-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -737,13 +792,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"test": "concurrent",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}@@ -823,13 +885,20 @@ var _ = Describe("OpenLIT Operator Integration Tests", func() {Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"perf": "test",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},}diff --git a/operator/internal/testing/suite.go b/operator/internal/testing/suite.goindex cf6e449e..87e088a9 100644--- a/operator/internal/testing/suite.go+++ b/operator/internal/testing/suite.go@@ -10,7 +10,6 @@ import (. "github.com/onsi/gomega""k8s.io/client-go/kubernetes/scheme""k8s.io/client-go/rest"- ctrl "sigs.k8s.io/controller-runtime""sigs.k8s.io/controller-runtime/pkg/client""sigs.k8s.io/controller-runtime/pkg/envtest"logf "sigs.k8s.io/controller-runtime/pkg/log"diff --git a/operator/internal/validation/autoinstrumentation_test.go b/operator/internal/validation/autoinstrumentation_test.goindex 37af6236..1929fa15 100644--- a/operator/internal/validation/autoinstrumentation_test.go+++ b/operator/internal/validation/autoinstrumentation_test.go@@ -8,7 +8,6 @@ import (metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"autoinstrumentationv1alpha1 "github.com/openlit/openlit/operator/api/v1alpha1"- "github.com/openlit/openlit/operator/internal/observability")type AutoInstrumentationValidatorTestSuite struct {@@ -17,16 +16,8 @@ type AutoInstrumentationValidatorTestSuite struct {}func (suite *AutoInstrumentationValidatorTestSuite) SetupTest() {- // Create mock logger provider- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }-- suite.validator = &AutoInstrumentationValidator{- logger: loggerProvider.GetLogger("validation"),- }+ // Create validator using the proper constructor+ suite.validator = NewAutoInstrumentationValidator()}func (suite *AutoInstrumentationValidatorTestSuite) TestValidateValidConfiguration() {@@ -36,16 +27,22 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateValidConfiguratiNamespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "python-app",},},- Environment: map[string]string{- "OTEL_EXPORTER_OTLP_ENDPOINT": "http://openlit.default.svc.cluster.local:4318",- "OPENLIT_APPLICATION_NAME": "test-app",+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://openlit.default.svc.cluster.local:4318",+ },+ Resource: &autoinstrumentationv1alpha1.ResourceConfig{+ Environment: "test",},},}@@ -72,11 +69,18 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateRequiredFields()Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{// Empty selector},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},},expectedErrors: []string{@@ -92,13 +96,20 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateRequiredFields()Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "python-app",},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},},expectedErrors: []string{},@@ -112,8 +123,6 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateRequiredFields()Namespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchExpressions: []metav1.LabelSelectorRequirement{{@@ -123,6 +132,15 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateRequiredFields()},},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },},},expectedErrors: []string{},@@ -332,10 +350,8 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateEnvironmentVariaValue: "direct-value",ValueFrom: &autoinstrumentationv1alpha1.EnvVarSource{SecretKeyRef: &autoinstrumentationv1alpha1.SecretKeySelector{- LocalObjectReference: autoinstrumentationv1alpha1.LocalObjectReference{- Name: "secret",- },- Key: "key",+ Name: "secret",+ Key: "key",},},},@@ -366,10 +382,8 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateEnvironmentVariaName: "DB_PASSWORD",ValueFrom: &autoinstrumentationv1alpha1.EnvVarSource{SecretKeyRef: &autoinstrumentationv1alpha1.SecretKeySelector{- LocalObjectReference: autoinstrumentationv1alpha1.LocalObjectReference{- Name: "db-secret",- },- Key: "password",+ Name: "db-secret",+ Key: "password",},},},@@ -474,10 +488,8 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestValidateOTLPConfig() {name: "Valid OTLP configuration",otlp: autoinstrumentationv1alpha1.OTLPConfig{Endpoint: "http://openlit.default.svc.cluster.local:4318",- Headers: map[string]string{- "Authorization": "Bearer token123",- },- Timeout: &[]int32{30}[0],+ Headers: "Authorization=Bearer token123",+ Timeout: &[]int32{30}[0],},expectedErrors: []string{},expectedWarnings: []string{},@@ -616,11 +628,18 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestComplexValidationScenariNamespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{// Empty selector - error},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "http://test:4318",+ },Ignore: &autoinstrumentationv1alpha1.PodSelector{// Empty ignore - warning},@@ -639,8 +658,6 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestComplexValidationScenariNamespace: "default",},Spec: autoinstrumentationv1alpha1.AutoInstrumentationSpec{- Provider: "openlit",- Image: "openlit-instrumentation:latest",Selector: autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"app": "python-app",@@ -653,16 +670,23 @@ func (suite *AutoInstrumentationValidatorTestSuite) TestComplexValidationScenari},},},+ Python: &autoinstrumentationv1alpha1.PythonInstrumentation{+ Instrumentation: &autoinstrumentationv1alpha1.InstrumentationSettings{+ Provider: "openlit",+ CustomInitImage: "openlit-instrumentation:latest",+ },+ },+ OTLP: autoinstrumentationv1alpha1.OTLPConfig{+ Endpoint: "https://otlp.example.com",+ },+ Resource: &autoinstrumentationv1alpha1.ResourceConfig{+ Environment: "production",+ },Ignore: &autoinstrumentationv1alpha1.PodSelector{MatchLabels: map[string]string{"skip-instrumentation": "true",},},- Environment: map[string]string{- "OPENLIT_APPLICATION_NAME": "complex-app",- "OPENLIT_ENVIRONMENT": "production",- "OTEL_EXPORTER_OTLP_ENDPOINT": "https://otlp.example.com",- },},},expectValid: true,@@ -699,13 +723,11 @@ func TestGetValidationAttributes(t *testing.T) {assert.NotNil(t, resource)attrs := resource.Attributes()- iterator := attrs.Iter()foundServiceName := falsefoundServiceVersion := false- for iterator.Next() {- kv := iterator.Attribute()+ for _, kv := range attrs {switch kv.Key {case "service.name":assert.Equal(t, "openlit-operator-validation", kv.Value.AsString())@@ -734,15 +756,8 @@ func TestValidationResultInitialization(t *testing.T) {func TestValidationErrorHandling(t *testing.T) {// Test that validator handles nil configurations gracefully- loggerProvider := &observability.LoggerProvider{- OTLPEnabled: false,- OTLPEndpoint: "",- ErrorMessage: "",- }-- validator := &AutoInstrumentationValidator{- logger: loggerProvider.GetLogger("validation"),- }+ // Create validator using the proper constructor+ validator := NewAutoInstrumentationValidator()// This should not panic even with a minimal configurationautoInstr := &autoinstrumentationv1alpha1.AutoInstrumentation{