beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-3861) Build test infra for end-to-end streaming test in Python SDK
Date Thu, 22 Mar 2018 04:20:00 GMT

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

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

                Author: ASF GitHub Bot
            Created on: 22/Mar/18 04:19
            Start Date: 22/Mar/18 04:19
    Worklog Time Spent: 10m 
      Work Description: aaltay commented on a change in pull request #4930: [BEAM-3861] Complete
streaming wordcount test in Python SDK
URL: https://github.com/apache/beam/pull/4930#discussion_r176304163
 
 

 ##########
 File path: sdks/python/apache_beam/io/gcp/tests/pubsub_matcher.py
 ##########
 @@ -0,0 +1,108 @@
+#
+# 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.
+#
+
+"""PubSub verifier used for end-to-end test."""
+
+import logging
+import time
+from collections import Counter
+
+from hamcrest.core.base_matcher import BaseMatcher
+
+__all__ = ['PubSubMessageMatcher']
+
+
+# Protect against environments where pubsub library is not available.
+# pylint: disable=wrong-import-order, wrong-import-position
+try:
+  from google.cloud import pubsub
+except ImportError:
+  pubsub = None
+# pylint: enable=wrong-import-order, wrong-import-position
+
+DEFAULT_TIMEOUT = 5 * 60
+MAX_MESSAGES_IN_ONE_PULL = 50
+
+
+class PubSubMessageMatcher(BaseMatcher):
+  """Matcher that verifies messages from given subscription.
+
+  This matcher can block the test and keep pulling messages from given
+  subscription until all expected messages are shown or timeout.
+  """
+
+  def __init__(self, project, sub_name, expected_msg, timeout=DEFAULT_TIMEOUT):
+    """Initialize PubSubMessageMatcher object.
+
+    Args:
+      project: A name string of project.
+      sub_name: A name string of subscription which is attached to output.
+      expected_msg: A string list that contains expected message data pulled
+        from the subscription.
+      timeout: Timeout in seconds to wait for all expected messages appears.
+    """
+    if pubsub is None:
+      raise ImportError(
+          'PubSub dependencies are not installed.')
+    if not project:
+      raise ValueError('Invalid project %s.' % project)
+    if not sub_name:
+      raise ValueError('Invalid subscription %s.' % sub_name)
+    if not expected_msg or not isinstance(expected_msg, list):
 
 Review comment:
   `if not isinstance(expected_msg, list):` should be enough?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 83056)
    Time Spent: 5h  (was: 4h 50m)

> Build test infra for end-to-end streaming test in Python SDK
> ------------------------------------------------------------
>
>                 Key: BEAM-3861
>                 URL: https://issues.apache.org/jira/browse/BEAM-3861
>             Project: Beam
>          Issue Type: Task
>          Components: testing
>            Reporter: Mark Liu
>            Assignee: Mark Liu
>            Priority: Major
>          Time Spent: 5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message