Skip to content

Commit

Permalink
Modify E2EStorageIntegration struct
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 66ef1f9 commit 4d4a882
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/badger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
9 changes: 5 additions & 4 deletions cmd/jaeger/internal/integration/e2e_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ 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
}

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

Check failure on line 128 in cmd/jaeger/internal/integration/e2e_integration.go

View workflow job for this annotation

GitHub Actions / lint

captLocal: `SkipStorageCleaner' should not be capitalized (gocritic)
data, err := os.ReadFile(configFile)
require.NoError(t, err)

Expand All @@ -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)
Expand Down
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, "../../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")
}
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions cmd/jaeger/internal/integration/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/opensearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 4d4a882

Please sign in to comment.