You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/05/04 10:34:00 UTC

[jira] [Work logged] (BEAM-9633) PubsubIO performance tests

     [ https://issues.apache.org/jira/browse/BEAM-9633?focusedWorklogId=430101&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-430101 ]

ASF GitHub Bot logged work on BEAM-9633:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/May/20 10:33
            Start Date: 04/May/20 10:33
    Worklog Time Spent: 10m 
      Work Description: piotr-szuberski commented on a change in pull request #11274:
URL: https://github.com/apache/beam/pull/11274#discussion_r419345099



##########
File path: sdks/python/apache_beam/io/gcp/pubsub_write_perf_test.py
##########
@@ -0,0 +1,104 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Performance PubsubIO streaming test for Write operation.
+
+Caution: only test runners (e.g. TestDataflowRunner) support matchers
+
+Example for TestDataflowRunner:
+
+python -m apache_beam.io.gcp.pubsub_read_perf_test \
+    --test-pipeline-options="
+    --runner=TestDataflowRunner
+    --sdk_location=.../dist/apache-beam-x.x.x.dev0.tar.gz
+    --project=<GCP_PROJECT_ID>
+    --temp_location=gs://<BUCKET_NAME>/tmp
+    --staging_location=gs://<BUCKET_NAME>/staging
+    --timeout=<TIME_IN_SECONDS>
+    --pubsub_name=<PUBSUB_NAME_TO_BE_CREATED>
+    --publish_to_big_query=<OPTIONAL><true/false>
+    --metrics_dataset=<OPTIONAL>
+    --metrics_table=<OPTIONAL>
+    --dataflow_worker_jar=<OPTIONAL>
+    --input_options='{
+    \"num_records\": <SIZE_OF_INPUT>,
+    \"key_size\": 1,
+    \"value_size\": <VALUE_SIZE>,
+    }'"
+
+"""
+
+# pytype: skip-file
+
+from __future__ import absolute_import
+
+import logging
+
+import apache_beam as beam
+from apache_beam.io import Read
+from apache_beam.io.gcp.pubsub_perf_test import PubsubPerfTest
+from apache_beam.testing.load_tests.load_test_metrics_utils import MeasureTime
+from apache_beam.testing.synthetic_pipeline import SyntheticSource
+
+
+class PubsubWritePerfTest(PubsubPerfTest):
+  def __init__(self):
+    super(PubsubWritePerfTest, self).__init__()
+    self._setup_env()
+    self._setup_pubsub()
+    self._setup_pipeline(self.write_matcher_sub_name)
+
+  def test(self):
+    def to_pubsub_message(element):
+      import uuid
+      from apache_beam.io import PubsubMessage
+      return PubsubMessage(
+          data=element[1],
+          attributes={'id': str(uuid.uuid1()).encode('utf-8')},
+      )
+
+    _ = (
+        self.pipeline
+        | 'Create input' >> Read(
+            SyntheticSource(self.parse_synthetic_source_options()))
+        | 'Format to pubsub message in bytes' >> beam.Map(to_pubsub_message)
+        | 'Measure time' >> beam.ParDo(MeasureTime(self.metrics_namespace))
+        | 'Write to Pubsub' >> beam.io.WriteToPubSub(
+            self.topic_name, with_attributes=True, id_label='id'))
+
+  def _setup_pubsub(self):
+    super(PubsubWritePerfTest, self)._setup_pubsub()
+
+    def make_subscription(sub_name):
+      _ = self.sub_client.create_subscription(
+          sub_name,
+          self.topic_name,
+          ack_deadline_seconds=300,
+          timeout=1200,
+          retain_acked_messages=True,
+      )
+
+    _ = self.pub_client.create_topic(self.topic_name)
+    make_subscription(self.write_matcher_sub_name)
+    make_subscription(self.read_sub_name)

Review comment:
       It is needed because the subscription must exists when the messages are being published. If I move it to the read test then the subscription will be empty.




----------------------------------------------------------------
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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 430101)
    Time Spent: 6h 10m  (was: 6h)

> PubsubIO performance tests
> --------------------------
>
>                 Key: BEAM-9633
>                 URL: https://issues.apache.org/jira/browse/BEAM-9633
>             Project: Beam
>          Issue Type: Test
>          Components: sdk-py-core
>    Affects Versions: Not applicable
>            Reporter: Piotr Szuberski
>            Assignee: Piotr Szuberski
>            Priority: Major
>             Fix For: Not applicable
>
>          Time Spent: 6h 10m
>  Remaining Estimate: 0h
>
> There is no performance tests for PubsubIO in Python sdk



--
This message was sent by Atlassian Jira
(v8.3.4#803005)