Skip to content

Make child-process tests portable across operating systems - #12355

Open
AlexeyKuznetsov-DD wants to merge 1 commit into
masterfrom
alexeyk/pure-java-test-commands
Open

Make child-process tests portable across operating systems#12355
AlexeyKuznetsov-DD wants to merge 1 commit into
masterfrom
alexeyk/pure-java-test-commands

Conversation

@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor

What Does This Do

Adds PortableCommand so tests can run echo, cat, sleep, and a non-terminating command without OS-specific call sites. POSIX keeps native utilities; Windows uses a small child JVM.

Migrates ProcessSupervisorTest and ShellCommandExecutorTest to the portable commands.

Motivation

Make child-process tests OS-independent without relying on Windows shell builtins or changing existing POSIX behavior.

Additional Notes

Validated the helper on the default JVM and Java 8, plus both migrated test classes: 43 focused test executions passed.

Contributor Checklist

Jira ticket: N/A

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD added comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Aug 31, 2026
@AlexeyKuznetsov-DD AlexeyKuznetsov-DD self-assigned this Aug 31, 2026
@datadog-prod-us1-6

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.82 s 14.79 s [-0.7%; +1.1%] (no difference)
startup:insecure-bank:tracing:Agent 13.63 s 13.75 s [-1.7%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 17.40 s 17.34 s [-0.7%; +1.4%] (no difference)
startup:petclinic:iast:Agent 16.87 s 17.60 s [-8.4%; +0.1%] (no difference)
startup:petclinic:profiling:Agent 17.45 s 17.32 s [-0.3%; +1.7%] (no difference)
startup:petclinic:sca:Agent 17.55 s 17.41 s [-0.1%; +1.7%] (no difference)
startup:petclinic:tracing:Agent 16.58 s 16.66 s [-1.4%; +0.5%] (no difference)

Commit: 25626260 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD removed the tag: ai generated Largely based on code generated by an AI or LLM label Sep 1, 2026
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD marked this pull request as ready for review September 1, 2026 23:11
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD requested review from a team as code owners September 1, 2026 23:11
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD requested review from dougqh and removed request for a team September 1, 2026 23:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T23:16:44.721286Z 2562626 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 256262607b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


@VisibleForTesting
static String[] echo(String value, boolean emulated) {
return emulated ? emulate("echo", value) : new String[] {"echo", value};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve literal echo values on POSIX

When value is option-like (for example -n, -e, or GNU --help), the native echo interprets it instead of printing it, while the Windows JVM implementation prints the literal value and a newline. This makes PortableCommand.echo(value) observably OS-dependent for valid inputs; use a literal-safe POSIX command such as printf or otherwise prevent native option parsing.

Useful? React with 👍 / 👎.

}
switch (arguments[0]) {
case "echo":
output.write((argument(arguments) + System.lineSeparator()).getBytes(UTF_8));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match the caller's charset in emulated echo

On Windows JVMs whose default charset is not UTF-8, such as typical JDK 8 installations, this writes UTF-8 bytes while the migrated ShellCommandExecutorTest consumes them through IOUtils.readFully, which decodes with Charset.defaultCharset(). A non-ASCII value such as é therefore becomes mojibake on the emulated path even though the API accepts arbitrary strings; encode using the inherited default charset or make callers explicitly decode UTF-8.

Useful? React with 👍 / 👎.

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Datadog Autotest: FAIL

The new echo helper changes valid values across operating systems. POSIX treats option-like values as flags, and Windows can write non-ASCII text in a charset that the migrated consumer does not use.

Open Bits AI session

🤖 Datadog Autotest · Commit 2562626 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest


@VisibleForTesting
static String[] echo(String value, boolean emulated) {
return emulated ? emulate("echo", value) : new String[] {"echo", value};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Preserve option-like echo values on POSIX

Tests that use option-like values can produce different results on POSIX and Windows.

Assertion details
  • Input: Call PortableCommand.echo("-n") on a POSIX system.
  • Expected: The command prints the literal value -n and a line separator on all operating systems.
  • Actual: The POSIX command is echo -n. The native utility treats -n as an option. It prints no value and no line separator.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest · Open Bits AI session

}
switch (arguments[0]) {
case "echo":
output.write((argument(arguments) + System.lineSeparator()).getBytes(UTF_8));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Use a compatible charset for Windows echo output

Tests with non-ASCII echo values can pass on POSIX and return incorrect output on Windows.

Assertion details
  • Input: Run PortableCommand.echo with a non-ASCII value on a Windows JVM whose default charset is not UTF-8, such as Java 8 with Cp1252.
  • Expected: The migrated consumer reads the same non-ASCII value that the caller supplies.
  • Actual: The child JVM writes UTF-8 bytes. The migrated consumer reads them with the default charset. On affected Windows JVMs, the consumer reads incorrect characters.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest · Open Bits AI session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: testing Testing tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant