Skip to content

Commit 91f3bcc

Browse files
Get integration test running
1 parent c0674e8 commit 91f3bcc

7 files changed

Lines changed: 28 additions & 6 deletions

File tree

.github/workflows/gcp-deploy.reusable.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,6 @@ jobs:
188188
full_integ_test_access_token: ${{ steps.get-full-id-token.outputs.id_token }}
189189
full_integ_test_base_url: ${{ needs.deploy.outputs.full_api_url }}
190190
simulation_integ_test_access_token: ${{ steps.get-simulation-id-token.outputs.id_token }}
191-
simulation_integ_test_base_url: ${{ needs.deploy.outputs.simulation_api_url }}
191+
simulation_integ_test_base_url: ${{ needs.deploy.outputs.simulation_api_url }}
192+
workflow_integ_test_project_id: ${{ vars.PROJECT_ID }}
193+
workflow_integ_test_us_model_version: ${{ steps.versions.outputs.us_version }}

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ jobs:
131131
run: |
132132
cd projects/policyengine-apis-integ
133133
uv sync --extra test
134-
# Run tests that don't require authentication
135-
uv run pytest tests/full/test_ping.py tests/simulation/test_ping.py -v
134+
# Run tests that don't require GCP credentials
135+
uv run pytest tests/ -v -m "not requires_gcp"
136136
137137
- name: Show service logs on failure
138138
if: failure()

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ test-integration: generate-clients
113113
@echo "Make sure services are running with 'make up' first!"
114114
@cd projects/policyengine-apis-integ && \
115115
uv sync --extra test && \
116-
uv run pytest tests/full/test_ping.py tests/simulation/test_ping.py -v
116+
uv run pytest tests/ -v -m "not requires_gcp"
117117

118118
test-integration-all: generate-clients
119119
@echo "Running all integration tests against local services..."
120120
@echo "Make sure services are running with 'make up' first!"
121+
@echo "Note: Workflow tests will be skipped without GCP credentials"
121122
@cd projects/policyengine-apis-integ && \
122123
uv sync --extra test && \
123124
uv run pytest tests/ -v

projects/policyengine-apis-integ/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pythonpath = [
2424
"src",
2525
]
2626
testpaths = ["tests"]
27+
markers = [
28+
"requires_gcp: mark test as requiring GCP credentials and workflow access",
29+
]
2730

2831
[tool.uv.sources]
2932
policyengine_api_full_client = { path = "../policyengine-api-full/artifacts/clients/python" }

projects/policyengine-apis-integ/tests/simulation_workflow/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pydantic_settings import BaseSettings, SettingsConfigDict
22
import pytest
33
from .simplified_workflow_client import SimplifiedWorkflowClient
4+
import os
45

56

67
class Settings(BaseSettings):
@@ -15,6 +16,15 @@ class Settings(BaseSettings):
1516
settings = Settings()
1617

1718

19+
# Skip all workflow tests if we don't have proper GCP configuration
20+
pytestmark = pytest.mark.skipif(
21+
settings.project_id == "UNKNOWN_PROJECT_ID" or
22+
settings.us_model_version == "UNKNOWN_US_MODEL_VERSION" or
23+
not os.getenv("GOOGLE_APPLICATION_CREDENTIALS", ""),
24+
reason="Workflow tests require GCP credentials and configuration"
25+
)
26+
27+
1828
@pytest.fixture()
1929
def us_model_version() -> str:
2030
return settings.us_model_version

projects/policyengine-apis-integ/tests/simulation_workflow/test_calculate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import pytest
12
from .simplified_workflow_client import SimplifiedWorkflowClient
23
from google.cloud.workflows.executions_v1.types import executions
34

45

6+
@pytest.mark.requires_gcp
57
def test_calculate_default_model(client: SimplifiedWorkflowClient):
68
execution = client.execute(
79
argument={
@@ -19,6 +21,7 @@ def test_calculate_default_model(client: SimplifiedWorkflowClient):
1921
assert execution.state == executions.Execution.State.SUCCEEDED
2022

2123

24+
@pytest.mark.requires_gcp
2225
def test_calculate_specific_model(
2326
client: SimplifiedWorkflowClient, us_model_version: str
2427
):

scripts/test-integration-local.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ check_service "api-simulation" 8082
3737
check_service "api-tagger" 8083
3838

3939
echo ""
40-
echo "Running integration tests..."
41-
make test-integration
40+
echo "Running integration tests (excluding GCP workflow tests)..."
41+
cd projects/policyengine-apis-integ
42+
uv sync --extra test
43+
uv run pytest tests/ -v -m "not requires_gcp"
44+
cd ../..
4245

4346
echo ""
4447
echo "Stopping services..."

0 commit comments

Comments
 (0)