Skip to content

Commit

Permalink
Fix flaky ES span reader test due to date differences (jaegertracing#…
Browse files Browse the repository at this point in the history
…1847)

* Fix flaky ES span reader test due to date differences

Signed-off-by: Pavol Loffay <[email protected]>

* fmt

Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: radekg <[email protected]>
  • Loading branch information
pavolloffay authored and radekg committed Oct 28, 2019
1 parent 5979d7e commit 4532ea3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions plugin/storage/es/mappings/gen_assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestSpanReaderIndices(t *testing.T) {
client := &mocks.Client{}
logger, _ := testutils.NewLogger()
metricsFactory := metricstest.NewFactory(0)
date := time.Now()
date := time.Date(2019, 10, 10, 5, 0, 0, 0, time.UTC)
dateFormat := date.UTC().Format("2006-01-02")
testCases := []struct {
index string
Expand Down Expand Up @@ -208,22 +208,22 @@ func TestSpanReader_GetTrace(t *testing.T) {

func TestSpanReader_multiRead_followUp_query(t *testing.T) {
withSpanReader(func(r *spanReaderTest) {
now := time.Now()
spanID1 := dbmodel.Span{SpanID: "0", TraceID: "1", StartTime: model.TimeAsEpochMicroseconds(now)}
date := time.Date(2019, 10, 10, 5, 0, 0, 0, time.UTC)
spanID1 := dbmodel.Span{SpanID: "0", TraceID: "1", StartTime: model.TimeAsEpochMicroseconds(date)}
spanBytesID1, err := json.Marshal(spanID1)
require.NoError(t, err)
spanID2 := dbmodel.Span{SpanID: "0", TraceID: "2", StartTime: model.TimeAsEpochMicroseconds(now)}
spanID2 := dbmodel.Span{SpanID: "0", TraceID: "2", StartTime: model.TimeAsEpochMicroseconds(date)}
spanBytesID2, err := json.Marshal(spanID2)
require.NoError(t, err)

id1Query := elastic.NewTermQuery("traceID", model.TraceID{High: 0, Low: 1}.String())
id1Search := elastic.NewSearchRequest().
IgnoreUnavailable(true).
Source(r.reader.sourceFn(id1Query, model.TimeAsEpochMicroseconds(now.Add(-time.Hour))))
Source(r.reader.sourceFn(id1Query, model.TimeAsEpochMicroseconds(date.Add(-time.Hour))))
id2Query := elastic.NewTermQuery("traceID", model.TraceID{High: 0, Low: 2}.String())
id2Search := elastic.NewSearchRequest().
IgnoreUnavailable(true).
Source(r.reader.sourceFn(id2Query, model.TimeAsEpochMicroseconds(now.Add(-time.Hour))))
Source(r.reader.sourceFn(id2Query, model.TimeAsEpochMicroseconds(date.Add(-time.Hour))))
id1SearchSpanTime := elastic.NewSearchRequest().
IgnoreUnavailable(true).
Source(r.reader.sourceFn(id1Query, spanID1.StartTime))
Expand Down Expand Up @@ -264,7 +264,7 @@ func TestSpanReader_multiRead_followUp_query(t *testing.T) {
},
}, nil)

traces, err := r.reader.multiRead(context.Background(), []model.TraceID{{High: 0, Low: 1}, {High: 0, Low: 2}}, now, now)
traces, err := r.reader.multiRead(context.Background(), []model.TraceID{{High: 0, Low: 1}, {High: 0, Low: 2}}, date, date)
require.NoError(t, err)
require.NotNil(t, traces)
require.Len(t, traces, 2)
Expand Down

0 comments on commit 4532ea3

Please sign in to comment.