Skip to content

Commit

Permalink
add basic integration test, move to mcp
Browse files Browse the repository at this point in the history
  • Loading branch information
shirshanka committed Jul 12, 2024
1 parent 3312b10 commit 2e05fb0
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
StatefulIngestionSourceBase,
)
from datahub.metadata.com.linkedin.pegasus2avro.common import ChangeAuditStamps
from datahub.metadata.schema_classes import DashboardInfoClass
from datahub.metadata.schema_classes import DashboardInfoClass, StatusClass


class GrafanaSourceConfig(StatefulIngestionConfigBase, PlatformInstanceConfigMixin):
Expand Down Expand Up @@ -92,36 +92,37 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
_title = item["title"]
_url = item["url"]
full_url = f"{self.source_config.url}{_url}"
_folder_id = item.get("folderId", None)
if _folder_id is not None:
dashboard_urn = builder.make_dashboard_urn(
platform=self.platform,
name=_uid,
platform_instance=self.source_config.platform_instance,
dashboard_urn = builder.make_dashboard_urn(
platform=self.platform,
name=_uid,
platform_instance=self.source_config.platform_instance,
)
for mcp in MetadataChangeProposalWrapper.construct_many(
entityUrn=dashboard_urn,
aspects=[
DashboardInfoClass(
description="",
title=_title,
charts=[],
lastModified=ChangeAuditStamps(),
dashboardUrl=full_url,
customProperties={
"displayName": _title,
"id": str(item["id"]),
"uid": _uid,
"title": _title,
"uri": item["uri"],
"type": item["type"],
"folderId": str(item.get("folderId", None)),
"folderUid": item.get("folderUid", None),
"folderTitle": str(item.get("folderTitle", None)),
},
),
StatusClass(removed=False),
],
):
breakpoint()
yield MetadataWorkUnit(
id=dashboard_urn,
mcp=mcp,
)
yield from [
mcp.as_workunit()
for mcp in MetadataChangeProposalWrapper.construct_many(
entityUrn=dashboard_urn,
aspects=[
DashboardInfoClass(
description="",
title=_title,
charts=[],
lastModified=ChangeAuditStamps(),
dashboardUrl=full_url,
customProperties={
"displayName": _title,
"id": str(item["id"]),
"uid": _uid,
"title": _title,
"uri": item["uri"],
"type": item["type"],
"folderId": str(item.get("folderId", None)),
"folderUid": item.get("folderUid", None),
"folderTitle": str(item.get("folderTitle", None)),
},
)
],
)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": null,
"uid": "default",
"title": "Default Dashboard",
"tags": [],
"timezone": "browser",
"schemaVersion": 16,
"version": 0,
"panels": [
{
"type": "text",
"title": "Welcome",
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 5
},
"options": {
"content": "Welcome to your Grafana dashboard!",
"mode": "markdown"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"entityType": "dashboard",
"entityUrn": "urn:li:dashboard:(grafana,default)",
"changeType": "UPSERT",
"aspectName": "status",
"aspect": {
"json": {
"removed": false
}
},
"systemMetadata": {
"lastObserved": 1720785600000,
"runId": "grafana-test-simple",
"lastRunId": "no-run-id-provided"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
api_keys:
- name: 'example-api-key'
role: 'Admin'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: 1

datasources:
- name: PostgreSQL
type: postgres
access: proxy
url: postgres:5432
database: grafana
user: grafana
password: grafana
jsonData:
sslmode: disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
service_accounts:
- name: 'example-service-account'
role: 'Admin'
apiKeys:
- keyName: 'example-api-key'
role: 'Admin'

0 comments on commit 2e05fb0

Please sign in to comment.