Repository navigation
TEST: Expect the cloud address the endpoint order gives - #267
Merged
Merged
Conversation
The cloud request engine takes its address from the cloud_endpoint setting first, then the _51DEGREES_CLOUD_ENDPOINT environment variable, then https://cloud.51degrees.com/api/v4/ when both are blank. Four tests gave no address but expected the default, so they failed whenever the variable pointed the suite at another cloud service, as it does in CI. Add tests/classes/endpoint.py with expected_endpoint(), which works out the address the engine uses when no setting is given, and use it in test_cloudresponse.py and test_credentials.py. The two error messages in tests/classes/constants.py now take the address. Add a test that an empty variable falls back to the default, next to the existing order tests.
Draft
Add a test that sets _51DEGREES_CLOUD_ENDPOINT to an address with no trailing slash and expects the engine to use it with one added, as tests/classes/endpoint.py assumes.
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.
Problem
The release pull request #240 (rc into main) fails in the cloud request engine integration tests. Four tests give the engine no address but expect
https://cloud.51degrees.com/api/v4/. CI sets_51DEGREES_CLOUD_ENDPOINTto the staging service, so the engine correctly uses that address and the tests fail.From run 45132994543, job Ubuntu_Python_3.12:
The order the tests follow
Every cloud request engine takes its address in this order, as customers are advised:
cloud_endpoint),_51DEGREES_CLOUD_ENDPOINTenvironment variable,https://cloud.51degrees.com/api/v4/when both are blank.The Python engine follows this order when the
cloud_endpointsetting holds an address, inpipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudrequestengine.pylines 176 to 181, with_endpoint_from_environment(lines 55 to 65) treating an empty variable as not set. The engine uses the setting whenever the key is present, so a blankcloud_endpointgives the address/andNoneraises anAttributeError, rather than falling through to the variable. The engine is not changed here, and that case is left for a separate change.What changed (tests only)
tests/classes/endpoint.py(new) holdsexpected_endpoint(), which works out the address the engine uses when nocloud_endpointis given. That is the variable when it is set and not empty, and the default otherwise, ending with a slash. It is written once here rather than in each test.tests/classes/constants.pyturnsnoDataKeyMessageCompleteandnoErrorNoSuccessMessageinto functions that take the address, because both messages include it.tests/test_cloudresponse.pyandtests/test_credentials.pyexpectexpected_endpoint()in the four failing tests.tests/test_cloudrequestengine.pyaddstestConfigEndPoint_BlankEnvironmentVariable, which sets the variable to an empty string and expects the default, andtestConfigEndPoint_EnvironmentVariableWithoutSlash, which sets an address with no trailing slash and expects one added. They join the existing order tests, which already check the setting over the variable, the variable over the default, and the default when unset. Each of these sets and clears the variable itself, andsetUpputs the environment back afterwards.Tests that give an address in code still expect that address.
How it was checked
Run on Windows with Python 3.12.10, from
pipeline/fiftyone_pipeline_cloudrequestengine, with the pipeline packages installed in editable mode:_51DEGREES_CLOUD_ENDPOINTtest_cloudresponse.py,test_credentials.py,test_cloudrequestengine.py-m "not live")https://cloud-staging.51degrees.com/api/v4/http://localhost:5000/api/v4(no trailing slash)Before the change, with the variable set to staging,
test_cloudresponse.pyandtest_credentials.pygave4 failed, 20 passed, matching CI.Not run here: the live tests that need a resource key, and the other packages in the repository, which CI runs.
Other failures in the same run (not fixed here)
device-detectionexample testtests/test_onpremiseexamples.py::DeviceDetectionExampleTests::test_onpremise_datafileupdate_consolefails because the data update service answers access denied:Error during check for data update. Error detail: Access denied to data update service at 'https://***/api/v2/download?Type=HashV41&licenseKeys=***&Product=V4Enterprise' for engine 'DeviceDetectionOnPremise'This needs a working license key in CI rather than a code change.