TobKed commented on a change in pull request #8550: URL: https://github.com/apache/airflow/pull/8550#discussion_r497343799
########## File path: tests/providers/google/cloud/operators/test_dataflow_system.py ########## @@ -26,4 +37,191 @@ class CloudDataflowExampleDagsSystemTest(GoogleSystemTest): @provide_gcp_context(GCP_DATAFLOW_KEY) def test_run_example_dag_function(self): - self.run_dag('example_gcp_dataflow', CLOUD_DAG_FOLDER) + self.run_dag("example_gcp_dataflow", CLOUD_DAG_FOLDER) + + +GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") +GCR_FLEX_TEMPLATE_IMAGE = f"gcr.io/{GCP_PROJECT_ID}/samples-dataflow-streaming-beam-sql:latest" + +# https://github.com/GoogleCloudPlatform/java-docs-samples/tree/954553c/dataflow/flex-templates/streaming_beam_sql +GCS_TEMPLATE_PARTS = urlparse(GCS_FLEX_TEMPLATE_TEMPLATE_PATH) +GCS_FLEX_TEMPLATE_BUCKET_NAME = GCS_TEMPLATE_PARTS.netloc + + +EXAMPLE_FLEX_TEMPLATE_REPO = "GoogleCloudPlatform/java-docs-samples" +EXAMPLE_FLEX_TEMPLATE_COMMIT = "deb0745be1d1ac1d133e1f0a7faa9413dbfbe5fe" +EXAMPLE_FLEX_TEMPLATE_SUBDIR = "dataflow/flex-templates/streaming_beam_sql" + + +@pytest.mark.backend("mysql", "postgres") +@pytest.mark.credential_file(GCP_GCS_TRANSFER_KEY) +class CloudDataflowExampleDagFlexTemplateJavagSystemTest(GoogleSystemTest): + @provide_gcp_context(GCP_GCS_TRANSFER_KEY, project_id=GoogleSystemTest._project_id()) + def setUp(self) -> None: + # Create a Cloud Storage bucket + self.execute_cmd(["gsutil", "mb", f"gs://{GCS_FLEX_TEMPLATE_BUCKET_NAME}"]) + + # Build image with pipeline + with NamedTemporaryFile() as f: + f.write( + textwrap.dedent( + """\ + steps: Review comment: You are right, I changed my mind. I think dictionary looks better especially that Cloud Build accept JSON config files ``` cloud_build_config = { 'steps': [ {'name': 'gcr.io/cloud-builders/git', 'args': ['clone', "$_EXAMPLE_REPO", "repo_dir"]}, { 'name': 'gcr.io/cloud-builders/git', 'args': ['checkout', '$_EXAMPLE_COMMIT'], 'dir': 'repo_dir', }, { 'name': 'maven', 'args': ['mvn', 'clean', 'package'], 'dir': 'repo_dir/$_EXAMPLE_SUBDIR', }, { 'name': 'gcr.io/cloud-builders/docker', 'args': ['build', '-t', '$_TEMPLATE_IMAGE', '.'], 'dir': 'repo_dir/$_EXAMPLE_SUBDIR', }, ], 'images': ['$_TEMPLATE_IMAGE'], } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org