From be71965998364bf8e6415bd38b75c84b63aab867 Mon Sep 17 00:00:00 2001 From: Sergey Murashov Date: Wed, 30 Jul 2014 11:30:07 +0400 Subject: [PATCH] Add port check for murano deployment tests - Refactor _try_port method - Move _try_port method from savanna to NovaNetworkScenarioTest - Change murano base class inheritance, now murano inherit from NovaNetworkScenarioTest - Add ports check method which allow us to check needed ports - Add "assignFloatingIp" in jsons for murano services(Telnet and Apache) Change-Id: Icb2743e1e84b664542d7bdec4551a974c84a87e9 Implements-blueprint: additional-checks-for-murano-engine-tests --- fuel_health/murano.py | 34 +++++++++++++---- fuel_health/nmanager.py | 25 ++++++++++++ fuel_health/sahara.py | 21 +--------- .../test_platform_murano_linux.py | 38 +++++++++++++------ 4 files changed, 79 insertions(+), 39 deletions(-) diff --git a/fuel_health/murano.py b/fuel_health/murano.py index 0fda3cf1..5d8bd1dd 100644 --- a/fuel_health/murano.py +++ b/fuel_health/murano.py @@ -26,7 +26,7 @@ import fuel_health.nmanager LOG = logging.getLogger(__name__) -class MuranoTest(fuel_health.nmanager.OfficialClientTest): +class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass): """ Manager that provides access to the Murano python client for calling Murano API. @@ -72,7 +72,6 @@ class MuranoTest(fuel_health.nmanager.OfficialClientTest): This method allows to clean up the OpenStack environment after the Murano OSTF tests. """ - super(MuranoTest, self).tearDown() if self.flavor_reqs: self.compute_client.flavors.delete(self.flavor.id) @@ -84,6 +83,8 @@ class MuranoTest(fuel_health.nmanager.OfficialClientTest): except: LOG.warning(traceback.format_exc()) + super(MuranoTest, self).tearDown() + def find_murano_image(self, image_type): """ This method allows to find Windows images with Murano tag. @@ -297,14 +298,14 @@ class MuranoTest(fuel_health.nmanager.OfficialClientTest): Input parameters: environment_id - ID of environment - Returns 'OK'. + Returns environment. """ - infa = self.get_environment(environment_id) - while infa['status'] != 'ready': + environment = self.get_environment(environment_id) + while environment['status'] != 'ready': time.sleep(5) - infa = self.get_environment(environment_id) - return 'OK' + environment = self.get_environment(environment_id) + return environment def deployments_status_check(self, environment_id): """ @@ -327,7 +328,24 @@ class MuranoTest(fuel_health.nmanager.OfficialClientTest): headers=self.headers).json() LOG.debug("Reports: {0}".format(r)) - assert depl['state'] == 'success' + self.assertEqual('success', depl['state']) + return 'OK' + + def ports_check(self, environment, ports): + """ + This method allows to check that needed ports are opened. + + Input parameters: + environment - Murano environment + ports - list of needed ports + + Returns 'OK'. + """ + check_ip = environment['services'][0]['instance']['floatingIpAddress'] + + for port in ports: + self.assertTrue(self._try_port(check_ip, port)) + return 'OK' def get_list_packages(self): diff --git a/fuel_health/nmanager.py b/fuel_health/nmanager.py index a3449d80..f28cda7a 100644 --- a/fuel_health/nmanager.py +++ b/fuel_health/nmanager.py @@ -652,6 +652,31 @@ class NovaNetworkScenarioTest(OfficialClientTest): cls._clean_flavors() +class PlatformServicesBaseClass(NovaNetworkScenarioTest): + + def _try_port(self, host, port): + start_time = time.time() + delta = time.time() - start_time + + while delta < 600: + cmd = ("timeout 60 bash -c 'echo >/dev/" + "tcp/{0}/{1}'; echo $?".format(host, port)) + + output, output_err = self._run_ssh_cmd(cmd) + print('NC output after %s seconds is "%s"' % (delta, output)) + LOG.debug('NC output after %s seconds is "%s"', + delta, output) + + if output or str(output_err).find(' succeeded!') > 0: + return True + + time.sleep(10) + delta = time.time() - start_time + + self.fail('On host %s port %s is not opened ' + 'more then 10 minutes' % (host, port)) + + class SanityChecksTest(OfficialClientTest): """ Base class for openstack sanity tests diff --git a/fuel_health/sahara.py b/fuel_health/sahara.py index c8114651..651e3daa 100644 --- a/fuel_health/sahara.py +++ b/fuel_health/sahara.py @@ -26,7 +26,8 @@ import fuel_health.nmanager as nmanager LOG = logging.getLogger(__name__) -class SaharaTest(nmanager.NovaNetworkScenarioTest): +class SaharaTest(nmanager.PlatformServicesBaseClass): + """ Base class for openstack sanity tests for Sahara """ @@ -241,24 +242,6 @@ class SaharaTest(nmanager.NovaNetworkScenarioTest): 'node_info': node_info } - def _try_port(self, host, port): - i = 0 - while True: - cmd = ("timeout 60 bash -c 'echo >/dev/" - "tcp/{0}/{1}'; echo $?".format(host, port)) - output, output_err = self._run_ssh_cmd(cmd) - print('NC output after %s seconds is "%s"' % (i * 10, output)) - LOG.debug('NC output after %s seconds is "%s"', - i * 10, output) - if output or str(output_err).find(' succeeded!') > 0: - break - if not output and i > 600: - self.fail('On host %s port %s is not opened ' - 'more then 10 minutes' % (host, port)) - time.sleep(10) - i += 1 - return True - def _check_auto_assign_floating_ip(self): cmd_nova = ('grep auto_assign_floating_ip ' '/etc/nova/nova.conf | grep True') diff --git a/fuel_health/tests/platform_tests/test_platform_murano_linux.py b/fuel_health/tests/platform_tests/test_platform_murano_linux.py index 97720ed7..53b6e26c 100644 --- a/fuel_health/tests/platform_tests/test_platform_murano_linux.py +++ b/fuel_health/tests/platform_tests/test_platform_murano_linux.py @@ -64,9 +64,10 @@ class MuranoDeployLinuxServicesTests(murano.MuranoTest): 4. Request to deploy session. 5. Checking environment status. 6. Checking deployments status - 7. Send request to delete environment. + 7. Checking ports + 8. Send request to delete environment. - Duration: 920 s. + Duration: 1520 s. Deployment tags: Murano, Heat """ @@ -85,6 +86,7 @@ class MuranoDeployLinuxServicesTests(murano.MuranoTest): "instance": { "flavor": self.flavor_name, "image": self.image.name, + "assignFloatingIp": True, "?": { "type": "io.murano.resources.Instance", "id": str(uuid.uuid4()) @@ -113,18 +115,23 @@ class MuranoDeployLinuxServicesTests(murano.MuranoTest): self.environment['id'], session['id']) fail_msg = "Deployment was not completed correctly. " - self.verify(900, self.deploy_check, - 5, fail_msg, 'deployment is going', - self.environment['id']) + environment = self.verify(900, self.deploy_check, + 5, fail_msg, 'deployment is going', + self.environment['id']) self.verify(5, self.deployments_status_check, 6, fail_msg, 'Check deployments status', self.environment['id']) + self.verify(600, self.ports_check, + 7, fail_msg, + 'Check that needed ports are opened', + environment, ['23']) + fail_msg = "Can't delete environment. " self.verify(5, self.delete_environment, - 7, fail_msg, "deleting environment", + 8, fail_msg, "deleting environment", self.environment['id']) def test_deploy_apache_service(self): @@ -138,9 +145,10 @@ class MuranoDeployLinuxServicesTests(murano.MuranoTest): 4. Request to deploy session. 5. Checking environment status. 6. Checking deployments status - 7. Send request to delete environment. + 7. Checking ports + 8. Send request to delete environment. - Duration: 920 s. + Duration: 1520 s. Deployment tags: Murano, Heat """ @@ -159,6 +167,7 @@ class MuranoDeployLinuxServicesTests(murano.MuranoTest): "instance": { "flavor": self.flavor_name, "image": self.image.name, + "assignFloatingIp": True, "?": { "type": "io.murano.resources.Instance", "id": str(uuid.uuid4()) @@ -187,16 +196,21 @@ class MuranoDeployLinuxServicesTests(murano.MuranoTest): self.environment['id'], session['id']) fail_msg = "Deployment was not completed correctly. " - self.verify(900, self.deploy_check, - 5, fail_msg, 'deployment is going', - self.environment['id']) + environment = self.verify(900, self.deploy_check, + 5, fail_msg, 'deployment is going', + self.environment['id']) self.verify(5, self.deployments_status_check, 6, fail_msg, 'Check deployments status', self.environment['id']) + self.verify(600, self.ports_check, + 7, fail_msg, + 'Check that needed ports are opened', + environment, ['80']) + fail_msg = "Can't delete environment. " self.verify(5, self.delete_environment, - 7, fail_msg, "deleting environment", + 8, fail_msg, "deleting environment", self.environment['id'])