Skip to content

Commit 3579fe3

Browse files
akagami-harshyurishkuro
authored andcommitted
Add Purge method for cassandra (jaegertracing#5414)
## Which problem is this PR solving? - jaegertracing#5398 (comment) ## Description of the changes - added purge for method for cassandra ## How was this change tested? - via integration tests ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Harshvir Potpose <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent f1c253a commit 3579fe3

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

plugin/storage/cassandra/factory.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package cassandra
1717

1818
import (
19+
"context"
1920
"errors"
2021
"flag"
2122
"io"
@@ -251,3 +252,7 @@ func (f *Factory) Close() error {
251252
func (f *Factory) PrimarySession() cassandra.Session {
252253
return f.primarySession
253254
}
255+
256+
func (f *Factory) Purge(_ context.Context) error {
257+
return f.primarySession.Query("TRUNCATE traces").Exec()
258+
}

plugin/storage/integration/cassandra_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
package integration
1717

1818
import (
19+
"context"
1920
"testing"
2021

2122
"github.com/stretchr/testify/require"
2223
"go.uber.org/zap"
2324
"go.uber.org/zap/zaptest"
2425

25-
dbsession "github.com/jaegertracing/jaeger/pkg/cassandra"
2626
"github.com/jaegertracing/jaeger/pkg/config"
2727
"github.com/jaegertracing/jaeger/pkg/metrics"
2828
"github.com/jaegertracing/jaeger/plugin/storage/cassandra"
@@ -31,8 +31,7 @@ import (
3131

3232
type CassandraStorageIntegration struct {
3333
StorageIntegration
34-
35-
session dbsession.Session
34+
factory *cassandra.Factory
3635
}
3736

3837
func newCassandraStorageIntegration() *CassandraStorageIntegration {
@@ -58,7 +57,7 @@ func newCassandraStorageIntegration() *CassandraStorageIntegration {
5857
}
5958

6059
func (s *CassandraStorageIntegration) cleanUp(t *testing.T) {
61-
require.NoError(t, s.session.Query("TRUNCATE traces").Exec())
60+
require.NoError(t, s.factory.Purge(context.Background()))
6261
}
6362

6463
func (s *CassandraStorageIntegration) initializeCassandraFactory(t *testing.T, flags []string) *cassandra.Factory {
@@ -75,7 +74,7 @@ func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
7574
f := s.initializeCassandraFactory(t, []string{
7675
"--cassandra.keyspace=jaeger_v1_dc1",
7776
})
78-
s.session = f.PrimarySession()
77+
s.factory = f
7978
var err error
8079
s.SpanWriter, err = f.CreateSpanWriter()
8180
require.NoError(t, err)

0 commit comments

Comments
 (0)