This is an automated email from the ASF dual-hosted git repository.
pabloem 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 0b4ce41 [BEAM-11045] Fix screendiff integration tests
new 968bea9 Merge pull request #13064 from [BEAM-11045] Fix screendiff
integration tests
0b4ce41 is described below
commit 0b4ce41e2bd2a7afef66a196bcf00d3b2a3852d9
Author: Ning Kang <[email protected]>
AuthorDate: Thu Oct 8 15:27:13 2020 -0700
[BEAM-11045] Fix screendiff integration tests
1. Removed the server daemon process from screen diff tests. Replaced it
with a lightweight daemon thread.
2. Upgraded chromedriver-binary version to 85 to match the newest chrome
browser version and updated the goldens to match the iframe changed
introduced in PR#13045.
3. Added an IFrameParser to extract iframe srcDoc into HTML for
screenshot so that explicit webdriver wait can still function.
---
.../Darwin/7a35f487b2a5f3a9b9852a8659eeb4bd.png | Bin 748447 -> 746483 bytes
.../Linux/7a35f487b2a5f3a9b9852a8659eeb4bd.png | Bin 716205 -> 700208 bytes
.../testing/integration/notebook_executor.py | 26 ++++++++++++++++++++-
.../interactive/testing/integration/screen_diff.py | 24 +++++++------------
.../integration/tests/init_square_cube_test.py | 4 ++++
sdks/python/setup.py | 2 +-
6 files changed, 39 insertions(+), 17 deletions(-)
diff --git
a/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Darwin/7a35f487b2a5f3a9b9852a8659eeb4bd.png
b/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Darwin/7a35f487b2a5f3a9b9852a8659eeb4bd.png
index fd64793..bfafc86 100644
Binary files
a/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Darwin/7a35f487b2a5f3a9b9852a8659eeb4bd.png
and
b/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Darwin/7a35f487b2a5f3a9b9852a8659eeb4bd.png
differ
diff --git
a/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Linux/7a35f487b2a5f3a9b9852a8659eeb4bd.png
b/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Linux/7a35f487b2a5f3a9b9852a8659eeb4bd.png
index d3edd5f..3e9f47c 100644
Binary files
a/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Linux/7a35f487b2a5f3a9b9852a8659eeb4bd.png
and
b/sdks/python/apache_beam/runners/interactive/testing/integration/goldens/Linux/7a35f487b2a5f3a9b9852a8659eeb4bd.png
differ
diff --git
a/sdks/python/apache_beam/runners/interactive/testing/integration/notebook_executor.py
b/sdks/python/apache_beam/runners/interactive/testing/integration/notebook_executor.py
index 6a2091f..1051722 100644
---
a/sdks/python/apache_beam/runners/interactive/testing/integration/notebook_executor.py
+++
b/sdks/python/apache_beam/runners/interactive/testing/integration/notebook_executor.py
@@ -22,9 +22,11 @@ HTML files."""
from __future__ import absolute_import
+import html
import os
import shutil
import subprocess
+from html.parser import HTMLParser
from apache_beam.runners.interactive.utils import obfuscate
@@ -138,4 +140,26 @@ def _extract_html(output, sink):
sink.write(data['application/javascript'])
sink.write('</script>\n')
if 'text/html' in data:
- sink.write(data['text/html'])
+ parser = IFrameParser()
+ parser.feed(data['text/html'])
+ if parser.srcdocs:
+ sink.write(parser.srcdocs)
+ else:
+ sink.write(data['text/html'])
+
+
+class IFrameParser(HTMLParser):
+ """A parser to extract iframe content from given HTML."""
+ def __init__(self):
+ self._srcdocs = []
+ super(IFrameParser, self).__init__()
+
+ def handle_starttag(self, tag, attrs):
+ if tag == 'iframe':
+ for attr in attrs:
+ if 'srcdoc' in attr:
+ self._srcdocs.append(html.unescape(attr[1]))
+
+ @property
+ def srcdocs(self):
+ return '\n'.join(self._srcdocs)
diff --git
a/sdks/python/apache_beam/runners/interactive/testing/integration/screen_diff.py
b/sdks/python/apache_beam/runners/interactive/testing/integration/screen_diff.py
index f49bc59..57dc0a7 100644
---
a/sdks/python/apache_beam/runners/interactive/testing/integration/screen_diff.py
+++
b/sdks/python/apache_beam/runners/interactive/testing/integration/screen_diff.py
@@ -25,7 +25,6 @@ import os
import platform
import threading
import unittest
-from multiprocessing import Process
import pytest
@@ -75,25 +74,22 @@ class ScreenDiffIntegrationTestEnvironment(object):
self._cleanup = cleanup
self._test_urls = {}
self._server = None
- self._server_daemon = None
def __enter__(self):
self._notebook_executor.execute()
- with HTTPServer(('', 0), SimpleHTTPRequestHandler) as server:
- self._server = server
+ self._server = HTTPServer(('', 0), SimpleHTTPRequestHandler)
- def start_serving(server):
- server.serve_forever()
+ def start_serving(server):
+ server.serve_forever()
- self._server_daemon = Process(
- target=start_serving, args=[server], daemon=True)
- self._server_daemon.start()
+ threading.Thread(
+ target=start_serving, args=[self._server], daemon=True).start()
- for test_id, output_path in\
- self._notebook_executor.output_html_paths.items():
- self._test_urls[test_id] = self.base_url + output_path
+ for test_id, output_path in\
+ self._notebook_executor.output_html_paths.items():
+ self._test_urls[test_id] = self.base_url + output_path
- return self
+ return self
def __exit__(self, exc_type, exc_value, traceback):
if self._notebook_executor and self._cleanup:
@@ -105,8 +101,6 @@ class ScreenDiffIntegrationTestEnvironment(object):
threading.Thread(
target=stop_serving, args=[self._server], daemon=True).start()
- if self._server_daemon:
- self._server_daemon.terminate()
@property
def base_url(self):
diff --git
a/sdks/python/apache_beam/runners/interactive/testing/integration/tests/init_square_cube_test.py
b/sdks/python/apache_beam/runners/interactive/testing/integration/tests/init_square_cube_test.py
index a798720..9853dd3 100644
---
a/sdks/python/apache_beam/runners/interactive/testing/integration/tests/init_square_cube_test.py
+++
b/sdks/python/apache_beam/runners/interactive/testing/integration/tests/init_square_cube_test.py
@@ -26,6 +26,10 @@ from
apache_beam.runners.interactive.testing.integration.screen_diff import Base
class InitSquareCubeTest(BaseTestCase):
+ def __init__(self, *args, **kwargs):
+ kwargs['golden_size'] = (1024, 7000)
+ super(InitSquareCubeTest, self).__init__(*args, **kwargs)
+
def test_init_square_cube_notebook(self):
self.assert_notebook('init_square_cube')
diff --git a/sdks/python/setup.py b/sdks/python/setup.py
index a0fc19f..e2b9b18 100644
--- a/sdks/python/setup.py
+++ b/sdks/python/setup.py
@@ -234,7 +234,7 @@ INTERACTIVE_BEAM_TEST = [
# headless chrome based integration tests
'selenium>=3.141.0,<4',
'needle>=0.5.0,<1',
- 'chromedriver-binary>=83,<84',
+ 'chromedriver-binary>=85,<86',
# use a fixed major version of PIL for different python versions
'pillow>=7.1.1,<8',
]