Skip to content

chore: migrate Trace Viewer tests to use real Trace viewer #1830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented Aug 20, 2025

Fixes #1829

@mxschmitt mxschmitt requested a review from Copilot August 20, 2025 14:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates Trace Viewer tests from a JSON-based approach to using the actual Trace Viewer web application for validation. The change improves test coverage by testing the real UI components instead of just parsing trace files.

  • Replaced JSON parsing and verification of trace events with actual Trace Viewer UI interactions
  • Added a new TraceViewerPage helper class to encapsulate Trace Viewer UI operations
  • Enhanced the test server to serve static files from the filesystem to support hosting the Trace Viewer

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
TestTracing.java Migrated all trace verification logic from JSON parsing to Trace Viewer UI testing, added TraceViewerPage helper class
Server.java Added static file serving capability to support hosting Trace Viewer from filesystem

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -187,7 +193,19 @@ public void handle(HttpExchange exchange) throws IOException {
path = "/index.html";
}

// Resources from "src/test/resources/" are copied to "resources/" directory in the jar.
// If static files directory is set, serve from filesystem first
if (staticFilesDirectory != null) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

underneath we do something similar but via getResourceAsStream which got introduced here - do you remember why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the standard way to read resources in a maven package (they move from the source into the test package artifact). I'd keep using it with the custom base dir too, can we do that?

@@ -187,7 +193,19 @@ public void handle(HttpExchange exchange) throws IOException {
path = "/index.html";
}

// Resources from "src/test/resources/" are copied to "resources/" directory in the jar.
// If static files directory is set, serve from filesystem first
if (staticFilesDirectory != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the standard way to read resources in a maven package (they move from the source into the test package artifact). I'd keep using it with the custom base dir too, can we do that?

// If static files directory is set, serve from filesystem first
if (staticFilesDirectory != null) {
java.nio.file.Path filePath = staticFilesDirectory.resolve(path.substring(1)); // Remove leading /
if (java.nio.file.Files.exists(filePath) && !java.nio.file.Files.isDirectory(filePath)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop java.nio.file. prefix?

}

private void showTraceViewer(Path tracePath, TraceViewerConsumer callback) throws Exception {
Path driverDir = Driver.ensureDriverInstalled(java.util.Collections.emptyMap(), true).driverDir();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this method along with the trace viewer POM into its own file? Also consider turning the viewer into a fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[internal] Use Real Trace Viewer for tracing tests
2 participants