Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Aug 20, 2018
1 parent f789e7f commit 3aed9d5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 1 addition & 2 deletions plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ func (s *SpanReader) findIndices(indexName string, startTime time.Time, endTime
}

func indexWithDate(prefix string, indexType string, date time.Time) string {
index := prefix + indexType + date.UTC().Format("2006-01-02")
return index
return prefix + indexType + date.UTC().Format("2006-01-02")
}

// GetServices returns all services traced by Jaeger, ordered by frequency
Expand Down
22 changes: 22 additions & 0 deletions plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,28 @@ func TestSpanReader_esJSONtoJSONSpanModelError(t *testing.T) {
})
}

func TestWriterReaderIndexNames(t *testing.T) {
testCases := []struct {
prefix string
}{
{prefix: ""},
{prefix: "foo"},
{prefix: "--"},
}

span := &model.Span{StartTime: time.Now()}
for _, testCase := range testCases {
spanIndexWrite, serviceIndexWrite := indexNames(testCase.prefix, span)

readSpanIndex := indexWithDate(testCase.prefix, spanIndex, span.StartTime)
readServiceIndex := indexWithDate(testCase.prefix, serviceIndex, span.StartTime)

assert.EqualValues(t, spanIndexWrite, readSpanIndex)
assert.EqualValues(t, serviceIndexWrite, readServiceIndex)
}

}

func TestSpanReaderFindIndices(t *testing.T) {
today := time.Date(1995, time.April, 21, 4, 12, 19, 95, time.UTC)
yesterday := today.AddDate(0, 0, -1)
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (s *ESStorageIntegration) esCleanUp() error {
func (s *ESStorageIntegration) initSpanstore() {
bp, _ := s.client.BulkProcessor().BulkActions(1).FlushInterval(time.Nanosecond).Do(context.Background())
client := es.WrapESClient(s.client, bp)
s.SpanWriter = spanstore.NewSpanWriter(client, s.logger, metrics.NullFactory, 0, 0)
s.SpanReader = spanstore.NewSpanReader(client, s.logger, 72*time.Hour, metrics.NullFactory)
s.SpanWriter = spanstore.NewSpanWriter(client, s.logger, metrics.NullFactory, 0, 0, "integration-test-")
s.SpanReader = spanstore.NewSpanReader(client, s.logger, 72*time.Hour, metrics.NullFactory, "integration-test-")
}

func (s *ESStorageIntegration) esRefresh() error {
Expand Down

0 comments on commit 3aed9d5

Please sign in to comment.