Skip to content

TEST: Expect the cloud address the endpoint order gives - #267

Merged
jwrosewell merged 2 commits into
rcfrom
fix/cloud-endpoint-tests
Nov 23, 2026
Merged

jwrosewell merged 2 commits into
rcfrom
fix/cloud-endpoint-tests

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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_ENDPOINT to the staging service, so the engine correctly uses that address and the tests fail.

From run 45132994543, job Ubuntu_Python_3.12:

FAILED tests/test_cloudresponse.py::TestCloudResponse::test_validate_error_handling_nodata
FAILED tests/test_cloudresponse.py::TestCloudResponse::test_validate_error_handling_noerror_nosuccess
FAILED tests/test_credentials.py::TestCredentials::test_licence_key_discovers_properties_with_the_key_in_the_body
FAILED tests/test_credentials.py::TestCredentials::test_licence_key_with_properties_is_accepted

The order the tests follow

Every cloud request engine takes its address in this order, as customers are advised:

  1. an address given in code or configuration (cloud_endpoint),
  2. then the _51DEGREES_CLOUD_ENDPOINT environment variable,
  3. then the default https://cloud.51degrees.com/api/v4/ when both are blank.

The Python engine follows this order when the cloud_endpoint setting holds an address, in pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudrequestengine.py lines 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 blank cloud_endpoint gives the address / and None raises an AttributeError, 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) holds expected_endpoint(), which works out the address the engine uses when no cloud_endpoint is 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.py turns noDataKeyMessageComplete and noErrorNoSuccessMessage into functions that take the address, because both messages include it.
  • tests/test_cloudresponse.py and tests/test_credentials.py expect expected_endpoint() in the four failing tests.
  • tests/test_cloudrequestengine.py adds testConfigEndPoint_BlankEnvironmentVariable, which sets the variable to an empty string and expects the default, and testConfigEndPoint_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, and setUp puts 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_ENDPOINT test_cloudresponse.py, test_credentials.py, test_cloudrequestengine.py whole package (-m "not live")
unset 45 passed 138 passed, 4 deselected (before the slash test)
https://cloud-staging.51degrees.com/api/v4/ 45 passed 139 passed, 4 deselected
http://localhost:5000/api/v4 (no trailing slash) 45 passed not run

Before the change, with the variable set to staging, test_cloudresponse.py and test_credentials.py gave 4 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-detection example test tests/test_onpremiseexamples.py::DeviceDetectionExampleTests::test_onpremise_datafileupdate_console fails 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.

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.
@jwrosewell jwrosewell mentioned this pull request Nov 23, 2026
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.
@jwrosewell
jwrosewell marked this pull request as ready for review November 23, 2026 09:30
@jwrosewell
jwrosewell merged commit 0f1ccdb into rc Nov 23, 2026
5 checks passed
@jwrosewell
jwrosewell deleted the fix/cloud-endpoint-tests branch November 23, 2026 09:30
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