Skip to content

[JBANG-IT] Add cleanups for tests that can produce state leaks - #25948

Merged
Croway merged 1 commit into
apache:mainfrom
jvrubel:jbang-fix-state-leaks
Aug 31, 2026
Merged

[JBANG-IT] Add cleanups for tests that can produce state leaks#25948
Croway merged 1 commit into
apache:mainfrom
jvrubel:jbang-fix-state-leaks

Conversation

@jvrubel

@jvrubel jvrubel commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

When running tests on bare metal using -Dcli.service.skip.install=true -Dcamel-cli.instance.type=local-camel-cli-process some configurations can affect subsequent tests. This PR aims to reset the environment to the default state after each test is finished by unsetting configuration and ending camel processes in classes that run them. Also setting CamelDebugITCase as container-only.

@github-actions github-actions Bot added the dsl label Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@Croway
Croway merged commit 6f45acb into apache:main Aug 31, 2026
5 checks passed

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good work adding @AfterEach cleanup to prevent state leaks when running JBang integration tests on bare metal. The base class JBangTestSupport.afterEach() change is especially valuable — centralizing config cleanup there covers all subclasses consistently.

A few gaps I noticed in the cleanup coverage:

Missing execute("stop") in three modified classes:

The PR adds @AfterEach cleanup methods to DevModeITCase, HistoryITCase, and RunCommandITCase, but these only clean up files — they don't call execute("stop") to terminate background Camel processes started via executeBackground(). This is inconsistent with the pattern applied to 17 other classes in this same PR (CamelGetITCase, CamelLogITCase, CmdLoadITCase, etc.) and contradicts the stated goal of "ending camel processes in classes that run them."

  • DevModeITCase — 6 executeBackground() calls, cleanup only does cleanupProfileFiles()
  • HistoryITCase — 1 executeBackground() call, cleanup only does cleanupInbox()
  • RunCommandITCase — 15+ executeBackground() calls, cleanup only does cleanupContainerFiles()

Adding execute("stop") to these three @AfterEach methods would make the cleanup consistent.

Redundant cleanup in CamelConfigITCase:

The resetConfig() method in CamelConfigITCase unsets runtime, gav, and directory, but the base class JBangTestSupport.afterEach() now also unsets all three (plus camel-version). Since JUnit 5 runs subclass @AfterEach before superclass @AfterEach, the subclass cleanup is entirely redundant. Consider removing the resetConfig() method or trimming it to only CamelConfigITCase-specific cleanup.

📋 PR Metadata

Aspect Current Suggested
Labels dsl + test
Milestone (none) 4.23.0

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

gnodet added a commit to gnodet/camel that referenced this pull request Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-it

🔬 Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 0 all tested

Maveniverse Scalpel detected 1 affected modules (current approach: 0).

⚠️ Modules only in Scalpel (1)
  • camel-jbang-it

Skip-tests mode would test 1 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (1)
  • camel-jbang-it

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-it: 1 test(s) disabled on GitHub Actions

⚙️ View full build and test results

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants