-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The test sends object for ingestion and then verifies whether object has been ingested. Testing: tested manually against ETL and Trino Signed-off-by: Miroslav Ivanov [email protected]
- Loading branch information
1 parent
1071b40
commit f3deac3
Showing
9 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...at/src/vdk/internal/heartbeat/vdk_heartbeat_data_job/trino_ingestion/05_set_properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2021 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import logging | ||
import uuid | ||
|
||
from vdk.api.job_input import IJobInput | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def run(job_input: IJobInput): | ||
props = job_input.get_all_properties() | ||
props["id1"] = str(uuid.uuid4()) | ||
props["id2"] = str(uuid.uuid4()) | ||
props["id3"] = str(uuid.uuid4()) | ||
job_input.set_all_properties(props) |
21 changes: 21 additions & 0 deletions
21
...tbeat/src/vdk/internal/heartbeat/vdk_heartbeat_data_job/trino_ingestion/10_ingest_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2021 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import logging | ||
|
||
from vdk.api.job_input import IJobInput | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def run(job_input: IJobInput): | ||
props = job_input.get_all_properties() | ||
payload = {"id1": props["id1"], "id2": props["id2"], "id3": props["id3"]} | ||
|
||
# Ingest the data | ||
log.info(f"Sending the following payload for ingestion: {payload}") | ||
job_input.send_object_for_ingestion( | ||
payload=payload, | ||
destination_table=props["ingest_destination_table"], | ||
method=props["ingest_method"], | ||
target=props["ingest_target"], | ||
) |
45 changes: 45 additions & 0 deletions
45
...tbeat/src/vdk/internal/heartbeat/vdk_heartbeat_data_job/trino_ingestion/20_verify_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2021 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import logging | ||
import time | ||
|
||
from vdk.api.job_input import IJobInput | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def run(job_input: IJobInput): | ||
# If db property includes catalog name, get only the schema name ('default' from 'memory.default'). | ||
# This is done because the templates' implementation escapes db, table and column names passed as arguments, so that | ||
# reserved words could be used for their values | ||
db_name = job_input.get_property("db").split(".")[-1] | ||
|
||
props = job_input.get_all_properties() | ||
destination_table = props["destination_table"] | ||
id1 = props["id1"] | ||
id2 = props["id2"] | ||
id3 = props["id3"] | ||
|
||
timeout = 300 # [seconds] | ||
timeout_start = time.time() | ||
|
||
while time.time() < timeout_start + timeout: | ||
# check if data was correctly ingested | ||
result = job_input.execute_query( | ||
f"SELECT id1, id2, id3 FROM {db_name}.{destination_table} " | ||
f"WHERE id1 = '{id1}' " | ||
f"AND id2 = '{id2}' " | ||
f"AND id3 = '{id3}'" | ||
) | ||
log.info(f"Query result: {result}") | ||
|
||
if result: | ||
if result[0][0] != id1 and result[0][1] != id2 and result[0][2] != id3: | ||
raise Exception("The data is not ingested correctly") | ||
else: | ||
props["succeeded"] = "true" | ||
break | ||
else: | ||
time.sleep(10) | ||
|
||
job_input.set_all_properties(props) |
11 changes: 11 additions & 0 deletions
11
...dk-heartbeat/src/vdk/internal/heartbeat/vdk_heartbeat_data_job/trino_ingestion/config.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[owner] | ||
team = taurus | ||
|
||
[job] | ||
schedule_cron = * * * * * | ||
|
||
[contacts] | ||
notified_on_job_failure_user_error= | ||
notified_on_job_failure_platform_error= | ||
notified_on_job_success= | ||
notified_on_job_deploy= |
1 change: 1 addition & 0 deletions
1
...rtbeat/src/vdk/internal/heartbeat/vdk_heartbeat_data_job/trino_ingestion/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vdk-trino |