You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/08/21 12:28:34 UTC

[GitHub] [airflow] ad-m commented on a change in pull request #8550: Add DataflowStartFlexTemplateOperator

ad-m commented on a change in pull request #8550:
URL: https://github.com/apache/airflow/pull/8550#discussion_r474665132



##########
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:
       Have you considered use standard `dict` and use `json.dumps` to generate file content? You don't use any YAML specific syntax and JSON is subset of YAML. I believe that `dict` is easier to maintain long term than a hard-coded text block.




----------------------------------------------------------------
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:
users@infra.apache.org