:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add 4 missing tables to the qdrant source (#126981)
Tom Owersb6e8f5363074
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex d5c8532cb448..1bb4d1ff58ab 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -9891,15 +9891,15 @@ Today (4): `backup_restores`, `backup_schedules`, `backups`, `clusters`Diffed against: <https://raw.githubusercontent.com/qdrant/qdrant-cloud-public-api/main/gen/openapiv2/qdrant/cloud/monitoring/v1/monitoring.swagger.json>-- [ ] `Packages (GET /api/booking/v1/accounts/{accountId}/packages)` — resolve cluster package identifiers into resource sizes and pricing dimensions (high)+- [x] `Packages (GET /api/booking/v1/accounts/{accountId}/packages)` — resolve cluster package identifiers into resource sizes and pricing dimensions (high)- [x] `Cloud providers (GET /api/platform/v1/accounts/{accountId}/cloud-providers)` — resolve cloud provider identifiers stored on clusters (high)- [x] `Cloud provider regions (GET /api/platform/v1/accounts/{accountId}/cloud-providers/{cloudProviderId}/regions)` — resolve cluster region identifiers for geographic and capacity analysis (high)- [x] `Cluster usage metrics (GET /api/monitoring/v1/accounts/{accountId}/cluster/{clusterId}/usage-metrics)` — measure resource utilization over time and identify capacity bottlenecks (high)- [x] `Metering entries (GET /api/metering/v1/accounts/{accountId}/meterings/{year}/{month})` — analyze monthly usage charges and attribute consumption to resources (high)-- [ ] `Invoices (GET /api/billing/v1/accounts/{accountId}/invoices)` — track billed spending and reconcile charges with usage (medium)+- [x] `Invoices (GET /api/billing/v1/accounts/{accountId}/invoices)` — track billed spending and reconcile charges with usage (medium)- [ ] `Cluster alerts (GET /api/monitoring/v1/accounts/{accountId}/cluster/{clusterId}/alerts)` — analyze alert frequency, severity, and recent incidents across clusters (medium)-- [ ] `Cluster inference metrics (GET /api/monitoring/v1/accounts/{accountId}/cluster/{clusterId}/metrics/inference)` — track model token usage for cluster inference workloads (medium)-- [ ] `Account members (GET /api/account/v1/accounts/{accountId}/members)` — analyze account membership and access alongside infrastructure inventory (medium)+- [x] `Cluster inference metrics (GET /api/monitoring/v1/accounts/{accountId}/cluster/{clusterId}/metrics/inference)` — track model token usage for cluster inference workloads (medium)+- [x] `Account members (GET /api/account/v1/accounts/{accountId}/members)` — analyze account membership and access alongside infrastructure inventory (medium)Note: Official generated Swagger specs were inspected for monitoring, billing, metering, booking, platform, account, and cluster services. Cluster rows contain package, cloud provider, and region identifiers without corresponding lookup tables. Metrics need cluster fan-out; metering needs month enumeration and additional permissions. Database keys, backup configuration, and vector data APIs are outside this cloud management audit.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/canonical_descriptions.pyindex 1311f021bfb6..4abbee930583 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/canonical_descriptions.py@@ -115,4 +115,64 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"value": "Value of the metric at the timestamp.",},},+ "cluster_inference_metrics": {+ "description": "Daily inference token usage for each cluster and inference model, one row per daily bucket.",+ "docs_url": "https://github.com/qdrant/qdrant-cloud-public-api/blob/main/proto/qdrant/cloud/monitoring/v1/monitoring.proto",+ "columns": {+ "cluster_id": "Identifier of the cluster that the data point belongs to.",+ "inference_model_id": "Identifier of the inference model.",+ "timestamp": "Start of the daily bucket.",+ "value": "Aggregated inference token usage in the bucket.",+ },+ },+ "packages": {+ "description": "Cluster packages, with their resources and hourly prices, for each cloud provider region the account can use.",+ "docs_url": "https://github.com/qdrant/qdrant-cloud-public-api/blob/main/proto/qdrant/cloud/booking/v1/booking.proto",+ "columns": {+ "id": "Unique package identifier. Clusters reference it as their package ID.",+ "cloud_provider_id": "Cloud provider that the package was listed for.",+ "cloud_provider_region_id": "Cloud provider region or hybrid cloud environment that the package was listed for.",+ "name": "Package name.",+ "type": "Whether the package is free or paid.",+ "resource_configuration": "CPU, RAM, disk, and GPU resources of the package.",+ "currency": "ISO 4217 currency of the prices.",+ "unit_int_price_per_hour": "Unit price per hour, in millicents.",+ "status": "Package status, active or deactivated.",+ "tier": "Package tier, standard or premium.",+ "available_additional_resources": "Additional resources, such as disk, that a cluster on this package can add, with their prices.",+ "available_storage_tier_configurations": "Available storage tier configurations and their prices.",+ "multi_az": "Whether clusters on this package spread their nodes across three availability zones.",+ },+ },+ "account_members": {+ "description": "Users who are members of the selected Qdrant Cloud account.",+ "docs_url": "https://github.com/qdrant/qdrant-cloud-public-api/blob/main/proto/qdrant/cloud/account/v1/account.proto",+ "columns": {+ "id": "Unique user identifier.",+ "created_at": "Time when Qdrant created the user.",+ "last_modified_at": "Time when the user was last updated.",+ "email": "Email address of the user.",+ "status": "User status.",+ "default_account_id": "Default account of the user.",+ "onboarding_status": "Onboarding status of the user.",+ "is_owner": "Whether the user owns the account.",+ },+ },+ "invoices": {+ "description": "Billing invoices issued to the selected Qdrant Cloud account.",+ "docs_url": "https://github.com/qdrant/qdrant-cloud-public-api/blob/main/proto/qdrant/cloud/billing/v1/billing.proto",+ "columns": {+ "id": "Unique invoice identifier.",+ "number": "Invoice number shown on the emails for the invoice.",+ "total_amount": "Total invoice amount, in millicents.",+ "subtotal_amount": "Invoice amount before discounts, in millicents.",+ "amount_due": "Remaining amount due after credits, in millicents.",+ "created_at": "Time when the invoice was created.",+ "status": "Invoice status, for example draft, open, paid, void, or uncollectible.",+ "pdf_url": "URL of the invoice PDF. Set only for finalized invoices.",+ "hosted_invoice_url": "URL of the customer-facing invoice page. It expires 30 days after the due date.",+ "paid_at": "Time when the invoice was paid.",+ "payment_failed_at": "Time of the most recent failed payment attempt.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/qdrant.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/qdrant.pyindex f97b7bb23498..40960de089c1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/qdrant.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/qdrant.py@@ -1,4 +1,5 @@-from datetime import UTC, datetime+from collections.abc import Callable+from datetime import UTC, datetime, timedeltafrom typing import Anyfrom uuid import UUID@@ -20,6 +21,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (ClientConfig,Endpoint,+ EndpointResource,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse@@ -30,6 +32,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.qdrant.setAUTH_ERROR,BASE_URL,ENDPOINTS,+ METRICS_ENDPOINTS,+ PACKAGE_STATUSES,PAGE_SIZE,PERMISSION_ERROR,USAGE_METRICS_LOOKBACK,@@ -73,8 +77,10 @@ def validate_credentials(config: QdrantSourceConfig, schema_name: str | None = Npath, params = ACCOUNTS_PATH, {}if schema_name:endpoint = endpoint_config(schema_name)- # A fan-out table needs the same permission as its parent listing, which has no path params to fill.+ # A fan-out table needs the same permission as its root listing, which has no path params to fill.probe: QdrantEndpoint | QdrantParent = endpoint.parent or endpoint+ while isinstance(probe, QdrantParent) and probe.parent is not None:+ probe = probe.parentpath = _account_path(probe.path, account)params = {"pageSize": 1} if probe.paginated else {}client = RESTClient(@@ -118,14 +124,21 @@ def _list_endpoint(path: str, paginated: bool) -> Endpoint:}-def usage_metrics_window(should_use_incremental_field: bool, db_incremental_field_last_value: Any) -> dict[str, str]:+def metrics_window(+ endpoint: str, should_use_incremental_field: bool, db_incremental_field_last_value: Any+) -> dict[str, str]:# One `until` for every cluster, so the table-wide watermark never passes a cluster's unread points.until = datetime.now(UTC)since = until - USAGE_METRICS_LOOKBACK+ overlap = USAGE_METRICS_OVERLAP if endpoint == "cluster_usage_metrics" else timedelta(0)last_value = parse_datetime_value(db_incremental_field_last_value) if should_use_incremental_field else None- if last_value is not None and last_value - USAGE_METRICS_OVERLAP > since:- since = last_value - USAGE_METRICS_OVERLAP- return {"since": _rfc3339(since), "until": _rfc3339(until)}+ if last_value is not None and last_value - overlap > since:+ since = last_value - overlap+ if endpoint != "cluster_inference_metrics":+ return {"since": _rfc3339(since), "until": _rfc3339(until)}+ # Daily buckets: starting at midnight keeps bucket timestamps stable across runs and re-reads the open day.+ since = since.replace(hour=0, minute=0, second=0, microsecond=0)+ return {"since": _rfc3339(since), "until": _rfc3339(until), "interval": "INFERENCE_METRICS_INTERVAL_DAY"}def _rfc3339(value: datetime) -> str:@@ -158,49 +171,94 @@ def usage_metric_rows(response: dict[str, Any]) -> list[dict[str, Any]]:return rows-def _fanout_resource(- client_config: ClientConfig,- endpoint: str,- config: QdrantEndpoint,- parent: QdrantParent,- account: str,- child_params: dict[str, Any],- incremental: bool,- team_id: int,- job_id: str,-) -> Any:- child_endpoint = _list_endpoint(_account_path(config.path, account), config.paginated)- if endpoint == "cluster_usage_metrics":- child_endpoint["data_selector"] = "$"- child_endpoint["params"] = {- **(child_endpoint.get("params") or {}),- **child_params,+def inference_metric_rows(response: dict[str, Any]) -> list[dict[str, Any]]:+ return [+ {+ "cluster_id": response.get("cluster_id"),+ "inference_model_id": model.get("inferenceModelId"),+ "timestamp": point.get("timestamp"),+ "value": point.get("value"),+ }+ for model in response.get("models") or []+ for point in model.get("values") or []+ ]+++def account_member_row(row: dict[str, Any]) -> dict[str, Any]:+ return {**(row.get("accountMember") or {}), "isOwner": row.get("isOwner", False)}+++ROW_MAPS: dict[str, Callable[[dict[str, Any]], dict[str, Any] | list[dict[str, Any]]]] = {+ "cluster_usage_metrics": usage_metric_rows,+ "cluster_inference_metrics": inference_metric_rows,+ "account_members": account_member_row,+}+++def _dependent_resource(+ name: str, path: str, paginated: bool, parent: QdrantParent, account: str, params: dict[str, Any]+) -> EndpointResource:+ endpoint = _list_endpoint(_account_path(path, account), paginated)+ if name in METRICS_ENDPOINTS:+ endpoint["data_selector"] = "$"+ endpoint["params"] = {+ **(endpoint.get("params") or {}),+ **params,**{param: {"type": "resolve", "resource": parent.name, "field": field}for param, field in parent.path_params.items()},}if parent.ignored_statuses:- child_endpoint["response_actions"] = [+ endpoint["response_actions"] = [{"status_code": status, "action": "ignore"} for status in parent.ignored_statuses]+ row_map = ROW_MAPS.get(name)- def child_row_map(row: dict[str, Any]) -> dict[str, Any] | list[dict[str, Any]]:+ def map_row(row: dict[str, Any]) -> dict[str, Any] | list[dict[str, Any]]:for field, column in parent.include.items():row[column] = row.pop(f"_{parent.name}_{field}", None)- return usage_metric_rows(row) if endpoint == "cluster_usage_metrics" else row+ return row_map(row) if row_map else row+ return {+ "name": name,+ "endpoint": endpoint,+ "include_from_parent": list(parent.include),+ "data_map": map_row,+ }+++def _parent_resources(parent: QdrantParent, account: str) -> list[EndpointResource]:+ if parent.parent is None:+ return [+ {"name": parent.name, "endpoint": _list_endpoint(_account_path(parent.path, account), parent.paginated)}+ ]+ return [+ *_parent_resources(parent.parent, account),+ _dependent_resource(parent.name, parent.path, parent.paginated, parent.parent, account, {}),+ ]+++def _fanout_resource(+ client_config: ClientConfig,+ endpoint: str,+ config: QdrantEndpoint,+ parent: QdrantParent,+ account: str,+ child_params: dict[str, Any],+ incremental: bool,+ team_id: int,+ job_id: str,+) -> Any:+ child = _dependent_resource(endpoint, config.path, config.paginated, parent, account, child_params)rest_config: RESTAPIConfig = {"client": client_config,"resources": [- {"name": parent.name, "endpoint": _list_endpoint(_account_path(parent.path, account), parent.paginated)},+ *_parent_resources(parent, account),{- "name": endpoint,+ **child,"table_name": endpoint,"write_disposition": {"disposition": "merge", "strategy": "upsert"} if incremental else "replace",- "endpoint": child_endpoint,- "include_from_parent": list(parent.include),- "data_map": child_row_map,},],}@@ -228,11 +286,11 @@ def qdrant_source(}if settings.parent is not None:- child_params = (- usage_metrics_window(should_use_incremental_field, db_incremental_field_last_value)- if endpoint == "cluster_usage_metrics"- else {}- )+ child_params: dict[str, Any] = {}+ if endpoint in METRICS_ENDPOINTS:+ child_params = metrics_window(endpoint, should_use_incremental_field, db_incremental_field_last_value)+ elif endpoint == "packages":+ child_params = {"statuses": PACKAGE_STATUSES}resource = _fanout_resource(client_config,endpoint,@@ -245,17 +303,15 @@ def qdrant_source(job_id,)else:- rest_config: RESTAPIConfig = {- "client": client_config,- "resources": [- {- "name": endpoint,- "table_name": endpoint,- "write_disposition": "replace",- "endpoint": _list_endpoint(_account_path(settings.path, account), settings.paginated),- }- ],+ resource_config: EndpointResource = {+ "name": endpoint,+ "table_name": endpoint,+ "write_disposition": "replace",+ "endpoint": _list_endpoint(_account_path(settings.path, account), settings.paginated),}+ if endpoint in ROW_MAPS:+ resource_config["data_map"] = ROW_MAPS[endpoint]+ rest_config: RESTAPIConfig = {"client": client_config, "resources": [resource_config]}initial_state = Noneif resumable_source_manager.can_resume():resume = resumable_source_manager.load_state()diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/settings.pyindex 6f1857895c46..ad7170d7f728 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/settings.py@@ -11,6 +11,7 @@ PAGE_SIZE = 100ACCOUNTS_PATH = "/api/account/v1/accounts"CLUSTERS_PATH = "/api/cluster/v1/accounts/{account_id}/clusters"CLOUD_PROVIDERS_PATH = "/api/platform/v1/accounts/{account_id}/cloud-providers"+CLOUD_PROVIDER_REGIONS_PATH = CLOUD_PROVIDERS_PATH + "/{cloudProviderId}/regions"MONTHLY_METERINGS_PATH = "/api/metering/v1/accounts/{account_id}/meterings"# The usage metrics API defaults to the last hour. Full refreshes and long-paused incremental@@ -19,6 +20,9 @@ USAGE_METRICS_LOOKBACK = timedelta(days=7)# Incremental syncs re-read this much before the watermark, for points Qdrant records late.USAGE_METRICS_OVERLAP = timedelta(hours=1)+# Without a status filter, the packages API lists only active packages, but clusters can still use deactivated ones.+PACKAGE_STATUSES = ["PACKAGE_STATUS_ACTIVE", "PACKAGE_STATUS_DEACTIVATED"]+@frozenclass QdrantParent:@@ -31,6 +35,29 @@ class QdrantParent:include: dict[str, str]# Child responses that skip one parent instead of failing the table.ignored_statuses: tuple[int, ...] = ()+ # Set when the parent listing is itself a fan-out.+ parent: "QdrantParent | None" = None+++CLOUD_PROVIDERS_PARENT = QdrantParent(+ name="cloud_providers",+ path=CLOUD_PROVIDERS_PATH,+ paginated=False,+ path_params={"cloudProviderId": "id"},+ include={"id": "cloud_provider_id"},+ # The "hybrid" provider needs read:clusters or read:hybrid_cloud_environments; the others need none.+ ignored_statuses=(403,),+)++CLUSTERS_PARENT = QdrantParent(+ name="clusters",+ path=CLUSTERS_PATH,+ paginated=True,+ path_params={"clusterId": "id"},+ include={"id": "cluster_id"},+ # A cluster deleted between the listing and its metrics request.+ ignored_statuses=(404,),+)@frozen@@ -49,20 +76,32 @@ ENDPOINTS: dict[str, QdrantEndpoint] = {"backup_restores": QdrantEndpoint(path="/api/cluster/backup/v1/accounts/{account_id}/backup_restores"),"cloud_providers": QdrantEndpoint(path=CLOUD_PROVIDERS_PATH, paginated=False, partition_key=None),"cloud_provider_regions": QdrantEndpoint(- path=CLOUD_PROVIDERS_PATH + "/{cloudProviderId}/regions",+ path=CLOUD_PROVIDER_REGIONS_PATH,paginated=False,primary_keys=("cloud_provider_id", "id"),partition_key=None,+ parent=CLOUD_PROVIDERS_PARENT,+ ),+ "packages": QdrantEndpoint(+ # Fan-out binds parent values only into the path, so the required filters ride in it.+ path="/api/booking/v1/accounts/{account_id}/packages"+ "?cloudProviderId={cloudProviderId}&cloudProviderRegionId={cloudProviderRegionId}",+ paginated=False,+ # Prices differ per region, so a package row is scoped to the region it was listed for.+ primary_keys=("cloud_provider_id", "cloud_provider_region_id", "id"),+ partition_key=None,parent=QdrantParent(- name="cloud_providers",- path=CLOUD_PROVIDERS_PATH,+ name="cloud_provider_regions",+ path=CLOUD_PROVIDER_REGIONS_PATH,paginated=False,- path_params={"cloudProviderId": "id"},- include={"id": "cloud_provider_id"},- # The "hybrid" provider needs read:clusters or read:hybrid_cloud_environments; the others need none.- ignored_statuses=(403,),+ # A hybrid region's own `provider` field names the underlying infrastructure, not "hybrid".+ path_params={"cloudProviderId": "cloud_provider_id", "cloudProviderRegionId": "id"},+ include={"cloud_provider_id": "cloud_provider_id", "id": "cloud_provider_region_id"},+ parent=CLOUD_PROVIDERS_PARENT,),),+ "account_members": QdrantEndpoint(path="/api/account/v1/accounts/{account_id}/members", paginated=False),+ "invoices": QdrantEndpoint(path="/api/billing/v1/accounts/{account_id}/invoices", paginated=False),"metering_entries": QdrantEndpoint(path=MONTHLY_METERINGS_PATH + "/{year}/{month}",paginated=False,@@ -82,29 +121,31 @@ ENDPOINTS: dict[str, QdrantEndpoint] = {paginated=False,primary_keys=("cluster_id", "node_id", "metric", "timestamp"),partition_key="timestamp",- parent=QdrantParent(- name="clusters",- path=CLUSTERS_PATH,- paginated=True,- path_params={"clusterId": "id"},- include={"id": "cluster_id"},- # A cluster deleted between the listing and its metrics request.- ignored_statuses=(404,),- ),+ parent=CLUSTERS_PARENT,+ ),+ "cluster_inference_metrics": QdrantEndpoint(+ path="/api/monitoring/v1/accounts/{account_id}/cluster/{clusterId}/metrics/inference",+ paginated=False,+ primary_keys=("cluster_id", "inference_model_id", "timestamp"),+ partition_key="timestamp",+ parent=CLUSTERS_PARENT,),}+METRICS_ENDPOINTS = ("cluster_usage_metrics", "cluster_inference_metrics")+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {- "cluster_usage_metrics": [+ endpoint: [{"label": "timestamp","type": IncrementalFieldType.DateTime,"field": "timestamp","field_type": IncrementalFieldType.DateTime,}- ],+ ]+ for endpoint in METRICS_ENDPOINTS}AUTH_ERROR = "Qdrant rejected the Cloud Management Key. Check the key in Access Management > Cloud Management Keys."-PERMISSION_ERROR = "The Qdrant key lacks permission. Grant read:clusters, read:backups, read:backup_schedules, or read:payment_information for the selected tables."+PERMISSION_ERROR = "The Qdrant key lacks permission. Grant read:clusters, read:backups, read:backup_schedules, read:payment_information, or read:users for the selected tables."ACCOUNT_ERROR = "Enter a valid Qdrant account ID from the Cloud Console."diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/source.pyindex 1bc2c895e9b6..ff163119d71c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/source.py@@ -120,7 +120,7 @@ class QdrantSource(ResumableSource[QdrantSourceConfig, QdrantResumeConfig]):caption=("Import Qdrant Cloud infrastructure metadata. ""Create a Cloud Management Key in the Cloud Console under Access Management > Cloud Management Keys. "- "Grant `read:clusters`, `read:backups`, `read:backup_schedules`, and `read:payment_information` for the tables you select. "+ "Grant `read:clusters`, `read:backups`, `read:backup_schedules`, `read:payment_information`, and `read:users` for the tables you select. ""Copy your account ID from the Cloud Console. Vector data and collections are not included."),fields=cast(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/tests/test_qdrant.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/tests/test_qdrant.pyindex e032ebbe43c1..8b6c7cd142c4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/tests/test_qdrant.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qdrant/tests/test_qdrant.py@@ -30,6 +30,8 @@ ACCOUNTS_URL = "https://api.cloud.qdrant.io/api/account/v1/accounts"CLUSTERS_URL = f"https://api.cloud.qdrant.io/api/cluster/v1/accounts/{ACCOUNT_ID}/clusters"PROVIDERS_PATH = f"/api/platform/v1/accounts/{ACCOUNT_ID}/cloud-providers"METERINGS_PATH = f"/api/metering/v1/accounts/{ACCOUNT_ID}/meterings"+PACKAGES_PATH = f"/api/booking/v1/accounts/{ACCOUNT_ID}/packages"+HYBRID_ENV = "00000000-0000-4000-8000-0000000000e1"CLUSTER_A = "00000000-0000-4000-8000-00000000000a"CLUSTER_B = "00000000-0000-4000-8000-00000000000b"@@ -107,6 +109,10 @@ def test_repeated_cursor_fails(config: QdrantSourceConfig) -> None:("cloud_provider_regions", f"https://api.cloud.qdrant.io{PROVIDERS_PATH}", False),("metering_entries", f"https://api.cloud.qdrant.io{METERINGS_PATH}", False),("cluster_usage_metrics", CLUSTERS_URL, True),+ ("cluster_inference_metrics", CLUSTERS_URL, True),+ ("packages", f"https://api.cloud.qdrant.io{PROVIDERS_PATH}", False),+ ("account_members", f"https://api.cloud.qdrant.io/api/account/v1/accounts/{ACCOUNT_ID}/members", False),+ ("invoices", f"https://api.cloud.qdrant.io/api/billing/v1/accounts/{ACCOUNT_ID}/invoices", False),],)def test_credentials_make_one_probe(@@ -206,6 +212,83 @@ def test_cluster_usage_metrics_explode_per_cluster(]+def test_packages_fan_out_over_every_provider_region(config: QdrantSourceConfig) -> None:+ result = drive(+ config,+ "packages",+ [+ ScriptedResponse(json={"items": [{"id": "aws"}, {"id": "hybrid"}]}),+ ScriptedResponse(json={"items": [{"id": "us-east-1", "provider": "aws"}]}),+ ScriptedResponse(json={"items": [{"id": "pkg-1", "name": "small"}]}),+ ScriptedResponse(json={"items": [{"id": HYBRID_ENV, "provider": "openshift"}]}),+ ScriptedResponse(json={"items": [{"id": "pkg-1", "name": "small"}]}),+ ],+ )++ assert result.raised is None+ assert result.paths == [+ PROVIDERS_PATH,+ f"{PROVIDERS_PATH}/aws/regions",+ PACKAGES_PATH,+ f"{PROVIDERS_PATH}/hybrid/regions",+ PACKAGES_PATH,+ ]+ package_queries = [query for query, path in zip(result.queries, result.paths) if path == PACKAGES_PATH]+ statuses = ("PACKAGE_STATUS_ACTIVE", "PACKAGE_STATUS_DEACTIVATED")+ assert package_queries == [+ {"cloudProviderId": ("aws",), "cloudProviderRegionId": ("us-east-1",), "statuses": statuses},+ {"cloudProviderId": ("hybrid",), "cloudProviderRegionId": (HYBRID_ENV,), "statuses": statuses},+ ]+ assert result.rows == [+ {"id": "pkg-1", "name": "small", "cloud_provider_id": "aws", "cloud_provider_region_id": "us-east-1"},+ {"id": "pkg-1", "name": "small", "cloud_provider_id": "hybrid", "cloud_provider_region_id": HYBRID_ENV},+ ]+++@time_machine.travel("2026-10-31T12:00:00Z", tick=False)+ "inputs,expected_since",+ [+ ({}, "2026-10-24T00:00:00Z"),+ (+ {"incremental_field": "timestamp", "db_incremental_field_last_value": "2026-10-31T00:00:00Z"},+ "2026-10-31T00:00:00Z",+ ),+ ],+)+def test_cluster_inference_metrics_explode_per_model(+ config: QdrantSourceConfig, inputs: dict[str, Any], expected_since: str+) -> None:+ point = {"timestamp": "2026-10-31T00:00:00Z", "value": 1200}+ result = drive(+ config,+ "cluster_inference_metrics",+ [+ ScriptedResponse(json={"items": [{"id": CLUSTER_A}, {"id": CLUSTER_B}]}),+ ScriptedResponse(json={"models": [{"inferenceModelId": "model-1", "values": [point]}]}),+ ScriptedResponse(json={}),+ ],+ **inputs,+ )++ assert result.raised is None+ assert result.params("since") == [None, expected_since, expected_since]+ assert result.params("interval") == [None, "INFERENCE_METRICS_INTERVAL_DAY", "INFERENCE_METRICS_INTERVAL_DAY"]+ assert result.rows == [{"cluster_id": CLUSTER_A, "inference_model_id": "model-1", **point}]+++def test_account_members_flatten_user(config: QdrantSourceConfig) -> None:+ user = {"id": "user-1", "email": "[email protected]", "createdAt": "2026-01-01T00:00:00Z"}+ result = drive(+ config,+ "account_members",+ [ScriptedResponse(json={"items": [{"accountMember": user, "isOwner": True}, {"accountMember": user}]})],+ )++ assert result.raised is None+ assert result.rows == [{**user, "isOwner": True}, {**user, "isOwner": False}]++@pytest.mark.parametrize("body", [{"items": []}, {"items": [{"id": "another-account"}]}])def test_credentials_reject_unavailable_account(config: QdrantSourceConfig, body: dict[str, Any]) -> None:with requests_mock.Mocker() as http: