]> review.fuel-infra Code Review - openstack-build/horizon-build.git/commitdiff
Added patch: Only_import_selenium_if_WITH_SELENIUM_is_set.patch
authorThomas Goirand <thomas@goirand.fr>
Fri, 19 Feb 2016 16:28:35 +0000 (16:28 +0000)
committerThomas Goirand <thomas@goirand.fr>
Fri, 19 Feb 2016 16:45:19 +0000 (16:45 +0000)
Rewritten-From: b0ea5fbb35a52aaa3aa2e70722fe36e2d5108eb3

trusty/debian/changelog
trusty/debian/patches/Only_import_selenium_if_WITH_SELENIUM_is_set.patch [new file with mode: 0644]
trusty/debian/patches/series

index 4eeb804ac76a43b96f1772567effcce20c0e083b..d0b3740646381a6d16b47094646d64bec9febfa2 100644 (file)
@@ -6,6 +6,7 @@ horizon (2:9.0.0~b2+2016.02.18.git.cda9604792-1) experimental; urgency=medium
   * Added patch: 0100-add-openstack_auth-in-INSTALLED_APPS.patch
   * Added patch: 0090-explicitly-declare-app_label.patch
   * Added patch: Fix_remaining_Django_1.9_test_failures.patch
+  * Added patch: Only_import_selenium_if_WITH_SELENIUM_is_set.patch
 
  -- Thomas Goirand <zigo@debian.org>  Wed, 09 Dec 2015 11:37:40 +0100
 
diff --git a/trusty/debian/patches/Only_import_selenium_if_WITH_SELENIUM_is_set.patch b/trusty/debian/patches/Only_import_selenium_if_WITH_SELENIUM_is_set.patch
new file mode 100644 (file)
index 0000000..c74cdff
--- /dev/null
@@ -0,0 +1,164 @@
+Subject: Only import selenium if WITH_SELENIUM is set
+ here's some unit tests errors in Debian when building the Horizon package,
+ because of missing conditionals when importing the selenium Python modules.
+ This patch fixes it.
+Author: Thomas Goirand <thomas@goirand.fr>
+Date: Fri, 19 Feb 2016 16:23:04 +0000
+Change-Id: I7e0c10f8a7dfe213d1b471a58bbef378bc80a615
+Forwarded: https://review.openstack.org/#/c/282410/
+Last-Update: 2016-02-20
+
+diff --git a/horizon/test/firefox_binary.py b/horizon/test/firefox_binary.py
+index 2597789..caacc88 100644
+--- a/horizon/test/firefox_binary.py
++++ b/horizon/test/firefox_binary.py
+@@ -11,64 +11,68 @@
+ # 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.
++import os
+ import platform
+ import shutil
+ import subprocess
+-from selenium.common import exceptions as selenium_exceptions
+-from selenium.webdriver.common import desired_capabilities as dc
+-from selenium.webdriver import firefox
++with_sel = os.environ.get('WITH_SELENIUM', False)
++if with_sel:
++    from selenium.common import exceptions as selenium_exceptions
++    from selenium.webdriver.common import desired_capabilities as dc
++    from selenium.webdriver import firefox
+-class FirefoxBinary(firefox.firefox_binary.FirefoxBinary):
+-    """Workarounds selenium firefox issues.
++    class FirefoxBinary(firefox.firefox_binary.FirefoxBinary):
++        """Workarounds selenium firefox issues.
+-    There is race condition in the way firefox is spawned. The exact
+-    cause hasn't been properly diagnosed yet but it's around:
++        There is race condition in the way firefox is spawned. The exact
++        cause hasn't been properly diagnosed yet but it's around:
+-    - getting a free port from the OS with
+-    selenium.webdriver.common.utils free_port(),
++        - getting a free port from the OS with
++        selenium.webdriver.common.utils free_port(),
+-    - release the port immediately but record it in ff prefs so that ff
+-    can listen on that port for the internal http server.
++        - release the port immediately but record it in ff prefs so that ff
++        can listen on that port for the internal http server.
+-    It has been observed that this leads to hanging processes for
+-    'firefox -silent'.
+-    """
++        It has been observed that this leads to hanging processes for
++        'firefox -silent'.
++        """
+-    def _start_from_profile_path(self, path):
+-        self._firefox_env["XRE_PROFILE_PATH"] = path
++        def _start_from_profile_path(self, path):
++            self._firefox_env["XRE_PROFILE_PATH"] = path
+-        if platform.system().lower() == 'linux':
+-            self._modify_link_library_path()
+-        command = [self._start_cmd, "-silent"]
+-        if self.command_line is not None:
+-            for cli in self.command_line:
+-                command.append(cli)
++            if platform.system().lower() == 'linux':
++                self._modify_link_library_path()
++            command = [self._start_cmd, "-silent"]
++            if self.command_line is not None:
++                for cli in self.command_line:
++                    command.append(cli)
+ # The following exists upstream and is known to create hanging
+ # firefoxes, leading to zombies.
+-#        subprocess.Popen(command, stdout=self._log_file,
+-#              stderr=subprocess.STDOUT,
+-#              env=self._firefox_env).communicate()
+-        command[1] = '-foreground'
+-        self.process = subprocess.Popen(
+-            command, stdout=self._log_file, stderr=subprocess.STDOUT,
+-            env=self._firefox_env)
++#            subprocess.Popen(command, stdout=self._log_file,
++#                  stderr=subprocess.STDOUT,
++#                  env=self._firefox_env).communicate()
++            command[1] = '-foreground'
++            self.process = subprocess.Popen(
++                command, stdout=self._log_file, stderr=subprocess.STDOUT,
++                env=self._firefox_env)
+-class WebDriver(firefox.webdriver.WebDriver):
+-    """Workarounds selenium firefox issues."""
+-    def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
+-                 desired_capabilities=dc.DesiredCapabilities.FIREFOX,
+-                 proxy=None):
+-        try:
+-            super(WebDriver, self).__init__(
+-                firefox_profile, FirefoxBinary(), timeout,
+-                desired_capabilities, proxy)
+-        except selenium_exceptions.WebDriverException:
+-            # If we can't start, cleanup profile
+-            shutil.rmtree(self.profile.path)
+-            if self.profile.tempfolder is not None:
+-                shutil.rmtree(self.profile.tempfolder)
+-            raise
++    class WebDriver(firefox.webdriver.WebDriver):
++        """Workarounds selenium firefox issues."""
++        def __init__(self, firefox_profile=None, firefox_binary=None,
++                     timeout=30,
++                     desired_capabilities=dc.DesiredCapabilities.FIREFOX,
++                     proxy=None):
++            try:
++                super(WebDriver, self).__init__(
++                    firefox_profile, FirefoxBinary(), timeout,
++                    desired_capabilities, proxy)
++            except selenium_exceptions.WebDriverException:
++                # If we can't start, cleanup profile
++                shutil.rmtree(self.profile.path)
++                if self.profile.tempfolder is not None:
++                    shutil.rmtree(self.profile.tempfolder)
++                raise
+diff --git a/horizon/test/webdriver.py b/horizon/test/webdriver.py
+index 2a699fc..83b2701 100644
+--- a/horizon/test/webdriver.py
++++ b/horizon/test/webdriver.py
+@@ -29,18 +29,20 @@ class ElementNotReloadableException(Exception):
+     pass
+-from selenium.common import exceptions
+-from selenium.webdriver.common import by
+-from selenium.webdriver.common import desired_capabilities as dc
+-from selenium.webdriver.remote import webelement
+-
+-# Select the WebDriver to use based on the --selenium-phantomjs switch.
+-if os.environ.get('SELENIUM_PHANTOMJS'):
+-    from selenium.webdriver import PhantomJS as WebDriver
+-    desired_capabilities = dc.DesiredCapabilities.PHANTOMJS
+-else:
+-    from horizon.test.firefox_binary import WebDriver
+-    desired_capabilities = dc.DesiredCapabilities.FIREFOX
++with_sel = os.environ.get('WITH_SELENIUM', False)
++if with_sel:
++    from selenium.common import exceptions
++    from selenium.webdriver.common import by
++    from selenium.webdriver.common import desired_capabilities as dc
++    from selenium.webdriver.remote import webelement
++
++    # Select the WebDriver to use based on the --selenium-phantomjs switch.
++    if os.environ.get('SELENIUM_PHANTOMJS'):
++        from selenium.webdriver import PhantomJS as WebDriver
++        desired_capabilities = dc.DesiredCapabilities.PHANTOMJS
++    else:
++        from horizon.test.firefox_binary import WebDriver
++        desired_capabilities = dc.DesiredCapabilities.FIREFOX
+ class WrapperFindOverride(object):
index 292da86d0db4ccfbf0216c2f422f0f2bdc6ec75c..9820d71c77356c8ed16349cd03d7bc3982540752 100644 (file)
@@ -6,3 +6,4 @@ enable_identity_users_panel.patch
 #0100-add-openstack_auth-in-INSTALLED_APPS.patch
 0090-explicitly-declare-app_label.patch
 Fix_remaining_Django_1.9_test_failures.patch
+Only_import_selenium_if_WITH_SELENIUM_is_set.patch
\ No newline at end of file