SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: list gcp accounts was missing config (#12175)
Swapnil Nakade9f5ad1ba267f
diff --git a/pkg/types/cloudintegrationtypes/account.go b/pkg/types/cloudintegrationtypes/account.goindex 95502f601d..21afedf9eb 100644--- a/pkg/types/cloudintegrationtypes/account.go+++ b/pkg/types/cloudintegrationtypes/account.go@@ -137,6 +137,13 @@ func NewAccountFromStorable(storableAccount *StorableCloudIntegration) (*Accountreturn nil, err}account.Config.Azure = azureConfig+ case CloudProviderTypeGCP:+ gcpConfig := new(GCPAccountConfig)+ err := json.Unmarshal([]byte(storableAccount.Config), gcpConfig)+ if err != nil {+ return nil, err+ }+ account.Config.GCP = gcpConfig}if storableAccount.LastAgentReport != nil {diff --git a/tests/fixtures/cloudintegrations.py b/tests/fixtures/cloudintegrations.pyindex 0e171fa4de..3d4e4cf19d 100644--- a/tests/fixtures/cloudintegrations.py+++ b/tests/fixtures/cloudintegrations.py@@ -1,6 +1,7 @@"""Fixtures for cloud integration tests."""from collections.abc import Callable+from dataclasses import dataclass, fieldfrom http import HTTPStatusimport pytest@@ -20,6 +21,29 @@ from fixtures.logger import setup_loggerlogger = setup_logger(__name__)+# Per-provider config shape.+@dataclass(frozen=True)+class ProviderAccountSpec:+ # provider slug used in the URL path and config key (e.g. "aws", "gcp").+ provider: str+ # params for the account created by default.+ initial_params: dict+ # params for the config an update (PUT) test sends.+ updated_params: dict+ # params -> the provider-keyed `config` block for a POST/PUT body.+ build_config: Callable[[dict], dict]+ # params -> the full config block the API is expected to return under+ # config[provider] on GET/list. This may differ from what build_config sends:+ # e.g. AWS accepts deploymentRegion on POST but the API does not echo it back.+ expected_config: Callable[[dict], dict]+ # id shown in parametrized test names; defaults to the provider slug.+ id: str = field(default="")++ def __post_init__(self) -> None:+ if not self.id:+ object.__setattr__(self, "id", self.provider)++@pytest.fixture(scope="function")def deprecated_create_cloud_integration_account(request: pytest.FixtureRequest,@@ -97,19 +121,26 @@ def create_cloud_integration_account(cloud_provider: str = "aws",deployment_region: str = "us-east-1",regions: list[str] | None = None,+ config: dict | None = None,) -> dict:- if regions is None:- regions = ["us-east-1"]-- endpoint = f"/api/v1/cloud_integrations/{cloud_provider}/accounts"-- request_payload = {- "config": {+ # `config`, when given, is the fully-formed provider-keyed config block+ # (e.g. built via a ProviderAccountSpec.build_config) and is used as-is.+ # Otherwise fall back to the AWS shape built from deployment_region/regions,+ # preserving existing AWS callers.+ if config is None:+ if regions is None:+ regions = ["us-east-1"]+ config = {cloud_provider: {"deploymentRegion": deployment_region,"regions": regions,}- },+ }++ endpoint = f"/api/v1/cloud_integrations/{cloud_provider}/accounts"++ request_payload = {+ "config": config,"credentials": {"sigNozApiURL": "https://test-deployment.test.signoz.cloud","sigNozApiKey": "test-api-key-789",diff --git a/tests/integration/tests/cloudintegrations/04_accounts.py b/tests/integration/tests/cloudintegrations/04_accounts.pyindex 043f9ad4c4..85f1120ea2 100644--- a/tests/integration/tests/cloudintegrations/04_accounts.py+++ b/tests/integration/tests/cloudintegrations/04_accounts.py@@ -2,16 +2,60 @@ import uuidfrom collections.abc import Callablefrom http import HTTPStatus+import pytestimport requestsfrom fixtures import typesfrom fixtures.auth import USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD, add_license-from fixtures.cloudintegrations import simulate_agent_checkin+from fixtures.cloudintegrations import (+ ProviderAccountSpec,+ simulate_agent_checkin,+)from fixtures.logger import setup_loggerlogger = setup_logger(__name__)-CLOUD_PROVIDER = "aws"+AWS_ACCOUNT_SPEC = ProviderAccountSpec(+ provider="aws",+ initial_params={"deployment_region": "us-east-1", "regions": ["us-east-1"]},+ updated_params={"deployment_region": "us-east-1", "regions": ["us-east-1", "us-west-2", "eu-west-1"]},+ build_config=lambda p: {"aws": {"deploymentRegion": p["deployment_region"], "regions": p["regions"]}},+ expected_config=lambda p: {"regions": p["regions"]},+)++GCP_ACCOUNT_SPEC = ProviderAccountSpec(+ provider="gcp",+ initial_params={+ "deployment_project_id": "signoz-test-project",+ "deployment_region": "us-central1",+ "project_ids": ["signoz-test-project"],+ },+ updated_params={+ "deployment_project_id": "signoz-test-project",+ "deployment_region": "us-central1",+ "project_ids": ["signoz-test-project", "signoz-test-project-2"],+ },+ build_config=lambda p: {+ "gcp": {+ "deploymentProjectId": p["deployment_project_id"],+ "deploymentRegion": p["deployment_region"],+ "projectIds": p["project_ids"],+ }+ },+ expected_config=lambda p: {+ "deploymentProjectId": p["deployment_project_id"],+ "deploymentRegion": p["deployment_region"],+ "projectIds": p["project_ids"],+ },+)++PROVIDER_ACCOUNT_SPECS = [AWS_ACCOUNT_SPEC, GCP_ACCOUNT_SPEC]++provider_spec = pytest.mark.parametrize(+ "spec",+ PROVIDER_ACCOUNT_SPECS,+ ids=[s.id for s in PROVIDER_ACCOUNT_SPECS],+)def test_apply_license(@@ -24,16 +68,18 @@ def test_apply_license(add_license(signoz, make_http_mocks, get_token)+@provider_specdef test_list_accounts_empty(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],+ spec: ProviderAccountSpec,) -> None:"""List accounts returns an empty list when no accounts have checked in."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -46,24 +92,30 @@ def test_list_accounts_empty(assert len(data["accounts"]) == 0, "accounts list should be empty when no accounts have checked in"+@provider_specdef test_list_accounts_after_checkin(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],create_cloud_integration_account: Callable,+ spec: ProviderAccountSpec,) -> None:- """List accounts returns an account after it has checked in."""+ """List accounts returns an account, with its provider config, after check-in."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)- account = create_cloud_integration_account(admin_token, CLOUD_PROVIDER, regions=["us-east-1"])+ account = create_cloud_integration_account(+ admin_token,+ spec.provider,+ config=spec.build_config(spec.initial_params),+ )account_id = account["id"]provider_account_id = str(uuid.uuid4())- checkin = simulate_agent_checkin(signoz, admin_token, CLOUD_PROVIDER, account_id, provider_account_id)+ checkin = simulate_agent_checkin(signoz, admin_token, spec.provider, account_id, provider_account_id)assert checkin.status_code == HTTPStatus.OK, f"Check-in failed: {checkin.text}"response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -74,25 +126,31 @@ def test_list_accounts_after_checkin(found = next((a for a in data["accounts"] if a["id"] == account_id), None)assert found is not None, f"Account {account_id} should appear in list after check-in"assert found["providerAccountId"] == provider_account_id, "providerAccountId should match"- assert found["config"]["aws"]["regions"] == ["us-east-1"], "regions should match account config"+ assert found["config"][spec.provider] == spec.expected_config(spec.initial_params), "config should match account config"assert found["agentReport"] is not None, "agentReport should be present after check-in"assert found["removedAt"] is None, "removedAt should be null for a live account"+@provider_specdef test_get_account(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],create_cloud_integration_account: Callable,+ spec: ProviderAccountSpec,) -> None:- """Get a specific account by ID returns the account with correct fields."""+ """Get a specific account by ID returns the account with its provider config."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)- account = create_cloud_integration_account(admin_token, CLOUD_PROVIDER, regions=["us-east-1", "eu-west-1"])+ account = create_cloud_integration_account(+ admin_token,+ spec.provider,+ config=spec.build_config(spec.initial_params),+ )account_id = account["id"]response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{account_id}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{account_id}"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -101,23 +159,22 @@ def test_get_account(data = response.json()["data"]assert data["id"] == account_id, "id should match"- assert data["config"]["aws"]["regions"] == [- "us-east-1",- "eu-west-1",- ], "regions should match"+ assert data["config"][spec.provider] == spec.expected_config(spec.initial_params), "config should match"assert data["removedAt"] is None, "removedAt should be null"+@provider_specdef test_get_account_not_found(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],+ spec: ProviderAccountSpec,) -> None:"""Get a non-existent account returns 404."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{uuid.uuid4()}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{uuid.uuid4()}"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -125,46 +182,52 @@ def test_get_account_not_found(assert response.status_code == HTTPStatus.NOT_FOUND, f"Expected 404, got {response.status_code}"+@provider_specdef test_update_account(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],create_cloud_integration_account: Callable,+ spec: ProviderAccountSpec,) -> None:"""Update account config and verify the change is persisted via GET."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)- account = create_cloud_integration_account(admin_token, CLOUD_PROVIDER, regions=["us-east-1"])+ account = create_cloud_integration_account(+ admin_token,+ spec.provider,+ config=spec.build_config(spec.initial_params),+ )account_id = account["id"]- checkin = simulate_agent_checkin(signoz, admin_token, CLOUD_PROVIDER, account_id, str(uuid.uuid4()))+ checkin = simulate_agent_checkin(signoz, admin_token, spec.provider, account_id, str(uuid.uuid4()))assert checkin.status_code == HTTPStatus.OK, f"Check-in failed: {checkin.text}"- updated_regions = ["us-east-1", "us-west-2", "eu-west-1"]-response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{account_id}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{account_id}"),headers={"Authorization": f"Bearer {admin_token}"},- json={"config": {"aws": {"regions": updated_regions}}},+ json={"config": spec.build_config(spec.updated_params)},timeout=10,)assert response.status_code == HTTPStatus.NO_CONTENT, f"Expected 204, got {response.status_code}"get_response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{account_id}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{account_id}"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)assert get_response.status_code == HTTPStatus.OK- assert get_response.json()["data"]["config"]["aws"]["regions"] == updated_regions, "Regions should reflect the update"+ assert get_response.json()["data"]["config"][spec.provider] == spec.expected_config(spec.updated_params), "Config should reflect the update"+@provider_specdef test_update_account_after_checkin_preserves_connected_status(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],create_cloud_integration_account: Callable,+ spec: ProviderAccountSpec,) -> None:"""Updating config after agent check-in must not remove the account from the connected list.@@ -175,17 +238,21 @@ def test_update_account_after_checkin_preserves_connected_status(admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# 1. Create account- account = create_cloud_integration_account(admin_token, CLOUD_PROVIDER, regions=["us-east-1"])+ account = create_cloud_integration_account(+ admin_token,+ spec.provider,+ config=spec.build_config(spec.initial_params),+ )account_id = account["id"]provider_account_id = str(uuid.uuid4())# 2. Agent checks in — sets account_id and last_agent_report- checkin = simulate_agent_checkin(signoz, admin_token, CLOUD_PROVIDER, account_id, provider_account_id)+ checkin = simulate_agent_checkin(signoz, admin_token, spec.provider, account_id, provider_account_id)assert checkin.status_code == HTTPStatus.OK, f"Check-in failed: {checkin.text}"# 3. Verify the account appears in the connected listlist_response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -195,18 +262,17 @@ def test_update_account_after_checkin_preserves_connected_status(assert found_before is not None, "Account should be listed after check-in"# 4. Update account config- updated_regions = ["us-east-1", "us-west-2"]update_response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{account_id}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{account_id}"),headers={"Authorization": f"Bearer {admin_token}"},- json={"config": {"aws": {"regions": updated_regions}}},+ json={"config": spec.build_config(spec.updated_params)},timeout=10,)assert update_response.status_code == HTTPStatus.NO_CONTENT, f"Expected 204, got {update_response.status_code}"# 5. Verify the account still appears in the connected list with correct fieldslist_response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -216,27 +282,33 @@ def test_update_account_after_checkin_preserves_connected_status(assert found_after is not None, "Account must still be listed after config update (account_id should not be reset)"assert found_after["providerAccountId"] == provider_account_id, "providerAccountId should be preserved after update"assert found_after["agentReport"] is not None, "agentReport should be preserved after update"- assert found_after["config"]["aws"]["regions"] == updated_regions, "Config should reflect the update"+ assert found_after["config"][spec.provider] == spec.expected_config(spec.updated_params), "Config should reflect the update"assert found_after["removedAt"] is None, "removedAt should still be null"+@provider_specdef test_disconnect_account(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],create_cloud_integration_account: Callable,+ spec: ProviderAccountSpec,) -> None:"""Disconnect an account removes it from the connected list."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)- account = create_cloud_integration_account(admin_token, CLOUD_PROVIDER)+ account = create_cloud_integration_account(+ admin_token,+ spec.provider,+ config=spec.build_config(spec.initial_params),+ )account_id = account["id"]- checkin = simulate_agent_checkin(signoz, admin_token, CLOUD_PROVIDER, account_id, str(uuid.uuid4()))+ checkin = simulate_agent_checkin(signoz, admin_token, spec.provider, account_id, str(uuid.uuid4()))assert checkin.status_code == HTTPStatus.OK, f"Check-in failed: {checkin.text}"response = requests.delete(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{account_id}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{account_id}"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -244,7 +316,7 @@ def test_disconnect_account(assert response.status_code == HTTPStatus.NO_CONTENT, f"Expected 204, got {response.status_code}"list_response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)@@ -252,16 +324,18 @@ def test_disconnect_account(assert not any(a["id"] == account_id for a in accounts), "Disconnected account should not appear in the connected list"+@provider_specdef test_disconnect_account_idempotent(signoz: types.SigNoz,create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],+ spec: ProviderAccountSpec,) -> None:"""Disconnect on a non-existent account ID returns 204 (blind update, no existence check)."""admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.delete(- signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{CLOUD_PROVIDER}/accounts/{uuid.uuid4()}"),+ signoz.self.host_configs["8080"].get(f"/api/v1/cloud_integrations/{spec.provider}/accounts/{uuid.uuid4()}"),headers={"Authorization": f"Bearer {admin_token}"},timeout=10,)