Skip to content

Commit

Permalink
Merge pull request #388 from jaceksan/gartner
Browse files Browse the repository at this point in the history
TRIVIAL: gooddata-dbt - allow skipping tests of specific insights

Reviewed-by: Jan Kadlec
             https://github.com/hkad98
  • Loading branch information
gdgate authored Oct 12, 2023
2 parents a103872 + 6f9faf3 commit 210a182
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 13 additions & 9 deletions gooddata-dbt/gooddata_dbt/dbt_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,22 @@ def store_analytics(
)


def test_insights(logger: logging.Logger, sdk: GoodDataSdk, workspace_id: str) -> None:
def test_insights(logger: logging.Logger, sdk: GoodDataSdk, workspace_id: str, skip_tests: Optional[List[str]]) -> None:
logger.info(f"Test insights {workspace_id=}")
insights = sdk.insights.get_insights(workspace_id)

for insight in insights:
try:
start = time()
sdk.tables.for_insight(workspace_id, insight)
duration = int((time() - start) * 1000)
logger.info(f'Test successful insight="{insight.title}" duration={duration}(ms) ...')
except RuntimeError:
sys.exit()
logger.info(f"Executing insight {insight.id=} {insight.title=} ...")
if skip_tests is not None and insight.id in skip_tests:
logger.info(f"Skip test insight={insight.title} (requested in gooddata.yaml)")
else:
try:
start = time()
sdk.tables.for_insight(workspace_id, insight)
duration = int((time() - start) * 1000)
logger.info(f"Test successful {insight.id=} {insight.title=} duration={duration}(ms)")
except RuntimeError:
sys.exit()


def create_localized_workspaces(data_product: GoodDataConfigProduct, sdk: GoodDataSdk, workspace_id: str) -> None:
Expand Down Expand Up @@ -328,7 +332,7 @@ def process_organization(
elif args.method == "deploy_analytics":
deploy_analytics(logger, sdk_wrapper, workspace_id, data_product)
elif args.method == "test_insights":
test_insights(logger, sdk_wrapper.sdk, workspace_id)
test_insights(logger, sdk_wrapper.sdk, workspace_id, data_product.skip_tests)
else:
raise Exception(f"Unsupported method requested in args: {args.method}")

Expand Down
1 change: 1 addition & 0 deletions gooddata-dbt/gooddata_dbt/gooddata/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class GoodDataConfigProduct(Base):
environment_setup_id: str
model_ids: List[str] = attr.field(default=list)
localization: Optional[GoodDataConfigLocalization] = None
skip_tests: Optional[List[str]] = None


@attrs.define(auto_attribs=True, kw_only=True)
Expand Down
3 changes: 3 additions & 0 deletions gooddata-dbt/gooddata_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ data_products:
environment_setup_id: default
model_ids:
- hubspot
# If execution of an insight fails, and you need some time to fix it
skip_tests:
- "<insight_id>"

# You can deliver data products to multiple organizations. Each organization can contain different (sub)set of products
organizations:
Expand Down

0 comments on commit 210a182

Please sign in to comment.