Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: joeyyy09 <[email protected]>
  • Loading branch information
joeyyy09 committed Jul 20, 2024
1 parent 4d4a882 commit 7cc6a6f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
47 changes: 17 additions & 30 deletions cmd/jaeger/internal/integration/e2e_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -207,4 +194,4 @@ func purge(t *testing.T) {
require.NoError(t, err)

require.Equal(t, http.StatusOK, resp.StatusCode, "body: %s", string(body))
}
}
4 changes: 2 additions & 2 deletions cmd/jaeger/internal/integration/e2e_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 0 additions & 4 deletions cmd/jaeger/internal/integration/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7cc6a6f

Please sign in to comment.