Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Dec 29, 2023
1 parent 156d28b commit 3abcaa2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ install-tools: install-test-tools install-build-tools
install-ci: install-test-tools install-build-tools

.PHONY: test-ci
#test-ci: GOTEST := $(GOTEST_QUIET) -json
test-ci: GOTEST := $(GOTEST_QUIET) -json
test-ci: install-test-tools build-examples cover

.PHONY: test-report
Expand Down
5 changes: 0 additions & 5 deletions cmd/query/app/apiv3/grpc_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,6 @@ func runGatewayGetTrace(t *testing.T, gw *testGateway, setupRequest func(*http.R
func runGatewayFindTraces(t *testing.T, gw *testGateway, setupRequest func(*http.Request)) {
trace, traceID := makeTestTrace()
q, qp := mockFindQueries()
if !useHTTPGateway {
// grpc-gateway forces inbound timestamps into UTC, so simulate this here
qp.StartTimeMin = qp.StartTimeMin.UTC()
qp.StartTimeMax = qp.StartTimeMax.UTC()
}
gw.reader.
On("FindTraces", matchContext, qp).
Return([]*model.Trace{trace}, nil).Once()
Expand Down
14 changes: 9 additions & 5 deletions cmd/query/app/apiv3/http_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,25 @@ func TestHTTPGatewayGetTraceErrors(t *testing.T) {
}

func mockFindQueries() (url.Values, *spanstore.TraceQueryParameters) {
goodTime := time.Now().Truncate(time.Nanosecond) // truncated to reset monotonic clock
// mock performs deep comparison of the timestamps and can fail
// if they are different in the timezone or the monotonic clocks.
// To void that we truncate monotonic clock and force UTC timezone.
time1 := time.Now().UTC().Truncate(time.Nanosecond)
time2 := time1.Add(-time.Second).UTC().Truncate(time.Nanosecond)
q := url.Values{}
q.Set(paramServiceName, "foo")
q.Set(paramOperationName, "bar")
q.Set(paramTimeMin, goodTime.Add(-time.Second).Format(time.RFC3339Nano))
q.Set(paramTimeMax, goodTime.Format(time.RFC3339Nano))
q.Set(paramTimeMin, time1.Format(time.RFC3339Nano))
q.Set(paramTimeMax, time2.Format(time.RFC3339Nano))
q.Set(paramDurationMin, "1s")
q.Set(paramDurationMax, "2s")
q.Set(paramNumTraces, "10")

return q, &spanstore.TraceQueryParameters{
ServiceName: "foo",
OperationName: "bar",
StartTimeMin: goodTime.Add(-time.Second),
StartTimeMax: goodTime,
StartTimeMin: time1,
StartTimeMax: time2,
DurationMin: 1 * time.Second,
DurationMax: 2 * time.Second,
NumTraces: 10,
Expand Down

0 comments on commit 3abcaa2

Please sign in to comment.