This document describes the testing strategy for tus-java-server, how to execute each testing tier, and step-by-step instructions for manual lock contention testing.
The repository follows a three-tiered testing hierarchy (see Architecture Guide for architectural details):
- Unit Tests (
*Test.java): Pure offline tests using Mockito. Fast (< 2s), zero containers or network dependencies. Run with:mvn test -q - Integration Tests (
IT*): End-to-end multi-backend validation using Testcontainers (Podman or Docker). Tested across Disk, S3 (RustFS), and Azure (Azurite) in CI. Run with:mvn verify -q
- Conformity Tests (
scripts/*_conformity_test.py): Socket-level Python protocol verification suites executed against running server deployments. See the Conformity Testing Guide for full instructions:python3 scripts/tus_conformity_test.py --url http://localhost:8080/test/api/upload python3 scripts/rufh_conformity_test.py --url http://localhost:8080/test/api/upload
Before performing the manual verification, you need to compile the library and start the Spring Boot demo server.
In the root directory of the tus-java-server project, run:
mvn clean installOpen the spring-boot-rest/pom.xml file in the sibling tus-java-server-spring-demo project and update the version of tus-java-server to the locally built SNAPSHOT version:
<dependency>
<groupId>me.desair.tus</groupId>
<artifactId>tus-java-server</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>Navigate to the sibling tus-java-server-spring-demo project and build/run the server:
cd ../tus-java-server-spring-demo
mvn clean package
java -jar spring-boot-rest/target/spring-boot-rest-0.0.1-SNAPSHOT.jarNote: The demo server runs locally on port 8080 and exposes the upload endpoint at http://localhost:8080/test/api/upload.
The Spring Boot demo application writes upload metadata and file chunks to your system's temporary directory under a folder named tus.
To clean up any files and folders created during testing, delete the temp directory:
- On macOS/Linux:
(or check your system's
rm -rf $TMPDIR/tus$TMPDIR/${java.io.tmpdir}if configured differently)
This guide outlines how to manually verify that the upload lock contention resolution works as expected using the Spring Boot demo server, curl, and pv (Pipe Viewer).
Ensure you have the following tools installed on your client testing machine:
- curl: Standard HTTP client.
- pv (Pipe Viewer): Throttling tool used to simulate a slow or stalled upload.
- macOS:
brew install pv - Debian/Ubuntu:
sudo apt-get install pv
- macOS:
Initiate a new upload to the server:
curl -X POST \
-H "Tus-Resumable: 1.0.0" \
-H "Upload-Length: 10000000" \
-I http://localhost:8080/test/api/uploadLook for the Location header in the response and record the upload resource URL (e.g., http://localhost:8080/test/api/upload/000003f1-a850-49de-af03-997272d834c9). We will refer to this as ${UPLOAD_URL}.
export UPLOAD_URL='http://localhost:8080/test/api/upload/0330595f-1c0d-49f5-9e78-c40b1845157d'
To simulate an active, ongoing upload that is extremely slow (or stalled), run a PATCH request using /dev/zero throttled to 50 KB/s via pv:
dd if=/dev/zero bs=1024 count=10000 | pv -L 50k | curl -X PATCH -T - \
-H "Tus-Resumable: 1.0.0" \
-H "Upload-Offset: 0" \
-H "Content-Type: application/offset+octet-stream" \
${UPLOAD_URL}Keep this request running in your first terminal.
While the upload in Step 2 is actively running and holding the file lock, open a second terminal window and send a HEAD request to query the offset of the same upload resource:
curl -X HEAD -H "Tus-Resumable: 1.0.0" -I ${UPLOAD_URL}- First Terminal (PATCH):
- The stalled/throttled
PATCHupload should immediately abort with an I/O error or exit because the server terminated its input stream in response to the lock release request.
- The stalled/throttled
- Second Terminal (HEAD):
- The
HEADrequest should succeed with status204 No Contentafter a short delay (the server retries up to 300 times at 200ms intervals, a 60-second retry budget, configurable viawithLockWaitTimeout(Duration), while releasing the lock). - The response will contain the
Upload-Offsetheader reflecting the number of bytes successfully written to disk before the stream was interrupted (e.g.,Upload-Offset: 153600).
- The
- Subsequent Uploads:
- You can immediately resume the upload using a new
PATCHrequest starting from the offset returned in theHEADresponse.
- You can immediately resume the upload using a new
To locally verify unit test coverage against a target percentage (default: 93%) and report which lines/files are not covered, you can run the Maven build with the check-coverage profile.
mvn verify -Pcheck-coveragemvn verify -Pcheck-coverage -Djacoco.coverage.limit=80This will:
- Run all unit/integration tests and generate the Jacoco XML coverage report.
- Execute the python checking script (
scripts/check-coverage.py) which parses the report. - Print a detailed list of uncovered (
❌) and partially covered (⚠️) lines for each file. - Fail the build with exit code 1 if the overall line coverage is below the threshold, or succeed if it meets or exceeds it.
You can also use this feature to verify that any new code added in your branch is fully covered compared to another branch (such as master):
mvn verify -Pcheck-coverage -Djacoco.compare.branch=masterIf there are any modified or added lines in your branch (located under src/main/java) that are not covered by unit tests, the build will output a detailed report listing only those lines and fail.