Skip to content

Commit

Permalink
[refactor] Decouple TraceQueryParams from Query in integration te…
Browse files Browse the repository at this point in the history
…sts (#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]>
  • Loading branch information
mahadzaryab1 authored Feb 27, 2025
1 parent ce07285 commit 1c99aa0
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions internal/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,30 @@ type StorageIntegration struct {

// === SpanStore Integration Tests ===

type Query struct {
ServiceName string
OperationName string
Tags map[string]string
StartTimeMin time.Time
StartTimeMax time.Time
DurationMin time.Duration
DurationMax time.Duration
NumTraces int
}

func (q *Query) ToTraceQueryParams() *tracestore.TraceQueryParams {
return &tracestore.TraceQueryParams{
ServiceName: q.ServiceName,
OperationName: q.OperationName,
Tags: q.Tags,
StartTimeMin: q.StartTimeMin,
StartTimeMax: q.StartTimeMax,
DurationMin: q.DurationMin,
DurationMax: q.DurationMax,
NumTraces: q.NumTraces,
}
}

// QueryFixtures and TraceFixtures are under ./fixtures/queries.json and ./fixtures/traces/*.json respectively.
// Each query fixture includes:
// - Caption: describes the query we are testing
Expand All @@ -75,7 +99,7 @@ type StorageIntegration struct {
// the service name is formatted "query##-service".
type QueryFixtures struct {
Caption string
Query *tracestore.TraceQueryParams
Query *Query
ExpectedFixtures []string
}

Expand Down Expand Up @@ -317,7 +341,7 @@ func (s *StorageIntegration) testFindTraces(t *testing.T) {
t.Run(queryTestCase.Caption, func(t *testing.T) {
s.skipIfNeeded(t)
expected := expectedTracesPerTestCase[i]
actual := s.findTracesByQuery(t, queryTestCase.Query, expected)
actual := s.findTracesByQuery(t, queryTestCase.Query.ToTraceQueryParams(), expected)
CompareSliceOfTraces(t, expected, actual)
})
}
Expand Down

0 comments on commit 1c99aa0

Please sign in to comment.