Skip to content

Commit

Permalink
[v2] Change e2e jaeger-v2 binary log output to temp file (#5431)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves #5421

## Description of the changes
- Instead of throwing binary logs to the parent's output, it now writes
the logs to a temp file and only outputs the logs if the test fails.
This behavior is similar to the current v1 tests that run `docker logs`
if failed.
- Here's the outcome if the test fails.
```
=== NAME  TestGRPCStorage
    e2e_integration.go:88: Jaeger-v2 logs:
        2024/05/08 00:41:25 application version: git-commit=, git-version=, build-date=
        2024-05-08T00:41:25.557+0700	info	service@v0.99.0/service.go:99	Setting up own telemetry...
        2024-05-08T00:41:25.557+0700	info	service@v0.99.0/telemetry.go:103	Serving metrics	{"address": ":8888", "level": "Normal"}
        2024-05-08T00:41:25.557+0700	info	exporter@v0.99.0/exporter.go:275	Development component. May change in the future.	{"kind": "exporter", "data_type": "traces", "name": "jaeger_storage_exporter"}
        2024-05-08T00:41:25.557+0700	info	service@v0.99.0/service.go:166	Starting jaeger...	{"Version": "git-commit=, git-version=, build-date=", "NumCPU": 8}
        ...
        2024-05-08T00:41:28.151+0700	warn	app/grpc_handler.go:105	trace not found	{"kind": "extension", "name": "jaeger_query", "id": "0000000000000011", "error": "trace not found"}
        2024-05-08T00:41:29.159+0700	warn	app/grpc_handler.go:105	trace not found	{"kind": "extension", "name": "jaeger_query", "id": "0000000000000001", "error": "trace not found"}
        2024-05-08T00:42:20.300+0700	info	exporterhelper/retry_sender.go:118	Exporting failed. Will retry the request after interval.	{"kind": "exporter", "data_type": "traces", "name": "jaeger_storage_exporter", "error": "plugin error: rpc error: code = Unavailable desc = error reading from server: read tcp [::1]:60235->[::1]:17271: read: connection reset by peer", "interval": "4.858861617s"}
--- ❌ FAIL: TestGRPCStorage (71.93s)
    ...
    --- ✅ PASS: TestGRPCStorage/GetLargeSpans (50.57s)
    --- ❌ FAIL: TestGRPCStorage/FindTraces (17.11s)
        --- ✅ PASS: TestGRPCStorage/FindTraces/Tags_in_one_spot_-_Tags (0.02s)
        ...
        --- ❌ FAIL: TestGRPCStorage/FindTraces/Operation_name_+_max_Duration (5.13s)
        ...
        --- ✅ PASS: TestGRPCStorage/FindTraces/Multiple_Traces (0.02s)
❌ FAIL
coverage: 13.0% of statements in ./...
❌ FAIL	github.com/jaegertracing/jaeger/cmd/jaeger/internal/integration	72.620s
❌ FAIL
```

## How was this change tested?
- Run locally the `STORAGE=grpc SPAN_STORAGE_TYPE=memory make
jaeger-v2-storage-integration-test` command with success and fail
scenario.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] 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`: `yarn lint` and `yarn test`

---------

Signed-off-by: James Ryans <james.ryans2012@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-authored-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
james-ryans and yurishkuro authored May 8, 2024
1 parent b6c7242 commit 7d21f49
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ignore:
- "**/thrift-0.9.2/*"
- "**/main.go"
- "examples/hotrod"
- "plugin/storage/integration"
- "cmd/jaeger/internal/integration"

coverage:
precision: 2
Expand Down
37 changes: 34 additions & 3 deletions cmd/jaeger/internal/integration/e2e_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,32 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) {
logger := zaptest.NewLogger(t, zaptest.Level(zap.DebugLevel))
configFile := createStorageCleanerConfig(t, s.ConfigFile, storage)
t.Logf("Starting Jaeger-v2 in the background with config file %s", configFile)

outFile, err := os.OpenFile(
filepath.Join(t.TempDir(), "jaeger_output_logs.txt"),
os.O_CREATE|os.O_WRONLY,
os.ModePerm,
)
require.NoError(t, err)
t.Logf("Writing the Jaeger-v2 output logs into %s", outFile.Name())

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

cmd := exec.Cmd{
Path: "./cmd/jaeger/jaeger",
Args: []string{"jaeger", "--config", configFile},
// Change the working directory to the root of this project
// since the binary config file jaeger_query's ui_config points to
// "./cmd/jaeger/config-ui.json"
Dir: "../../../..",
Stdout: os.Stderr,
Stderr: os.Stderr,
Stdout: outFile,
Stderr: errFile,
}
require.NoError(t, cmd.Start())
require.Eventually(t, func() bool {
Expand All @@ -77,9 +94,23 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) {
t.Log("Jaeger-v2 is ready")
t.Cleanup(func() {
require.NoError(t, cmd.Process.Kill())
if t.Failed() {
// A Github Actions special annotation to create a foldable section
// in the Github runner output.
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
fmt.Println("::group::Jaeger-v2 binary logs")
outLogs, err := os.ReadFile(outFile.Name())
require.NoError(t, err)
fmt.Printf("Jaeger-v2 output logs:\n%s", outLogs)

errLogs, err := os.ReadFile(errFile.Name())
require.NoError(t, err)
fmt.Printf("Jaeger-v2 error logs:\n%s", errLogs)
// End of Github Actions foldable section annotation.
fmt.Println("::endgroup::")
}
})

var err error
s.SpanWriter, err = createSpanWriter(logger, otlpPort)
require.NoError(t, err)
s.SpanReader, err = createSpanReader(ports.QueryGRPC)
Expand Down

0 comments on commit 7d21f49

Please sign in to comment.