Skip to content

TEST: Run the data file update example against a local stand-in - #284

Draft
jwrosewell wants to merge 2 commits into
rcfrom
test/update-example-stand-in
Draft

jwrosewell wants to merge 2 commits into
rcfrom
test/update-example-stand-in

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Whytest_onpremise_datafileupdate_console ran the data file update example with the CI license key and asked the Distributor for V4TAC, so a test downloaded a data file. Tests use the data files the CI fetch-assets step fetched instead, and a data update test serves its file from a stand-in.## What changes- New device-detection/fiftyone_devicedetection_examples/tests/data_update_standin.py is a stand-in for the Distributor on 127.0.0.1, for a key that holds V4Enterprise and V4TAC. With no product it answers 300 with AvailableUris and a Location header. A product it does not offer gets 403. An offered product gets the file gzipped, with a lowercase hex Content-MD5, or 304 when If-Modified-Since is not earlier than the file's published date. It records each request as its product and status. serving() sends requests to the Distributor's host to the stand-in, as the engines' tests already do with fake_get, and leaves any other address alone.- test_onpremiseexamples.py replaces that test with two. Each copies the fetched TAC-HashV41.hash to a temporary folder, serves a copy published a day later, and runs the example with a made-up key. - test_onpremise_datafileupdate_console_with_product gives V4TAC. The first request must ask for V4TAC and get the file, and the example's file must then hold the served date. - test_onpremise_datafileupdate_console_without_product gives no product. The first request must get the 300, the second must ask for V4TAC and get the file, and the date is checked as above.- The examples' tox.ini sets _51DEGREES_LICENSE_KEY empty, so no example test gets a real key. pass_env still lists _51DEGREES_*, as ci/key-names.Tests.ps1 checks that each tox.ini passes every variable its package reads.## Expected to failtest_onpremise_datafileupdate_console_without_product fails until the data update service reads the product from the data file at start-up. Before an engine has loaded the file, the service asks for no product and stops with "Product '' is not offered by data update service", and the example raises "Auto update failed". This pull request stays a draft until that change is in.## TestsBoth changed Python files compile. Neither new test has been run yet, as they need Python 3.8 or later and the fetched data files, which CI has.## Before this leaves draft1. The examples' tests in CI show test_onpremise_datafileupdate_console_with_product passing, and test_onpremise_datafileupdate_console_without_product failing only with "Product '' is not offered" until the product change is in, then passing.2. No test in the run sends a request to the Distributor.3. The CI script tests pass, ci/key-names.Tests.ps1 among them.

Second commit, the free-threaded workflow

The free-threaded workflow downloaded the four free data files from the links in the data submodule whenever its own cache missed. Its first job is now Configure, which checks out common-ci with this repository below it and runs common-ci's prefetch_assets action, as the other workflows do. The test jobs restore the asset cache under that key, stop if it misses, and copy 51Degrees-LiteV4.1.hash, 20000 Evidence Records.yml, 51Degrees-IPIV4AsnIpiV41.ipi and the Lite IP Intelligence file into place. The job has to be called Configure, because ci/fetch-assets.ps1 fetches every product's assets only in a job of that name, and the cache is shared with the day's other workflows.

ci/free-threaded-python.Tests.ps1 is rewritten for the new shape and gives 11 passed with Pester 6.2. ci/key-names.Tests.ps1 gives 148 passed.

Still to show, on this pull request:

  1. The Free-threaded Python workflow passes, with the Configure job fetching the assets or seeing them already in the cache, and every test job restoring them, and no job downloading a data file.
  2. How much time each test job now spends restoring the whole asset cache, which holds the large data files as well as the four free ones.

Pull requests from forks cannot fetch the assets, so this workflow now fails for them, where before it downloaded the free files.

The update example's test ran with the CI license key and asked the
Distributor for V4TAC, so a test downloaded a data file. It now runs
against a stand-in for the Distributor on this machine, with a made-up
key, and the file it serves is a copy of the TAC file CI fetched.

The stand-in answers as the Distributor does for a key that holds two
products. A request with no product gets 300 and the list of products,
a product not on the list gets 403, and V4TAC gets the copy gzipped
with its MD5, or 304 when there is nothing newer. The copy's published
date is a day later, so a test can check the example's file holds that
date afterwards.

One test gives V4TAC, and one gives no product, where the second
request must ask for the product of the file in use. The second fails
until the update service reads the product from the file at start-up.

tox passes the license key to the examples' tests empty, as none of
them needs a real one.
The free-threaded workflow's first job ran get-data-files.ps1 on a
cache miss, which downloads the four free data files from the links in
the data submodule. It now runs common-ci's prefetch_assets action, as
the other workflows do, and the test jobs restore that action's asset
cache and copy the four files where the tests look for them. Nothing in
the workflow downloads a data file itself.

The first job is named Configure, because ci/fetch-assets.ps1 fetches
every product's assets only in a job of that name. The other workflows
restore the same cache that day, so it must never be saved holding only
some of them.

ci/free-threaded-python.Tests.ps1 checks the new shape.
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