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

Add Purge method for cassandra #5414

Merged
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
5 changes: 5 additions & 0 deletions plugin/storage/cassandra/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cassandra

import (
"context"
"errors"
"flag"
"io"
Expand Down Expand Up @@ -251,3 +252,7 @@ func (f *Factory) Close() error {
func (f *Factory) PrimarySession() cassandra.Session {
return f.primarySession
}

func (f *Factory) Purge(_ context.Context) error {
return f.primarySession.Query("TRUNCATE traces").Exec()
}
9 changes: 4 additions & 5 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package integration

import (
"context"
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"

dbsession "github.com/jaegertracing/jaeger/pkg/cassandra"
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/plugin/storage/cassandra"
Expand All @@ -31,8 +31,7 @@ import (

type CassandraStorageIntegration struct {
StorageIntegration

session dbsession.Session
factory *cassandra.Factory
}

func newCassandraStorageIntegration() *CassandraStorageIntegration {
Expand All @@ -58,7 +57,7 @@ func newCassandraStorageIntegration() *CassandraStorageIntegration {
}

func (s *CassandraStorageIntegration) cleanUp(t *testing.T) {
require.NoError(t, s.session.Query("TRUNCATE traces").Exec())
require.NoError(t, s.factory.Purge(context.Background()))
}

func (s *CassandraStorageIntegration) initializeCassandraFactory(t *testing.T, flags []string) *cassandra.Factory {
Expand All @@ -75,7 +74,7 @@ func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
f := s.initializeCassandraFactory(t, []string{
"--cassandra.keyspace=jaeger_v1_dc1",
})
s.session = f.PrimarySession()
s.factory = f
var err error
s.SpanWriter, err = f.CreateSpanWriter()
require.NoError(t, err)
Expand Down
Loading