Skip to content

Commit

Permalink
conflicts resolved
Browse files Browse the repository at this point in the history
Signed-off-by: Manik2708 <[email protected]>
  • Loading branch information
Manik2708 committed Dec 28, 2024
2 parents b0da654 + e7a0205 commit 6570013
Show file tree
Hide file tree
Showing 61 changed files with 774 additions and 712 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e-kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
jaeger-version: [v1, v2]
kafka-version: ["3.x", "2.x"]
kafka-version: ["3.x"]
name: kafka ${{matrix.kafka-version }} ${{ matrix.jaeger-version }}
steps:
- name: Harden Runner
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,24 @@ SCRIPTS_SRC = $(shell find . \( -name '*.sh' -o -name '*.py' -o -name '*.mk' -o
# ALL_PKGS is used with 'nocover' and 'goleak'
ALL_PKGS = $(shell echo $(dir $(ALL_SRC)) | tr ' ' '\n' | sort -u)

UNAME := $(shell uname -m)
ifeq ($(UNAME), s390x)
GO=go
GOOS ?= $(shell $(GO) env GOOS)
GOARCH ?= $(shell $(GO) env GOARCH)

# go test does not support -race flag on s390x architecture
ifeq ($(GOARCH), s390x)
RACE=
else
RACE=-race
endif
# sed on Mac does not support the same syntax for in-place updates as sed on Linux
# When running on MacOS it's best to install gsed and run Makefile with SED=gsed
SED=sed
GO=go
GOOS ?= $(shell $(GO) env GOOS)
GOARCH ?= $(shell $(GO) env GOARCH)
ifeq ($(GOOS),darwin)
SED=gsed
else
SED=sed
endif

GOTEST_QUIET=$(GO) test $(RACE)
GOTEST=$(GOTEST_QUIET) -v
COVEROUT=cover.out
Expand Down
4 changes: 2 additions & 2 deletions Makefile.IntegrationTests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ all-in-one-integration-test:
.PHONY: jaeger-v2-storage-integration-test
jaeger-v2-storage-integration-test:
(cd cmd/jaeger/ && go build .)
# Expire tests results for jaeger storage integration tests since the environment might change
# even though the code remains the same.
# Expire tests results for jaeger storage integration tests since the environment
# might have changed even though the code remains the same.
go clean -testcache
bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(JAEGER_V2_STORAGE_PKGS) $(COLORIZE)"

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ proto-zipkin:
# only to fields in a struct, so we use regex search/replace to swap it.
# Note that the .pb.go types must be generated into the same internal package $(API_V3_PATH)
# where a manually defined traces.go file is located.
API_V3_PATH=cmd/query/app/internal/api_v3
API_V3_PATH=internal/proto/api_v3
API_V3_PATCHED_DIR=proto-gen/.patched/api_v3
API_V3_PATCHED=$(API_V3_PATCHED_DIR)/query_service.proto
.PHONY: patch-api-v3
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/config-kafka-ingester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service:
level: detailed
address: 0.0.0.0:8888
logs:
level: debug
level: info

extensions:
healthcheckv2:
Expand Down
145 changes: 145 additions & 0 deletions cmd/jaeger/internal/integration/binary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package integration

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/ports"
)

// Binary is a wrapper around exec.Cmd to help running binaries in tests.
type Binary struct {
Name string
HealthCheckPort int // overridable for Kafka tests which run two binaries and need different ports
exec.Cmd
}

func (b *Binary) Start(t *testing.T) {
outFile, err := os.OpenFile(
filepath.Join(t.TempDir(), "output_logs.txt"),
os.O_CREATE|os.O_WRONLY,
os.ModePerm,
)
require.NoError(t, err)
t.Logf("Writing the %s output logs into %s", b.Name, outFile.Name())

errFile, err := os.OpenFile(
filepath.Join(t.TempDir(), "error_logs.txt"),
os.O_CREATE|os.O_WRONLY,
os.ModePerm,
)
require.NoError(t, err)
t.Logf("Writing the %s error logs into %s", b.Name, errFile.Name())

b.Stdout = outFile
b.Stderr = errFile

t.Logf("Running command: %v", b.Args)
require.NoError(t, b.Cmd.Start())

t.Cleanup(func() {
if err := b.Process.Kill(); err != nil {
t.Errorf("Failed to kill %s process: %v", b.Name, err)
}
t.Logf("Waiting for %s to exit", b.Name)
b.Process.Wait()
t.Logf("%s exited", b.Name)
if t.Failed() {
b.dumpLogs(t, outFile, errFile)
}
})

// Wait for the binary to start and become ready to serve requests.
require.Eventually(t, func() bool { return b.doHealthCheck(t) },
60*time.Second, 3*time.Second, "%s did not start", b.Name)
t.Logf("%s is ready", b.Name)
}

func (b *Binary) doHealthCheck(t *testing.T) bool {
healthCheckPort := b.HealthCheckPort
if healthCheckPort == 0 {
healthCheckPort = ports.CollectorV2HealthChecks
}
healthCheckEndpoint := fmt.Sprintf("http://localhost:%d/status", healthCheckPort)
t.Logf("Checking if %s is available on %s", b.Name, healthCheckEndpoint)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, healthCheckEndpoint, nil)
if err != nil {
t.Logf("HTTP request creation failed: %v", err)
return false
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
t.Logf("HTTP request failed: %v", err)
return false
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Logf("Failed to read HTTP response body: %v", err)
return false
}
if resp.StatusCode != http.StatusOK {
t.Logf("HTTP response not OK: %v", string(body))
return false
}

var healthResponse struct {
Status string `json:"status"`
}
if err := json.NewDecoder(bytes.NewReader(body)).Decode(&healthResponse); err != nil {
t.Logf("Failed to decode JSON response '%s': %v", string(body), err)
return false
}

// Check if the status field in the JSON is "StatusOK"
if healthResponse.Status != "StatusOK" {
t.Logf("Received non-OK status %s: %s", healthResponse.Status, string(body))
return false
}
return true
}

// Special Github markers to create a foldable section in the GitHub Actions runner output.
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
const (
githubBeginGroup = "::group::"
githubEndGroup = "::endgroup::"
)

func (b *Binary) dumpLogs(t *testing.T, outFile, errFile *os.File) {
fmt.Printf(githubBeginGroup+" 🚧 🚧 🚧 %s binary logs\n", b.Name)
outLogs, err := os.ReadFile(outFile.Name())
if err != nil {
t.Errorf("Failed to read output logs: %v", err)
} else {
fmt.Printf("⏩⏩⏩ Start %s output logs:\n", b.Name)
fmt.Printf("%s\n", outLogs)
fmt.Printf("⏹️⏹️⏹️ End %s output logs.\n", b.Name)
}

errLogs, err := os.ReadFile(errFile.Name())
if err != nil {
t.Errorf("Failed to read error logs: %v", err)
} else {
fmt.Printf("⏩⏩⏩ Start %s error logs:\n", b.Name)
fmt.Printf("%s\n", errLogs)
fmt.Printf("⏹️⏹️⏹️ End %s error logs.\n", b.Name)
}
fmt.Println(githubEndGroup)
}
Loading

0 comments on commit 6570013

Please sign in to comment.