Skip to content

Commit

Permalink
Add Purge method for cassandra (jaegertracing#5414)
Browse files Browse the repository at this point in the history
## 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 <hpotpose62@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-authored-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
2 people authored and Pushkarm029 committed May 4, 2024
1 parent f1c253a commit 3579fe3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit 3579fe3

Please sign in to comment.