Repository navigation
Allow airflowctl integration tests to use a non-default API server port - #76124
Merged
Merged
Conversation
… port The airflowctl integration suite could not run on a host where TCP 8080 is already taken. HOST_PORT was honoured only by the harness's own requests calls; the compose file hard-coded 8080 and every CLI command under test fell back to http://localhost:8080. - airflowctl: add AIRFLOW_CLI_API_URL as the default API URL. It is resolved at call time for 'auth login' and 'auth token' when --api-url is not given, and is the client fallback when no URL is stored in the credentials (this also covers 'version --remote' without credentials). - Compose quickstart: publish the API server on the host port given by AIRFLOW_API_SERVER_PORT (default 8080) and document the variable. - Integration harness: export AIRFLOW_API_SERVER_PORT derived from HOST_PORT before compose up, and pass AIRFLOW_CLI_API_URL to every CLI command. The defaults stay at localhost:8080, so CI behaviour does not change.
shahar1
requested review from
amoghrajesh,
ashb,
bugraoz93,
dheerajturaga,
gopidesupavan,
henry3260 and
jason810496
as code owners
October 31, 2026 09:02
shahar1
enabled auto-merge (squash)
October 31, 2026 09:44
choo121600
approved these changes
Oct 31, 2026
Contributor
Backport successfully created: airflow-ctl/v0-1-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
shahar1
added a commit
that referenced
this pull request
Oct 31, 2026
…a non-default API server port (#76124) (#76137) The airflowctl integration suite could not run on a host where TCP 8080 is already taken. HOST_PORT was honoured only by the harness's own requests calls; the compose file hard-coded 8080 and every CLI command under test fell back to http://localhost:8080. - airflowctl: add AIRFLOW_CLI_API_URL as the default API URL. It is resolved at call time for 'auth login' and 'auth token' when --api-url is not given, and is the client fallback when no URL is stored in the credentials (this also covers 'version --remote' without credentials). - Compose quickstart: publish the API server on the host port given by AIRFLOW_API_SERVER_PORT (default 8080) and document the variable. - Integration harness: export AIRFLOW_API_SERVER_PORT derived from HOST_PORT before compose up, and pass AIRFLOW_CLI_API_URL to every CLI command. The defaults stay at localhost:8080, so CI behaviour does not change. (cherry picked from commit f3b4fec) Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
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.
While testing the airflowctl 0.1.6 (pre-)release candidate locally, I ran into problems when port 8080 was already in use. This PR lets to run the API server and airflowctl integration tests on a different port.
AI Summary
`breeze testing airflow-ctl-integration-tests` cannot run on a host where TCP port 8080 is already taken. The harness variable `HOST_PORT` is honoured only by the harness's own `requests` calls: the quickstart compose file it copies hard-codes `8080:8080`, the `auth login` it prepends to every command has no `--api-url`, and the no-auth `version --remote` test falls back to `http://localhost:8080` inside the client. With `HOST_PORT=localhost:18080` the stack cannot even bind, and with the port mapping patched by hand every CLI command still talks to the wrong port (36/36 server-bound tests fail, zero requests reach the API server).This makes
HOST_PORTthe single knob:AIRFLOW_CLI_API_URLas its default API URL:auth loginandauth tokenresolve--api-urlat call time asargs.api_url or get_default_api_url(), andget_clientfalls back to it when the stored credentials carry no URL (theversion --remotecase). Precedence is--api-url, then the URL stored byauth login, then the variable, thenhttp://localhost:8080; documented incli-and-env-variables-ref.rst.${AIRFLOW_API_SERVER_PORT:-8080}:8080(same interpolation style asAIRFLOW_IMAGE_NAMEandAIRFLOW_UID); documented indocker-compose/index.rst.HOST_PORT, exportsAIRFLOW_API_SERVER_PORTbeforecompose up, and passesAIRFLOW_CLI_API_URLto every CLI command (a test's ownenv_varsstill win).Defaults are unchanged, so CI behaviour does not change. The
--api-urlhelp text is deliberately untouched (its SVG would need regenerating); the variable is documented in the environment-variable reference instead.Tested:
uv run --project airflow-ctl pytest airflow-ctl/tests: 708 passed (new tests: default-URL helper incl. the empty-string case,get_clientfallback,auth login/auth tokenURL resolution with and without--api-url,HOST_PORTport parsing incl. the invalid cases).prek run mypy-airflow-ctl --all-files: 0 errors before and after.HOST_PORT=localhost:18080 breeze testing airflow-ctl-integration-tests --image-name apache/airflow:3.4.0rc2-python3.12(rc2 PROD image built locally from Sync v3-4-stable with v3-4-test to release 3.4.0rc2 #76068) from this branch with no other change: 207 passed, 2 failed.test_airflowctl_no_auth_commands[version --remote]passes; the two failures areproviders get apache-airflow-providers-standardin both passes, which a 3.4.0rc2 server answers withAPI route not found(the endpoint is newer than rc2) and is unrelated to this change.Follow-ups, not in this PR: mention the variable in the
--api-urlhelp (needs the help SVGs regenerated);docker-tests/tests/docker_tests/test_docker_compose_quick_start.pyreadsHOST_PORTbut does not exportAIRFLOW_API_SERVER_PORT.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Fable 5.1) following the guidelines