Browse Source

Merge "Multiple integration test fixes" into stable/newton

tags/10.0.0.0rc2
Jenkins 2 years ago
parent
commit
8b417374f7

+ 27
- 3
horizon/test/firefox_binary.py View File

@@ -11,10 +11,13 @@
11 11
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14
+import errno
14 15
 import platform
15 16
 import shutil
17
+import socket
16 18
 import subprocess
17 19
 import tempfile
20
+import time
18 21
 
19 22
 from selenium.common import exceptions as selenium_exceptions
20 23
 from selenium.webdriver.common import desired_capabilities as dc
@@ -62,6 +65,9 @@ class WebDriver(firefox.webdriver.WebDriver):
62 65
     """Workarounds selenium firefox issues."""
63 66
     TEMPDIR = tempfile.mkdtemp(dir="/tmp")
64 67
 
68
+    CONNREFUSED_RETRY_COUNT = 3
69
+    CONNREFUSED_RETRY_INTERVAL = 5
70
+
65 71
     def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
66 72
                  desired_capabilities=dc.DesiredCapabilities.FIREFOX,
67 73
                  proxy=None):
@@ -69,9 +75,27 @@ class WebDriver(firefox.webdriver.WebDriver):
69 75
             if firefox_profile is None:
70 76
                 firefox_profile = firefox.webdriver.FirefoxProfile()
71 77
             self.setup_profile(firefox_profile)
72
-            super(WebDriver, self).__init__(
73
-                firefox_profile, FirefoxBinary(), timeout,
74
-                desired_capabilities, proxy)
78
+
79
+            # NOTE(amotoki): workaround for bug 1626643
80
+            # Connection refused error happens randomly in integration tests.
81
+            # When a connection refused exception is raised from start_session
82
+            # called from WebDriver.__init__, retry __init__.
83
+            for i in range(self.CONNREFUSED_RETRY_COUNT + 1):
84
+                try:
85
+                    super(WebDriver, self).__init__(
86
+                        firefox_profile, FirefoxBinary(), timeout,
87
+                        desired_capabilities, proxy)
88
+                    if i > 0:
89
+                        # i==0 is normal behavior without connection refused.
90
+                        print('NOTE: Retried %s time(s) due to '
91
+                              'connection refused.' % i)
92
+                    break
93
+                except socket.error as socket_error:
94
+                    if (socket_error.errno == errno.ECONNREFUSED
95
+                            and i < self.CONNREFUSED_RETRY_COUNT):
96
+                        time.sleep(self.CONNREFUSED_RETRY_INTERVAL)
97
+                        continue
98
+                    raise
75 99
         except selenium_exceptions.WebDriverException:
76 100
             # If we can't start, cleanup profile
77 101
             shutil.rmtree(self.profile.path)

+ 5
- 1
openstack_dashboard/test/integration_tests/pages/project/compute/instancespage.py View File

@@ -9,6 +9,8 @@
9 9
 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 10
 #    License for the specific language governing permissions and limitations
11 11
 #    under the License.
12
+import netaddr
13
+
12 14
 from openstack_dashboard.test.integration_tests.pages import basepage
13 15
 from openstack_dashboard.test.integration_tests.regions import forms
14 16
 from openstack_dashboard.test.integration_tests.regions import tables
@@ -156,4 +158,6 @@ class InstancesPage(basepage.BaseNavigationPage):
156 158
     def get_fixed_ipv4(self, name):
157 159
         row = self._get_row_with_instance_name(name)
158 160
         ips = row.cells[self.INSTANCES_TABLE_IP_COLUMN].text
159
-        return ips.split()[0]
161
+        for ip in ips.split():
162
+            if netaddr.valid_ipv4(ip):
163
+                return ip

Loading…
Cancel
Save