diff options
-rw-r--r-- | docker/vnf/Dockerfile | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/clearwater.py | 36 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims.py | 8 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/heat_ims.py | 12 | ||||
-rw-r--r-- | functest/tests/unit/vnf/ims/test_clearwater.py | 3 |
5 files changed, 25 insertions, 36 deletions
diff --git a/docker/vnf/Dockerfile b/docker/vnf/Dockerfile index 8395cbfb0..0ec97064a 100644 --- a/docker/vnf/Dockerfile +++ b/docker/vnf/Dockerfile @@ -20,7 +20,7 @@ ENV PATH $GOBIN:$PATH COPY clearwater-heat-singlenet-deps.patch /tmp/clearwater-heat-singlenet-deps.patch COPY cloudify-rest-client-py3.patch /tmp/cloudify-rest-client-py3.patch RUN apk --no-cache add --update \ - ruby ruby-bundler ruby-irb ruby-rdoc dnsmasq \ + ruby ruby-bundler ruby-irb ruby-rdoc \ procps libxslt libxml2 zlib libffi go musl-dev && \ apk --no-cache add --virtual .build-deps --update \ ruby-dev g++ make libxslt-dev libxml2-dev zlib-dev libffi-dev g++ make && \ diff --git a/functest/opnfv_tests/vnf/ims/clearwater.py b/functest/opnfv_tests/vnf/ims/clearwater.py index b05f8e7d6..64f0428b3 100644 --- a/functest/opnfv_tests/vnf/ims/clearwater.py +++ b/functest/opnfv_tests/vnf/ims/clearwater.py @@ -12,9 +12,6 @@ import logging import os import re -import shlex -import shutil -import subprocess import time import pkg_resources @@ -30,7 +27,7 @@ __author__ = ("Valentin Boucher <valentin.boucher@orange.com>, " class ClearwaterTesting(object): """vIMS clearwater base usable by several orchestrators""" - def __init__(self, case_name, ellis_ip): + def __init__(self, case_name, bono_ip, ellis_ip): self.logger = logging.getLogger(__name__) self.case_dir = pkg_resources.resource_filename( 'functest', 'opnfv_tests/vnf/ims') @@ -45,6 +42,7 @@ class ClearwaterTesting(object): os.makedirs(self.result_dir) self.ellis_ip = ellis_ip + self.bono_ip = bono_ip def availability_check(self, signup_code='secret', two_numbers=False): """Create one or two numbers""" @@ -143,9 +141,7 @@ class ClearwaterTesting(object): time.sleep(25) raise Exception('Failed to create a number') - def run_clearwater_live_test(self, dns_ip, public_domain, - bono_ip=None, ellis_ip=None, - signup_code='secret'): + def run_clearwater_live_test(self, public_domain, signup_code='secret'): """Run the Clearwater live tests It first runs dnsmasq to reach clearwater services by FQDN and then the @@ -157,23 +153,14 @@ class ClearwaterTesting(object): """ # pylint: disable=too-many-locals,too-many-arguments self.logger.info('Run Clearwater live test') - dns_file = '/etc/resolv.conf' - dns_file_bak = '/etc/resolv.conf.bak' - self.logger.debug('Backup %s -> %s', dns_file, dns_file_bak) - shutil.copy(dns_file, dns_file_bak) - cmd = ("dnsmasq -d -u root --server=/clearwater.opnfv/{0} " - "-r /etc/resolv.conf.bak".format(dns_ip)) - dnsmasq_process = subprocess.Popen(shlex.split(cmd)) - script = ('echo -e "nameserver {0}" > {1};' - 'cd {2};' - 'rake test[{3}] SIGNUP_CODE={4}' - .format('127.0.0.1', - dns_file, - self.test_dir, + script = ('cd {0};' + 'rake test[{1}] SIGNUP_CODE={2}' + .format(self.test_dir, public_domain, signup_code)) - if bono_ip and ellis_ip: - subscript = ' PROXY={0} ELLIS={1}'.format(bono_ip, ellis_ip) + if self.bono_ip and self.ellis_ip: + subscript = ' PROXY={0} ELLIS={1}'.format( + self.bono_ip, self.ellis_ip) script = '{0}{1}'.format(script, subscript) script = ('{0}{1}'.format(script, ' --trace')) cmd = "/bin/bash -c '{0}'".format(script) @@ -182,11 +169,6 @@ class ClearwaterTesting(object): ft_utils.execute_command(cmd, error_msg='Clearwater live test failed', output_file=output_file) - dnsmasq_process.kill() - with open(dns_file_bak, 'r') as bak_file: - result = bak_file.read() - with open(dns_file, 'w') as dfile: - dfile.write(result) with open(output_file, 'r') as ofile: result = ofile.read() diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index 8e3ec3e2b..288e0316c 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -224,8 +224,10 @@ class CloudifyIms(cloudify.Cloudify): ellis_ip = self.cfy_client.deployments.outputs.get( self.vnf['descriptor'].get('name'))['outputs']['ellis_ip'] - self.clearwater = clearwater.ClearwaterTesting(self.case_name, - ellis_ip) + bono_ip = self.cfy_client.deployments.outputs.get( + self.vnf['descriptor'].get('name'))['outputs']['bono_ip'] + self.clearwater = clearwater.ClearwaterTesting( + self.case_name, bono_ip, ellis_ip) self.clearwater.availability_check() self.details['vnf'].update(status='PASS', @@ -241,7 +243,7 @@ class CloudifyIms(cloudify.Cloudify): if not dns_ip: return False short_result, vnf_test_rate = self.clearwater.run_clearwater_live_test( - dns_ip=dns_ip, public_domain=self.vnf['inputs']["public_domain"]) + public_domain=self.vnf['inputs']["public_domain"]) duration = time.time() - start_time self.__logger.info(short_result) self.details['test_vnf'].update(result=short_result, duration=duration) diff --git a/functest/opnfv_tests/vnf/ims/heat_ims.py b/functest/opnfv_tests/vnf/ims/heat_ims.py index cce1a330b..9ea9c5627 100644 --- a/functest/opnfv_tests/vnf/ims/heat_ims.py +++ b/functest/opnfv_tests/vnf/ims/heat_ims.py @@ -194,12 +194,16 @@ class HeatIms(singlevm.VmReady2): server.name, regex='Cloud-init .* finished at ', loop=1): return False if 'ellis' in server.name: - self.__logger.debug("server: %s", server) + self.__logger.debug("ellis: %s", server) ellis_ip = server.public_v4 + elif 'bono' in server.name: + self.__logger.debug("bono: %s", server) + bono_ip = server.public_v4 assert ellis_ip - self.clearwater = clearwater.ClearwaterTesting(self.case_name, - ellis_ip) + assert bono_ip + self.clearwater = clearwater.ClearwaterTesting( + self.case_name, bono_ip, ellis_ip) # This call can take time and many retry because Heat is # an infrastructure orchestrator so when Heat say "stack created" # it means that all OpenStack ressources are created but not that @@ -222,7 +226,7 @@ class HeatIms(singlevm.VmReady2): if not dns_ip: return False short_result, vnf_test_rate = self.clearwater.run_clearwater_live_test( - dns_ip=dns_ip, public_domain=self.vnf['parameters']["zone"]) + public_domain=self.vnf['parameters']["zone"]) duration = time.time() - start_time self.__logger.info(short_result) self.details['test_vnf'] = dict(result=short_result, duration=duration) diff --git a/functest/tests/unit/vnf/ims/test_clearwater.py b/functest/tests/unit/vnf/ims/test_clearwater.py index 93f8ffe4a..435b172db 100644 --- a/functest/tests/unit/vnf/ims/test_clearwater.py +++ b/functest/tests/unit/vnf/ims/test_clearwater.py @@ -20,7 +20,8 @@ class ClearwaterTesting(unittest.TestCase): def setUp(self): with mock.patch('functest.opnfv_tests.vnf.ims.cloudify_ims.' 'os.makedirs'): - self.ims_vnf = clearwater.ClearwaterTesting("foo", "0.0.0.0") + self.ims_vnf = clearwater.ClearwaterTesting( + "foo", "0.0.0.0", "0.0.0.0") self.mock_post = mock.Mock() attrs = {'status_code': 201, |