Multiple integration test fixes

This patch represents the following patches, combined:

---

integration tests: retry WebDriver instantiation when conn refused
  https://review.openstack.org/#/c/375042/

We see connection refused which leads to integration test failure randomly.
This seems to come from high load of test infra. This commit retries
WebDriver instantiation when connection refused is returned.

There is no confident this workaround works, but it would be great
if this reduces the number of failures. Let's try.

---

integration test: ensure IPv4 address is extracted
  https://review.openstack.org/#/c/374826/

In test_floatingip_associate_disassociate, IPv6 address is passed
to Floating IP associate API. This commit ensures to pick up IPv4
address of an instance.

Change-Id: Iba71d1e17e252527a82cd53c34dca35723367b28
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Partial-Bug: #1626643
Closes-Bug: #1626536
(cherry picked from commit b89c1abfa5)
This commit is contained in:
Akihiro Motoki 2016-09-23 03:03:46 +09:00 committed by Rob Cresswell
parent 74c9c152fe
commit a33ac87de1
2 changed files with 32 additions and 4 deletions

View File

@ -11,10 +11,13 @@
# 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 errno
import platform
import shutil
import socket
import subprocess
import tempfile
import time
from selenium.common import exceptions as selenium_exceptions
from selenium.webdriver.common import desired_capabilities as dc
@ -62,6 +65,9 @@ class WebDriver(firefox.webdriver.WebDriver):
"""Workarounds selenium firefox issues."""
TEMPDIR = tempfile.mkdtemp(dir="/tmp")
CONNREFUSED_RETRY_COUNT = 3
CONNREFUSED_RETRY_INTERVAL = 5
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
desired_capabilities=dc.DesiredCapabilities.FIREFOX,
proxy=None):
@ -69,9 +75,27 @@ class WebDriver(firefox.webdriver.WebDriver):
if firefox_profile is None:
firefox_profile = firefox.webdriver.FirefoxProfile()
self.setup_profile(firefox_profile)
super(WebDriver, self).__init__(
firefox_profile, FirefoxBinary(), timeout,
desired_capabilities, proxy)
# NOTE(amotoki): workaround for bug 1626643
# Connection refused error happens randomly in integration tests.
# When a connection refused exception is raised from start_session
# called from WebDriver.__init__, retry __init__.
for i in range(self.CONNREFUSED_RETRY_COUNT + 1):
try:
super(WebDriver, self).__init__(
firefox_profile, FirefoxBinary(), timeout,
desired_capabilities, proxy)
if i > 0:
# i==0 is normal behavior without connection refused.
print('NOTE: Retried %s time(s) due to '
'connection refused.' % i)
break
except socket.error as socket_error:
if (socket_error.errno == errno.ECONNREFUSED
and i < self.CONNREFUSED_RETRY_COUNT):
time.sleep(self.CONNREFUSED_RETRY_INTERVAL)
continue
raise
except selenium_exceptions.WebDriverException:
# If we can't start, cleanup profile
shutil.rmtree(self.profile.path)

View File

@ -9,6 +9,8 @@
# 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 netaddr
from openstack_dashboard.test.integration_tests.pages import basepage
from openstack_dashboard.test.integration_tests.regions import forms
from openstack_dashboard.test.integration_tests.regions import tables
@ -156,4 +158,6 @@ class InstancesPage(basepage.BaseNavigationPage):
def get_fixed_ipv4(self, name):
row = self._get_row_with_instance_name(name)
ips = row.cells[self.INSTANCES_TABLE_IP_COLUMN].text
return ips.split()[0]
for ip in ips.split():
if netaddr.valid_ipv4(ip):
return ip