Skip to content

Commit 1c99aa0

Browse files
authored
[refactor] Decouple TraceQueryParams from Query in integration tests (#6779)
## Which problem is this PR solving? - Towards #6765 ## Description of the changes - This PR is a prelude to #6769. That PR was running into issues because a JSON type cannot be unmarshalled into the `pcommon.Map` type. In order to fix that, this PR decouples the `Query` in the integration test from `TraceQueryParams` so that we can accept queries as JSON and populate them into the `TraceQueryParams` as we see fit. ## How was this change tested? - CI ## 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`: `npm run lint` and `npm run test` --------- Signed-off-by: Mahad Zaryab <[email protected]>
1 parent ce07285 commit 1c99aa0

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

internal/storage/integration/integration.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,30 @@ type StorageIntegration struct {
6666

6767
// === SpanStore Integration Tests ===
6868

69+
type Query struct {
70+
ServiceName string
71+
OperationName string
72+
Tags map[string]string
73+
StartTimeMin time.Time
74+
StartTimeMax time.Time
75+
DurationMin time.Duration
76+
DurationMax time.Duration
77+
NumTraces int
78+
}
79+
80+
func (q *Query) ToTraceQueryParams() *tracestore.TraceQueryParams {
81+
return &tracestore.TraceQueryParams{
82+
ServiceName: q.ServiceName,
83+
OperationName: q.OperationName,
84+
Tags: q.Tags,
85+
StartTimeMin: q.StartTimeMin,
86+
StartTimeMax: q.StartTimeMax,
87+
DurationMin: q.DurationMin,
88+
DurationMax: q.DurationMax,
89+
NumTraces: q.NumTraces,
90+
}
91+
}
92+
6993
// QueryFixtures and TraceFixtures are under ./fixtures/queries.json and ./fixtures/traces/*.json respectively.
7094
// Each query fixture includes:
7195
// - Caption: describes the query we are testing
@@ -75,7 +99,7 @@ type StorageIntegration struct {
7599
// the service name is formatted "query##-service".
76100
type QueryFixtures struct {
77101
Caption string
78-
Query *tracestore.TraceQueryParams
102+
Query *Query
79103
ExpectedFixtures []string
80104
}
81105

@@ -317,7 +341,7 @@ func (s *StorageIntegration) testFindTraces(t *testing.T) {
317341
t.Run(queryTestCase.Caption, func(t *testing.T) {
318342
s.skipIfNeeded(t)
319343
expected := expectedTracesPerTestCase[i]
320-
actual := s.findTracesByQuery(t, queryTestCase.Query, expected)
344+
actual := s.findTracesByQuery(t, queryTestCase.Query.ToTraceQueryParams(), expected)
321345
CompareSliceOfTraces(t, expected, actual)
322346
})
323347
}

0 commit comments

Comments
 (0)