You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2019/03/19 20:26:46 UTC

[beam] branch master updated: [BEAM-6619] [BEAM-6593] fix autocomplete it test

This is an automated email from the ASF dual-hosted git repository.

altay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new d6971bf  [BEAM-6619] [BEAM-6593] fix autocomplete it test
     new 13c1452  Merge pull request #8070 from Juta/it-tests
d6971bf is described below

commit d6971bf41db73689df780e67058c5c5ede7f1489
Author: Juta <ju...@gmail.com>
AuthorDate: Fri Mar 15 15:48:44 2019 +0100

    [BEAM-6619] [BEAM-6593] fix autocomplete it test
---
 sdks/python/apache_beam/examples/complete/autocomplete_test.py | 10 +++++++---
 sdks/python/test-suites/dataflow/py3/build.gradle              |  1 +
 sdks/python/test-suites/direct/py3/build.gradle                |  1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/sdks/python/apache_beam/examples/complete/autocomplete_test.py b/sdks/python/apache_beam/examples/complete/autocomplete_test.py
index e7144da..29d8203 100644
--- a/sdks/python/apache_beam/examples/complete/autocomplete_test.py
+++ b/sdks/python/apache_beam/examples/complete/autocomplete_test.py
@@ -26,6 +26,7 @@ from nose.plugins.attrib import attr
 import apache_beam as beam
 from apache_beam.examples.complete import autocomplete
 from apache_beam.testing.test_pipeline import TestPipeline
+from apache_beam.testing.test_utils import compute_hash
 from apache_beam.testing.util import assert_that
 from apache_beam.testing.util import equal_to
 
@@ -33,7 +34,7 @@ from apache_beam.testing.util import equal_to
 class AutocompleteTest(unittest.TestCase):
 
   WORDS = ['this', 'this', 'that', 'to', 'to', 'to']
-  KINGLEAR_HASH_SUM = 3104188901048578415956
+  KINGLEAR_HASH_SUM = 268011785062540
   KINGLEAR_INPUT = 'gs://dataflow-samples/shakespeare/kinglear.txt'
 
   def test_top_prefixes(self):
@@ -59,8 +60,11 @@ class AutocompleteTest(unittest.TestCase):
       words = p | beam.io.ReadFromText(self.KINGLEAR_INPUT)
       result = words | autocomplete.TopPerPrefix(10)
       # values must be hashable for now
-      result = result | beam.Map(lambda k_vs: (k_vs[0], tuple(k_vs[1])))
-      checksum = result | beam.Map(hash) | beam.CombineGlobally(sum)
+      result = result | beam.Map(lambda k_vs: [k_vs[0],
+                                               k_vs[1][0][0], k_vs[1][0][1]])
+      checksum = (result
+                  | beam.Map(lambda x: int(compute_hash(x)[:8], 16))
+                  | beam.CombineGlobally(sum))
 
       assert_that(checksum, equal_to([self.KINGLEAR_HASH_SUM]))
 
diff --git a/sdks/python/test-suites/dataflow/py3/build.gradle b/sdks/python/test-suites/dataflow/py3/build.gradle
index 3675943..b033153 100644
--- a/sdks/python/test-suites/dataflow/py3/build.gradle
+++ b/sdks/python/test-suites/dataflow/py3/build.gradle
@@ -47,6 +47,7 @@ task postCommitIT(dependsOn: ['sdist', 'installGcpTest']) {
         "apache_beam.io.gcp.pubsub_integration_test:PubSubIntegrationTest.test_streaming_data_only",
         "apache_beam.io.gcp.pubsub_integration_test:PubSubIntegrationTest.test_streaming_with_attributes",
         "apache_beam.io.parquetio_it_test:TestParquetIT.test_parquetio_it",
+        "apache_beam.examples.complete.autocomplete_test:AutocompleteTest.test_autocomplete_it",
     ]
     def testOpts = basicTestOpts + ["--tests=${tests.join(',')}"]
     def cmdArgs = project.mapToArgString([
diff --git a/sdks/python/test-suites/direct/py3/build.gradle b/sdks/python/test-suites/direct/py3/build.gradle
index 471b583..e1b358a 100644
--- a/sdks/python/test-suites/direct/py3/build.gradle
+++ b/sdks/python/test-suites/direct/py3/build.gradle
@@ -41,6 +41,7 @@ task postCommitIT(dependsOn: 'installGcpTest') {
         "apache_beam.io.gcp.pubsub_integration_test:PubSubIntegrationTest.test_streaming_data_only",
         "apache_beam.io.gcp.pubsub_integration_test:PubSubIntegrationTest.test_streaming_with_attributes",
         "apache_beam.io.parquetio_it_test:TestParquetIT.test_parquetio_it",
+        "apache_beam.examples.complete.autocomplete_test:AutocompleteTest.test_autocomplete_it",
     ]
     def testOpts = [
         "--tests=${batchTests.join(',')}",