Repository navigation
TEST: Run the data file update example against a local stand-in - #284
Draft
jwrosewell wants to merge 2 commits into
Draft
jwrosewell wants to merge 2 commits into
jwrosewell wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
test_onpremise_datafileupdate_consoleran 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- Newdevice-detection/fiftyone_devicedetection_examples/tests/data_update_standin.pyis 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 withAvailableUrisand aLocationheader. A product it does not offer gets 403. An offered product gets the file gzipped, with a lowercase hexContent-MD5, or 304 whenIf-Modified-Sinceis 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 withfake_get, and leaves any other address alone.-test_onpremiseexamples.pyreplaces that test with two. Each copies the fetchedTAC-HashV41.hashto a temporary folder, serves a copy published a day later, and runs the example with a made-up key. -test_onpremise_datafileupdate_console_with_productgives 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_productgives 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.inisets_51DEGREES_LICENSE_KEYempty, so no example test gets a real key.pass_envstill lists_51DEGREES_*, asci/key-names.Tests.ps1checks that eachtox.inipasses every variable its package reads.## Expected to failtest_onpremise_datafileupdate_console_without_productfails 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 showtest_onpremise_datafileupdate_console_with_productpassing, andtest_onpremise_datafileupdate_console_without_productfailing 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.ps1among 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'sprefetch_assetsaction, as the other workflows do. The test jobs restore the asset cache under that key, stop if it misses, and copy51Degrees-LiteV4.1.hash,20000 Evidence Records.yml,51Degrees-IPIV4AsnIpiV41.ipiand the Lite IP Intelligence file into place. The job has to be calledConfigure, becauseci/fetch-assets.ps1fetches 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.ps1is rewritten for the new shape and gives 11 passed with Pester 6.2.ci/key-names.Tests.ps1gives 148 passed.Still to show, on this pull request:
Pull requests from forks cannot fetch the assets, so this workflow now fails for them, where before it downloaded the free files.