Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Simplify Cassandra e2e test cleanup #4794

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,25 @@ var errInitializeCassandraDependencyWriter = errors.New("failed to initialize ca
type CassandraStorageIntegration struct {
StorageIntegration

logger *zap.Logger
session dbsession.Session
logger *zap.Logger
}

func newCassandraStorageIntegration() *CassandraStorageIntegration {
return &CassandraStorageIntegration{
s := &CassandraStorageIntegration{
StorageIntegration: StorageIntegration{
GetDependenciesReturnsSource: true,

Refresh: func() error { return nil },
CleanUp: func() error { return nil },
SkipList: []string{"Tags_+_Operation_name_+_Duration_range", "Tags_+_Duration_range", "Tags_+_Operation_name_+_max_Duration", "Tags_+_max_Duration", "Operation_name_+_Duration_range", "Duration_range", "max_Duration"},
},
}
s.CleanUp = s.cleanUp
return s
}

func (s *CassandraStorageIntegration) cleanUp(q dbsession.Session) (func() error, error) {
return func() error {
if err := q.Query("TRUNCATE traces").Exec(); err != nil {
return err
}
return nil
}, nil
func (s *CassandraStorageIntegration) cleanUp() error {
return s.session.Query("TRUNCATE traces").Exec()
}

func (s *CassandraStorageIntegration) initializeCassandraFactory(flags []string) (*cassandra.Factory, error) {
Expand All @@ -82,15 +79,13 @@ func (s *CassandraStorageIntegration) initializeCassandra() error {
if err != nil {
return err
}
s.session = f.PrimarySession()
if s.SpanWriter, err = f.CreateSpanWriter(); err != nil {
return err
}
if s.SpanReader, err = f.CreateSpanReader(); err != nil {
return err
}
if s.CleanUp, err = s.cleanUp(f.PrimarySession()); err != nil {
return err
}
if err = s.initializeDependencyReaderAndWriter(f); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type StorageIntegration struct {

// List of tests which has to be skipped, it can be regex too.
SkipList []string

// CleanUp() should ensure that the storage backend is clean before another test.
// called either before or after each test, and should be idempotent
CleanUp func() error
Expand Down