Skip to content

Commit

Permalink
Merge branch 'main' into kind
Browse files Browse the repository at this point in the history
  • Loading branch information
Manik2708 authored Jan 5, 2025
2 parents 543eb32 + e7ed1e1 commit fc72af5
Show file tree
Hide file tree
Showing 43 changed files with 446 additions and 454 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: define matrix
id: set-matrix
run: |
echo "matrix=$(bash scripts/platforms-to-gh-matrix.sh)" >> $GITHUB_OUTPUT
echo "matrix=$(bash scripts/utils/platforms-to-gh-matrix.sh)" >> $GITHUB_OUTPUT
build-binaries:
needs: generate-matrix
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-lint-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
python-version: '3.x'

- name: Run DCO check
run: python3 scripts/dco_check.py -b main -v --exclude-pattern '@users\.noreply\.github\.com'
run: python3 scripts/lint/dco_check.py -b main -v --exclude-pattern '@users\.noreply\.github\.com'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -116,4 +116,4 @@ jobs:

- name: Run unit tests for scripts
run: |
SHUNIT2=.tools/shunit2 bash scripts/compute-tags.test.sh
SHUNIT2=.tools/shunit2 bash scripts/utils/compute-tags.test.sh
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,26 @@ cover: nocover
.PHONY: nocover
nocover:
@echo Verifying that all packages have test files to count in coverage
@scripts/check-test-files.sh $(ALL_PKGS)
@scripts/lint/check-test-files.sh $(ALL_PKGS)

.PHONY: fmt
fmt: $(GOFUMPT)
@echo Running import-order-cleanup on ALL_SRC ...
@./scripts/import-order-cleanup.py -o inplace -t $(ALL_SRC)
@./scripts/lint/import-order-cleanup.py -o inplace -t $(ALL_SRC)
@echo Running gofmt on ALL_SRC ...
@$(GOFMT) -e -s -l -w $(ALL_SRC)
@echo Running gofumpt on ALL_SRC ...
@$(GOFUMPT) -e -l -w $(ALL_SRC)
@echo Running updateLicense.py on ALL_SRC ...
@./scripts/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC)
@./scripts/lint/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC)

.PHONY: lint
lint: lint-license lint-imports lint-semconv lint-goversion lint-goleak lint-go

.PHONY: lint-license
lint-license:
@echo Verifying that all files have license headers
@./scripts/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC) > $(FMT_LOG)
@./scripts/lint/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC) > $(FMT_LOG)
@[ ! -s "$(FMT_LOG)" ] || (echo "License check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)

.PHONY: lint-nocommit
Expand All @@ -169,21 +169,21 @@ lint-nocommit:
.PHONY: lint-imports
lint-imports:
@echo Verifying that all Go files have correctly ordered imports
@./scripts/import-order-cleanup.py -o stdout -t $(ALL_SRC) > $(IMPORT_LOG)
@./scripts/lint/import-order-cleanup.py -o stdout -t $(ALL_SRC) > $(IMPORT_LOG)
@[ ! -s "$(IMPORT_LOG)" ] || (echo "Import ordering failures, run 'make fmt'" | cat - $(IMPORT_LOG) && false)

.PHONY: lint-semconv
lint-semconv:
./scripts/check-semconv-version.sh
./scripts/lint/check-semconv-version.sh

.PHONY: lint-goversion
lint-goversion:
./scripts/check-go-version.sh
./scripts/lint/check-go-version.sh

.PHONY: lint-goleak
lint-goleak:
@echo Verifying that all packages with tests have goleak in their TestMain
@scripts/check-goleak-files.sh $(ALL_PKGS)
@scripts/lint/check-goleak-files.sh $(ALL_PKGS)

.PHONY: lint-go
lint-go: $(LINT)
Expand All @@ -195,11 +195,11 @@ run-all-in-one: build-ui

.PHONY: changelog
changelog:
./scripts/release-notes.py --exclude-dependabot --verbose
./scripts/release/notes.py --exclude-dependabot --verbose

.PHONY: draft-release
draft-release:
./scripts/draft-release.py
./scripts/release/draft.py

.PHONY: test-ci
test-ci: GOTEST := $(GOTEST_QUIET)
Expand Down
4 changes: 2 additions & 2 deletions Makefile.BuildInfo.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ GIT_SHA=$(shell git rev-parse HEAD)
DATE=$(shell TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%dT%H:%M:%SZ' --format="%cd")
# Defer evaluation of semver tags until actually needed, using trick from StackOverflow:
# https://stackoverflow.com/questions/44114466/how-to-declare-a-deferred-variable-that-is-computed-only-once-for-all
GIT_CLOSEST_TAG_V1 = $(eval GIT_CLOSEST_TAG_V1 := $(shell scripts/compute-version.sh v1))$(GIT_CLOSEST_TAG_V1)
GIT_CLOSEST_TAG_V2 = $(eval GIT_CLOSEST_TAG_V2 := $(shell scripts/compute-version.sh v2))$(GIT_CLOSEST_TAG_V2)
GIT_CLOSEST_TAG_V1 = $(eval GIT_CLOSEST_TAG_V1 := $(shell scripts/utils/compute-version.sh v1))$(GIT_CLOSEST_TAG_V1)
GIT_CLOSEST_TAG_V2 = $(eval GIT_CLOSEST_TAG_V2 := $(shell scripts/utils/compute-version.sh v2))$(GIT_CLOSEST_TAG_V2)

# args: (1) - name, (2) - value
define buildinfo
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endef

.PHONY: _build-syso
_build-syso: $(GOVERSIONINFO)
$(eval SEMVER_ALL := $(shell scripts/compute-version.sh -s v1))
$(eval SEMVER_ALL := $(shell scripts/utils/compute-version.sh -s v1))
$(eval SEMVER_MAJOR := $(word 2, $(SEMVER_ALL)))
$(eval SEMVER_MINOR := $(word 3, $(SEMVER_ALL)))
$(eval SEMVER_PATCH := $(word 4, $(SEMVER_ALL)))
Expand Down
71 changes: 38 additions & 33 deletions cmd/query/app/apiv3/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import (
"github.com/gorilla/mux"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"

"github.com/jaegertracing/jaeger/internal/proto/api_v3"
"github.com/jaegertracing/jaeger/model"
_ "github.com/jaegertracing/jaeger/pkg/gogocodec" // force gogo codec registration
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
"github.com/jaegertracing/jaeger/pkg/iter"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
tracestoremocks "github.com/jaegertracing/jaeger/storage_v2/tracestore/mocks"
)

// Utility functions used from http_gateway_test.go.
Expand All @@ -35,10 +37,13 @@ const (
// Snapshots can be regenerated via:
//
// REGENERATE_SNAPSHOTS=true go test -v ./cmd/query/app/apiv3/...
var regenerateSnapshots = os.Getenv("REGENERATE_SNAPSHOTS") == "true"
var (
regenerateSnapshots = os.Getenv("REGENERATE_SNAPSHOTS") == "true"
traceID = pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
)

type testGateway struct {
reader *spanstoremocks.Reader
reader *tracestoremocks.Reader
url string
router *mux.Router
// used to set a tenancy header when executing requests
Expand Down Expand Up @@ -80,23 +85,19 @@ func parseResponse(t *testing.T, body []byte, obj gogoproto.Message) {
require.NoError(t, gogojsonpb.Unmarshal(bytes.NewBuffer(body), obj))
}

func makeTestTrace() (*model.Trace, spanstore.GetTraceParameters) {
traceID := model.NewTraceID(150, 160)
query := spanstore.GetTraceParameters{TraceID: traceID}
return &model.Trace{
Spans: []*model.Span{
{
TraceID: traceID,
SpanID: model.NewSpanID(180),
OperationName: "foobar",
Tags: []model.KeyValue{
model.SpanKindTag(model.SpanKindServer),
model.Bool("error", true),
},
Process: &model.Process{},
},
},
}, query
func makeTestTraceV2() ptrace.Traces {
trace := ptrace.NewTraces()
resources := trace.ResourceSpans().AppendEmpty()
scopes := resources.ScopeSpans().AppendEmpty()

spanA := scopes.Spans().AppendEmpty()
spanA.SetName("foobar")
spanA.SetTraceID(traceID)
spanA.SetSpanID(pcommon.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 2}))
spanA.SetKind(ptrace.SpanKindServer)
spanA.Status().SetCode(ptrace.StatusCodeError)

return trace
}

func runGatewayTests(
Expand Down Expand Up @@ -125,10 +126,10 @@ func (gw *testGateway) runGatewayGetServices(t *testing.T) {
}

func (gw *testGateway) runGatewayGetOperations(t *testing.T) {
qp := spanstore.OperationQueryParameters{ServiceName: "foo", SpanKind: "server"}
qp := tracestore.OperationQueryParams{ServiceName: "foo", SpanKind: "server"}
gw.reader.
On("GetOperations", matchContext, qp).
Return([]spanstore.Operation{{Name: "get_users", SpanKind: "server"}}, nil).Once()
Return([]tracestore.Operation{{Name: "get_users", SpanKind: "server"}}, nil).Once()

body, statusCode := gw.execRequest(t, "/api/v3/operations?service=foo&span_kind=server")
require.Equal(t, http.StatusOK, statusCode)
Expand All @@ -142,21 +143,25 @@ func (gw *testGateway) runGatewayGetOperations(t *testing.T) {
}

func (gw *testGateway) runGatewayGetTrace(t *testing.T) {
trace, query := makeTestTrace()
gw.reader.On("GetTrace", matchContext, query).Return(trace, nil).Once()
gw.getTracesAndVerify(t, "/api/v3/traces/"+query.TraceID.String(), query.TraceID)
query := tracestore.GetTraceParams{TraceID: traceID}
gw.reader.
On("GetTraces", matchContext, query).
Return(iter.Seq2[[]ptrace.Traces, error](func(yield func([]ptrace.Traces, error) bool) {
yield([]ptrace.Traces{makeTestTraceV2()}, nil)
})).Once()
gw.getTracesAndVerify(t, "/api/v3/traces/1", traceID)
}

func (gw *testGateway) runGatewayFindTraces(t *testing.T) {
trace, query := makeTestTrace()
q, qp := mockFindQueries()
gw.reader.
On("FindTraces", matchContext, qp).
Return([]*model.Trace{trace}, nil).Once()
gw.getTracesAndVerify(t, "/api/v3/traces?"+q.Encode(), query.TraceID)
gw.reader.On("FindTraces", matchContext, qp).
Return(iter.Seq2[[]ptrace.Traces, error](func(yield func([]ptrace.Traces, error) bool) {
yield([]ptrace.Traces{makeTestTraceV2()}, nil)
})).Once()
gw.getTracesAndVerify(t, "/api/v3/traces?"+q.Encode(), traceID)
}

func (gw *testGateway) getTracesAndVerify(t *testing.T, url string, expectedTraceID model.TraceID) {
func (gw *testGateway) getTracesAndVerify(t *testing.T, url string, expectedTraceID pcommon.TraceID) {
body, statusCode := gw.execRequest(t, url)
require.Equal(t, http.StatusOK, statusCode, "response=%s", string(body))
body = gw.verifySnapshot(t, body)
Expand Down
Loading

0 comments on commit fc72af5

Please sign in to comment.