diff --git a/src/ingestion/connectors/collaboration/zoom/README.md b/src/ingestion/connectors/collaboration/zoom/README.md index 955f70431d..354d854ffb 100644 --- a/src/ingestion/connectors/collaboration/zoom/README.md +++ b/src/ingestion/connectors/collaboration/zoom/README.md @@ -25,7 +25,6 @@ stringData: zoom_account_id: "" # Zoom account ID zoom_client_id: "" # OAuth app client ID zoom_client_secret: "" # OAuth app client secret - zoom_start_date: "2026-01-01" # Earliest date for incremental sync (YYYY-MM-DD) ``` ### Fields @@ -35,7 +34,11 @@ stringData: | `zoom_account_id` | Yes | Zoom Server-to-Server OAuth account ID | | `zoom_client_id` | Yes | OAuth app client ID | | `zoom_client_secret` | Yes | OAuth app client secret (sensitive) | -| `zoom_start_date` | Yes | Earliest date for incremental sync (YYYY-MM-DD) | + +There is no start-date knob: the `meetings` stream reads the Zoom Dashboard API +(`/v2/metrics/*`), which only serves data for the last six months. The first +sync automatically backfills from `now - 150 days` (a safety margin inside that +window); later syncs continue incrementally from saved state. ### Automatically injected diff --git a/src/ingestion/connectors/collaboration/zoom/connector.yaml b/src/ingestion/connectors/collaboration/zoom/connector.yaml index 7b1ebf7540..1061914790 100644 --- a/src/ingestion/connectors/collaboration/zoom/connector.yaml +++ b/src/ingestion/connectors/collaboration/zoom/connector.yaml @@ -105,7 +105,10 @@ streams: http_method: POST url: https://zoom.us/oauth/token request_body: - $ref: "#/definitions/linked/HttpRequester/request_body" + type: RequestBodyUrlEncodedForm + value: + grant_type: account_credentials + account_id: "{{ config['zoom_account_id'] }}" expiration_duration: PT1H session_token_path: - access_token @@ -113,10 +116,53 @@ streams: type: Bearer http_method: GET error_handler: - $ref: "#/definitions/linked/HttpRequester/error_handler" + type: CompositeErrorHandler + error_handlers: + - type: DefaultErrorHandler + response_filters: + - type: HttpResponseFilter + action: RATE_LIMITED + http_codes: + - 429 + backoff_strategies: + - type: WaitTimeFromHeader + header: Retry-After + - type: DefaultErrorHandler + response_filters: + - type: HttpResponseFilter + action: RATE_LIMITED + http_codes: + - 503 + backoff_strategies: + - type: WaitTimeFromHeader + header: Retry-After + - type: DefaultErrorHandler + max_retries: 5 + response_filters: + - type: HttpResponseFilter + action: RETRY + http_codes: + - 500 + - 502 + - 504 + backoff_strategies: + - type: ExponentialBackoffStrategy + factor: 5 + request_parameters: + page_size: "{{ config['page_size'] }}" url: https://api.zoom.us/v2/users paginator: - $ref: "#/definitions/linked/SimpleRetriever/paginator" + type: DefaultPaginator + page_token_option: + type: RequestOption + inject_into: request_parameter + field_name: next_page_token + pagination_strategy: + type: CursorPagination + cursor_value: "{{ response.get('next_page_token') }}" + stop_condition: + type: StopCondition + condition: "{{ not response.get('next_page_token') }}" record_selector: type: RecordSelector extractor: @@ -267,7 +313,10 @@ streams: http_method: POST url: https://zoom.us/oauth/token request_body: - $ref: "#/definitions/linked/HttpRequester/request_body" + type: RequestBodyUrlEncodedForm + value: + grant_type: account_credentials + account_id: "{{ config['zoom_account_id'] }}" expiration_duration: PT1H session_token_path: - access_token @@ -336,7 +385,7 @@ streams: - "%Y-%m-%dT%H:%M:%S%z" start_datetime: type: MinMaxDatetime - datetime: "{{ config['zoom_start_date'] }}" + datetime: "{{ (now_utc() - duration('P150D')).strftime('%Y-%m-%d') }}" datetime_format: "%Y-%m-%d" end_datetime: type: MinMaxDatetime @@ -521,14 +570,162 @@ streams: - type: ParentStreamConfig parent_key: uuid partition_field: meeting_uuid + # NOTE: incremental_dependency is deliberately NOT set. It only has + # an effect when the substream itself is incremental (the parent + # cursor piggybacks on the child state); participants is + # full-refresh, so the CDK emits no child state at all — verified + # by tests/test_participants.py. Partition enumeration is instead + # bounded by the parent's now-150d window. stream: - $ref: "#/streams/1" + type: DeclarativeStream + name: _meetings + primary_key: + - uuid + retriever: + type: SimpleRetriever + decoder: + type: JsonDecoder + requester: + type: HttpRequester + authenticator: + type: SessionTokenAuthenticator + login_requester: + type: HttpRequester + authenticator: + type: BasicHttpAuthenticator + username: "{{ config['zoom_client_id'] }}" + password: "{{ config['zoom_client_secret'] }}" + http_method: POST + url: https://zoom.us/oauth/token + request_body: + type: RequestBodyUrlEncodedForm + value: + grant_type: account_credentials + account_id: "{{ config['zoom_account_id'] }}" + expiration_duration: PT1H + session_token_path: + - access_token + request_authentication: + type: Bearer + http_method: GET + error_handler: + type: CompositeErrorHandler + error_handlers: + - type: DefaultErrorHandler + response_filters: + - type: HttpResponseFilter + action: RATE_LIMITED + http_codes: + - 429 + backoff_strategies: + - type: WaitTimeFromHeader + header: Retry-After + - type: DefaultErrorHandler + response_filters: + - type: HttpResponseFilter + action: RATE_LIMITED + http_codes: + - 503 + backoff_strategies: + - type: WaitTimeFromHeader + header: Retry-After + - type: DefaultErrorHandler + max_retries: 5 + response_filters: + - type: HttpResponseFilter + action: RETRY + http_codes: + - 500 + - 502 + - 504 + backoff_strategies: + - type: ExponentialBackoffStrategy + factor: 5 + request_parameters: + $ref: "#/definitions/linked/HttpRequester/request_parameters" + url: https://api.zoom.us/v2/metrics/meetings + paginator: + type: DefaultPaginator + page_token_option: + type: RequestOption + inject_into: request_parameter + field_name: next_page_token + pagination_strategy: + type: CursorPagination + cursor_value: "{{ response.get('next_page_token') }}" + stop_condition: + type: StopCondition + condition: "{{ not response.get('next_page_token') }}" + record_selector: + type: RecordSelector + extractor: + type: DpathExtractor + field_path: + - meetings + incremental_sync: + type: DatetimeBasedCursor + cursor_field: end_time + cursor_datetime_formats: + - "%Y-%m-%dT%H:%M:%SZ" + - "%Y-%m-%dT%H:%M:%S%z" + start_datetime: + type: MinMaxDatetime + datetime: >- + {{ (now_utc() - duration('P150D')).strftime('%Y-%m-%d') }} + datetime_format: "%Y-%m-%d" + end_datetime: + type: MinMaxDatetime + datetime: "{{ now_utc().strftime('%Y-%m-%d') }}" + datetime_format: "%Y-%m-%d" + datetime_format: "%Y-%m-%d" + start_time_option: + type: RequestOption + field_name: from + inject_into: request_parameter + end_time_option: + type: RequestOption + field_name: to + inject_into: request_parameter + lookback_window: P7D + step: P30D + cursor_granularity: P1D + schema_loader: + type: InlineSchemaLoader + schema: + type: object + $schema: http://json-schema.org/schema# + properties: + uuid: + type: + - string + - "null" + end_time: + type: string + additionalProperties: true decoder: type: JsonDecoder requester: type: HttpRequester authenticator: - $ref: "#/definitions/linked/HttpRequester/authenticator" + type: SessionTokenAuthenticator + login_requester: + type: HttpRequester + authenticator: + type: BasicHttpAuthenticator + username: "{{ config['zoom_client_id'] }}" + password: "{{ config['zoom_client_secret'] }}" + http_method: POST + url: https://zoom.us/oauth/token + request_body: + type: RequestBodyUrlEncodedForm + value: + grant_type: account_credentials + account_id: "{{ config['zoom_account_id'] }}" + expiration_duration: PT1H + session_token_path: + - access_token + request_authentication: + type: Bearer http_method: GET error_handler: type: CompositeErrorHandler @@ -859,7 +1056,6 @@ spec: - zoom_account_id - zoom_client_id - zoom_client_secret - - zoom_start_date properties: insight_tenant_id: type: string @@ -886,14 +1082,6 @@ spec: title: Zoom Client Secret airbyte_secret: true order: 4 - zoom_start_date: - type: string - description: >- - Earliest date to request during initial sync or best-effort historical - backfill. - title: Start Date - format: date - order: 5 page_size: type: integer description: Requested page size for paginated Zoom endpoints. @@ -901,7 +1089,7 @@ spec: default: 100 minimum: 1 maximum: 300 - order: 6 + order: 5 additionalProperties: true metadata: diff --git a/src/ingestion/connectors/collaboration/zoom/descriptor.yaml b/src/ingestion/connectors/collaboration/zoom/descriptor.yaml index 0833828ea1..c2bb083751 100644 --- a/src/ingestion/connectors/collaboration/zoom/descriptor.yaml +++ b/src/ingestion/connectors/collaboration/zoom/descriptor.yaml @@ -1,5 +1,5 @@ name: zoom -version: "1.0.0" +version: "1.1.0" schedule: 0 3 * * * dbt_select: tag:zoom+ workflow: sync @@ -10,4 +10,3 @@ secret: - zoom_account_id - zoom_client_id - zoom_client_secret - - zoom_start_date diff --git a/src/ingestion/connectors/collaboration/zoom/tests/config.py b/src/ingestion/connectors/collaboration/zoom/tests/config.py new file mode 100644 index 0000000000..78988988f2 --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/config.py @@ -0,0 +1,81 @@ +"""Zoom connector test config builder.""" + +from __future__ import annotations + +import json + +from connector_tests import ConfigBuilder, HttpRequest, HttpResponse + +API_URL = "https://api.zoom.us/v2" +TOKEN_URL = "https://zoom.us/oauth/token" +METRICS_URL = f"{API_URL}/metrics/meetings" + +# Frozen "now" every meetings/participants test uses. With this clock the +# DatetimeBasedCursor (start = now - P150D, step P30D, granularity P1D) slices +# the window into exactly these five from/to pairs — the final slice absorbs +# the remainder up to end_datetime instead of emitting a 1-day tail. The first +# slice starting at now-150d (inside Zoom's six-month Dashboard-API limit) is +# the job-529 regression pin. +FROZEN_NOW = "2026-07-01T00:00:00Z" +MEETING_SLICES = [ + ("2026-02-01", "2026-03-02"), + ("2026-03-03", "2026-04-01"), + ("2026-04-02", "2026-05-01"), + ("2026-05-02", "2026-05-31"), + ("2026-06-01", "2026-07-01"), +] + +# The inline `_meetings` PARENT of participants is read through the CDK's +# synchronous path (SubstreamPartitionRouter.read_only_records), whose slice +# generator does NOT absorb the remainder into the last slice — it emits the +# plain step layout with a 1-day tail. Same window pin, different tail shape. +PARENT_MEETING_SLICES = MEETING_SLICES[:-1] + [("2026-06-01", "2026-06-30"), ("2026-07-01", "2026-07-01")] + + +def metrics_params(from_date: str, to_date: str, page_token: str | None = None) -> dict: + params = {"type": "past", "page_size": "100", "from": from_date, "to": to_date} + if page_token: + params["next_page_token"] = page_token + return params + + +def mock_meeting_slices(http_mocker, non_empty: dict, slices=MEETING_SLICES) -> None: + """Register every expected meetings slice; slices whose `from` date is not + a key of `non_empty` serve an empty page. Exact from/to matchers mean an + out-of-window request (the job-529 failure mode) matches nothing and fails + the test.""" + for from_date, to_date in slices: + http_mocker.get( + HttpRequest(METRICS_URL, query_params=metrics_params(from_date, to_date)), + non_empty.get(from_date, HttpResponse(body=json.dumps({"meetings": []}), status_code=200)), + ) + + +class ZoomConfigBuilder(ConfigBuilder): + def __init__(self) -> None: + super().__init__() + self._config.update( + { + "zoom_account_id": "test-account", + "zoom_client_id": "test-client", + "zoom_client_secret": "test-secret", + # Explicit so exact request matchers can pin page_size=100 on + # every stream (the spec default only applies when Airbyte + # injects it into the config). + "page_size": 100, + } + ) + + +def mock_token(http_mocker) -> None: + """Register the Server-to-Server OAuth token exchange every stream's + SessionTokenAuthenticator performs before its first API call. The matcher + compares the form body byte-exact, so this also pins the + account_credentials grant the manifest declares.""" + http_mocker.post( + HttpRequest(TOKEN_URL, body="grant_type=account_credentials&account_id=test-account"), + HttpResponse( + body=json.dumps({"access_token": "test-bearer", "token_type": "bearer", "expires_in": 3600}), + status_code=200, + ), + ) diff --git a/src/ingestion/connectors/collaboration/zoom/tests/conftest.py b/src/ingestion/connectors/collaboration/zoom/tests/conftest.py new file mode 100644 index 0000000000..799e7bc6d0 --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +# Local builder modules (config.py) are importable under --import-mode=importlib. +sys.path.insert(0, str(Path(__file__).parent)) + +from connector_tests.plugin import * # noqa: E402,F401,F403 — http_mocker fixture + hooks diff --git a/src/ingestion/connectors/collaboration/zoom/tests/fixtures/meeting.json b/src/ingestion/connectors/collaboration/zoom/tests/fixtures/meeting.json new file mode 100644 index 0000000000..c685ead74b --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/fixtures/meeting.json @@ -0,0 +1,19 @@ +{ + "uuid": "mtg-uuid-1==", + "id": 88011122233, + "topic": "Weekly Sync", + "host": "Alice Example", + "email": "alice@example.com", + "user_type": "Licensed", + "start_time": "2026-06-15T10:00:00Z", + "end_time": "2026-06-15T10:30:00Z", + "duration": "30:00", + "participants": 2, + "has_pstn": false, + "has_voip": true, + "has_3rd_party_audio": false, + "has_video": false, + "has_screen_share": false, + "has_recording": false, + "has_sip": false +} diff --git a/src/ingestion/connectors/collaboration/zoom/tests/fixtures/participant.json b/src/ingestion/connectors/collaboration/zoom/tests/fixtures/participant.json new file mode 100644 index 0000000000..2e4bded55f --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/fixtures/participant.json @@ -0,0 +1,23 @@ +{ + "id": "p-reg-1", + "participant_uuid": "part-uuid-1", + "user_id": "16778240", + "user_name": "Alice Example", + "email": "alice@example.com", + "device": "Mac", + "ip_address": "10.0.0.1", + "location": "Berlin (DE)", + "network_type": "Wifi", + "microphone": "MacBook Pro Microphone", + "speaker": "MacBook Pro Speakers", + "camera": null, + "data_center": "Frankfurt", + "connection_type": "UDP", + "join_time": "2026-06-15T10:00:05Z", + "leave_time": "2026-06-15T10:29:55Z", + "share_application": false, + "share_desktop": false, + "share_whiteboard": false, + "recording": false, + "status": "in_meeting" +} diff --git a/src/ingestion/connectors/collaboration/zoom/tests/fixtures/user.json b/src/ingestion/connectors/collaboration/zoom/tests/fixtures/user.json new file mode 100644 index 0000000000..56ee43c5f5 --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/fixtures/user.json @@ -0,0 +1,19 @@ +{ + "id": "usr-1", + "first_name": "Alice", + "last_name": "Example", + "display_name": "Alice Example", + "email": "alice@example.com", + "type": 2, + "pmi": 1234567890, + "timezone": "Europe/Berlin", + "verified": 1, + "dept": "Engineering", + "created_at": "2025-01-15T09:00:00Z", + "last_login_time": "2026-06-30T08:00:00Z", + "last_client_version": "6.0.0(mac)", + "group_ids": [], + "language": "en-US", + "status": "active", + "role_id": "2" +} diff --git a/src/ingestion/connectors/collaboration/zoom/tests/test_meetings.py b/src/ingestion/connectors/collaboration/zoom/tests/test_meetings.py new file mode 100644 index 0000000000..51dcbdbe3b --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/test_meetings.py @@ -0,0 +1,138 @@ +"""Mock-server tests for the `meetings` stream. + +Incremental stream over the Zoom Dashboard API: GET /v2/metrics/meetings with +type=past & page_size, DatetimeBasedCursor on `end_time` (start = now_utc() - +P150D, end = today, step P30D, cursor granularity P1D, lookback P7D) injected +as `from`/`to` date params, CursorPagination on `next_page_token`. + +Coverage matrix rows: full_refresh_single_page (per-slice), schema_conformance, +tenant_source_stamping (unique_key from meeting uuid), empty_page, +pagination_multi_page, incremental_state (state emission + resume-request +filtering with the P7D lookback). + +REGRESSION — dev-vhc Airbyte job 529: the Dashboard API only serves the last +six months, and the stream previously sliced from a static `zoom_start_date` +config; once that date fell out of the window Zoom answered +`400 {"code": 300, "message": "The request can only be queried for a month +that falls within the last six months."}` and every sync died at the pre-sync +connection check. The `six_month_window` test freezes the clock and pins — +with EXACT `from`/`to` matchers on every slice — that the first slice starts +at now-150d (inside the window) and no request predates it: with no network +fallthrough, a connector regressing to an out-of-window start date fails this +test with an unmatched-request error. +""" + +from __future__ import annotations + +import json + +import freezegun +from config import FROZEN_NOW, METRICS_URL, ZoomConfigBuilder, metrics_params, mock_meeting_slices, mock_token +from connector_tests import HttpMocker, HttpRequest, HttpResponse, assert_records_conform, load_fixture, read_stream + +_STREAM = "meetings" +_CONNECTOR = "collaboration/zoom" +_NOW = FROZEN_NOW + + +def _meeting(uuid: str, end_time: str) -> dict: + start_time = end_time.replace("T10:30:00Z", "T10:00:00Z") + return load_fixture(__file__, "meeting.json", uuid=uuid, start_time=start_time, end_time=end_time) + + +def _page(meetings: list[dict], next_token: str | None = None) -> HttpResponse: + body: dict = {"meetings": meetings} + if next_token: + body["next_page_token"] = next_token + return HttpResponse(body=json.dumps(body), status_code=200) + + +@freezegun.freeze_time(_NOW) +def test_six_month_window_regression(http_mocker: HttpMocker) -> None: + """Job-529 regression: every slice the connector requests is pinned by an + exact from/to matcher, first slice = now-150d. A regression to a static / + out-of-window start date (e.g. the old zoom_start_date=2026-01-01) issues a + request no matcher accepts and fails immediately.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + mock_meeting_slices(http_mocker, {"2026-06-01": _page([_meeting("mtg-uuid-1==", "2026-06-15T10:30:00Z")])}) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 1 + assert not output.errors + assert output.records[0].record.data["uuid"] == "mtg-uuid-1==" + + +@freezegun.freeze_time(_NOW) +def test_tenant_source_stamping_and_schema(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + mock_meeting_slices(http_mocker, {"2026-06-01": _page([_meeting("mtg-uuid-1==", "2026-06-15T10:30:00Z")])}) + + output = read_stream(_CONNECTOR, _STREAM, config) + + rec = output.records[0].record.data + assert rec["tenant_id"] == config["insight_tenant_id"] + assert rec["source_id"] == config["insight_source_id"] + assert rec["unique_key"] == (f"{config['insight_tenant_id']}-{config['insight_source_id']}-mtg-uuid-1==") + assert_records_conform(output.records, _CONNECTOR, _STREAM) + + +@freezegun.freeze_time(_NOW) +def test_empty_window(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + mock_meeting_slices(http_mocker, {}) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 0 + assert not output.errors + + +@freezegun.freeze_time(_NOW) +def test_pagination_multi_page(http_mocker: HttpMocker) -> None: + """CursorPagination inside one slice: a next_page_token drives a second + request carrying the token AND the same from/to window.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + mock_meeting_slices( + http_mocker, {"2026-06-01": _page([_meeting("mtg-uuid-1==", "2026-06-10T10:30:00Z")], next_token="tok-2")} + ) + http_mocker.get( + HttpRequest(METRICS_URL, query_params=metrics_params("2026-06-01", "2026-07-01", page_token="tok-2")), + _page([_meeting("mtg-uuid-2==", "2026-06-12T10:30:00Z")]), + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 2 + assert sorted(r.record.data["uuid"] for r in output.records) == ["mtg-uuid-1==", "mtg-uuid-2=="] + + +@freezegun.freeze_time(_NOW) +def test_incremental_state_emitted_and_resume_filters(http_mocker: HttpMocker) -> None: + """First read emits a state message with the max observed end_time; a + second read given that state must slice from the cursor minus the P7D + lookback — asserted by exact from/to matchers.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + mock_meeting_slices(http_mocker, {"2026-06-01": _page([_meeting("mtg-uuid-1==", "2026-06-15T10:30:00Z")])}) + + first = read_stream(_CONNECTOR, _STREAM, config) + + assert len(first.records) == 1 + assert first.state_messages, "incremental stream must emit state" + state = [m.state for m in first.state_messages][-1:] + + # Resume: cursor 2026-06-15 minus lookback P7D -> 2026-06-08. + resume_mocker = HttpMocker() + with resume_mocker: + mock_token(resume_mocker) + resume_mocker.get(HttpRequest(METRICS_URL, query_params=metrics_params("2026-06-08", "2026-07-01")), _page([])) + + second = read_stream(_CONNECTOR, _STREAM, config, state=state) + + assert len(second.records) == 0 + assert not second.errors diff --git a/src/ingestion/connectors/collaboration/zoom/tests/test_participants.py b/src/ingestion/connectors/collaboration/zoom/tests/test_participants.py new file mode 100644 index 0000000000..4ed91e3f6b --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/test_participants.py @@ -0,0 +1,158 @@ +"""Mock-server tests for the `participants` stream. + +Substream of the inline `_meetings` parent (PR #1746 replaced the whole-object +`$ref: "#/streams/1"` parent with an inline definition): the parent enumerates +Dashboard meetings over the now-150d window, then one +GET /v2/metrics/meetings/{uuid}/participants per partition, with the meeting +uuid URL-escaped in the path (`/`→%2F, `+`→%2B, `=`→%3D). AddFields stamps +tenant_id / source_id / meeting_uuid (from the partition) / unique_key = +"{tenant}-{source}-{meeting_uuid}-{participant_uuid}-{join_time}". + +Coverage matrix rows: substream_partition (one child request per parent +partition, uuid escaping), transformations + tenant_source_stamping, +schema_conformance, pagination_multi_page. incremental_state is N/A — the +stream is full-refresh; test_full_refresh_substream_emits_no_cursor_state pins +that contract (and documents why incremental_dependency is absent). +""" + +from __future__ import annotations + +import json + +import freezegun +from config import FROZEN_NOW, METRICS_URL, PARENT_MEETING_SLICES, ZoomConfigBuilder, mock_meeting_slices, mock_token +from connector_tests import HttpMocker, HttpRequest, HttpResponse, assert_records_conform, load_fixture, read_stream + +_STREAM = "participants" +_CONNECTOR = "collaboration/zoom" +_NOW = FROZEN_NOW + + +def _meeting(uuid: str, end_time: str) -> dict: + start_time = end_time.replace("T10:30:00Z", "T10:00:00Z") + return load_fixture(__file__, "meeting.json", uuid=uuid, start_time=start_time, end_time=end_time) + + +def _participant(puid: str, email: str, join_time: str = "2026-06-15T10:00:05Z") -> dict: + return load_fixture(__file__, "participant.json", participant_uuid=puid, email=email, join_time=join_time) + + +def _meetings_page(meetings: list[dict]) -> HttpResponse: + return HttpResponse(body=json.dumps({"meetings": meetings}), status_code=200) + + +def _participants_page(participants: list[dict], next_token: str | None = None) -> HttpResponse: + body: dict = {"participants": participants} + if next_token: + body["next_page_token"] = next_token + return HttpResponse(body=json.dumps(body), status_code=200) + + +def _mock_parent(http_mocker: HttpMocker, meetings: list[dict]) -> None: + """The inline `_meetings` parent slices the same now-150d window as the + top-level meetings stream (PARENT_MEETING_SLICES — the sync read path emits + a 1-day tail instead of absorbing it); all parent meetings are served in + the 2026-06-01 slice, the other slices are empty. Exact from/to matchers + keep the job-529 window pin on the parent path too.""" + mock_meeting_slices(http_mocker, {"2026-06-01": _meetings_page(meetings)}, slices=PARENT_MEETING_SLICES) + + +def _participants_url(escaped_uuid: str) -> str: + return f"{METRICS_URL}/{escaped_uuid}/participants" + + +_CHILD_PARAMS = {"type": "past", "page_size": "100"} + + +@freezegun.freeze_time(_NOW) +def test_substream_partition_per_meeting_with_uuid_escaping(http_mocker: HttpMocker) -> None: + """One participants request per parent meeting; the `==` uuid suffix (and + any `/`, `+`) must be percent-escaped in the URL path — an unescaped + request would not match and fail the test.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + _mock_parent( + http_mocker, [_meeting("mtg/a+1==", "2026-06-15T10:30:00Z"), _meeting("mtg-b-2==", "2026-06-16T10:30:00Z")] + ) + http_mocker.get( + HttpRequest(_participants_url("mtg%2Fa%2B1%3D%3D"), query_params=_CHILD_PARAMS), + _participants_page([_participant("part-a", "alice@example.com")]), + ) + http_mocker.get( + HttpRequest(_participants_url("mtg-b-2%3D%3D"), query_params=_CHILD_PARAMS), + _participants_page([_participant("part-b", "bob@example.com")]), + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 2 + assert not output.errors + assert sorted(r.record.data["participant_uuid"] for r in output.records) == ["part-a", "part-b"] + + +@freezegun.freeze_time(_NOW) +def test_transformations_stamping_and_schema(http_mocker: HttpMocker) -> None: + """meeting_uuid is stamped from the partition (the API payload does not + carry it), and unique_key composes meeting_uuid + participant_uuid + + join_time.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + _mock_parent(http_mocker, [_meeting("mtg-uuid-1==", "2026-06-15T10:30:00Z")]) + http_mocker.get( + HttpRequest(_participants_url("mtg-uuid-1%3D%3D"), query_params=_CHILD_PARAMS), + _participants_page([_participant("part-uuid-1", "alice@example.com")]), + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + rec = output.records[0].record.data + assert rec["tenant_id"] == config["insight_tenant_id"] + assert rec["source_id"] == config["insight_source_id"] + assert rec["meeting_uuid"] == "mtg-uuid-1==" + assert rec["unique_key"] == ( + f"{config['insight_tenant_id']}-{config['insight_source_id']}-mtg-uuid-1==-part-uuid-1-2026-06-15T10:00:05Z" + ) + assert_records_conform(output.records, _CONNECTOR, _STREAM) + + +@freezegun.freeze_time(_NOW) +def test_pagination_multi_page(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + _mock_parent(http_mocker, [_meeting("mtg-uuid-1==", "2026-06-15T10:30:00Z")]) + http_mocker.get( + HttpRequest(_participants_url("mtg-uuid-1%3D%3D"), query_params=_CHILD_PARAMS), + _participants_page([_participant("part-1", "alice@example.com")], next_token="tok-2"), + ) + http_mocker.get( + HttpRequest(_participants_url("mtg-uuid-1%3D%3D"), query_params={**_CHILD_PARAMS, "next_page_token": "tok-2"}), + _participants_page([_participant("part-2", "bob@example.com")]), + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 2 + + +@freezegun.freeze_time(_NOW) +def test_full_refresh_substream_emits_no_cursor_state(http_mocker: HttpMocker) -> None: + """participants is a full-refresh substream: the CDK emits only the + no-cursor sentinel state, and in particular NO parent_state — this is why + `incremental_dependency` is deliberately absent from the ParentStreamConfig + (it only piggybacks the parent cursor on an incremental child's state; on a + full-refresh child it is a silent no-op — this test found that). Freshness + is instead bounded by the parent's now-150d slicing, re-read each sync.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + _mock_parent(http_mocker, [_meeting("mtg-uuid-1==", "2026-06-15T10:30:00Z")]) + http_mocker.get( + HttpRequest(_participants_url("mtg-uuid-1%3D%3D"), query_params=_CHILD_PARAMS), + _participants_page([_participant("part-1", "alice@example.com")]), + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert output.state_messages, "read must close with a state message" + final_state = output.state_messages[-1].state.stream.stream_state.__dict__ + assert final_state.get("__ab_no_cursor_state_message") is True + assert "parent_state" not in final_state diff --git a/src/ingestion/connectors/collaboration/zoom/tests/test_users.py b/src/ingestion/connectors/collaboration/zoom/tests/test_users.py new file mode 100644 index 0000000000..138e4638d4 --- /dev/null +++ b/src/ingestion/connectors/collaboration/zoom/tests/test_users.py @@ -0,0 +1,130 @@ +"""Mock-server tests for the `users` stream. + +Plain paginated stream: GET /v2/users behind a Server-to-Server OAuth token +exchange (SessionTokenAuthenticator), CursorPagination on `next_page_token`, +`users` extract field, AddFields stamping tenant_id / source_id / +unique_key = "{tenant}-{source}-{id}". + +Coverage matrix rows: full_refresh_single_page, schema_conformance, +tenant_source_stamping, empty_page, pagination_multi_page, error_retry (429). +The exact query matcher on page_size=100 also pins the PR #1746 review fix +(the users requester previously sent no page_size at all). +""" + +from __future__ import annotations + +import json + +from config import API_URL, ZoomConfigBuilder, mock_token +from connector_tests import HttpMocker, HttpRequest, HttpResponse, assert_records_conform, load_fixture, read_stream + +_STREAM = "users" +_CONNECTOR = "collaboration/zoom" +_USERS_URL = f"{API_URL}/users" + + +def _user(uid: str, email: str) -> dict: + return load_fixture(__file__, "user.json", id=uid, email=email) + + +def _page(users: list[dict], next_token: str | None = None) -> HttpResponse: + body: dict = {"users": users} + if next_token: + body["next_page_token"] = next_token + return HttpResponse(body=json.dumps(body), status_code=200) + + +def _params(page_token: str | None = None) -> dict: + params = {"page_size": "100"} + if page_token: + params["next_page_token"] = page_token + return params + + +def test_full_refresh_single_page(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + http_mocker.get( + HttpRequest(_USERS_URL, query_params=_params()), + _page([_user("usr-1", "alice@example.com"), _user("usr-2", "bob@example.com")]), + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 2 + assert not output.errors + assert sorted(r.record.data["email"] for r in output.records) == ["alice@example.com", "bob@example.com"] + + +def test_tenant_source_stamping(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + http_mocker.get(HttpRequest(_USERS_URL, query_params=_params()), _page([_user("usr-1", "alice@example.com")])) + + output = read_stream(_CONNECTOR, _STREAM, config) + + rec = output.records[0].record.data + assert rec["tenant_id"] == config["insight_tenant_id"] + assert rec["source_id"] == config["insight_source_id"] + assert rec["unique_key"] == (f"{config['insight_tenant_id']}-{config['insight_source_id']}-usr-1") + + +def test_schema_conformance(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + http_mocker.get(HttpRequest(_USERS_URL, query_params=_params()), _page([_user("usr-1", "alice@example.com")])) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert_records_conform(output.records, _CONNECTOR, _STREAM) + + +def test_pagination_multi_page(http_mocker: HttpMocker) -> None: + """CursorPagination: a next_page_token in the response drives a second + request carrying it; a response without the token stops.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + http_mocker.get( + HttpRequest(_USERS_URL, query_params=_params()), + _page([_user("usr-1", "alice@example.com")], next_token="tok-2"), + ) + http_mocker.get( + HttpRequest(_USERS_URL, query_params=_params(page_token="tok-2")), _page([_user("usr-2", "bob@example.com")]) + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 2 + assert output.records[-1].record.data["id"] == "usr-2" + + +def test_empty_page(http_mocker: HttpMocker) -> None: + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + http_mocker.get(HttpRequest(_USERS_URL, query_params=_params()), _page([])) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 0 + assert not output.errors + + +def test_error_retry_429(http_mocker: HttpMocker) -> None: + """The manifest error handler RETRIES 429 (WaitTimeFromHeader Retry-After); + the read must succeed once the source recovers, without losing records.""" + config = ZoomConfigBuilder().build() + mock_token(http_mocker) + http_mocker.get( + HttpRequest(_USERS_URL, query_params=_params()), + [ + HttpResponse( + body=json.dumps({"code": 429, "message": "rate limited"}), status_code=429, headers={"Retry-After": "0"} + ), + _page([_user("usr-1", "alice@example.com")]), + ], + ) + + output = read_stream(_CONNECTOR, _STREAM, config) + + assert len(output.records) == 1 + assert not output.errors diff --git a/src/ingestion/scripts/create-bronze-placeholders.sh b/src/ingestion/scripts/create-bronze-placeholders.sh index 61af1f0641..d190117512 100644 --- a/src/ingestion/scripts/create-bronze-placeholders.sh +++ b/src/ingestion/scripts/create-bronze-placeholders.sh @@ -1223,12 +1223,21 @@ SQL fi # bronze_zoom — needed by gold-views comms_daily, zoom_person_daily +# +# Key shape mirrors the PROMOTED table (`promote_bronze_to_rmt(order_by='unique_key')` +# in zoom__bronze_promoted.sql): ORDER BY unique_key, allow_nullable_key. The +# previous placeholder ordered by `email`, which silently collapsed every +# participant row of one person into a single row on RMT merge — deployed +# tables were unaffected (Airbyte + the promote macro produce the unique_key +# shape), but the e2e rig runs on the placeholder and could not seed more than +# one meeting per person. if ! ch_table_exists bronze_zoom participants; then echo " Creating placeholder: bronze_zoom.participants" run_ch <<'SQL' CREATE TABLE IF NOT EXISTS bronze_zoom.participants ( tenant_id String, source_id String, + unique_key Nullable(String), email String, user_name Nullable(String), meeting_uuid String, @@ -1244,13 +1253,15 @@ CREATE TABLE IF NOT EXISTS bronze_zoom.participants ( _airbyte_extracted_at DateTime64(3) DEFAULT now64(3), _airbyte_meta String DEFAULT '{}', _airbyte_generation_id UInt32 DEFAULT 0 -) ENGINE = ReplacingMergeTree(_airbyte_extracted_at) ORDER BY email; +) ENGINE = ReplacingMergeTree(_airbyte_extracted_at) ORDER BY unique_key + SETTINGS allow_nullable_key = 1; SQL else echo " Reconciling placeholder schema: bronze_zoom.participants" run_ch <<'SQL' ALTER TABLE bronze_zoom.participants ADD COLUMN IF NOT EXISTS tenant_id String; ALTER TABLE bronze_zoom.participants ADD COLUMN IF NOT EXISTS source_id String; +ALTER TABLE bronze_zoom.participants ADD COLUMN IF NOT EXISTS unique_key Nullable(String); ALTER TABLE bronze_zoom.participants ADD COLUMN IF NOT EXISTS user_name Nullable(String); ALTER TABLE bronze_zoom.participants ADD COLUMN IF NOT EXISTS participant_uuid String; ALTER TABLE bronze_zoom.participants ADD COLUMN IF NOT EXISTS camera Nullable(String); @@ -1263,14 +1274,17 @@ fi # bronze_zoom.meetings — read by zoom__meeting_sessions (session stitching). # The meeting-hours path computes duration from participants join/leave, so this -# table may be empty in tests; it only needs to EXIST so the sessions model builds -# (the participant→session LEFT JOIN then falls back to meeting_uuid). +# table may be empty in tests; it needs to EXIST so the sessions model builds +# (the participant→session LEFT JOIN then falls back to meeting_uuid), and it is +# seeded by session-stitching e2e fixtures. Key shape mirrors the promoted table +# (ORDER BY unique_key), same as participants above. if ! ch_table_exists bronze_zoom meetings; then echo " Creating placeholder: bronze_zoom.meetings" run_ch <<'SQL' CREATE TABLE IF NOT EXISTS bronze_zoom.meetings ( tenant_id String, source_id String, + unique_key Nullable(String), id Nullable(String), uuid String, start_time Nullable(String), @@ -1281,7 +1295,13 @@ CREATE TABLE IF NOT EXISTS bronze_zoom.meetings ( _airbyte_extracted_at DateTime64(3) DEFAULT now64(3), _airbyte_meta String DEFAULT '{}', _airbyte_generation_id UInt32 DEFAULT 0 -) ENGINE = ReplacingMergeTree(_airbyte_extracted_at) ORDER BY uuid; +) ENGINE = ReplacingMergeTree(_airbyte_extracted_at) ORDER BY unique_key + SETTINGS allow_nullable_key = 1; +SQL +else + echo " Reconciling placeholder schema: bronze_zoom.meetings" + run_ch <<'SQL' +ALTER TABLE bronze_zoom.meetings ADD COLUMN IF NOT EXISTS unique_key Nullable(String); SQL fi diff --git a/src/ingestion/secrets/connectors/zoom.yaml.example b/src/ingestion/secrets/connectors/zoom.yaml.example index f0b5a0dd53..583fa5670d 100644 --- a/src/ingestion/secrets/connectors/zoom.yaml.example +++ b/src/ingestion/secrets/connectors/zoom.yaml.example @@ -12,4 +12,3 @@ stringData: zoom_account_id: "CHANGE_ME" zoom_client_id: "CHANGE_ME" zoom_client_secret: "CHANGE_ME" - zoom_start_date: "2026-01-01" diff --git a/src/ingestion/tests/e2e/conftest.py b/src/ingestion/tests/e2e/conftest.py index 67c0bd3b11..caa5ed1ade 100644 --- a/src/ingestion/tests/e2e/conftest.py +++ b/src/ingestion/tests/e2e/conftest.py @@ -126,6 +126,15 @@ def compose_stack(session_cfg: SessionConfig): # Zoom feeds class_collab_meeting_activity (cross-source meeting_hours). ("staging", "zoom__collab_meeting_activity"), ("staging", "zoom__meeting_sessions"), + # bronze_zoom.meetings is READ (via `+zoom__collab_meeting_activity` pulling + # zoom__meeting_sessions) by every test that seeds only participants — so it + # is neither seed-truncated by those tests nor ledger-truncated between them + # (derive_selectors records only models sourced from SEEDED tables). A prior + # session's leftover rows get re-appended into zoom__meeting_sessions on + # every such build, tripping its `unique` dbt test on the second one. Bronze + # participants added for symmetry. + ("bronze_zoom", "meetings"), + ("bronze_zoom", "participants"), # Task-tracking: the bullet/MV chain reads class_task_* even when a fixture # seeds only one connector, and the enrich path writes staging.jira__task_*. # Reset them once at session start so warm re-runs are deterministic (CI is diff --git a/src/ingestion/tests/e2e/lib/metric_coverage.py b/src/ingestion/tests/e2e/lib/metric_coverage.py index aa3def69a2..36e0bad0a3 100644 --- a/src/ingestion/tests/e2e/lib/metric_coverage.py +++ b/src/ingestion/tests/e2e/lib/metric_coverage.py @@ -76,14 +76,12 @@ } SKIP_LIST: list[tuple[str, str]] = [ - # collab_bullet_rows — Slack has no connector; Zoom fixtures exist (reachable) + # collab_bullet_rows — Slack has no connector ("collab_bullet_rows.slack_active_days", "needs Slack connector"), ("collab_bullet_rows.slack_channel_posts", "needs Slack connector"), ("collab_bullet_rows.slack_messages_sent", "needs Slack connector"), ("collab_bullet_rows.slack_msgs_per_active_day", "needs Slack connector"), ("collab_bullet_rows.slack_dm_ratio", "needs Slack connector"), - ("collab_bullet_rows.zoom_meeting_hours", "reachable — Zoom fixtures exist"), - ("collab_bullet_rows.zoom_meetings", "reachable — Zoom fixtures exist"), # collab_person_counter_daily — collaboration messaging (M365 Teams / Zulip) ("collab_person_counter_daily.channel_posts", "reachable — Teams/Zulip fixtures exist"), ("collab_person_counter_daily.messages_sent", "reachable — Teams/Zulip fixtures exist"), diff --git a/src/ingestion/tests/e2e/metrics/collab_meeting_free_zoom.test.yaml b/src/ingestion/tests/e2e/metrics/collab_meeting_free_zoom.test.yaml new file mode 100644 index 0000000000..e124160326 --- /dev/null +++ b/src/ingestion/tests/e2e/metrics/collab_meeting_free_zoom.test.yaml @@ -0,0 +1,78 @@ +spec_version: 1 +description: > + Metric: meeting_free, Zoom leg — IC Bullet Collaboration (…0012), PR #1746. + The base Teams-only fixture is collab_meeting_free.test.yaml; this one proves + Zoom activity CANCELS a meeting-free day. + How it's computed (bronze → silver → gold): + • bronze: daily Teams meeting report + Zoom participant sessions per person + • silver: both sources deduped to per-person/day meeting durations + • gold: a DAY is "meeting-free" if a meeting row EXISTS that day but the + total duration ACROSS BOTH SOURCES = 0 — so a zero-duration Teams + day stops being meeting-free the moment the person sat in a Zoom + meeting that day; the metric is the COUNT of such days over the + window. value = the requested member's meeting-free day count; + median/p25/p75/range = the distribution across the DEPARTMENT. + + Department: all 5 Engineering members get one zero-duration Teams row on + 2026-12-23 (a meeting-free-day candidate). erin ALSO has a 1h Zoom meeting on + 2026-12-23 → her day is NOT meeting-free. Counts {alice 1, bob 1, carol 1, + dave 1, erin 0}; the IC case requests erin, so value = 0; the department of 5 + yields median 1, p25 1, p75 1, range [0,1] — if the Zoom leg were ignored the + value would be 1 and range_min 0 would not occur. + Cases: custom scope (single window over the department) · empty window. + +bronze: + bronze_bamboohr.employees: + - $ref: templates/people.yaml#/templates/alice + - $ref: templates/people.yaml#/templates/bob + - $ref: templates/people.yaml#/templates/carol + - $ref: templates/people.yaml#/templates/dave + - $ref: templates/people.yaml#/templates/erin + + bronze_m365.teams_activity: + # zero-duration Teams day for everyone → 5 meeting-free-day candidates + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: alice@example.com, reportRefreshDate: "2026-12-23", unique_key: mfz-alice-20261223, meetingsAttendedCount: 0, audioDuration: PT0S, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: bob@example.com, reportRefreshDate: "2026-12-23", unique_key: mfz-bob-20261223, meetingsAttendedCount: 0, audioDuration: PT0S, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: carol@example.com, reportRefreshDate: "2026-12-23", unique_key: mfz-carol-20261223, meetingsAttendedCount: 0, audioDuration: PT0S, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: dave@example.com, reportRefreshDate: "2026-12-23", unique_key: mfz-dave-20261223, meetingsAttendedCount: 0, audioDuration: PT0S, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: erin@example.com, reportRefreshDate: "2026-12-23", unique_key: mfz-erin-20261223, meetingsAttendedCount: 0, audioDuration: PT0S, videoDuration: PT0S, screenShareDuration: PT0S } + + bronze_zoom.participants: + # erin's 1h Zoom meeting on the SAME day cancels her meeting-free day + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: mfz-z-erin-1, meeting_uuid: "mfz-e1==", participant_uuid: "mfz-e1-p1", join_time: "2026-12-23T15:00:00Z", leave_time: "2026-12-23T16:00:00Z" } + +cases: + # dept {1,1,1,1,0}; erin value 0. p25=1 median=1 p75=1 range=[0,1] + - name: "meeting_free — Zoom activity cancels the meeting-free day (department of 5)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + find: { metric_key: meeting_free } + equal: { value: 0, median: 1, range_min: 0, range_max: 1, p25: 1, p75: 1 } + + # ── EMPTY window (no rows in range) ────────────────────────────────────────── + - name: "meeting_free zoom leg — EMPTY window (no data → no items)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-06-01' and metric_date le '2026-06-30'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + assert: "size(items) == 0" diff --git a/src/ingestion/tests/e2e/metrics/collab_meeting_hours_zoom_cross.test.yaml b/src/ingestion/tests/e2e/metrics/collab_meeting_hours_zoom_cross.test.yaml new file mode 100644 index 0000000000..50009a0a1d --- /dev/null +++ b/src/ingestion/tests/e2e/metrics/collab_meeting_hours_zoom_cross.test.yaml @@ -0,0 +1,78 @@ +spec_version: 1 +description: > + Metric: meeting_hours, Teams+Zoom cross-source additivity — IC Bullet + Collaboration (…0012), PR #1746. The base Teams-only fixture is + collab_meeting_hours.test.yaml; this one proves the Zoom leg is ADDED. + How it's computed (bronze → silver → gold): + • bronze: daily Teams meeting report + Zoom participant sessions per person + • silver: each source deduped to per-person/day durations + • gold: per source-day take the longest single modality, then value = the + requested member's SUM across BOTH sources over the window + (Teams + Zoom additive). median/p25/p75/range = the distribution + of those per-person SUMs across the member's DEPARTMENT. + + Department: 5 Engineering members, each with Teams hours {1,2,3,4,5} PLUS one + 1h Zoom meeting on the same day (2026-12-25) → totals {2,3,4,5,6}. The IC case + requests erin (5+1=6), so value = 6; the department of 5 yields median 4, + p25 3, p75 5, range [2,6] — distinguishable from the Teams-only distribution + {1,2,3,4,5} (median 3), so a dropped Zoom leg fails every asserted field. + Cases: custom scope (single window over the department) · empty window. + +bronze: + bronze_bamboohr.employees: + - $ref: templates/people.yaml#/templates/alice + - $ref: templates/people.yaml#/templates/bob + - $ref: templates/people.yaml#/templates/carol + - $ref: templates/people.yaml#/templates/dave + - $ref: templates/people.yaml#/templates/erin + + bronze_m365.teams_activity: + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: alice@example.com, reportRefreshDate: "2026-12-25", unique_key: mhx-alice-20261225, audioDuration: PT1H, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: bob@example.com, reportRefreshDate: "2026-12-25", unique_key: mhx-bob-20261225, audioDuration: PT2H, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: carol@example.com, reportRefreshDate: "2026-12-25", unique_key: mhx-carol-20261225, audioDuration: PT3H, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: dave@example.com, reportRefreshDate: "2026-12-25", unique_key: mhx-dave-20261225, audioDuration: PT4H, videoDuration: PT0S, screenShareDuration: PT0S } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: erin@example.com, reportRefreshDate: "2026-12-25", unique_key: mhx-erin-20261225, audioDuration: PT5H, videoDuration: PT0S, screenShareDuration: PT0S } + + bronze_zoom.participants: + # one 1h Zoom meeting each, same day as the Teams hours → strictly additive + - { $ref: templates/zoom.yaml#/templates/alice_zoom, unique_key: mhx-z-alice-1, meeting_uuid: "mhx-a1==", participant_uuid: "mhx-a1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T16:00:00Z" } + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: mhx-z-bob-1, meeting_uuid: "mhx-b1==", participant_uuid: "mhx-b1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T16:00:00Z" } + - { $ref: templates/zoom.yaml#/templates/carol_zoom, unique_key: mhx-z-carol-1, meeting_uuid: "mhx-c1==", participant_uuid: "mhx-c1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T16:00:00Z" } + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: mhx-z-dave-1, meeting_uuid: "mhx-d1==", participant_uuid: "mhx-d1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T16:00:00Z" } + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: mhx-z-erin-1, meeting_uuid: "mhx-e1==", participant_uuid: "mhx-e1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T16:00:00Z" } + +cases: + # dept {2,3,4,5,6}; erin value 6. p25=3 median=4 p75=5 range=[2,6] + - name: "meeting_hours — Teams+Zoom additive (department of 5)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + find: { metric_key: meeting_hours } + equal: { value: 6, median: 4, range_min: 2, range_max: 6, p25: 3, p75: 5 } + + # ── EMPTY window (no rows in range) ────────────────────────────────────────── + - name: "meeting_hours cross-source — EMPTY window (no data → no items)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-06-01' and metric_date le '2026-06-30'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + assert: "size(items) == 0" diff --git a/src/ingestion/tests/e2e/metrics/collab_meetings_count.test.yaml b/src/ingestion/tests/e2e/metrics/collab_meetings_count.test.yaml index d3be3aefc2..07718b2c6e 100644 --- a/src/ingestion/tests/e2e/metrics/collab_meetings_count.test.yaml +++ b/src/ingestion/tests/e2e/metrics/collab_meetings_count.test.yaml @@ -15,14 +15,13 @@ description: > The IC case requests erin (5), so value = 5; the department of 5 yields median 3, p25 2, p75 4, range [1,5]. - Zoom note: the Zoom side is intentionally NOT used to vary per-person counts. - bronze_zoom.participants is ReplacingMergeTree ORDER BY email, so EVERY - participant row for one email collapses to a single bronze row on RMT merge — - a person can contribute at most ONE distinct Zoom meeting per day regardless of - how many participant rows are seeded. This fixture is therefore Teams-only — - each member's value is exactly meetingsAttendedCount. (Teams+Zoom cross-source - additivity is not asserted in the single-scope suite; it would be its own - fixture if reintroduced.) + Zoom note: this fixture stays Teams-only — each member's value is exactly + meetingsAttendedCount. Teams+Zoom cross-source additivity has its own fixture + (collab_meetings_count_zoom_cross.test.yaml), and the Zoom-only count path is + pinned by collab_zoom_meetings.test.yaml. (The historical blocker — the + bronze_zoom.participants placeholder was RMT ORDER BY email, collapsing all of + a person's rows on merge — is fixed: the placeholder now mirrors the promoted + table, ORDER BY unique_key.) Cases: custom scope (single window over the department) · empty window. bronze: diff --git a/src/ingestion/tests/e2e/metrics/collab_meetings_count_zoom_cross.test.yaml b/src/ingestion/tests/e2e/metrics/collab_meetings_count_zoom_cross.test.yaml new file mode 100644 index 0000000000..1c573cf971 --- /dev/null +++ b/src/ingestion/tests/e2e/metrics/collab_meetings_count_zoom_cross.test.yaml @@ -0,0 +1,80 @@ +spec_version: 1 +description: > + Metric: meetings_count, Teams+Zoom cross-source additivity — IC Bullet + Collaboration (…0012), PR #1746. The base Teams-only fixture is + collab_meetings_count.test.yaml; this one proves the Zoom leg is ADDED. + How it's computed (bronze → silver → gold): + • bronze: daily Teams meeting report (meetings attended) + Zoom participant + sessions per person + • silver: Teams deduped to meetings-attended per person/day; Zoom counted as + distinct meetings per person/day + • gold: value = the requested member's per-person SUM of meetings attended + over the window across BOTH sources (Teams + Zoom additive). + median/p25/p75/range = the distribution of those per-person SUMs + across the member's DEPARTMENT (org_unit_id). + + Department: 5 Engineering members, each with Teams meetings {1,2,3,4,5} PLUS + one Zoom meeting on the same day (2026-12-25) → totals {2,3,4,5,6}. The IC + case requests erin (5+1=6), so value = 6; the department of 5 yields median 4, + p25 3, p75 5, range [2,6] — distinguishable from the Teams-only distribution + {1,2,3,4,5} (median 3), so a dropped Zoom leg fails every asserted field. + Cases: custom scope (single window over the department) · empty window. + +bronze: + bronze_bamboohr.employees: + - $ref: templates/people.yaml#/templates/alice + - $ref: templates/people.yaml#/templates/bob + - $ref: templates/people.yaml#/templates/carol + - $ref: templates/people.yaml#/templates/dave + - $ref: templates/people.yaml#/templates/erin + + bronze_m365.teams_activity: + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: alice@example.com, reportRefreshDate: "2026-12-25", unique_key: mcx-alice-20261225, meetingsAttendedCount: 1 } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: bob@example.com, reportRefreshDate: "2026-12-25", unique_key: mcx-bob-20261225, meetingsAttendedCount: 2 } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: carol@example.com, reportRefreshDate: "2026-12-25", unique_key: mcx-carol-20261225, meetingsAttendedCount: 3 } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: dave@example.com, reportRefreshDate: "2026-12-25", unique_key: mcx-dave-20261225, meetingsAttendedCount: 4 } + - { $ref: templates/m365_teams.yaml#/templates/m365_teams, userPrincipalName: erin@example.com, reportRefreshDate: "2026-12-25", unique_key: mcx-erin-20261225, meetingsAttendedCount: 5 } + + bronze_zoom.participants: + # one Zoom meeting each, same day as the Teams counts → strictly additive + - { $ref: templates/zoom.yaml#/templates/alice_zoom, unique_key: mcx-z-alice-1, meeting_uuid: "mcx-a1==", participant_uuid: "mcx-a1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T15:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: mcx-z-bob-1, meeting_uuid: "mcx-b1==", participant_uuid: "mcx-b1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T15:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/carol_zoom, unique_key: mcx-z-carol-1, meeting_uuid: "mcx-c1==", participant_uuid: "mcx-c1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T15:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: mcx-z-dave-1, meeting_uuid: "mcx-d1==", participant_uuid: "mcx-d1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T15:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: mcx-z-erin-1, meeting_uuid: "mcx-e1==", participant_uuid: "mcx-e1-p1", join_time: "2026-12-25T15:00:00Z", leave_time: "2026-12-25T15:30:00Z" } + +cases: + # dept {2,3,4,5,6}; erin value 6. p25=3 median=4 p75=5 range=[2,6] + - name: "meetings_count — Teams+Zoom additive (department of 5)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + find: { metric_key: meetings_count } + equal: { value: 6, median: 4, range_min: 2, range_max: 6, p25: 3, p75: 5 } + + # ── EMPTY window (no rows in range) ────────────────────────────────────────── + - name: "meetings_count cross-source — EMPTY window (no data → no items)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-06-01' and metric_date le '2026-06-30'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + assert: "size(items) == 0" diff --git a/src/ingestion/tests/e2e/metrics/collab_zoom_meeting_hours.test.yaml b/src/ingestion/tests/e2e/metrics/collab_zoom_meeting_hours.test.yaml new file mode 100644 index 0000000000..b4d891ab3e --- /dev/null +++ b/src/ingestion/tests/e2e/metrics/collab_zoom_meeting_hours.test.yaml @@ -0,0 +1,81 @@ +spec_version: 1 +description: > + Metric: zoom_meeting_hours — IC Bullet Collaboration (…0012), PR #1746. + How it's computed (bronze → silver → gold): + • bronze: Zoom participant sessions (join/leave per person per meeting) + • silver: sessions deduped (a re-synced duplicate row must not double), then + summed to per-person/day durations; video counts only when the + participant used a camera, screen-share only when they shared + • gold: per day take the longest single modality (audio vs video vs screen) + — for Zoom these coincide because the whole session length is + attributed to a modality the participant used; value = the requested + member's per-person SUM of those hours over the window, Zoom rows + only (Teams hours land in teams_/meeting_hours, not here). + median/p25/p75/range = the distribution of those per-person SUMs + across the member's DEPARTMENT (org_unit_id). + + Department: 5 Engineering members with Zoom hours {1,2,3,4,5} on 2026-12-25 — + alice 1×1h (+ an exact duplicate row that must dedup), bob 0.5h+1.5h across TWO + meetings (sums to 2), carol 3h with a camera on (video == audio → longest + modality still 3), dave 4h with desktop share (same, 4), erin 5h audio-only. + The IC case requests erin (5), so value = 5; the department of 5 yields + median 3, p25 2, p75 4, range [1,5]. + Cases: custom scope (single window over the department) · empty window. + +bronze: + bronze_bamboohr.employees: + - $ref: templates/people.yaml#/templates/alice + - $ref: templates/people.yaml#/templates/bob + - $ref: templates/people.yaml#/templates/carol + - $ref: templates/people.yaml#/templates/dave + - $ref: templates/people.yaml#/templates/erin + + bronze_zoom.participants: + # ── alice: 1h (one meeting; the duplicate is a verbatim Airbyte re-emit → must NOT double) + - { $ref: templates/zoom.yaml#/templates/alice_zoom, unique_key: zmh-alice-1, meeting_uuid: "zmh-a1==", participant_uuid: "zmh-a1-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T11:00:00Z" } + - { $ref: templates/zoom.yaml#/templates/alice_zoom, unique_key: zmh-alice-1, meeting_uuid: "zmh-a1==", participant_uuid: "zmh-a1-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T11:00:00Z" } + # ── bob: 0.5h + 1.5h across two meetings → 2h (per-day SUM across meetings) + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: zmh-bob-1, meeting_uuid: "zmh-b1==", participant_uuid: "zmh-b1-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T10:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: zmh-bob-2, meeting_uuid: "zmh-b2==", participant_uuid: "zmh-b2-p1", join_time: "2026-12-25T13:00:00Z", leave_time: "2026-12-25T14:30:00Z" } + # ── carol: 3h with camera on (video == audio; longest modality still 3h) + - { $ref: templates/zoom.yaml#/templates/carol_zoom, unique_key: zmh-carol-1, meeting_uuid: "zmh-c1==", participant_uuid: "zmh-c1-p1", join_time: "2026-12-25T09:00:00Z", leave_time: "2026-12-25T12:00:00Z", camera: "FaceTime HD Camera" } + # ── dave: 4h with desktop share (screen == audio; longest modality still 4h) + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: zmh-dave-1, meeting_uuid: "zmh-d1==", participant_uuid: "zmh-d1-p1", join_time: "2026-12-25T09:00:00Z", leave_time: "2026-12-25T13:00:00Z", share_desktop: true } + # ── erin: 5h audio-only + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: zmh-erin-1, meeting_uuid: "zmh-e1==", participant_uuid: "zmh-e1-p1", join_time: "2026-12-25T09:00:00Z", leave_time: "2026-12-25T14:00:00Z" } + +cases: + # dept {1,2,3,4,5}; erin value 5. p25=2 median=3 p75=4 range=[1,5] + - name: "zoom_meeting_hours — custom scope (department of 5)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + find: { metric_key: zoom_meeting_hours } + equal: { value: 5, median: 3, range_min: 1, range_max: 5, p25: 2, p75: 4 } + + # ── EMPTY window (no rows in range) ────────────────────────────────────────── + - name: "zoom_meeting_hours — EMPTY window (no data → no items)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-06-01' and metric_date le '2026-06-30'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + assert: "size(items) == 0" diff --git a/src/ingestion/tests/e2e/metrics/collab_zoom_meetings.test.yaml b/src/ingestion/tests/e2e/metrics/collab_zoom_meetings.test.yaml new file mode 100644 index 0000000000..702738583b --- /dev/null +++ b/src/ingestion/tests/e2e/metrics/collab_zoom_meetings.test.yaml @@ -0,0 +1,100 @@ +spec_version: 1 +description: > + Metric: zoom_meetings — IC Bullet Collaboration (…0012), PR #1746. + How it's computed (bronze → silver → gold): + • bronze: Zoom participant sessions (one row per person per session) + the + Zoom meeting-session report (one row per session uuid, carrying the + reusable Meeting ID) + • silver: participant sessions deduped, then counted as DISTINCT logical + meetings per person/day — consecutive sessions of the SAME Zoom + Meeting ID with an end→start gap ≤ 5 min are stitched into ONE + logical meeting (a host-drop rejoin is not a second meeting) + • gold: value = the requested member's per-person SUM of distinct meetings + over the window, Zoom rows only (Teams meetings land in + teams_meetings, not here). median/p25/p75/range = the distribution + of those per-person SUMs across the member's DEPARTMENT (org_unit_id). + + Department: 5 Engineering members with distinct-meeting counts {1,2,3,4,5} on + 2026-12-25 — alice 1 meeting (+ an exact duplicate row that must dedup); bob + 2 = one meeting he dropped from and rejoined 2 min later (two sessions of + Meeting ID 88011, stitched to ONE) plus one ordinary meeting; carol/dave/erin + 3/4/5 ordinary distinct meetings (no meeting-report rows — the count falls + back to one-session-one-meeting). The IC case requests erin (5), so value = 5; + the department of 5 yields median 3, p25 2, p75 4, range [1,5]. + NOTE: the session-stitching report is only read for rows extracted within the + last 90 days of REAL now() — the seeded meeting rows pin _airbyte_extracted_at + next to the meeting date (2026-12-25), which satisfies that until ~2027-03. + Cases: custom scope (single window over the department) · empty window. + +bronze: + bronze_bamboohr.employees: + - $ref: templates/people.yaml#/templates/alice + - $ref: templates/people.yaml#/templates/bob + - $ref: templates/people.yaml#/templates/carol + - $ref: templates/people.yaml#/templates/dave + - $ref: templates/people.yaml#/templates/erin + + # bob's Meeting ID 88011 ran as two sessions 2 min apart → ONE logical meeting. + bronze_zoom.meetings: + - { $ref: templates/zoom.yaml#/templates/zoom_meeting, _airbyte_extracted_at: "2026-12-25T15:00:00", unique_key: zm-88011-s1, id: "88011", uuid: "zm-b1a==", start_time: "2026-12-25T10:00:00Z", end_time: "2026-12-25T10:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/zoom_meeting, _airbyte_extracted_at: "2026-12-25T15:00:00", unique_key: zm-88011-s2, id: "88011", uuid: "zm-b1b==", start_time: "2026-12-25T10:32:00Z", end_time: "2026-12-25T11:00:00Z" } + + bronze_zoom.participants: + # ── alice: 1 meeting (+ verbatim re-emit duplicate → must NOT count as 2) + - { $ref: templates/zoom.yaml#/templates/alice_zoom, unique_key: zm-alice-1, meeting_uuid: "zm-a1==", participant_uuid: "zm-a1-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T10:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/alice_zoom, unique_key: zm-alice-1, meeting_uuid: "zm-a1==", participant_uuid: "zm-a1-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T10:30:00Z" } + # ── bob: 2 = stitched rejoin (sessions zm-b1a== + zm-b1b== of Meeting 88011 → 1) + one ordinary meeting + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: zm-bob-1, meeting_uuid: "zm-b1a==", participant_uuid: "zm-b1-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T10:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: zm-bob-2, meeting_uuid: "zm-b1b==", participant_uuid: "zm-b1-p2", join_time: "2026-12-25T10:32:00Z", leave_time: "2026-12-25T11:00:00Z" } + - { $ref: templates/zoom.yaml#/templates/bob_zoom, unique_key: zm-bob-3, meeting_uuid: "zm-b2==", participant_uuid: "zm-b2-p1", join_time: "2026-12-25T13:00:00Z", leave_time: "2026-12-25T13:30:00Z" } + # ── carol: 3 distinct meetings + - { $ref: templates/zoom.yaml#/templates/carol_zoom, unique_key: zm-carol-1, meeting_uuid: "zm-c1==", participant_uuid: "zm-c1-p1", join_time: "2026-12-25T09:00:00Z", leave_time: "2026-12-25T09:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/carol_zoom, unique_key: zm-carol-2, meeting_uuid: "zm-c2==", participant_uuid: "zm-c2-p1", join_time: "2026-12-25T11:00:00Z", leave_time: "2026-12-25T11:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/carol_zoom, unique_key: zm-carol-3, meeting_uuid: "zm-c3==", participant_uuid: "zm-c3-p1", join_time: "2026-12-25T14:00:00Z", leave_time: "2026-12-25T14:30:00Z" } + # ── dave: 4 distinct meetings + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: zm-dave-1, meeting_uuid: "zm-d1==", participant_uuid: "zm-d1-p1", join_time: "2026-12-25T09:00:00Z", leave_time: "2026-12-25T09:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: zm-dave-2, meeting_uuid: "zm-d2==", participant_uuid: "zm-d2-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T10:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: zm-dave-3, meeting_uuid: "zm-d3==", participant_uuid: "zm-d3-p1", join_time: "2026-12-25T11:00:00Z", leave_time: "2026-12-25T11:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/dave_zoom, unique_key: zm-dave-4, meeting_uuid: "zm-d4==", participant_uuid: "zm-d4-p1", join_time: "2026-12-25T12:00:00Z", leave_time: "2026-12-25T12:30:00Z" } + # ── erin: 5 distinct meetings + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: zm-erin-1, meeting_uuid: "zm-e1==", participant_uuid: "zm-e1-p1", join_time: "2026-12-25T09:00:00Z", leave_time: "2026-12-25T09:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: zm-erin-2, meeting_uuid: "zm-e2==", participant_uuid: "zm-e2-p1", join_time: "2026-12-25T10:00:00Z", leave_time: "2026-12-25T10:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: zm-erin-3, meeting_uuid: "zm-e3==", participant_uuid: "zm-e3-p1", join_time: "2026-12-25T11:00:00Z", leave_time: "2026-12-25T11:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: zm-erin-4, meeting_uuid: "zm-e4==", participant_uuid: "zm-e4-p1", join_time: "2026-12-25T12:00:00Z", leave_time: "2026-12-25T12:30:00Z" } + - { $ref: templates/zoom.yaml#/templates/erin_zoom, unique_key: zm-erin-5, meeting_uuid: "zm-e5==", participant_uuid: "zm-e5-p1", join_time: "2026-12-25T13:00:00Z", leave_time: "2026-12-25T13:30:00Z" } + +cases: + # dept {1,2,3,4,5}; erin value 5. p25=2 median=3 p75=4 range=[1,5] + - name: "zoom_meetings — custom scope (department of 5, stitched rejoin counts once)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-12-01' and metric_date le '2026-12-31'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + find: { metric_key: zoom_meetings } + equal: { value: 5, median: 3, range_min: 1, range_max: 5, p25: 2, p75: 4 } + + # ── EMPTY window (no rows in range) ────────────────────────────────────────── + - name: "zoom_meetings — EMPTY window (no data → no items)" + request: + url: /v1/metrics/queries + method: POST + body: + queries: + - id: collaboration + metric_id: 00000000-0000-0000-0001-000000000012 + $filter: "person_id eq 'erin@example.com' and metric_date ge '2026-06-01' and metric_date le '2026-06-30'" + expect: + - assert: "status == 200" + - in: collaboration + assert: "result.status == 'ok'" + - in: collaboration + assert: "size(items) == 0" diff --git a/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.meetings.yaml b/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.meetings.yaml new file mode 100644 index 0000000000..36fe90e10b --- /dev/null +++ b/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.meetings.yaml @@ -0,0 +1,24 @@ +# Reusable JSON schema for bronze_zoom.meetings (the columns zoom__meeting_sessions +# reads for session stitching). `id` is the reusable Zoom Meeting ID; `uuid` is the +# per-session UUID — consecutive sessions of the same `id` whose gap is ≤ 5 min are +# stitched into one logical meeting. `unique_key` is the connector-computed row key +# the table is ORDER BY'd on (distinct per seeded row). +schemas: + bronze_zoom.meetings: + $schema: http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + properties: + _airbyte_raw_id: { type: string } + _airbyte_extracted_at: { type: string, format: date-time } + _airbyte_meta: { type: string } + _airbyte_generation_id: { type: integer } + tenant_id: { type: string } + source_id: { type: string } + unique_key: { type: [string, "null"] } + id: { type: [string, "null"] } + uuid: { type: string } + start_time: { type: [string, "null"] } + end_time: { type: [string, "null"] } + has_video: { type: [boolean, "null"] } + has_screen_share: { type: [boolean, "null"] } diff --git a/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.participants.yaml b/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.participants.yaml index bedc5d47c8..e027bdb331 100644 --- a/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.participants.yaml +++ b/src/ingestion/tests/e2e/metrics/schemas/bronze_zoom.participants.yaml @@ -1,7 +1,10 @@ # Reusable JSON schema for bronze_zoom.participants (the columns the zoom collab -# meeting models read). Zoom has NO bronze unique_key column — silver derives -# MD5(tenant, source, lower(email), date-of-join_time); the staging model also -# dedups participants via `LIMIT 1 BY (meeting_uuid, participant_uuid, join_time)`. +# meeting models read). Bronze `unique_key` is the connector-computed row key the +# promoted table (and the placeholder) is ORDER BY'd on — give every distinct +# seeded row a distinct unique_key or RMT merges may collapse them; an intentional +# re-sync duplicate carries the SAME unique_key. Silver still derives its own +# MD5(tenant, source, lower(email), date-of-join_time) key and dedups participants +# via `LIMIT 1 BY (meeting_uuid, participant_uuid, join_time)`. schemas: bronze_zoom.participants: $schema: http://json-schema.org/draft-07/schema# @@ -14,6 +17,7 @@ schemas: _airbyte_generation_id: { type: integer } tenant_id: { type: string } source_id: { type: string } + unique_key: { type: [string, "null"] } email: { type: string } user_name: { type: [string, "null"] } meeting_uuid: { type: string } diff --git a/src/ingestion/tests/e2e/metrics/templates/zoom.yaml b/src/ingestion/tests/e2e/metrics/templates/zoom.yaml index 7e5a864be5..1c13af4596 100644 --- a/src/ingestion/tests/e2e/metrics/templates/zoom.yaml +++ b/src/ingestion/tests/e2e/metrics/templates/zoom.yaml @@ -1,10 +1,20 @@ -# Reusable Zoom participant records (bronze_zoom.participants). +# Reusable Zoom records (bronze_zoom.participants + bronze_zoom.meetings). # The base carries EVERY schema column (so a merged row is complete); the fields -# under test (join_time / leave_time / meeting_uuid / participant_uuid) are set in -# each test's `bronze`. Meeting duration = dateDiff(join_time, leave_time); video is -# gated by `camera` (NULL/'' => 0) and screen-share by the share_* flags, so a -# participant with audio only contributes audio seconds as the longest modality. -# There is NO bronze unique_key column — silver derives its own key. +# under test (join_time / leave_time / meeting_uuid / participant_uuid / +# unique_key) are set in each test's `bronze`. Meeting duration = +# dateDiff(join_time, leave_time); video is gated by `camera` (NULL/'' => 0) and +# screen-share by the share_* flags, so a participant with audio only contributes +# audio seconds as the longest modality. +# +# `unique_key` is the bronze row key (the table is RMT ORDER BY unique_key): give +# every DISTINCT seeded row a distinct unique_key; an Airbyte re-sync duplicate +# repeats the row verbatim (same unique_key). +# +# zoom_meeting rows feed session stitching (zoom__meeting_sessions): consecutive +# sessions (`uuid`) of the same Zoom Meeting ID (`id`) with an end→start gap +# ≤ 5 min collapse into one logical meeting. NOTE: the sessions model only reads +# bronze meetings whose `_airbyte_extracted_at` is within 90 days of REAL now() +# — override it per test to a date near the seeded meeting dates. templates: zoom_participant: _airbyte_raw_id: "00000000-0000-0000-0000-000000000000" @@ -13,6 +23,7 @@ templates: _airbyte_generation_id: 0 tenant_id: "00000000-0000-0000-0000-000000000000" source_id: "zoom-test" + unique_key: null email: null user_name: null meeting_uuid: null @@ -25,10 +36,37 @@ templates: share_whiteboard: null video_connection_type: null + zoom_meeting: + _airbyte_raw_id: "00000000-0000-0000-0000-000000000000" + _airbyte_extracted_at: "2026-01-05T00:00:00" + _airbyte_meta: "{}" + _airbyte_generation_id: 0 + tenant_id: "00000000-0000-0000-0000-000000000000" + source_id: "zoom-test" + unique_key: null + id: null + uuid: null + start_time: null + end_time: null + has_video: false + has_screen_share: false + alice_zoom: $ref: "#/templates/zoom_participant" email: alice@example.com + bob_zoom: + $ref: "#/templates/zoom_participant" + email: bob@example.com + carol_zoom: $ref: "#/templates/zoom_participant" email: carol@example.com + + dave_zoom: + $ref: "#/templates/zoom_participant" + email: dave@example.com + + erin_zoom: + $ref: "#/templates/zoom_participant" + email: erin@example.com