Merge "External dns and ntp check"

This commit is contained in:
Jenkins 2015-02-19 08:23:08 +00:00 committed by Gerrit Code Review
commit 5472409c50
4 changed files with 132 additions and 0 deletions

View File

@ -22,6 +22,8 @@ from ipaddr import IPNetwork
from fuelweb_test import logger
from fuelweb_test import logwrap
from fuelweb_test.settings import EXTERNAL_DNS
from fuelweb_test.settings import EXTERNAL_NTP
from fuelweb_test.settings import OPENSTACK_RELEASE
from fuelweb_test.settings import OPENSTACK_RELEASE_UBUNTU
from fuelweb_test.settings import POOLS
@ -817,3 +819,40 @@ def check_stats_private_info(collector_remote, postgres_actions,
def check_kernel(kernel, expected_kernel):
assert_equal(kernel, expected_kernel,
"kernel version is wrong, it is {0}".format(kernel))
@logwrap
def external_dns_check(remote_slave):
logger.info("External dns check")
ext_dns_ip = ''.join(
remote_slave.execute("grep {0} /etc/resolv.dnsmasq.conf | "
"awk {{'print $2'}}".
format(EXTERNAL_DNS))["stdout"]).rstrip()
assert_equal(ext_dns_ip, EXTERNAL_DNS,
"/etc/resolv.dnsmasq.conf does not contain external dns ip")
command_hostname = ''.join(
remote_slave.execute("host 8.8.8.8 | awk {'print $5'}")
["stdout"]).rstrip()
hostname = 'google-public-dns-a.google.com.'
assert_equal(command_hostname, hostname,
"Can't resolve hostname")
@logwrap
def external_ntp_check(remote_slave, vip):
logger.info("External ntp check")
ext_ntp_ip = ''.join(
remote_slave.execute("awk '/^server +{0}/{{print $2}}' "
"/etc/ntp.conf".
format(EXTERNAL_NTP))["stdout"]).rstrip()
assert_equal(ext_ntp_ip, EXTERNAL_NTP,
"/etc/ntp.conf does not contain external ntp ip")
status = "ntpdate -s {0}".format(vip)
try:
wait(
lambda: not remote_slave.execute(status)['exit_code'], timeout=120)
except Exception as e:
logger.error(e)
a = remote_slave.execute(status)
assert_equal(a['exit_code'], 0,
"Failed update ntp")

View File

@ -365,6 +365,10 @@ class FuelWebClient(object):
section = 'vcenter'
if option == 'assign_to_all_nodes':
section = 'public_network_assignment'
if option in ('dns_list'):
section = 'external_dns'
if option in ('ntp_list'):
section = 'external_ntp'
if section:
attributes['editable'][section][option]['value'] =\
settings[option]

View File

@ -361,3 +361,6 @@ CUSTOM_ENV = os.environ.get('CUSTOM_ENV', 'false') == 'true'
BUILD_IMAGES = os.environ.get('BUILD_IMAGES', 'false') == 'true'
STORE_ASTUTE_YAML = os.environ.get('STORE_ASTUTE_YAML', 'false') == 'true'
EXTERNAL_DNS = os.environ.get('EXTERNAL_DNS', '208.67.220.220')
EXTERNAL_NTP = os.environ.get('EXTERNAL_NTP', 'ua.pool.ntp.org')

View File

@ -16,7 +16,9 @@ from proboscis.asserts import assert_equal
from proboscis import test
from fuelweb_test.helpers import common
from fuelweb_test.helpers import checkers
from fuelweb_test.helpers import os_actions
from fuelweb_test.helpers.decorators import log_snapshot_on_error
from fuelweb_test import settings
from fuelweb_test import logger
from fuelweb_test.tests import base_test_case
@ -94,3 +96,87 @@ class DeployHAOneControllerMasterNodeFail(base_test_case.TestBasic):
# delete instance
common_func.delete_instance(server)
@test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_5],
groups=["deploy_ha_flat_dns_ntp"])
@log_snapshot_on_error
def deploy_ha_flat_dns_ntp(self):
"""Use external ntp and dns in ha mode
Scenario:
1. Create cluster
2 Configure external NTP,DNS settings
3. Add 3 nodes with controller roles
4. Add 2 nodes with compute roles
5. Deploy the cluster
"""
self.env.revert_snapshot("ready_with_5_slaves")
cluster_id = self.fuel_web.create_cluster(
name=self.__class__.__name__,
mode=settings.DEPLOYMENT_MODE_HA,
settings={
'ntp_list': settings.EXTERNAL_NTP,
'dns_list': settings.EXTERNAL_DNS
}
)
self.fuel_web.update_nodes(
cluster_id,
{
'slave-01': ['controller'],
'slave-02': ['controller'],
'slave-03': ['controller'],
'slave-04': ['compute'],
'slave-05': ['compute']
}
)
self.fuel_web.deploy_cluster_wait(cluster_id)
os_conn = os_actions.OpenStackActions(self.fuel_web.
get_public_vip(cluster_id))
self.fuel_web.assert_cluster_ready(
os_conn, smiles_count=16, networks_count=1, timeout=300)
self.env.make_snapshot("deploy_ha_flat_dns_ntp", is_make=True)
@test(depends_on=[deploy_ha_flat_dns_ntp],
groups=["external_dns_ha_flat"])
@log_snapshot_on_error
def external_dns_ha_flat(self):
"""Check external dns in ha mode
Scenario:
1. Revert cluster
2. Shutdown dnsmasq
3. Check dns resolution
"""
self.env.revert_snapshot("deploy_ha_flat_dns_ntp")
remote = self.env.get_admin_remote()
remote_slave = self.env.get_ssh_to_remote_by_name('slave-01')
remote.execute("dockerctl shell cobbler killall dnsmasq")
checkers.external_dns_check(remote_slave)
@test(depends_on=[deploy_ha_flat_dns_ntp],
groups=["external_ntp_ha_flat"])
@log_snapshot_on_error
def external_ntp_ha_flat(self):
"""Check external ntp in ha mode
Scenario:
1. Create cluster
2. Shutdown ntpd
3. Check ntp update
"""
self.env.revert_snapshot("deploy_ha_flat_dns_ntp")
cluster_id = self.fuel_web.get_last_created_cluster()
remote = self.env.get_admin_remote()
remote_slave = self.env.get_ssh_to_remote_by_name('slave-01')
vip = self.fuel_web.get_public_vip(cluster_id)
remote.execute("pkill -9 ntpd")
checkers.external_ntp_check(remote_slave, vip)