Skip to content

TEST: Run the Selenium contract tests against the on-premise web example too - #589

Draft
jwrosewell wants to merge 7 commits into
mainfrom
feature/selenium-onprem-demo
Draft

jwrosewell wants to merge 7 commits into
mainfrom
feature/selenium-onprem-demo

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Problem

ci/run-integration-tests.ps1 ran the shared Selenium contract tests from selenium-api-tests (category Contract, 9 cases) against the cloud web example only. Every web example, cloud and on-premise, is expected to give the same client-side results, so the on-premise example should be tested the same way.

Reading the script and the logs of run 34989242481 showed three further faults.

  1. A Selenium failure did not fail the job. The exit code of dotnet test was never checked, and the performance tests that follow reset $LASTEXITCODE. In that run the Ubuntu_ARM_Java_17 job reported success with Failed! - Failed: 9, Passed: 0.
  2. Those nine failures were all Exec format error when starting selenium-manager, because the Selenium Manager binary the suite ships for Linux is built for x64 only.
  3. On Windows, the wait for the example (curl -o /dev/null) ended with curl: (23) client returned ERROR on write, so it did not really wait. The tests passed anyway because the cloud example happened to be up.

Change

  • The Selenium section is now a function, Invoke-ContractTests, that builds one example module, starts it with Start-Process on its own port with the environment it needs, waits up to three minutes with Invoke-WebRequest, runs dotnet test selenium-api-tests -c Release --filter TestCategory=Contract with EXAMPLE_URL and EXAMPLE_LANG=java, prints the example's output on failure, and stops the process.
  • It runs twice, for web/getting-started.cloud on port 8099 (as before) and for web/getting-started.onprem on port 8098 with 51DEGREES_DD_PATH set to the TAC data file already copied into the examples repository. The Lite data file has neither DeviceType nor the JavaScript properties the contract tests need.
  • Failures from both runs are collected and then thrown, so either one fails the job.
  • On Arm64 Linux the Selenium tests are skipped with a message, for the reason in point 2.
  • A separate commit makes failing example tests fail the job too. The exit code of the examples' mvn clean test was stored in $status and never read. It is now kept and reported together with any Selenium failure, once all the tests have run.

Merge order

The companion change in device-detection-java-examples, device-detection-java-examples#663, must merge first. This script clones that repository's main, and before that change the on-premise example ignores PORT and 51DEGREES_DD_PATH and waits for Enter, so the on-premise run would fail.

Verification

The branch test/selenium-onprem-demo held this branch's commits plus one extra commit that cloned the examples branch instead of main. It has been deleted now that the runs are done. The "Pull Requests" workflow was dispatched on it with dryrun=true, which builds that branch without merging anything.

Run 35157685031, on the head of this branch plus the test commit, concluded success. Contract result lines per job:

Job Result Cloud example (port 8099) On-premise example (port 8098, TAC file)
MacOS_ARM_Java_11 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
MacOS_ARM_Java_17 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
MacOS_ARM_Java_21 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
MacOS_X64_Java_11 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
MacOS_X64_Java_17 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
MacOS_X64_Java_21 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
MacOS_X64_Java_8 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Ubuntu_ARM_Java_17 success skipped (Arm64 Linux) skipped (Arm64 Linux)
Ubuntu_Java_11 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Ubuntu_Java_17 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Ubuntu_Java_21 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Ubuntu_Java_8 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Windows_Java_11 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Windows_Java_17 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Windows_Java_21 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped
Windows_Java_8 success Passed 9 of 9, 0 failed, 0 skipped Passed 9 of 9, 0 failed, 0 skipped

The earlier run 35153491220, before the example exit code commit, gave the same 9 of 9 for both examples in the same 15 jobs. The first attempt, run 35152629775, failed before any test ran, because a mandatory parameter refused the empty failure list. The second commit on this branch fixes that.

Outstanding

  • Running the Selenium tests on Arm64 Linux would need a change in the suite, for example pointing Selenium at a locally installed chromedriver.

State on 17 September 2026, and why this is still a draft

The last full run on this branch's head 0ebdda9,
35161390489,
failed in Ubuntu_Java_17 for the reason the merge order section above gives.
The on-premise example was started on port 8098 and ignored it, listening on
8081 instead, then read the data file path it was given as a relative path it
could not use, and finally died waiting for Enter:

Caused by: java.lang.IllegalStateException: Failed to create SwigEngine after 10
retries, last exception was The data was not in the correct format. Check the
data file 'device-detection-data/51Degrees-LiteV4.1.hash' is uncompressed.
...
Started ServerConnector@23986957{HTTP/1.1, (http/1.1)}{0.0.0.0:8081}
Exception in thread "main" java.util.NoSuchElementException: No line found
        at fiftyone.devicedetection.examples.web.EmbedJetty.runWebApp
Integration tests failed: the on-premise example did not answer on port 8098

That is the old example, taken from main of the examples repository, because
ci/run-integration-tests.ps1 calls clone-repo.ps1 with no branch and that
step defaults to main. So this pull request cannot go green until
device-detection-java-examples#663
has merged. That one is now out of draft, so the nightly can take it.

One more thing for whoever merges these. This pull request and
#592 both rewrite
parts of ci/run-integration-tests.ps1 and they conflict with each other, in the
Selenium block. Whichever merges second needs main merged into it by hand and
the block resolved, rather than a straight merge.

…ple too

The integration tests already ran the shared contract tests against the
cloud web example. They now also start the on-premise web example on
port 8098 with the TAC data file, because the Lite file lacks DeviceType
and the JavaScript properties the tests need.

A failing Selenium run now fails the job. Before, the exit code of dotnet
test was overwritten by later steps, so a run where all nine tests failed
on the Arm64 Linux runner still reported success. That runner is now
skipped with a message, because the Selenium Manager binary the suite
ships for Linux is x64 only.

The wait for the example uses Invoke-WebRequest, because curl on Windows
could not write to /dev/null and returned exit code 23.

The on-premise example must first be able to take its port and data file
from the environment, a change in device-detection-java-examples that has
to merge before this one.
A mandatory parameter refuses an empty collection, so the first call
failed before any test ran.
The exit code of the examples' mvn clean test was stored in $status and
never read, so failing example tests left the job green. The code is now
kept and reported, together with any Selenium failure, once all the
tests have run.
A failing dotnet test returns non-zero, and PowerShell carries on, so the
Selenium step could fail every case and the job was still reported as a
success. On the ARM64 Linux job it did exactly that, with nine failures in
the log and a green tick on the run. The exit code is now checked and the
step stops.

SELENIUM_TESTS_REF picks a branch of the shared browser suite, defaulting
to main, so a change there can be tried here before it is merged.
Points the browser suite at the branch carrying the ARM64 fix and trims
the matrix to the ARM64 Linux job, so one dispatched run shows whether the
browser tests really run there.
This reverts the temporary pin and matrix trim used for run 35198427368,
which proved the browser tests really run on the ARM64 Linux job. The
matrix is back to the full list and the suite is read from main again.
…ium-onprem-demo

Both branches rewrite the Selenium block of ci/run-integration-tests.ps1, and
that block is the only place they conflicted. The resolution keeps this
branch's structure, being the Invoke-ContractTests function that runs the
contract tests against one example, the Arm64 Linux skip and the collected
failures, and adds the SELENIUM_TESTS_REF branch selection from the other
branch so a change to the shared contract test suite can be tried here before
it is merged.

The other branch also checks the exit code from dotnet test so a failing
contract run reaches the job result. That behaviour already has an equivalent
on this branch, inside Invoke-ContractTests, which records a failure when
dotnet test returns non-zero, so both changes survive the merge.
@jwrosewell

Copy link
Copy Markdown
Contributor Author

The conflict with 592 is resolved here

fix/selenium-result-reaches-the-job, the branch of #592, has been merged into this branch at 08751d7. Both branches rewrote the Selenium block of ci/run-integration-tests.ps1 and that block was the only place they clashed.

The resolution keeps this branch's structure, being the Invoke-ContractTests function that runs the contract tests against one example, the Arm64 Linux skip and the collected failures, and adds the SELENIUM_TESTS_REF branch selection from 592 so a change to the shared contract test suite can be tried here before it is merged. The other thing 592 does, checking the exit code from dotnet test so a failing contract run reaches the job result, already has an equivalent inside Invoke-ContractTests, which records a failure when dotnet test returns non-zero. Both changes survive.

Merge 592 first and this one second. A local trial of that order onto main merged both with no conflict, and the file that came out matched this branch exactly. git diff --stat origin/main HEAD on this branch is ci/run-integration-tests.ps1 alone, 123 insertions and 26 deletions, and nothing else.

Real run on the merged head

Run 35273266844, dispatched on this branch with dryrun=true, ran on 08751d7. It failed, on one thing only, and everything else the branch does worked.

Build and Test - 0 - Ubuntu_ARM_Java_17 passed, so the Arm64 Linux skip survived the merge. Build and Test - 0 - Ubuntu_Java_21 (job log) failed, and reading it:

Running Selenium tests...
Cloning the Selenium contract tests from 'main'
Running Selenium contract tests against the cloud example on port 8099
Passed!  - Failed: 0, Passed: 9, Skipped: 0, Total: 9, Duration: 23 s - SeleniumApiTests.dll
Running Selenium contract tests against the on-premise example on port 8098
... Creation of Swig Engine failed: The data was not in the correct format.
    Check the data file 'device-detection-data/51Degrees-LiteV4.1.hash' is uncompressed.
... Started ServerConnector@36c88a32{HTTP/1.1, (http/1.1)}{0.0.0.0:8081}
 204 |      throw "Integration tests failed: $($failures -join '; ')"
     | Integration tests failed: the on-premise example did not answer on port 8098

The Cloning the Selenium contract tests from 'main' line is 592's branch selection working after the merge, and the cloud example passing nine out of nine shows the Invoke-ContractTests rewrite is sound. The one failure is the on-premise example, and its two faults are plain in that output. It bound port 8081 rather than the 8098 it was given, and it loaded the relative Lite path rather than the TAC file it was given.

Why this is still a draft

Both of those faults are on main of device-detection-java-examples, and device-detection-java-examples#663 is the change that fixes them. The CI script clones the examples repository with no branch argument, and steps/clone-repo.ps1 defaults to main, so a run here always takes examples main and there is no way to test against 663 before it merges.

663 is ready, mergeable, clean, green on its head cf5e69ff, and has no pending review request, so the examples nightly should take it. Once it is on examples main, dispatch the Pull Requests workflow on this branch again and read the result. Nothing here needs changing in the meantime.

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.

1 participant