Skip to content

chore(snowflake): some debug logs to trace missing views #13369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sgomezvillamor
Copy link
Contributor

@sgomezvillamor sgomezvillamor commented Apr 30, 2025

Just adds some debug traces that were useful during a troubleshooting.

@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Apr 30, 2025
Copy link

codecov bot commented Apr 30, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2598 1 2597 47
View the full list of 1 ❄️ flaky tests
tests.audit_events.audit_events_test::test_policy_events

Flake rate in main: 35.00% (Passed 13 times, Failed 7 times)

Stack Traces | 30.5s run time
auth_exclude_filter = {'condition': 'EQUAL', 'field': 'name', 'negated': True, 'values': ['Test Session Token']}

    def test_policy_events(auth_exclude_filter):
        user_session = login_as(admin_user, admin_pass)
        json = {
            "query": """mutation createPolicy($input: PolicyUpdateInput!) {\n
                createPolicy(input: $input) }""",
            "variables": {
                "input": {
                    "type": "METADATA",
                    "name": "Test Metadata Policy",
                    "description": "My Metadaata Policy",
                    "state": "ACTIVE",
                    "resources": {"type": "dataset", "allResources": True},
                    "privileges": ["EDIT_ENTITY_TAGS"],
                    "actors": {
                        "users": ["urn:li:corpuser:datahub", "urn:li:corpuser:admin"],
                        "resourceOwners": False,
                        "allUsers": False,
                        "allGroups": False,
                    },
                }
            },
        }
    
        response = user_session.post(f"{get_frontend_url()}....../api/v2/graphql", json=json)
        response.raise_for_status()
        res_data = response.json()
    
        assert res_data
        assert res_data["data"]
        assert res_data["data"]["createPolicy"]
    
        wait_for_writes_to_sync(consumer_group="datahub-usage-event-consumer-job-client")
    
        new_urn = res_data["data"]["createPolicy"]
    
        update_json = {
            "query": """mutation updatePolicy($urn: String!, $input: PolicyUpdateInput!) {\n
                updatePolicy(urn: $urn, input: $input) }""",
            "variables": {
                "urn": new_urn,
                "input": {
                    "type": "METADATA",
                    "state": "ACTIVE",
                    "name": "Test Metadata Policy",
                    "description": "Updated Metadaata Policy",
                    "privileges": ["EDIT_ENTITY_TAGS", "EDIT_ENTITY_GLOSSARY_TERMS"],
                    "actors": {
                        "resourceOwners": False,
                        "allUsers": True,
                        "allGroups": False,
                    },
                },
            },
        }
    
        response = user_session.post(
            f"{get_frontend_url()}....../api/v2/graphql", json=update_json
        )
        response.raise_for_status()
        res_data = response.json()
    
        # Check updated was submitted successfully
        assert res_data
        assert res_data["data"]
        assert res_data["data"]["updatePolicy"]
        assert res_data["data"]["updatePolicy"] == new_urn
    
        wait_for_writes_to_sync(consumer_group="datahub-usage-event-consumer-job-client")
        res_data = searchForAuditEvents(
            user_session,
            3,
            ["CreatePolicyEvent", "UpdatePolicyEvent"],
            ["urn:li:corpuser:datahub", "urn:li:corpuser:admin"],
            [],
        )
        print(res_data)
        assert res_data
        assert res_data["usageEvents"]
>       assert len(res_data["usageEvents"]) == 3
E       AssertionError: assert 2 == 3
E        +  where 2 = len([{'eventType': 'CreatePolicyEvent', 'timestamp': 1746791770556, 'actorUrn': 'urn:li:corpuser:datahub', 'sourceIP': '172.18.0.5', 'eventSource': 'GRAPHQL', 'userAgent': 'python-requests/2.31.0', 'telemetryTraceId': '000634b2a6fa9518927e6a6cc1c62a04', 'rawUsageEvent': {'traceId': '000634b2a6fa9518927e6a6cc1c62a04', 'aspectName': 'dataHubPolicyKey', 'actorUrn': 'urn:li:corpuser:datahub', 'entityType': 'dataHubPolicy', 'eventSource': 'GRAPHQL', 'usageSource': 'backend', 'userAgent': 'python-requests/2.31.0', 'corp_user_username': 'datahub', 'type': 'CreatePolicyEvent', '@timestamp': 1746791770556, 'corp_user_name': 'DataHub', 'sourceIP': '172.18.0.5', 'entityUrn': 'urn:li:dataHubPolicy:27b5a37f-4266-4c81-a210-fe2bfe374bcf', 'timestamp': 1746791770556}, 'entityUrn': 'urn:li:dataHubPolicy:27b5a37f-4266-4c81-a210-fe2bfe374bcf', 'entityType': 'dataHubPolicy', 'aspectName': 'dataHubPolicyKey'}, {'eventType': 'UpdatePolicyEvent', 'timestamp': 1746791770554, 'actorUrn': 'urn:li:corpuser:datahub', 'sourceIP': '172.18.0.5', 'eventSource': 'GRAPHQL', 'userAgent': 'python-requests/2.31.0', 'telemetryTraceId': '000634b2a6fa9518927e6a6cc1c62a04', 'rawUsageEvent': {'traceId': '000634b2a6fa9518927e6a6cc1c62a04', 'aspectName': 'dataHubPolicyInfo', 'actorUrn': 'urn:li:corpuser:datahub', 'entityType': 'dataHubPolicy', 'eventSource': 'GRAPHQL', 'usageSource': 'backend', 'userAgent': 'python-requests/2.31.0', 'corp_user_username': 'datahub', 'type': 'UpdatePolicyEvent', '@timestamp': 1746791770554, 'corp_user_name': 'DataHub', 'sourceIP': '172.18.0.5', 'entityUrn': 'urn:li:dataHubPolicy:27b5a37f-4266-4c81-a210-fe2bfe374bcf', 'timestamp': 1746791770554}, 'entityUrn': 'urn:li:dataHubPolicy:27b5a37f-4266-4c81-a210-fe2bfe374bcf', 'entityType': 'dataHubPolicy', 'aspectName': 'dataHubPolicyInfo'}])

tests/audit_events/audit_events_test.py:317: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@sgomezvillamor sgomezvillamor changed the title fix(snowflake): missing views chore(snowflake): some debug logs to trace missing views May 9, 2025
@sgomezvillamor sgomezvillamor marked this pull request as ready for review May 9, 2025 11:40
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ingestion PR or Issue related to the ingestion of metadata needs-review Label for PRs that need review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant