Skip to content

Use temporary folders in tests and smoke test message export archives - #579

Open
tonygermano wants to merge 3 commits into
mainfrom
test/extension-controller-tempdir
Open

tonygermano wants to merge 3 commits into
mainfrom
test/extension-controller-tempdir

Conversation

@tonygermano

Copy link
Copy Markdown
Member

Tests that wrote into the working directory or /tmp now use JUnit TemporaryFolder, a smoke test covers message export to archives, and a misnamed test class now runs.

  • Commit 1 adds MessageExportArchiveTest to the smoke tests. It exports messages to an unencrypted ZIP, a gzipped TAR and a password-protected ZIP for each encryption type, plus a server-side AES-256 export. It checks the archives with the JDK and commons-compress rather than zip4j, so it also holds across a zip4j upgrade (the follow-up PR).
  • Commit 2 converts DefaultExtensionControllerTest, ArchiveUtilsTest, XsltStepTest, FileConnectionTests, Log4jMigrationsTest, Log4jBootstrapTest and XMLBatchAdaptorTest to TemporaryFolder, so they leave nothing behind.
  • Commit 3 renames FileConnectionTests to FileConnectionTest. The root build.gradle only includes **/*Test.class, so Gradle never ran it.

The server-side export in the smoke test writes under the server's appdata/temp in a safe-to-delete-smoketest-export-* folder, because the harness can't delete server files. It is harmless in CI containers.

Claude checked:

  • ./gradlew clean build dist passes on this branch and /tmp is left clean.
  • The new smoke test passes 6 of 6, and the whole admin smoke package 26 of 26, against a server built from commit 1.

No release notes. Test and build changes only.


🤖 Drafted with Claude Code

Nothing exercises message export to an archive against a running server or the
packaged distribution. The unit tests run on the build classpath, so a library
missing from the distribution, or one that misbehaves in it, would go unnoticed
until someone exported messages.

Add a smoke test that sends a few messages through a channel and exports them
the way the administrator's export dialog does:

- Locally, in the harness JVM, which runs with the engine's own jars: an
  unencrypted ZIP, a gzipped TAR, and a ZIP for each encryption type. The
  archives are checked with the JDK and commons-compress, not the ZIP library
  under test, so the test holds when that library is upgraded. For the
  encrypted ones it checks that the JDK refuses to open the archive, that every
  entry name is in the directory, and that the WinZip AES record is present
  exactly when AES was asked for.
- On the server, a password protected ZIP. The harness cannot read the
  server's file system, so this checks that the export completes and counts
  the messages, which fails if the library cannot be loaded or the archive
  cannot be finished.

The test passes against the current zip4j 1.3.3.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Tony Germano <tony@germano.name>
…d /tmp

Several tests created files outside a managed directory:

- DefaultExtensionControllerTest and ArchiveUtilsTest extracted into
  tests/zipextraction relative to the working directory, with an @after that
  only deleted top-level files, and created their zip fixtures in the system
  temp directory without removing them.
- XsltStepTest left its resource-library directory behind, because
  deleteOnExit cannot remove a directory that is not empty.
- FileConnectionTests used a TEST_FileConnection folder in the working
  directory, and Log4jMigrationsTest, Log4jBootstrapTest and
  XMLBatchAdaptorTest relied on deleteOnExit for files in the system temp
  directory.

Use a JUnit TemporaryFolder in all of them so everything is removed after each
test, and use java.nio.file for the files the tests create, read and write
themselves. Calls that need a java.io.File, such as the production APIs under
test and File.setReadable, keep it. The zip extraction directory is a
subfolder of the temporary folder so that the "../" zip-slip entries still
resolve inside it.

FileConnectionTests stays on java.io.File to keep its diff small. Besides
moving its folder to the rule, it restores the read and write permissions that
some tests remove so the rule can delete the folder, and testReadFile now
closes its stream with try-with-resources and lets a FileConnectorException
fail the test instead of catching it.

ZipTestUtils gains an overload that creates the zip in a given directory, and
now also closes the stream when it writes an empty zip. The one-argument
method delegates to it and still uses the system temp directory for
UnzipEngineTest, which is removed separately.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Tony Germano <tony@germano.name>
The test task only includes classes matching **/*Test.class, so
FileConnectionTests was never run by ./gradlew test or in CI. It needs no
database or other infrastructure and passes, so rename it to
FileConnectionTest.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Tony Germano <tony@germano.name>
@github-actions

Copy link
Copy Markdown

Test Results

  143 files  + 1    143 suites  +1   4m 9s ⏱️ +53s
  973 tests +15    973 ✅ +15  0 💤 ±0  0 ❌ ±0 
1 291 runs  +51  1 285 ✅ +51  6 💤 ±0  0 ❌ ±0 

Results for commit 7cc7cd5. ± Comparison against base commit dcd48b9.

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.

3 participants