From f02e2fcf8e631319b68695ad4f981fc9614f5dd1 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Wed, 3 Jul 2024 15:30:23 +0530 Subject: [PATCH 01/28] Add configs for collector and ingester Signed-off-by: joeyyy09 --- cmd/jaeger/collector-with-kafka.yaml | 30 +++++++++++++++++ .../ingester-remote-backend-storage.yaml | 33 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 cmd/jaeger/collector-with-kafka.yaml create mode 100644 cmd/jaeger/ingester-remote-backend-storage.yaml diff --git a/cmd/jaeger/collector-with-kafka.yaml b/cmd/jaeger/collector-with-kafka.yaml new file mode 100644 index 00000000000..82ae0de2990 --- /dev/null +++ b/cmd/jaeger/collector-with-kafka.yaml @@ -0,0 +1,30 @@ +service: + pipelines: + traces: + receivers: [otlp, jaeger, zipkin] + processors: [batch] + exporters: [kafka] + +receivers: + otlp: + protocols: + grpc: + http: + + jaeger: + protocols: + grpc: + thrift_binary: + thrift_compact: + thrift_http: + + zipkin: + +processors: + batch: + +exporters: + kafka: + brokers: + - localhost:9092 + encoding: otlp_proto \ No newline at end of file diff --git a/cmd/jaeger/ingester-remote-backend-storage.yaml b/cmd/jaeger/ingester-remote-backend-storage.yaml new file mode 100644 index 00000000000..684268a211e --- /dev/null +++ b/cmd/jaeger/ingester-remote-backend-storage.yaml @@ -0,0 +1,33 @@ + +service: + extensions: [jaeger_storage] + pipelines: + traces: + receivers: [kafka] + processors: [batch] + exporters: [jaeger_storage_exporter] + telemetry: + metrics: + address: 0.0.0.0:8889 + +extensions: + jaeger_storage: + grpc: + some-external-storage: + server: localhost:17271 + connection-timeout: 5s + +receivers: + kafka: + brokers: + - localhost:9092 + encoding: otlp_proto + initial_offset: earliest + +processors: + batch: + +exporters: + jaeger_storage_exporter: + trace_storage: some-external-storage + \ No newline at end of file From a728c2e34d4a23e4fa69b6ce07792eeeab7acbac Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Wed, 10 Jul 2024 22:40:37 +0530 Subject: [PATCH 02/28] Update collector config Signed-off-by: joeyyy09 --- cmd/jaeger/collector-with-kafka.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/jaeger/collector-with-kafka.yaml b/cmd/jaeger/collector-with-kafka.yaml index 82ae0de2990..bcc14c46736 100644 --- a/cmd/jaeger/collector-with-kafka.yaml +++ b/cmd/jaeger/collector-with-kafka.yaml @@ -27,4 +27,5 @@ exporters: kafka: brokers: - localhost:9092 + topic: "jaeger-spans" encoding: otlp_proto \ No newline at end of file From fc7da594a48ac9a1bf0a535c8bab252e4cebf16c Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sun, 14 Jul 2024 12:00:15 +0530 Subject: [PATCH 03/28] Update ingester config Signed-off-by: joeyyy09 --- cmd/jaeger/ingester-remote-backend-storage.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/jaeger/ingester-remote-backend-storage.yaml b/cmd/jaeger/ingester-remote-backend-storage.yaml index 684268a211e..842e20ebc0e 100644 --- a/cmd/jaeger/ingester-remote-backend-storage.yaml +++ b/cmd/jaeger/ingester-remote-backend-storage.yaml @@ -1,6 +1,5 @@ - service: - extensions: [jaeger_storage] + extensions: [jaeger_storage, jaeger_query] pipelines: traces: receivers: [kafka] @@ -11,11 +10,14 @@ service: address: 0.0.0.0:8889 extensions: + jaeger_query: + trace_storage: some_storage + jaeger_storage: - grpc: - some-external-storage: - server: localhost:17271 - connection-timeout: 5s + backends: + some_storage: + memory: + max_traces: 100000 receivers: kafka: @@ -29,5 +31,4 @@ processors: exporters: jaeger_storage_exporter: - trace_storage: some-external-storage - \ No newline at end of file + trace_storage: some_storage From 53173c53df36a450e6f53f1cff4302fa308e3832 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sun, 14 Jul 2024 12:01:06 +0530 Subject: [PATCH 04/28] Add initial kafka_test.go Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/kafka_test.go | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cmd/jaeger/internal/integration/kafka_test.go diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go new file mode 100644 index 00000000000..4bfcbd9e766 --- /dev/null +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -0,0 +1,33 @@ +// Copyright (c) 2024 The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 + +package integration + +import ( + "testing" + + "github.com/jaegertracing/jaeger/plugin/storage/integration" +) + +func TestKafkaStorage(t *testing.T) { + integration.SkipUnlessEnv(t, "kafka") + + s := &E2EStorageIntegration{ + ConfigFile: "../../collector-with-kafka.yaml", + StorageIntegration: integration.StorageIntegration{ + CleanUp: purge, + GetDependenciesReturnsSource: true, + SkipArchiveTest: true, + }, + } + + s.e2eInitialize(t, "kafka") + + t.Cleanup(func() { + s.e2eCleanUp(t) + }) + + s.RunSpanStoreTests(t) +} + + From b2133cc7076adba867c8c4ac9644ba94754279d4 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Mon, 15 Jul 2024 12:37:53 +0530 Subject: [PATCH 05/28] Add debug logs in the config Signed-off-by: joeyyy09 --- cmd/jaeger/ingester-remote-backend-storage.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/jaeger/ingester-remote-backend-storage.yaml b/cmd/jaeger/ingester-remote-backend-storage.yaml index 842e20ebc0e..de6d1ad27a1 100644 --- a/cmd/jaeger/ingester-remote-backend-storage.yaml +++ b/cmd/jaeger/ingester-remote-backend-storage.yaml @@ -8,6 +8,8 @@ service: telemetry: metrics: address: 0.0.0.0:8889 + logs: + level: debug extensions: jaeger_query: From 2ccff53c23e777a8ebbcafa735a5460cc625448c Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Mon, 15 Jul 2024 13:27:54 +0530 Subject: [PATCH 06/28] Update conig files for UI Signed-off-by: joeyyy09 --- cmd/jaeger/collector-with-kafka.yaml | 19 ++++++++----------- .../ingester-remote-backend-storage.yaml | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cmd/jaeger/collector-with-kafka.yaml b/cmd/jaeger/collector-with-kafka.yaml index bcc14c46736..5b57bce4cf7 100644 --- a/cmd/jaeger/collector-with-kafka.yaml +++ b/cmd/jaeger/collector-with-kafka.yaml @@ -1,16 +1,8 @@ -service: - pipelines: - traces: - receivers: [otlp, jaeger, zipkin] - processors: [batch] - exporters: [kafka] - receivers: otlp: protocols: grpc: http: - jaeger: protocols: grpc: @@ -18,8 +10,6 @@ receivers: thrift_compact: thrift_http: - zipkin: - processors: batch: @@ -28,4 +18,11 @@ exporters: brokers: - localhost:9092 topic: "jaeger-spans" - encoding: otlp_proto \ No newline at end of file + encoding: otlp_proto + +service: + pipelines: + traces: + receivers: [otlp, jaeger] + processors: [batch] + exporters: [kafka] diff --git a/cmd/jaeger/ingester-remote-backend-storage.yaml b/cmd/jaeger/ingester-remote-backend-storage.yaml index de6d1ad27a1..99863d082b0 100644 --- a/cmd/jaeger/ingester-remote-backend-storage.yaml +++ b/cmd/jaeger/ingester-remote-backend-storage.yaml @@ -2,7 +2,7 @@ service: extensions: [jaeger_storage, jaeger_query] pipelines: traces: - receivers: [kafka] + receivers: [kafka, otlp, jaeger, zipkin] processors: [batch] exporters: [jaeger_storage_exporter] telemetry: @@ -28,6 +28,20 @@ receivers: encoding: otlp_proto initial_offset: earliest + otlp: + protocols: + grpc: + http: + + jaeger: + protocols: + grpc: + thrift_binary: + thrift_compact: + thrift_http: + + zipkin: + processors: batch: From c9c32cc0f707d0fae8602d5c9cc5919bb6614998 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Tue, 16 Jul 2024 11:07:09 +0530 Subject: [PATCH 07/28] Update conig files Signed-off-by: joeyyy09 --- cmd/jaeger/collector-with-kafka.yaml | 14 +++++++------- ...rage.yaml => ingester-remote-storage.yaml} | 19 +++---------------- 2 files changed, 10 insertions(+), 23 deletions(-) rename cmd/jaeger/{ingester-remote-backend-storage.yaml => ingester-remote-storage.yaml} (72%) diff --git a/cmd/jaeger/collector-with-kafka.yaml b/cmd/jaeger/collector-with-kafka.yaml index 5b57bce4cf7..fb16234bc8c 100644 --- a/cmd/jaeger/collector-with-kafka.yaml +++ b/cmd/jaeger/collector-with-kafka.yaml @@ -1,3 +1,10 @@ +service: + pipelines: + traces: + receivers: [otlp, jaeger] + processors: [batch] + exporters: [kafka] + receivers: otlp: protocols: @@ -19,10 +26,3 @@ exporters: - localhost:9092 topic: "jaeger-spans" encoding: otlp_proto - -service: - pipelines: - traces: - receivers: [otlp, jaeger] - processors: [batch] - exporters: [kafka] diff --git a/cmd/jaeger/ingester-remote-backend-storage.yaml b/cmd/jaeger/ingester-remote-storage.yaml similarity index 72% rename from cmd/jaeger/ingester-remote-backend-storage.yaml rename to cmd/jaeger/ingester-remote-storage.yaml index 99863d082b0..2f200c6533a 100644 --- a/cmd/jaeger/ingester-remote-backend-storage.yaml +++ b/cmd/jaeger/ingester-remote-storage.yaml @@ -2,7 +2,7 @@ service: extensions: [jaeger_storage, jaeger_query] pipelines: traces: - receivers: [kafka, otlp, jaeger, zipkin] + receivers: [kafka] processors: [batch] exporters: [jaeger_storage_exporter] telemetry: @@ -21,27 +21,14 @@ extensions: memory: max_traces: 100000 -receivers: +receivers: kafka: brokers: - localhost:9092 + topic: "jaeger-spans" encoding: otlp_proto initial_offset: earliest - otlp: - protocols: - grpc: - http: - - jaeger: - protocols: - grpc: - thrift_binary: - thrift_compact: - thrift_http: - - zipkin: - processors: batch: From 802413a0d8ed544a9b525c39f81cc146d09a2132 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Thu, 18 Jul 2024 15:04:21 +0530 Subject: [PATCH 08/28] Add kafka e2e setup Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/kafka_test.go | 107 ++++++++++++++++-- 1 file changed, 97 insertions(+), 10 deletions(-) diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index 4bfcbd9e766..d99cb4446d5 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -4,30 +4,117 @@ package integration import ( + "context" + "fmt" + "net/http" + "os" + "os/exec" + "path/filepath" "testing" + "time" + + "github.com/stretchr/testify/require" "github.com/jaegertracing/jaeger/plugin/storage/integration" + "github.com/jaegertracing/jaeger/ports" ) +// KafkaCollectorIntegration handles the Jaeger collector with a custom configuration. +type KafkaCollectorIntegration struct { + CollectorConfigFile string + collectorCmd *exec.Cmd +} + +// e2eInitialize starts the Jaeger collector with the provided config file. +func (s *KafkaCollectorIntegration) e2eInitialize(t *testing.T) { + collectorConfigFile := createStorageCleanerConfig(t, s.CollectorConfigFile, "kafka") + + // Start the collector + t.Logf("Starting Jaeger collector in the background with config file %s", collectorConfigFile) + s.startProcess(t, "collector", collectorConfigFile) +} + +func (s *KafkaCollectorIntegration) startProcess(t *testing.T, processType, configFile string) { + outFile, err := os.OpenFile( + filepath.Join(t.TempDir(), fmt.Sprintf("jaeger_%s_output_logs.txt", processType)), + os.O_CREATE|os.O_WRONLY, + os.ModePerm, + ) + require.NoError(t, err) + t.Logf("Writing the Jaeger %s output logs into %s", processType, outFile.Name()) + + errFile, err := os.OpenFile( + filepath.Join(t.TempDir(), fmt.Sprintf("jaeger_%s_error_logs.txt", processType)), + os.O_CREATE|os.O_WRONLY, + os.ModePerm, + ) + require.NoError(t, err) + t.Logf("Writing the Jaeger %s error logs into %s", processType, errFile.Name()) + + cmd := &exec.Cmd{ + Path: fmt.Sprintf("./cmd/jaeger/jaeger-%s", processType), + Args: []string{fmt.Sprintf("jaeger-%s", processType), "--config", configFile}, + Dir: "../../../..", + Stdout: outFile, + Stderr: errFile, + } + require.NoError(t, cmd.Start()) + + require.Eventually(t, func() bool { + url := fmt.Sprintf("http://localhost:%d/", ports.QueryHTTP) + t.Logf("Checking if Jaeger %s is available on %s", processType, url) + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + require.NoError(t, err) + resp, err := http.DefaultClient.Do(req) + if err != nil { + t.Log(err) + return false + } + defer resp.Body.Close() + return resp.StatusCode == http.StatusOK + }, 30*time.Second, 500*time.Millisecond, fmt.Sprintf("Jaeger %s did not start", processType)) + t.Logf("Jaeger %s is ready", processType) + + if processType == "collector" { + s.collectorCmd = cmd + } +} + +// e2eCleanUp stops the processes. +func (s *KafkaCollectorIntegration) e2eCleanUp(t *testing.T) { + if s.collectorCmd != nil { + require.NoError(t, s.collectorCmd.Process.Kill()) + } +} + func TestKafkaStorage(t *testing.T) { integration.SkipUnlessEnv(t, "kafka") - s := &E2EStorageIntegration{ - ConfigFile: "../../collector-with-kafka.yaml", + // Initialize and start the collector + collector := &KafkaCollectorIntegration{ + CollectorConfigFile: "../../collector-with-kafka.yaml", + } + collector.e2eInitialize(t) + t.Cleanup(func() { + collector.e2eCleanUp(t) + }) + + // Reuse E2EStorageIntegration for the ingester + ingester := &E2EStorageIntegration{ + ConfigFile: "../../ingester-remote-storage.yaml", StorageIntegration: integration.StorageIntegration{ - CleanUp: purge, + CleanUp: purge, GetDependenciesReturnsSource: true, SkipArchiveTest: true, }, } - - s.e2eInitialize(t, "kafka") - + ingester.e2eInitialize(t, "kafka") t.Cleanup(func() { - s.e2eCleanUp(t) + ingester.e2eCleanUp(t) }) - s.RunSpanStoreTests(t) + // Run the span store tests + ingester.RunSpanStoreTests(t) } - - From 819ee216e360e21cef59d7370f91f518835bc7fd Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Thu, 18 Jul 2024 21:14:41 +0530 Subject: [PATCH 09/28] Add kafka e2e setup Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/kafka_test.go | 147 +++++------------- 1 file changed, 39 insertions(+), 108 deletions(-) diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index d99cb4446d5..b540b063519 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -4,117 +4,48 @@ package integration import ( - "context" - "fmt" - "net/http" - "os" - "os/exec" - "path/filepath" "testing" - "time" - - "github.com/stretchr/testify/require" "github.com/jaegertracing/jaeger/plugin/storage/integration" - "github.com/jaegertracing/jaeger/ports" ) -// KafkaCollectorIntegration handles the Jaeger collector with a custom configuration. -type KafkaCollectorIntegration struct { - CollectorConfigFile string - collectorCmd *exec.Cmd -} - -// e2eInitialize starts the Jaeger collector with the provided config file. -func (s *KafkaCollectorIntegration) e2eInitialize(t *testing.T) { - collectorConfigFile := createStorageCleanerConfig(t, s.CollectorConfigFile, "kafka") - - // Start the collector - t.Logf("Starting Jaeger collector in the background with config file %s", collectorConfigFile) - s.startProcess(t, "collector", collectorConfigFile) -} - -func (s *KafkaCollectorIntegration) startProcess(t *testing.T, processType, configFile string) { - outFile, err := os.OpenFile( - filepath.Join(t.TempDir(), fmt.Sprintf("jaeger_%s_output_logs.txt", processType)), - os.O_CREATE|os.O_WRONLY, - os.ModePerm, - ) - require.NoError(t, err) - t.Logf("Writing the Jaeger %s output logs into %s", processType, outFile.Name()) - - errFile, err := os.OpenFile( - filepath.Join(t.TempDir(), fmt.Sprintf("jaeger_%s_error_logs.txt", processType)), - os.O_CREATE|os.O_WRONLY, - os.ModePerm, - ) - require.NoError(t, err) - t.Logf("Writing the Jaeger %s error logs into %s", processType, errFile.Name()) - - cmd := &exec.Cmd{ - Path: fmt.Sprintf("./cmd/jaeger/jaeger-%s", processType), - Args: []string{fmt.Sprintf("jaeger-%s", processType), "--config", configFile}, - Dir: "../../../..", - Stdout: outFile, - Stderr: errFile, - } - require.NoError(t, cmd.Start()) - - require.Eventually(t, func() bool { - url := fmt.Sprintf("http://localhost:%d/", ports.QueryHTTP) - t.Logf("Checking if Jaeger %s is available on %s", processType, url) - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) - defer cancel() - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - require.NoError(t, err) - resp, err := http.DefaultClient.Do(req) - if err != nil { - t.Log(err) - return false - } - defer resp.Body.Close() - return resp.StatusCode == http.StatusOK - }, 30*time.Second, 500*time.Millisecond, fmt.Sprintf("Jaeger %s did not start", processType)) - t.Logf("Jaeger %s is ready", processType) - - if processType == "collector" { - s.collectorCmd = cmd - } -} - -// e2eCleanUp stops the processes. -func (s *KafkaCollectorIntegration) e2eCleanUp(t *testing.T) { - if s.collectorCmd != nil { - require.NoError(t, s.collectorCmd.Process.Kill()) - } -} - func TestKafkaStorage(t *testing.T) { - integration.SkipUnlessEnv(t, "kafka") - - // Initialize and start the collector - collector := &KafkaCollectorIntegration{ - CollectorConfigFile: "../../collector-with-kafka.yaml", - } - collector.e2eInitialize(t) - t.Cleanup(func() { - collector.e2eCleanUp(t) - }) - - // Reuse E2EStorageIntegration for the ingester - ingester := &E2EStorageIntegration{ - ConfigFile: "../../ingester-remote-storage.yaml", - StorageIntegration: integration.StorageIntegration{ - CleanUp: purge, - GetDependenciesReturnsSource: true, - SkipArchiveTest: true, - }, - } - ingester.e2eInitialize(t, "kafka") - t.Cleanup(func() { - ingester.e2eCleanUp(t) - }) - - // Run the span store tests - ingester.RunSpanStoreTests(t) -} + integration.SkipUnlessEnv(t, "kafka") + + collectorConfig := "../../collector-with-kafka.yaml" + ingesterConfig := "../../ingester-remote-storage.yaml" + + collector := &E2EStorageIntegration{ + ConfigFile: collectorConfig, + StorageIntegration: integration.StorageIntegration{ + GetDependenciesReturnsSource: true, + SkipArchiveTest: true, + }, + } + + // Initialize and start the collector + collector.e2eInitialize(t, "kafka-collector") + + + ingester := &E2EStorageIntegration{ + ConfigFile: ingesterConfig, + StorageIntegration: integration.StorageIntegration{ + CleanUp: purge, + GetDependenciesReturnsSource: true, + SkipArchiveTest: true, + }, + } + + // Initialize and start the ingester + ingester.e2eInitialize(t, "kafka-ingester") + + // Set up cleanup for both collector and ingester + t.Cleanup(func() { + collector.e2eCleanUp(t) + ingester.e2eCleanUp(t) + }) + + // Run the span store tests for both collector and ingester + collector.RunSpanStoreTests(t) + ingester.RunSpanStoreTests(t) +} \ No newline at end of file From d02136ea9f6c94851c79073fd55bd02ae765e885 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Thu, 18 Jul 2024 23:27:16 +0530 Subject: [PATCH 10/28] Add Readme for Kafka Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/README.md | 50 +++++++++++++++++++++++ plugin/storage/integration/integration.go | 4 +- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/cmd/jaeger/internal/integration/README.md b/cmd/jaeger/internal/integration/README.md index 3c97bfddbd0..ea6370bc014 100644 --- a/cmd/jaeger/internal/integration/README.md +++ b/cmd/jaeger/internal/integration/README.md @@ -63,6 +63,56 @@ flowchart LR end ``` +## Kafka Integration + +The primary difference between the Kafka integration tests and other integration tests lies in the flow of data. In the standard tests, spans are written by the SpanWriter, sent through an RPC_client directly to a receiver, then to an exporter, and stored in an in-memory backend. Spans are read by the SpanReader, which queries the jaeger_query process accessing the storage backend. In contrast, the Kafka tests introduce Kafka as an intermediary. Spans go from the SpanWriter through an RPC_client to an OTLP receiver in the Jaeger Collector, exported to Kafka, received by the Jaeger Ingester, and then stored. For details, see the [Architecture](#KafkaArchitecture) section below. + + +## Kafka Architecture + +``` mermaid +flowchart LR + Test -->|writeSpan| SpanWriter + SpanWriter --> RPCW[RPC_client] + RPCW --> OTLP_Receiver[Receiver] + OTLP_Receiver --> CollectorExporter[Kafka Exporter] + CollectorExporter --> Kafka[Kafka] + Kafka --> IngesterReceiver[Kafka Receiver] + IngesterReceiver --> IngesterExporter[Exporter] + IngesterExporter --> StorageBackend[(In-Memory Store)] + Test -->|readSpan| SpanReader + SpanReader --> RPCR[RPC_client] + RPCR --> QueryProcess[jaeger_query] + QueryProcess --> StorageBackend + IngesterExporter -.-> StorageCleaner + StorageCleaner --> StorageBackend + + subgraph Integration_Test_Executable + Test + SpanWriter + SpanReader + RPCW + RPCR + end + + subgraph Jaeger Collector + OTLP_Receiver + CollectorExporter + end + + subgraph Jaeger Ingester + IngesterReceiver + IngesterExporter + QueryProcess + StorageBackend + StorageCleaner[Storage Cleaner Extension] + end + + subgraph Kafka Buffer + Kafka + end +``` + ## Running tests locally All integration tests can be run locally. diff --git a/plugin/storage/integration/integration.go b/plugin/storage/integration/integration.go index f9ca020c41d..19dbf826c85 100644 --- a/plugin/storage/integration/integration.go +++ b/plugin/storage/integration/integration.go @@ -49,7 +49,7 @@ var fixtures embed.FS // - in those functions it instantiates and populates this struct // - it then calls RunAll. // -// Some implementations may declate multuple tests, with different settings, +// Some implementations may declare multiple tests, with different settings, // and RunAll() under different conditions. type StorageIntegration struct { SpanWriter spanstore.Writer @@ -541,4 +541,4 @@ func (s *StorageIntegration) RunSpanStoreTests(t *testing.T) { t.Run("GetTrace", s.testGetTrace) t.Run("GetLargeSpans", s.testGetLargeSpan) t.Run("FindTraces", s.testFindTraces) -} +} \ No newline at end of file From 3cf0151e09d722c4786bdc6f5315acd52886675c Mon Sep 17 00:00:00 2001 From: Harshith Mente <109957201+joeyyy09@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:28:59 +0530 Subject: [PATCH 11/28] Update cmd/jaeger/internal/integration/README.md Co-authored-by: Yuri Shkuro Signed-off-by: Harshith Mente <109957201+joeyyy09@users.noreply.github.com> --- cmd/jaeger/internal/integration/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/jaeger/internal/integration/README.md b/cmd/jaeger/internal/integration/README.md index ea6370bc014..dcb3d35cc0b 100644 --- a/cmd/jaeger/internal/integration/README.md +++ b/cmd/jaeger/internal/integration/README.md @@ -65,7 +65,7 @@ flowchart LR ## Kafka Integration -The primary difference between the Kafka integration tests and other integration tests lies in the flow of data. In the standard tests, spans are written by the SpanWriter, sent through an RPC_client directly to a receiver, then to an exporter, and stored in an in-memory backend. Spans are read by the SpanReader, which queries the jaeger_query process accessing the storage backend. In contrast, the Kafka tests introduce Kafka as an intermediary. Spans go from the SpanWriter through an RPC_client to an OTLP receiver in the Jaeger Collector, exported to Kafka, received by the Jaeger Ingester, and then stored. For details, see the [Architecture](#KafkaArchitecture) section below. +The primary difference between the Kafka integration tests and other integration tests lies in the flow of data. In the standard tests, spans are written by the SpanWriter, sent through an RPC_client directly to a receiver, then to an exporter, and written to a storage backend. Spans are read by the SpanReader, which queries the jaeger_query process accessing the storage backend. In contrast, the Kafka tests introduce Kafka as an intermediary. Spans go from the SpanWriter through an RPC_client to an OTLP receiver in the Jaeger Collector, exported to Kafka, received by the Jaeger Ingester, and then stored. For details, see the [Architecture](#KafkaArchitecture) section below. ## Kafka Architecture From d09eaa4d47b22e389718fec4cef786f0516dfa5c Mon Sep 17 00:00:00 2001 From: Harshith Mente <109957201+joeyyy09@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:29:38 +0530 Subject: [PATCH 12/28] Update cmd/jaeger/internal/integration/README.md Co-authored-by: Yuri Shkuro Signed-off-by: Harshith Mente <109957201+joeyyy09@users.noreply.github.com> --- cmd/jaeger/internal/integration/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/jaeger/internal/integration/README.md b/cmd/jaeger/internal/integration/README.md index dcb3d35cc0b..cbc9b171a7d 100644 --- a/cmd/jaeger/internal/integration/README.md +++ b/cmd/jaeger/internal/integration/README.md @@ -85,7 +85,7 @@ flowchart LR RPCR --> QueryProcess[jaeger_query] QueryProcess --> StorageBackend IngesterExporter -.-> StorageCleaner - StorageCleaner --> StorageBackend + StorageCleaner -->[purge] StorageBackend subgraph Integration_Test_Executable Test From 0acf969d41b0aaf430bddf3c092e762537429625 Mon Sep 17 00:00:00 2001 From: Harshith Mente <109957201+joeyyy09@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:29:54 +0530 Subject: [PATCH 13/28] Update cmd/jaeger/internal/integration/README.md Co-authored-by: Yuri Shkuro Signed-off-by: Harshith Mente <109957201+joeyyy09@users.noreply.github.com> --- cmd/jaeger/internal/integration/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/jaeger/internal/integration/README.md b/cmd/jaeger/internal/integration/README.md index cbc9b171a7d..bf587d8315c 100644 --- a/cmd/jaeger/internal/integration/README.md +++ b/cmd/jaeger/internal/integration/README.md @@ -108,8 +108,8 @@ flowchart LR StorageCleaner[Storage Cleaner Extension] end - subgraph Kafka Buffer - Kafka + subgraph Kafka + Topic end ``` From 17ebd78b55baadda6fb4e5961940809624ac1e0b Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Fri, 19 Jul 2024 09:35:28 +0530 Subject: [PATCH 14/28] Fixes Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/kafka_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index b540b063519..bc73427ea92 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -45,7 +45,6 @@ func TestKafkaStorage(t *testing.T) { ingester.e2eCleanUp(t) }) - // Run the span store tests for both collector and ingester - collector.RunSpanStoreTests(t) + // Run the span store tests ingester.RunSpanStoreTests(t) } \ No newline at end of file From dfcba732c279b9bc9780ba5cfd06b3b387818598 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Fri, 19 Jul 2024 11:58:11 +0530 Subject: [PATCH 15/28] Fix broken syntax Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/README.md | 72 +++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/cmd/jaeger/internal/integration/README.md b/cmd/jaeger/internal/integration/README.md index bf587d8315c..9237aac4dcf 100644 --- a/cmd/jaeger/internal/integration/README.md +++ b/cmd/jaeger/internal/integration/README.md @@ -72,45 +72,45 @@ The primary difference between the Kafka integration tests and other integration ``` mermaid flowchart LR - Test -->|writeSpan| SpanWriter - SpanWriter --> RPCW[RPC_client] - RPCW --> OTLP_Receiver[Receiver] - OTLP_Receiver --> CollectorExporter[Kafka Exporter] - CollectorExporter --> Kafka[Kafka] - Kafka --> IngesterReceiver[Kafka Receiver] - IngesterReceiver --> IngesterExporter[Exporter] - IngesterExporter --> StorageBackend[(In-Memory Store)] - Test -->|readSpan| SpanReader - SpanReader --> RPCR[RPC_client] - RPCR --> QueryProcess[jaeger_query] - QueryProcess --> StorageBackend - IngesterExporter -.-> StorageCleaner - StorageCleaner -->[purge] StorageBackend - - subgraph Integration_Test_Executable - Test - SpanWriter - SpanReader - RPCW - RPCR - end + Test -->|writeSpan| SpanWriter + SpanWriter --> RPCW[RPC_client] + RPCW --> OTLP_Receiver[Receiver] + OTLP_Receiver --> CollectorExporter[Kafka Exporter] + CollectorExporter --> Kafka[Kafka] + Kafka --> IngesterReceiver[Kafka Receiver] + IngesterReceiver --> IngesterExporter[Exporter] + IngesterExporter --> StorageBackend[(In-Memory Store)] + Test -->|readSpan| SpanReader + SpanReader --> RPCR[RPC_client] + RPCR --> QueryProcess[jaeger_query] + StorageCleaner -->|purge| StorageBackend + QueryProcess --> StorageBackend + + + subgraph Integration_Test_Executable + Test + SpanWriter + SpanReader + RPCW + RPCR + end - subgraph Jaeger Collector - OTLP_Receiver - CollectorExporter - end + subgraph Jaeger Collector + OTLP_Receiver + CollectorExporter + end - subgraph Jaeger Ingester - IngesterReceiver - IngesterExporter - QueryProcess - StorageBackend - StorageCleaner[Storage Cleaner Extension] - end + subgraph Jaeger Ingester + IngesterReceiver + IngesterExporter + QueryProcess + StorageBackend + StorageCleaner[Storage Cleaner Extension] + end - subgraph Kafka - Topic - end + subgraph Kafka + Topic + end ``` ## Running tests locally From fe794c12a7f79569433a8112e84348a235d3747a Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Fri, 19 Jul 2024 13:10:16 +0530 Subject: [PATCH 16/28] Add injectStorageCleaner parameter Signed-off-by: joeyyy09 --- .../internal/integration/badger_test.go | 2 +- .../internal/integration/cassandra_test.go | 2 +- .../internal/integration/e2e_integration.go | 36 ++++++++++++------- cmd/jaeger/internal/integration/es_test.go | 2 +- cmd/jaeger/internal/integration/grpc_test.go | 2 +- cmd/jaeger/internal/integration/kafka_test.go | 4 +-- cmd/jaeger/internal/integration/os_test.go | 2 +- 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/cmd/jaeger/internal/integration/badger_test.go b/cmd/jaeger/internal/integration/badger_test.go index a0fe00f669a..fba7f53d334 100644 --- a/cmd/jaeger/internal/integration/badger_test.go +++ b/cmd/jaeger/internal/integration/badger_test.go @@ -23,7 +23,7 @@ func TestBadgerStorage(t *testing.T) { GetOperationsMissingSpanKind: true, }, } - s.e2eInitialize(t, "badger") + s.e2eInitialize(t, "badger", true) t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/cassandra_test.go b/cmd/jaeger/internal/integration/cassandra_test.go index 0ac74c13149..7507a543efc 100644 --- a/cmd/jaeger/internal/integration/cassandra_test.go +++ b/cmd/jaeger/internal/integration/cassandra_test.go @@ -21,7 +21,7 @@ func TestCassandraStorage(t *testing.T) { SkipList: integration.CassandraSkippedTests, }, } - s.e2eInitialize(t, "cassandra") + s.e2eInitialize(t, "cassandra", true) t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index 9b803050904..0832e6d1fe3 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -44,9 +44,9 @@ type E2EStorageIntegration struct { // e2eInitialize starts the Jaeger-v2 collector with the provided config file, // it also initialize the SpanWriter and SpanReader below. // This function should be called before any of the tests start. -func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { +func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string, injectStorageCleaner bool) { logger := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())) - configFile := createStorageCleanerConfig(t, s.ConfigFile, storage) + configFile := createStorageCleanerConfig(t, s.ConfigFile, storage, injectStorageCleaner) t.Logf("Starting Jaeger-v2 in the background with config file %s", configFile) outFile, err := os.OpenFile( @@ -124,25 +124,35 @@ func (s *E2EStorageIntegration) e2eCleanUp(t *testing.T) { require.NoError(t, s.SpanWriter.(io.Closer).Close()) } -func createStorageCleanerConfig(t *testing.T, configFile string, storage string) string { +func createStorageCleanerConfig(t *testing.T, configFile string, storage string, injectStorageCleaner bool) string { data, err := os.ReadFile(configFile) require.NoError(t, err) var config map[string]any err = yaml.Unmarshal(data, &config) require.NoError(t, err) - service, ok := config["service"].(map[string]any) - require.True(t, ok) - service["extensions"] = append(service["extensions"].([]any), "storage_cleaner") + if injectStorageCleaner{ + // Add storage_cleaner to the service extensions + service, ok := config["service"].(map[string]any) + require.True(t, ok) + serviceExtensions, ok := service["extensions"].([]any) + require.True(t, ok) + serviceExtensions = append(serviceExtensions, "storage_cleaner") + service["extensions"] = serviceExtensions - extensions, ok := config["extensions"].(map[string]any) - require.True(t, ok) - query, ok := extensions["jaeger_query"].(map[string]any) - require.True(t, ok) - trace_storage := query["trace_storage"].(string) - extensions["storage_cleaner"] = map[string]string{"trace_storage": trace_storage} + // Configure the storage_cleaner extension + extensions, ok := config["extensions"].(map[string]any) + require.True(t, ok) + query, ok := extensions["jaeger_query"].(map[string]any) + require.True(t, ok) + trace_storage := query["trace_storage"].(string) + extensions["storage_cleaner"] = map[string]string{"trace_storage": trace_storage} + } - jaegerStorage, ok := extensions["jaeger_storage"].(map[string]any) + // Modify the jaeger_storage settings based on the storage type + extensions, ok := config["extensions"].(map[string]any) + require.True(t, ok) + jaegerStorage, ok := extensions["jaeger_storage"].(map[string]any) require.True(t, ok) switch storage { diff --git a/cmd/jaeger/internal/integration/es_test.go b/cmd/jaeger/internal/integration/es_test.go index 92b9f0c79e0..64738e1d44b 100644 --- a/cmd/jaeger/internal/integration/es_test.go +++ b/cmd/jaeger/internal/integration/es_test.go @@ -20,7 +20,7 @@ func TestESStorage(t *testing.T) { GetOperationsMissingSpanKind: true, }, } - s.e2eInitialize(t, "elasticsearch") + s.e2eInitialize(t, "elasticsearch", true) t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/grpc_test.go b/cmd/jaeger/internal/integration/grpc_test.go index b33b7b002a0..fc27ba01222 100644 --- a/cmd/jaeger/internal/integration/grpc_test.go +++ b/cmd/jaeger/internal/integration/grpc_test.go @@ -34,7 +34,7 @@ func TestGRPCStorage(t *testing.T) { } s.CleanUp = s.cleanUp s.initialize(t) - s.e2eInitialize(t, "grpc") + s.e2eInitialize(t, "grpc", true) t.Cleanup(func() { s.e2eCleanUp(t) s.remoteStorage.Close(t) diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index bc73427ea92..68dcc4a40b6 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -24,7 +24,7 @@ func TestKafkaStorage(t *testing.T) { } // Initialize and start the collector - collector.e2eInitialize(t, "kafka-collector") + collector.e2eInitialize(t, "kafka-collector", false) ingester := &E2EStorageIntegration{ @@ -37,7 +37,7 @@ func TestKafkaStorage(t *testing.T) { } // Initialize and start the ingester - ingester.e2eInitialize(t, "kafka-ingester") + ingester.e2eInitialize(t, "kafka-ingester", true) // Set up cleanup for both collector and ingester t.Cleanup(func() { diff --git a/cmd/jaeger/internal/integration/os_test.go b/cmd/jaeger/internal/integration/os_test.go index a5d3e945214..f1273e1eb93 100644 --- a/cmd/jaeger/internal/integration/os_test.go +++ b/cmd/jaeger/internal/integration/os_test.go @@ -19,7 +19,7 @@ func TestOSStorage(t *testing.T) { GetOperationsMissingSpanKind: true, }, } - s.e2eInitialize(t, "opensearch") + s.e2eInitialize(t, "opensearch", true) t.Cleanup(func() { s.e2eCleanUp(t) }) From 66ef1f9888306f76381d232795e95d8732362fce Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Fri, 19 Jul 2024 17:03:58 +0530 Subject: [PATCH 17/28] fix merge conflicts Signed-off-by: joeyyy09 --- .../internal/integration/e2e_integration.go | 37 ++++++++++++++----- .../integration/e2e_integration_test.go | 4 +- .../internal/integration/memory_test.go | 2 +- jaeger-ui | 2 +- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index cf590fbab3f..f399e696095 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -127,22 +127,41 @@ func (s *E2EStorageIntegration) e2eCleanUp(t *testing.T) { func createStorageCleanerConfig(t *testing.T, configFile string, storage string, injectStorageCleaner bool) string { data, err := os.ReadFile(configFile) require.NoError(t, err) + var config map[string]any err = yaml.Unmarshal(data, &config) require.NoError(t, err) - serviceAny, ok := config["service"] + // Ensure extensions are correctly parsed before any modifications + extensionsAny, ok := config["extensions"] require.True(t, ok) - service := serviceAny.(map[string]any) - service["extensions"] = append(service["extensions"].([]any), "storage_cleaner") + extensions := extensionsAny.(map[string]any) - extensions, ok := config["extensions"].(map[string]any) - require.True(t, ok) - query, ok := extensions["jaeger_query"].(map[string]any) - require.True(t, ok) - trace_storage := query["trace_storage"].(string) - extensions["storage_cleaner"] = map[string]string{"trace_storage": trace_storage} + if injectStorageCleaner{ + // 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) diff --git a/cmd/jaeger/internal/integration/e2e_integration_test.go b/cmd/jaeger/internal/integration/e2e_integration_test.go index a6aaca13623..adaa8031c22 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, "../../config-elasticsearch.yaml", "elasticsearch") - createStorageCleanerConfig(t, "../../config-opensearch.yaml", "opensearch") + createStorageCleanerConfig(t, "../../config-elasticsearch.yaml", "elasticsearch", true) + createStorageCleanerConfig(t, "../../config-opensearch.yaml", "opensearch", true) } diff --git a/cmd/jaeger/internal/integration/memory_test.go b/cmd/jaeger/internal/integration/memory_test.go index a2592b04a38..9c1b628cf7a 100644 --- a/cmd/jaeger/internal/integration/memory_test.go +++ b/cmd/jaeger/internal/integration/memory_test.go @@ -19,7 +19,7 @@ func TestMemoryStorage(t *testing.T) { CleanUp: purge, }, } - s.e2eInitialize(t, "memory") + s.e2eInitialize(t, "memory", true) t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/jaeger-ui b/jaeger-ui index 1704a9a66ae..560c749b481 160000 --- a/jaeger-ui +++ b/jaeger-ui @@ -1 +1 @@ -Subproject commit 1704a9a66ae780ec6bb2f524116176aa9c8a23f8 +Subproject commit 560c749b481f8244bf76b0afe001174fa9ce11f5 From 4d4a8820b56f4cf1191c354238c58acc0d05d983 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sat, 20 Jul 2024 12:18:14 +0530 Subject: [PATCH 18/28] Modify E2EStorageIntegration struct Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/badger_test.go | 2 +- cmd/jaeger/internal/integration/cassandra_test.go | 2 +- cmd/jaeger/internal/integration/e2e_integration.go | 9 +++++---- cmd/jaeger/internal/integration/e2e_integration_test.go | 4 ++-- cmd/jaeger/internal/integration/elasticsearch_test.go | 2 +- cmd/jaeger/internal/integration/grpc_test.go | 2 +- cmd/jaeger/internal/integration/kafka_test.go | 5 +++-- cmd/jaeger/internal/integration/memory_test.go | 2 +- cmd/jaeger/internal/integration/opensearch_test.go | 2 +- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmd/jaeger/internal/integration/badger_test.go b/cmd/jaeger/internal/integration/badger_test.go index fba7f53d334..a0fe00f669a 100644 --- a/cmd/jaeger/internal/integration/badger_test.go +++ b/cmd/jaeger/internal/integration/badger_test.go @@ -23,7 +23,7 @@ func TestBadgerStorage(t *testing.T) { GetOperationsMissingSpanKind: true, }, } - s.e2eInitialize(t, "badger", true) + s.e2eInitialize(t, "badger") t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/cassandra_test.go b/cmd/jaeger/internal/integration/cassandra_test.go index 7507a543efc..0ac74c13149 100644 --- a/cmd/jaeger/internal/integration/cassandra_test.go +++ b/cmd/jaeger/internal/integration/cassandra_test.go @@ -21,7 +21,7 @@ func TestCassandraStorage(t *testing.T) { SkipList: integration.CassandraSkippedTests, }, } - s.e2eInitialize(t, "cassandra", true) + s.e2eInitialize(t, "cassandra") t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index f399e696095..85adfaef71d 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -37,6 +37,7 @@ const otlpPort = 4317 // - At last, clean up anything declared in its own test functions. // (e.g. close remote-storage) type E2EStorageIntegration struct { + SkipStorageCleaner bool integration.StorageIntegration ConfigFile string } @@ -44,9 +45,9 @@ type E2EStorageIntegration struct { // e2eInitialize starts the Jaeger-v2 collector with the provided config file, // it also initialize the SpanWriter and SpanReader below. // This function should be called before any of the tests start. -func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string, injectStorageCleaner bool) { +func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { logger := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())) - configFile := createStorageCleanerConfig(t, s.ConfigFile, storage, injectStorageCleaner) + configFile := createStorageCleanerConfig(t, s.SkipStorageCleaner,s.ConfigFile, storage) t.Logf("Starting Jaeger-v2 in the background with config file %s", configFile) outFile, err := os.OpenFile( @@ -124,7 +125,7 @@ func (s *E2EStorageIntegration) e2eCleanUp(t *testing.T) { require.NoError(t, s.SpanWriter.(io.Closer).Close()) } -func createStorageCleanerConfig(t *testing.T, configFile string, storage string, injectStorageCleaner bool) string { +func createStorageCleanerConfig(t *testing.T, SkipStorageCleaner bool, configFile string, storage string) string { data, err := os.ReadFile(configFile) require.NoError(t, err) @@ -138,7 +139,7 @@ func createStorageCleanerConfig(t *testing.T, configFile string, storage string, extensions := extensionsAny.(map[string]any) - if injectStorageCleaner{ + if !SkipStorageCleaner{ // Add storage_cleaner to the service extensions serviceAny, ok := config["service"] require.True(t, ok) diff --git a/cmd/jaeger/internal/integration/e2e_integration_test.go b/cmd/jaeger/internal/integration/e2e_integration_test.go index adaa8031c22..d8a8e8c581d 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, "../../config-elasticsearch.yaml", "elasticsearch", true) - createStorageCleanerConfig(t, "../../config-opensearch.yaml", "opensearch", true) + createStorageCleanerConfig(t, false,"../../config-elasticsearch.yaml", "elasticsearch") + createStorageCleanerConfig(t, false, "../../config-opensearch.yaml", "opensearch") } diff --git a/cmd/jaeger/internal/integration/elasticsearch_test.go b/cmd/jaeger/internal/integration/elasticsearch_test.go index 421139967b7..2c78bfdb7af 100644 --- a/cmd/jaeger/internal/integration/elasticsearch_test.go +++ b/cmd/jaeger/internal/integration/elasticsearch_test.go @@ -20,7 +20,7 @@ func TestElasticsearchStorage(t *testing.T) { GetOperationsMissingSpanKind: true, }, } - s.e2eInitialize(t, "elasticsearch", true) + s.e2eInitialize(t, "elasticsearch") t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/grpc_test.go b/cmd/jaeger/internal/integration/grpc_test.go index fc27ba01222..b33b7b002a0 100644 --- a/cmd/jaeger/internal/integration/grpc_test.go +++ b/cmd/jaeger/internal/integration/grpc_test.go @@ -34,7 +34,7 @@ func TestGRPCStorage(t *testing.T) { } s.CleanUp = s.cleanUp s.initialize(t) - s.e2eInitialize(t, "grpc", true) + s.e2eInitialize(t, "grpc") t.Cleanup(func() { s.e2eCleanUp(t) s.remoteStorage.Close(t) diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index 68dcc4a40b6..d47a0a34f0f 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -16,6 +16,7 @@ func TestKafkaStorage(t *testing.T) { ingesterConfig := "../../ingester-remote-storage.yaml" collector := &E2EStorageIntegration{ + SkipStorageCleaner: true, ConfigFile: collectorConfig, StorageIntegration: integration.StorageIntegration{ GetDependenciesReturnsSource: true, @@ -24,7 +25,7 @@ func TestKafkaStorage(t *testing.T) { } // Initialize and start the collector - collector.e2eInitialize(t, "kafka-collector", false) + collector.e2eInitialize(t, "kafka-collector") ingester := &E2EStorageIntegration{ @@ -37,7 +38,7 @@ func TestKafkaStorage(t *testing.T) { } // Initialize and start the ingester - ingester.e2eInitialize(t, "kafka-ingester", true) + ingester.e2eInitialize(t, "kafka-ingester") // Set up cleanup for both collector and ingester t.Cleanup(func() { diff --git a/cmd/jaeger/internal/integration/memory_test.go b/cmd/jaeger/internal/integration/memory_test.go index 9c1b628cf7a..a2592b04a38 100644 --- a/cmd/jaeger/internal/integration/memory_test.go +++ b/cmd/jaeger/internal/integration/memory_test.go @@ -19,7 +19,7 @@ func TestMemoryStorage(t *testing.T) { CleanUp: purge, }, } - s.e2eInitialize(t, "memory", true) + s.e2eInitialize(t, "memory") t.Cleanup(func() { s.e2eCleanUp(t) }) diff --git a/cmd/jaeger/internal/integration/opensearch_test.go b/cmd/jaeger/internal/integration/opensearch_test.go index eca853fa8ff..909c0be6510 100644 --- a/cmd/jaeger/internal/integration/opensearch_test.go +++ b/cmd/jaeger/internal/integration/opensearch_test.go @@ -19,7 +19,7 @@ func TestOpenSearchStorage(t *testing.T) { GetOperationsMissingSpanKind: true, }, } - s.e2eInitialize(t, "opensearch", true) + s.e2eInitialize(t, "opensearch") t.Cleanup(func() { s.e2eCleanUp(t) }) From 7cc6a6f6360f9e81077387143b86dcf3b37545ca Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sat, 20 Jul 2024 22:44:55 +0530 Subject: [PATCH 19/28] Fixes Signed-off-by: joeyyy09 --- .../internal/integration/e2e_integration.go | 47 +++++++------------ .../integration/e2e_integration_test.go | 4 +- cmd/jaeger/internal/integration/kafka_test.go | 4 -- 3 files changed, 19 insertions(+), 36 deletions(-) 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 From 29581a444d6d86d24577e34249a173d5d639aadc Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sat, 20 Jul 2024 22:45:17 +0530 Subject: [PATCH 20/28] Fixes Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/kafka_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index 9bda6ea2e65..2a42a86aa4d 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -21,7 +21,7 @@ func TestKafkaStorage(t *testing.T) { } // Initialize and start the collector - collector.e2eInitialize(t, "kafka-collector") + collector.e2eInitialize(t, "kafka") ingester := &E2EStorageIntegration{ @@ -34,7 +34,7 @@ func TestKafkaStorage(t *testing.T) { } // Initialize and start the ingester - ingester.e2eInitialize(t, "kafka-ingester") + ingester.e2eInitialize(t, "kafka") // Set up cleanup for both collector and ingester t.Cleanup(func() { From 580bdc9d7df94cd6a20bbfa6c1255fb718f89b10 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sat, 20 Jul 2024 22:52:57 +0530 Subject: [PATCH 21/28] Update Lint Signed-off-by: joeyyy09 --- .../internal/integration/e2e_integration.go | 4 +- cmd/jaeger/internal/integration/kafka_test.go | 53 +++++++++---------- plugin/storage/integration/integration.go | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index aba1af4aa25..93902706a59 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -50,7 +50,7 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { 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( @@ -194,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/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index 2a42a86aa4d..b3ca83a22ac 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -10,38 +10,37 @@ import ( ) func TestKafkaStorage(t *testing.T) { - integration.SkipUnlessEnv(t, "kafka") + integration.SkipUnlessEnv(t, "kafka") - collectorConfig := "../../collector-with-kafka.yaml" - ingesterConfig := "../../ingester-remote-storage.yaml" + collectorConfig := "../../collector-with-kafka.yaml" + ingesterConfig := "../../ingester-remote-storage.yaml" - collector := &E2EStorageIntegration{ - SkipStorageCleaner: true, - ConfigFile: collectorConfig, - } + collector := &E2EStorageIntegration{ + SkipStorageCleaner: true, + ConfigFile: collectorConfig, + } - // Initialize and start the collector - collector.e2eInitialize(t, "kafka") + // Initialize and start the collector + collector.e2eInitialize(t, "kafka") - - ingester := &E2EStorageIntegration{ - ConfigFile: ingesterConfig, - StorageIntegration: integration.StorageIntegration{ - CleanUp: purge, - GetDependenciesReturnsSource: true, - SkipArchiveTest: true, - }, - } + ingester := &E2EStorageIntegration{ + ConfigFile: ingesterConfig, + StorageIntegration: integration.StorageIntegration{ + CleanUp: purge, + GetDependenciesReturnsSource: true, + SkipArchiveTest: true, + }, + } // Initialize and start the ingester - ingester.e2eInitialize(t, "kafka") + ingester.e2eInitialize(t, "kafka") - // Set up cleanup for both collector and ingester - t.Cleanup(func() { - collector.e2eCleanUp(t) - ingester.e2eCleanUp(t) - }) + // Set up cleanup for both collector and ingester + t.Cleanup(func() { + collector.e2eCleanUp(t) + ingester.e2eCleanUp(t) + }) - // Run the span store tests - ingester.RunSpanStoreTests(t) -} \ No newline at end of file + // Run the span store tests + ingester.RunSpanStoreTests(t) +} diff --git a/plugin/storage/integration/integration.go b/plugin/storage/integration/integration.go index 19dbf826c85..8ed6d905b83 100644 --- a/plugin/storage/integration/integration.go +++ b/plugin/storage/integration/integration.go @@ -541,4 +541,4 @@ func (s *StorageIntegration) RunSpanStoreTests(t *testing.T) { t.Run("GetTrace", s.testGetTrace) t.Run("GetLargeSpans", s.testGetLargeSpan) t.Run("FindTraces", s.testFindTraces) -} \ No newline at end of file +} From fea62c672e1a09c08b215d189815a6446d1d2b46 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sat, 20 Jul 2024 23:17:00 +0530 Subject: [PATCH 22/28] Fix Lint Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/e2e_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/jaeger/internal/integration/e2e_integration_test.go b/cmd/jaeger/internal/integration/e2e_integration_test.go index 1fd1318c5da..a6aaca13623 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,"../../config-elasticsearch.yaml", "elasticsearch") + createStorageCleanerConfig(t, "../../config-elasticsearch.yaml", "elasticsearch") createStorageCleanerConfig(t, "../../config-opensearch.yaml", "opensearch") } From 284acc9dfd6d17f01db6a72a34f0a54afac66726 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Sun, 21 Jul 2024 10:06:24 +0530 Subject: [PATCH 23/28] Add e2eCleanup in e2eInitialize Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/badger_test.go | 3 --- cmd/jaeger/internal/integration/cassandra_test.go | 3 --- cmd/jaeger/internal/integration/e2e_integration.go | 2 ++ cmd/jaeger/internal/integration/elasticsearch_test.go | 3 --- cmd/jaeger/internal/integration/grpc_test.go | 4 ---- cmd/jaeger/internal/integration/kafka_test.go | 6 ------ cmd/jaeger/internal/integration/memory_test.go | 3 --- cmd/jaeger/internal/integration/opensearch_test.go | 3 --- 8 files changed, 2 insertions(+), 25 deletions(-) diff --git a/cmd/jaeger/internal/integration/badger_test.go b/cmd/jaeger/internal/integration/badger_test.go index a0fe00f669a..b5c62d5c21a 100644 --- a/cmd/jaeger/internal/integration/badger_test.go +++ b/cmd/jaeger/internal/integration/badger_test.go @@ -24,8 +24,5 @@ func TestBadgerStorage(t *testing.T) { }, } s.e2eInitialize(t, "badger") - t.Cleanup(func() { - s.e2eCleanUp(t) - }) s.RunAll(t) } diff --git a/cmd/jaeger/internal/integration/cassandra_test.go b/cmd/jaeger/internal/integration/cassandra_test.go index 0ac74c13149..a78f66b3ec9 100644 --- a/cmd/jaeger/internal/integration/cassandra_test.go +++ b/cmd/jaeger/internal/integration/cassandra_test.go @@ -22,8 +22,5 @@ func TestCassandraStorage(t *testing.T) { }, } s.e2eInitialize(t, "cassandra") - t.Cleanup(func() { - s.e2eCleanUp(t) - }) s.RunSpanStoreTests(t) } diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index 93902706a59..aa3549f961d 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -113,6 +113,8 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { // End of Github Actions foldable section annotation. fmt.Println("::endgroup::") } + // Call e2eCleanUp to close the SpanReader and SpanWriter gRPC connection. + s.e2eCleanUp(t) }) s.SpanWriter, err = createSpanWriter(logger, otlpPort) diff --git a/cmd/jaeger/internal/integration/elasticsearch_test.go b/cmd/jaeger/internal/integration/elasticsearch_test.go index 2c78bfdb7af..844c4866321 100644 --- a/cmd/jaeger/internal/integration/elasticsearch_test.go +++ b/cmd/jaeger/internal/integration/elasticsearch_test.go @@ -21,8 +21,5 @@ func TestElasticsearchStorage(t *testing.T) { }, } s.e2eInitialize(t, "elasticsearch") - t.Cleanup(func() { - s.e2eCleanUp(t) - }) s.RunSpanStoreTests(t) } diff --git a/cmd/jaeger/internal/integration/grpc_test.go b/cmd/jaeger/internal/integration/grpc_test.go index b33b7b002a0..4256690613c 100644 --- a/cmd/jaeger/internal/integration/grpc_test.go +++ b/cmd/jaeger/internal/integration/grpc_test.go @@ -35,9 +35,5 @@ func TestGRPCStorage(t *testing.T) { s.CleanUp = s.cleanUp s.initialize(t) s.e2eInitialize(t, "grpc") - t.Cleanup(func() { - s.e2eCleanUp(t) - s.remoteStorage.Close(t) - }) s.RunSpanStoreTests(t) } diff --git a/cmd/jaeger/internal/integration/kafka_test.go b/cmd/jaeger/internal/integration/kafka_test.go index b3ca83a22ac..099bddba3e1 100644 --- a/cmd/jaeger/internal/integration/kafka_test.go +++ b/cmd/jaeger/internal/integration/kafka_test.go @@ -35,12 +35,6 @@ func TestKafkaStorage(t *testing.T) { // Initialize and start the ingester ingester.e2eInitialize(t, "kafka") - // Set up cleanup for both collector and ingester - t.Cleanup(func() { - collector.e2eCleanUp(t) - ingester.e2eCleanUp(t) - }) - // Run the span store tests ingester.RunSpanStoreTests(t) } diff --git a/cmd/jaeger/internal/integration/memory_test.go b/cmd/jaeger/internal/integration/memory_test.go index a2592b04a38..81f0bfa94fb 100644 --- a/cmd/jaeger/internal/integration/memory_test.go +++ b/cmd/jaeger/internal/integration/memory_test.go @@ -20,8 +20,5 @@ func TestMemoryStorage(t *testing.T) { }, } s.e2eInitialize(t, "memory") - t.Cleanup(func() { - s.e2eCleanUp(t) - }) s.RunAll(t) } diff --git a/cmd/jaeger/internal/integration/opensearch_test.go b/cmd/jaeger/internal/integration/opensearch_test.go index 909c0be6510..f164bfcda26 100644 --- a/cmd/jaeger/internal/integration/opensearch_test.go +++ b/cmd/jaeger/internal/integration/opensearch_test.go @@ -20,8 +20,5 @@ func TestOpenSearchStorage(t *testing.T) { }, } s.e2eInitialize(t, "opensearch") - t.Cleanup(func() { - s.e2eCleanUp(t) - }) s.RunSpanStoreTests(t) } From 4ba59175543addbbc82a0d44531db1368de82424 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Wed, 24 Jul 2024 14:09:45 +0530 Subject: [PATCH 24/28] Fixes Signed-off-by: joeyyy09 --- .../internal/integration/e2e_integration.go | 23 +++++++++++++------ cmd/jaeger/internal/integration/grpc_test.go | 4 ++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index aa3549f961d..af0e448e678 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -97,24 +97,33 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { }, 30*time.Second, 500*time.Millisecond, "Jaeger-v2 did not start") t.Log("Jaeger-v2 is ready") t.Cleanup(func() { - require.NoError(t, cmd.Process.Kill()) + if err := cmd.Process.Kill(); err != nil { + t.Errorf("Failed to kill Jaeger-v2 process: %v", err) + } + // Call e2eCleanUp to close the SpanReader and SpanWriter gRPC connection. + s.e2eCleanUp(t) if t.Failed() { // A Github Actions special annotation to create a foldable section // in the Github runner output. // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines fmt.Println("::group::🚧 🚧 🚧 Jaeger-v2 binary logs") outLogs, err := os.ReadFile(outFile.Name()) - require.NoError(t, err) - fmt.Printf("🚧 🚧 🚧 Jaeger-v2 output logs:\n%s", outLogs) + if err != nil { + t.Errorf("Failed to read output logs: %v", err) + } else { + fmt.Printf("🚧 🚧 🚧 Jaeger-v2 output logs:\n%s", outLogs) + } errLogs, err := os.ReadFile(errFile.Name()) - require.NoError(t, err) - fmt.Printf("🚧 🚧 🚧 Jaeger-v2 error logs:\n%s", errLogs) + if err != nil { + t.Errorf("Failed to read error logs: %v", err) + } else { + fmt.Printf("🚧 🚧 🚧 Jaeger-v2 error logs:\n%s", errLogs) + } // End of Github Actions foldable section annotation. fmt.Println("::endgroup::") } - // Call e2eCleanUp to close the SpanReader and SpanWriter gRPC connection. - s.e2eCleanUp(t) + }) s.SpanWriter, err = createSpanWriter(logger, otlpPort) diff --git a/cmd/jaeger/internal/integration/grpc_test.go b/cmd/jaeger/internal/integration/grpc_test.go index 4256690613c..b33b7b002a0 100644 --- a/cmd/jaeger/internal/integration/grpc_test.go +++ b/cmd/jaeger/internal/integration/grpc_test.go @@ -35,5 +35,9 @@ func TestGRPCStorage(t *testing.T) { s.CleanUp = s.cleanUp s.initialize(t) s.e2eInitialize(t, "grpc") + t.Cleanup(func() { + s.e2eCleanUp(t) + s.remoteStorage.Close(t) + }) s.RunSpanStoreTests(t) } From 06e68ac9ea59dfa528ff5947ef9bc5bd4c7c66ab Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Wed, 24 Jul 2024 14:15:06 +0530 Subject: [PATCH 25/28] Lint fixes Signed-off-by: joeyyy09 --- cmd/jaeger/internal/integration/e2e_integration.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index af0e448e678..37da8a60086 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -123,7 +123,6 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { // End of Github Actions foldable section annotation. fmt.Println("::endgroup::") } - }) s.SpanWriter, err = createSpanWriter(logger, otlpPort) From 07f903e7b3ba379b54076f016f2524a74cacfa6d Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Wed, 24 Jul 2024 16:09:41 -0400 Subject: [PATCH 26/28] fix ui Signed-off-by: Yuri Shkuro --- jaeger-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaeger-ui b/jaeger-ui index 560c749b481..1704a9a66ae 160000 --- a/jaeger-ui +++ b/jaeger-ui @@ -1 +1 @@ -Subproject commit 560c749b481f8244bf76b0afe001174fa9ce11f5 +Subproject commit 1704a9a66ae780ec6bb2f524116176aa9c8a23f8 From 4d624d646d5ffbd2d25b4b5c610d5cfae3273e44 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Wed, 24 Jul 2024 16:30:00 -0400 Subject: [PATCH 27/28] schedule clean-up after reader/writer are created Signed-off-by: Yuri Shkuro --- cmd/jaeger/internal/integration/e2e_integration.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/jaeger/internal/integration/e2e_integration.go b/cmd/jaeger/internal/integration/e2e_integration.go index 37da8a60086..4bf341a2a8f 100644 --- a/cmd/jaeger/internal/integration/e2e_integration.go +++ b/cmd/jaeger/internal/integration/e2e_integration.go @@ -100,8 +100,6 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { if err := cmd.Process.Kill(); err != nil { t.Errorf("Failed to kill Jaeger-v2 process: %v", err) } - // Call e2eCleanUp to close the SpanReader and SpanWriter gRPC connection. - s.e2eCleanUp(t) if t.Failed() { // A Github Actions special annotation to create a foldable section // in the Github runner output. @@ -129,6 +127,11 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) { require.NoError(t, err) s.SpanReader, err = createSpanReader(logger, ports.QueryGRPC) require.NoError(t, err) + + t.Cleanup(func() { + // Call e2eCleanUp to close the SpanReader and SpanWriter gRPC connection. + s.e2eCleanUp(t) + }) } // e2eCleanUp closes the SpanReader and SpanWriter gRPC connection. From d7c70cf748268ee38de7486f37df1a57897a1de1 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Wed, 24 Jul 2024 16:47:16 -0400 Subject: [PATCH 28/28] remove duplicate call to cleanup Signed-off-by: Yuri Shkuro --- cmd/jaeger/internal/integration/grpc_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/jaeger/internal/integration/grpc_test.go b/cmd/jaeger/internal/integration/grpc_test.go index b33b7b002a0..cd12984bc62 100644 --- a/cmd/jaeger/internal/integration/grpc_test.go +++ b/cmd/jaeger/internal/integration/grpc_test.go @@ -36,7 +36,6 @@ func TestGRPCStorage(t *testing.T) { s.initialize(t) s.e2eInitialize(t, "grpc") t.Cleanup(func() { - s.e2eCleanUp(t) s.remoteStorage.Close(t) }) s.RunSpanStoreTests(t)