Skip to content

Commit 2f729b5

Browse files
haranrkcopybara-github
authored andcommitted
test(cli): fix agent engine ignore test failing on CI without ADC
The test_to_agent_engine_respects_multiple_ignore_files unit test added in PR #4187 failed in GitHub Actions. On CI runners there are no Application Default Credentials and no project/region, so to_agent_engine falls back to the interactive `gcloud auth application-default login` onboarding flow and aborts with click.Abort. The test only appeared to pass locally because ambient ADC let it return early (region unset) before reaching the deploy path. - Pass project, region and adk_version explicitly so the onboarding flow is skipped, exercising the full deploy path deterministically. - Give the mocked Agent Engine client a realistic resource name so the downstream console-URL formatting does not fail on a bare Mock. Co-authored-by: Haran Rajkumar <haranrk@google.com> PiperOrigin-RevId: 934630935
1 parent 43115b2 commit 2f729b5

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tests/unittests/cli/utils/test_cli_deploy_ignore.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ def test_to_agent_engine_respects_multiple_ignore_files(
121121
(agent_dir / ".gitignore").write_text("ignored_by_git.txt\n")
122122
(agent_dir / ".ae_ignore").write_text("ignored_by_ae.txt\n")
123123

124-
# Mock vertexai.Client and other things to avoid network/complex setup
125-
monkeypatch.setattr("vertexai.Client", mock.Mock())
124+
# Mock vertexai.Client and other things to avoid network/complex setup. The
125+
# created agent engine must expose a realistic resource name so the downstream
126+
# console-URL formatting does not choke on a bare Mock.
127+
mock_client = mock.Mock()
128+
mock_client.agent_engines.create.return_value.api_resource.name = (
129+
"projects/proj/locations/us-central1/reasoningEngines/123"
130+
)
131+
monkeypatch.setattr("vertexai.Client", mock.Mock(return_value=mock_client))
126132
# Mock shutil.rmtree to keep the temp folder for verification
127133
original_rmtree = shutil.rmtree
128134

@@ -137,6 +143,12 @@ def mock_rmtree(path, **kwargs):
137143
agent_folder=str(agent_dir),
138144
staging_bucket="gs://test",
139145
adk_app="adk_app",
146+
# Pass project/region explicitly so the function does not fall back to
147+
# the interactive `gcloud auth application-default login` onboarding flow,
148+
# which fails on CI runners without Application Default Credentials.
149+
project="proj",
150+
region="us-central1",
151+
adk_version="1.0.0",
140152
)
141153

142154
# Find the temp folder created by to_agent_engine

0 commit comments

Comments
 (0)