Skip to content

Add integration tests - #24

Merged
slominskir merged 2 commits into
mainfrom
integration-tests
Oct 1, 2026
Merged

slominskir merged 2 commits into
mainfrom
integration-tests

Conversation

@slominskir-coding-agent

Copy link
Copy Markdown
Contributor

Adds integration tests that run against the app and its services in containers, following the pattern of JLab projects such as myquery and epics2web: an integration source set (src/integration/java) and an integrationTest task. The task is not part of ./gradlew build.

Running them

docker compose -f build.yaml up -d --build
./gradlew integrationTest

The tests wait up to 5 minutes for the app, Oracle and Keycloak to be ready (ADM_READY_TIMEOUT_SECONDS). ADM_URL and KEYCLOAK_URL point them at other ports. The README's Develop section says the same.

Tests

The tests use real Keycloak tokens, like CI's deploy workflow: the demo users tbrown (admin) and jadams (user) by password, and the adm client's service account (service-account-adm) by client credentials. Requests go to the app over HTTPS as bearer tokens.

  • DeployIT (10): deploys to the sshd container and reads each job from /log:
  • InventoryIT (2): an admin can add and remove an app env; jadams can't add one.

Each run adds its own app envs, named it- plus a random suffix, and removes them at the end, which removes their deploy jobs too (ON DELETE CASCADE). So runs leave the demo data as they found it, and two runs against one stack don't collide.

Other changes

  • container/keycloak/initdb.d/03_customize.sh now also enables the password grant on the test realm's adm client, so tests can get tokens for demo users. This only affects the local test realm.
  • That script is now executable. The Keycloak image runs only executable *.sh files, so it was silently skipped before, the same problem as Make the sshd container's entrypoint executable #18. Its existing setup (the deployer-group role for jsmith) never ran either; it does now.

CI: please add this job

The GitHub App can't change workflows, so this PR doesn't touch .github/workflows/ci.yaml. To run the tests on every PR, like myquery does, add this job:

  integration:
    needs:
      - build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 21
      - uses: gradle/actions/setup-gradle@v4
        with:
          gradle-version: wrapper
      - name: Start containers
        run: docker compose -f build.yaml up -d --build
      - name: Run integration tests
        run: ./gradlew integrationTest
      - name: Dump container logs
        if: failure()
        run: docker compose -f build.yaml logs
      - name: Stop containers
        if: always()
        run: docker compose -f build.yaml down

I haven't been able to run that job. One risk: Dockerfile-sshd downloads http://pki.jlab.org/JLabCA.crt by default. It's reachable from the agent VM, but I don't know whether GitHub's runners can reach it. If they can't, add --build-arg, or set CUSTOM_CRT_URL to empty for the sshd build in build.yaml.

Checks

On the agent VM, with the stack started by docker compose -f build.yaml up -d --build:

  • ./gradlew integrationTest: 12 passed in 16 s, and again on a second run. No it- envs were left afterwards.
  • With the sshd container stopped, the 4 tests that run a deploy command fail, as they should.
  • ./gradlew clean spotlessCheck build still runs only the unit tests.

The first --build on a fresh machine took about 13 minutes, mostly downloading images (Oracle XE alone is 4.5 GB). After that, the stack was ready about 2 minutes after up.

🤖 Generated with Claude Code

Add an integration source set and an integrationTest task that test
the running app, as started by docker compose -f build.yaml up. Like
other JLab projects, the task is not part of build: it needs the
containers, which take minutes to build and start.

The tests log in to Keycloak with the demo users and with the adm
client's service account, which uses client credentials as CI deploys
do, then call the app over HTTPS:

- DeployIT: deploys to the sshd container as an admin and as the
  service account, and checks each job on the log page: a failing
  command keeps its exit code and output, a prompt gets no input, and
  an unknown host is recorded. Other users, invalid and missing
  versions, unknown envs, and requests without a token are refused.
- InventoryIT: only admins can add app envs.

The tests add their own app envs with unique names and remove them
afterwards, removing their deploy jobs too. They wait up to 5 minutes
for the services to start. ADM_URL and KEYCLOAK_URL point them at
other ports.

To get tokens for demo users, the test realm's adm client now allows
the password grant. container/keycloak/initdb.d/03_customize.sh, which
does that, is now executable: the Keycloak image runs only executable
scripts, so it was skipped before, and the deployer-group role it
creates never existed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/integration/java/org/jlab/adm/Adm.java Fixed
CodeQL flagged the TrustManager that accepted any certificate. Trust the
JDK's CAs plus the self-signed certificate of the jeffersonlab/wildfly
image instead, saved as a test resource. A different certificate now
fails the TLS handshake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@slominskir
slominskir merged commit 70540a6 into main Oct 1, 2026
5 checks passed
@slominskir
slominskir deleted the integration-tests branch October 1, 2026 18:39
@slominskir-coding-agent

slominskir-coding-agent Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Two commits since you started reviewing:

  • 48e22e2: trust only the app's certificate, for the CodeQL alert. I've replied in that thread.
  • 9d46791: wait for Keycloak's setup. awaitReady didn't retry a failed token request, which is an assertion error. It also treated the stack as ready once the service account could log in, which happens before the setup script that enables password logins has run. Starting two stacks at once for Make the Compose stack's ports configurable #26 showed this. I checked it by recreating Keycloak and running the tests straight away: they waited about 2.5 minutes, then all 12 passed.

The squash template uses the first commit's message, which still describes the PR.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants