diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index 85adfaef71d..aba1af4aa25 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -47,7 +47,10 @@ type E2EStorageIntegration struct { // This function should be called before any of the tests start. func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { logger := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())) - configFile := createStorageCleanerConfig(t, s.SkipStorageCleaner,s.ConfigFile, storage) + configFile := s.ConfigFile + if !s.SkipStorageCleaner { + configFile = createStorageCleanerConfig(t, s.ConfigFile, storage) + } t.Logf("Starting Jaeger-v2 in the background with config file %s", configFile) outFile, err := os.OpenFile( @@ -125,44 +128,28 @@ func (s *E2EStorageIntegration) e2eCleanUp(t *testing.T) { require.NoError(t, s.SpanWriter.(io.Closer).Close()) } -func createStorageCleanerConfig(t *testing.T, SkipStorageCleaner bool, configFile string, storage string) string { +func createStorageCleanerConfig(t *testing.T, configFile string, storage string) string { data, err := os.ReadFile(configFile) require.NoError(t, err) - var config map[string]any err = yaml.Unmarshal(data, &config) require.NoError(t, err) - // Ensure extensions are correctly parsed before any modifications + serviceAny, ok := config["service"] + require.True(t, ok) + service := serviceAny.(map[string]any) + service["extensions"] = append(service["extensions"].([]any), "storage_cleaner") + extensionsAny, ok := config["extensions"] require.True(t, ok) extensions := extensionsAny.(map[string]any) + queryAny, ok := extensions["jaeger_query"] + require.True(t, ok) + traceStorageAny, ok := queryAny.(map[string]any)["trace_storage"] + require.True(t, ok) + traceStorage := traceStorageAny.(string) + extensions["storage_cleaner"] = map[string]string{"trace_storage": traceStorage} - - if !SkipStorageCleaner{ - // Add storage_cleaner to the service extensions - serviceAny, ok := config["service"] - require.True(t, ok) - service := serviceAny.(map[string]any) - - // Ensure the extensions key is present and is a slice - if extList, ok := service["extensions"].([]any); ok { - service["extensions"] = append(extList, "storage_cleaner") - } else { - service["extensions"] = []any{"storage_cleaner"} - } - - // Ensure jaeger_query is correctly parsed - queryAny, ok := extensions["jaeger_query"] - require.True(t, ok) - query := queryAny.(map[string]any) - trace_storage, ok := query["trace_storage"].(string) - require.True(t, ok) - - extensions["storage_cleaner"] = map[string]string{"trace_storage": trace_storage} - } - - // Ensure jaeger_storage is correctly parsed jaegerStorageAny, ok := extensions["jaeger_storage"] require.True(t, ok) jaegerStorage := jaegerStorageAny.(map[string]any) @@ -207,4 +194,4 @@ func purge(t *testing.T) { require.NoError(t, err) require.Equal(t, http.StatusOK, resp.StatusCode, "body: %s", string(body)) -} +} \ No newline at end of file diff --git a/cmd/jaeger/internal/integration/e2e_integration_test.go b/cmd/jaeger/internal/integration/e2e_integration_test.go index d8a8e8c581d..1fd1318c5da 100644 --- a/cmd/jaeger/internal/integration/e2e_integration_test.go +++ b/cmd/jaeger/internal/integration/e2e_integration_test.go @@ -8,6 +8,6 @@ import "testing" func TestCreateStorageCleanerConfig(t *testing.T) { // Ensure that we can parse the existing configs correctly. // This is faster to run than the full integration test. - createStorageCleanerConfig(t, false,"../../config-elasticsearch.yaml", "elasticsearch") - createStorageCleanerConfig(t, false, "../../config-opensearch.yaml", "opensearch") + createStorageCleanerConfig(t,"../../config-elasticsearch.yaml", "elasticsearch") + createStorageCleanerConfig(t, "../../config-opensearch.yaml", "opensearch") } diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index d47a0a34f0f..9bda6ea2e65 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -18,10 +18,6 @@ func TestKafkaStorage(t *testing.T) { collector := &E2EStorageIntegration{ SkipStorageCleaner: true, ConfigFile: collectorConfig, - StorageIntegration: integration.StorageIntegration{ - GetDependenciesReturnsSource: true, - SkipArchiveTest: true, - }, } // Initialize and start the collector