Skip to content

Commit 6b809a3

Browse files
CrowiantAnton Nitochkin
andauthored
Update system tests in google provider. Add constraints to prevent from failing and modify example_cloud_logging_sink (#55939)
Co-authored-by: Anton Nitochkin <[email protected]>
1 parent 8966d28 commit 6b809a3

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

providers/google/tests/system/google/ads/example_ads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
# [START howto_google_ads_env_variables]
6363
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID", "default")
64-
PROJECT_ID = os.environ.get("SYSTEM_TESTS_PROJECT_ID", "default")
64+
PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT", "default")
6565
API_VERSION = "v21"
6666

6767
DAG_ID = "google_ads"

providers/google/tests/system/google/cloud/cloud_logging_sink/example_cloud_logging_sink.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,38 @@
3232
CloudLoggingListSinksOperator,
3333
CloudLoggingUpdateSinkOperator,
3434
)
35+
from airflow.providers.google.cloud.operators.gcs import GCSCreateBucketOperator, GCSDeleteBucketOperator
36+
37+
try:
38+
from airflow.sdk import TriggerRule
39+
except ImportError:
40+
# Compatibility for Airflow < 3.1
41+
from airflow.utils.trigger_rule import TriggerRule # type: ignore[no-redef,attr-defined]
3542

3643
PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT", "default")
3744
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID", "default")
45+
DAG_ID = "gcp_cloud_logging_sink"
46+
BUCKET_NAME = f"bucket_{DAG_ID}_{ENV_ID}"
3847

3948
SINK_NAME = "example-airflow-test-sink"
4049
CONN_ID = "google_cloud_default"
4150

4251
with DAG(
43-
dag_id="google_cloud_logging_sink",
52+
dag_id=DAG_ID,
4453
schedule="@once",
4554
start_date=datetime(2024, 1, 1),
4655
catchup=False,
4756
tags=["example", "gcp", "cloud-logging"],
4857
) as dag:
58+
create_bucket = GCSCreateBucketOperator(task_id="create_bucket", bucket_name=BUCKET_NAME)
59+
4960
# [START howto_operator_cloud_logging_create_sink_native_obj]
5061
create_sink = CloudLoggingCreateSinkOperator(
5162
task_id="create_sink",
5263
project_id=PROJECT_ID,
5364
sink_config={
5465
"name": SINK_NAME,
55-
"destination": "storage.googleapis.com/test-log-sink-af",
66+
"destination": f"storage.googleapis.com/{BUCKET_NAME}",
5667
"description": "Create with full sink_config",
5768
"filter": "severity>=INFO",
5869
"disabled": False,
@@ -110,7 +121,11 @@
110121
)
111122
# [END howto_operator_cloud_logging_delete_sink]
112123

113-
(create_sink >> update_sink_config >> list_sinks_after >> delete_sink)
124+
delete_bucket = GCSDeleteBucketOperator(
125+
task_id="delete_bucket", bucket_name=BUCKET_NAME, trigger_rule=TriggerRule.ALL_DONE
126+
)
127+
128+
(create_bucket >> create_sink >> update_sink_config >> list_sinks_after >> delete_sink >> delete_bucket)
114129

115130
from tests_common.test_utils.watcher import watcher
116131

providers/google/tests/system/google/cloud/vertex_ai/example_vertex_ai_feature_store.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from __future__ import annotations
2424

2525
import os
26+
import random
27+
import string
2628
from datetime import datetime, timedelta
2729

2830
from google.cloud.aiplatform_v1beta1 import FeatureOnlineStore, FeatureView, FeatureViewDataKey
@@ -61,7 +63,11 @@
6163
BQ_VIEW_ID = "product_features_view"
6264
BQ_VIEW_FQN = f"{PROJECT_ID}.{BQ_DATASET_ID}.{BQ_VIEW_ID}"
6365

64-
FEATURE_ONLINE_STORE_ID = f"my_feature_online_store_unique_{ENV_ID}"
66+
# Please take into consideration that max ID length is 60 symbols
67+
PREFIX_FEATURE_ONLINE_STORE_ID = "".join(
68+
random.choice(string.ascii_letters + string.digits) for _ in range(20)
69+
)
70+
FEATURE_ONLINE_STORE_ID = f"feature_online_store_{PREFIX_FEATURE_ONLINE_STORE_ID}".replace("-", "_")
6571
FEATURE_VIEW_ID = "feature_view_product"
6672
FEATURE_VIEW_DATA_KEY = {"key": "28098"}
6773

providers/google/tests/system/google/marketing_platform/example_display_video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
ADVERTISER_ID = "{{ task_instance.xcom_pull('get_display_video_advertiser_id') }}"
8484
GMP_PARTNER_ID = "{{ task_instance.xcom_pull('get_display_video_gmp_partner_id') }}"
8585
SDF_VERSION = "SDF_VERSION_8_1"
86-
BQ_DATASET = f"bq_dataset_{DAG_ID}_{ENV_ID}"
86+
BQ_DATASET = f"bq_dataset_{DAG_ID}_{ENV_ID}".replace("-", "_")
8787
ENTITY_TYPE = "CAMPAIGN"
8888
ERF_SOURCE_OBJECT = GoogleDisplayVideo360Hook.erf_uri(GMP_PARTNER_ID, ENTITY_TYPE)
8989

0 commit comments

Comments
 (0)