From 32f8880e4e034fec50215ca8bc4498900cc4a638 Mon Sep 17 00:00:00 2001 From: Ignatious Johnson Christopher Date: Mon, 21 Mar 2016 21:43:35 +0000 Subject: [PATCH] Removing distribute from test-requirements, becaause distribute is deprecated in favour of setuptools python-keystoneclient latest has moved middleware to keystonemiddleware. fixing it in unit-test and code. Also detecting failure of .venv building is broken so invoke testr run with pipefail. Closes-Bug: 1559867 Fixes: API server: A slash is appended to vhost name for accessing rabbitmq RabbitMQ URL has an extra / which fails RMQ connection Closes-Bug:1477814 Change-Id: I8a82905ff960cf73ec8f4d6702ae8d2b087adbfa --- src/api-lib/run_tests.sh | 4 +- src/api-lib/setup.py | 4 +- src/api-lib/test-requirements.txt | 2 - src/config/api-server/requirements.txt | 2 +- src/config/api-server/run_tests.sh | 4 +- src/config/api-server/setup.py | 4 +- src/config/api-server/test-requirements.txt | 2 +- .../api-server/tests/test_crud_basic.py | 4 +- src/config/api-server/tests/test_ip_alloc.py | 180 +++++++++--------- src/config/api-server/tests/test_kombu.py | 2 +- src/config/api-server/vnc_auth_keystone.py | 7 +- src/config/api-server/vnc_cfg_api_server.py | 15 +- src/config/common/test-requirements.txt | 1 - src/config/common/tests/tools/colorizer.py | 6 +- src/config/device-manager/run_tests.sh | 4 +- src/config/device-manager/setup.py | 4 +- src/config/schema-transformer/run_tests.sh | 4 +- src/config/schema-transformer/setup.py | 4 +- .../schema-transformer/test-requirements.txt | 2 +- src/config/svc-monitor/run_tests.sh | 4 +- src/config/svc-monitor/setup.py | 4 +- .../svc_monitor/tests/test_snat.py | 45 ++++- .../tests/test_virtual_machine_manager.py | 59 +++++- .../tests/test_vrouter_instance_manager.py | 41 +++- src/config/svc-monitor/test-requirements.txt | 1 - src/config/vnc_openstack/run_tests.sh | 4 +- src/config/vnc_openstack/setup.py | 4 +- .../vnc_openstack/test-requirements.txt | 3 +- src/discovery/run_tests.sh | 4 +- src/discovery/setup.py | 4 +- src/discovery/test-requirements.txt | 1 - 31 files changed, 285 insertions(+), 144 deletions(-) diff --git a/src/api-lib/run_tests.sh b/src/api-lib/run_tests.sh index 1a5b4cdb6be..2260528e44b 100755 --- a/src/api-lib/run_tests.sh +++ b/src/api-lib/run_tests.sh @@ -148,9 +148,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/api-lib/setup.py b/src/api-lib/setup.py index 54023bd3659..180875e0296 100644 --- a/src/api-lib/setup.py +++ b/src/api-lib/setup.py @@ -13,7 +13,9 @@ def initialize_options(self): def finalize_options(self): pass def run(self): - os.system('./run_tests.sh -V') + rc_sig = os.system('./run_tests.sh -V') + if rc_sig >> 8: + os._exit(rc_sig>>8) with open('test.log') as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/api-lib/test-requirements.txt b/src/api-lib/test-requirements.txt index 0b94c454dc8..b21ee45cd71 100644 --- a/src/api-lib/test-requirements.txt +++ b/src/api-lib/test-requirements.txt @@ -4,5 +4,3 @@ flexmock coverage pyaml httpretty==0.8.10 -distribute>=0.7.3 - diff --git a/src/config/api-server/requirements.txt b/src/config/api-server/requirements.txt index 91bcbb1eab3..cac6abaa4ac 100644 --- a/src/config/api-server/requirements.txt +++ b/src/config/api-server/requirements.txt @@ -4,7 +4,7 @@ discoveryclient sandesh sandesh-common lxml>=2.3.3 -gevent +gevent==1.1a2 geventhttpclient==1.0a pycassa>=1.7.2 netaddr>=0.7.5 diff --git a/src/config/api-server/run_tests.sh b/src/config/api-server/run_tests.sh index 3eca5c612c0..a7d452eecf8 100755 --- a/src/config/api-server/run_tests.sh +++ b/src/config/api-server/run_tests.sh @@ -153,9 +153,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/config/api-server/setup.py b/src/config/api-server/setup.py index 07b54bc27d3..bdec0e7aa1c 100644 --- a/src/config/api-server/setup.py +++ b/src/config/api-server/setup.py @@ -12,7 +12,9 @@ def initialize_options(self): def finalize_options(self): self.cwd = os.getcwd() def run(self): - os.system('./run_tests.sh -V') + rc_sig = os.system('./run_tests.sh -V') + if rc_sig >> 8: + os._exit(rc_sig>>8) with open('test.log') as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/config/api-server/test-requirements.txt b/src/config/api-server/test-requirements.txt index a2a57334019..f0f550f41b6 100644 --- a/src/config/api-server/test-requirements.txt +++ b/src/config/api-server/test-requirements.txt @@ -5,4 +5,4 @@ flexmock coverage webtest pyaml -distribute>=0.7.3 +keystonemiddleware diff --git a/src/config/api-server/tests/test_crud_basic.py b/src/config/api-server/tests/test_crud_basic.py index e8c4815fe34..d89bff67a7d 100644 --- a/src/config/api-server/tests/test_crud_basic.py +++ b/src/config/api-server/tests/test_crud_basic.py @@ -1412,7 +1412,7 @@ def stub(*args, **kwargs): with test_common.flexmocks([ (self._api_server._db_conn, 'dbe_create', stub), (self._api_server.get_resource_class('virtual-network'), - 'post_dbe_create', stub)]): + 'http_post_collection', stub)]): self._create_test_object() with ExpectedException(RefsExistError) as e: self._create_test_object() @@ -1566,7 +1566,7 @@ def __init__(self, *args, **kwargs): ('KEYSTONE', 'admin_password', 'bar'),]) def setup_flexmock(self): - from keystoneclient.middleware import auth_token + from keystonemiddleware import auth_token class FakeAuthProtocol(object): def __init__(self, app, *args, **kwargs): self._app = app diff --git a/src/config/api-server/tests/test_ip_alloc.py b/src/config/api-server/tests/test_ip_alloc.py index 35e1016a12f..d0337e8431e 100644 --- a/src/config/api-server/tests/test_ip_alloc.py +++ b/src/config/api-server/tests/test_ip_alloc.py @@ -42,26 +42,26 @@ class TestIpAlloc(test_case.ApiServerTestCase): def test_ip_alloction(self): - print 'test ip allocation' + logger.debug('test ip allocation') # Create Domain domain = Domain('my-v4-v6-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('my-v4-v6-proj', domain) self._vnc_lib.project_create(project) - print 'Created Project' + logger.debug('Created Project') # Create NetworkIpam ipam = NetworkIpam('default-network-ipam', project, IpamType("dhcp")) self._vnc_lib.network_ipam_create(ipam) - print 'Created network ipam' + logger.debug('Created network ipam') ipam = self._vnc_lib.network_ipam_read(fq_name=['my-v4-v6-domain', 'my-v4-v6-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') # Create subnets ipam_sn_v4 = IpamSubnetType(subnet=SubnetType('11.1.1.0', 24)) @@ -71,18 +71,18 @@ def test_ip_alloction(self): vn = VirtualNetwork('my-v4-v6-vn', project) vn.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4, ipam_sn_v6])) self._vnc_lib.virtual_network_create(vn) - print 'Created Virtual Network object', vn.uuid + logger.debug('Created Virtual Network object %s', vn.uuid) net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid) # Create v4 Ip object ip_obj1 = InstanceIp(name=str(uuid.uuid4()), instance_ip_family='v4') ip_obj1.uuid = ip_obj1.name - print 'Created Instance IP object 1 ', ip_obj1.uuid + logger.debug('Created Instance IP object 1 %s', ip_obj1.uuid) # Create v6 Ip object ip_obj2 = InstanceIp(name=str(uuid.uuid4()), instance_ip_family='v6') ip_obj2.uuid = ip_obj2.name - print 'Created Instance IP object 2', ip_obj2.uuid + logger.debug('Created Instance IP object 2 %s', ip_obj2.uuid) # Create VM vm_inst_obj1 = VirtualMachine(str(uuid.uuid4())) @@ -100,35 +100,35 @@ def test_ip_alloction(self): ip_obj2.set_virtual_network(net_obj) port_id1 = self._vnc_lib.virtual_machine_interface_create(port_obj1) - print 'Allocating an IP4 address for first VM' + logger.debug('Allocating an IP4 address for first VM') ip_id1 = self._vnc_lib.instance_ip_create(ip_obj1) ip_obj1 = self._vnc_lib.instance_ip_read(id=ip_id1) ip_addr1 = ip_obj1.get_instance_ip_address() - print ' got v4 IP Address for first instance', ip_addr1 + logger.debug(' got v4 IP Address for first instance %s', ip_addr1) if ip_addr1 != '11.1.1.253': - print 'Allocation failed, expected v4 IP Address 11.1.1.253' + logger.debug('Allocation failed, expected v4 IP Address 11.1.1.253') - print 'Allocating an IP6 address for first VM' + logger.debug('Allocating an IP6 address for first VM') ip_id2 = self._vnc_lib.instance_ip_create(ip_obj2) ip_obj2 = self._vnc_lib.instance_ip_read(id=ip_id2) ip_addr2 = ip_obj2.get_instance_ip_address() - print ' got v6 IP Address for first instance', ip_addr2 + logger.debug(' got v6 IP Address for first instance %s', ip_addr2) if ip_addr2 != 'fd14::fd': - print 'Allocation failed, expected v6 IP Address fd14::fd' + logger.debug('Allocation failed, expected v6 IP Address fd14::fd') # Read gateway ip address - print 'Read default gateway ip address' + logger.debug('Read default gateway ip address' ) ipam_refs = net_obj.get_network_ipam_refs() for ipam_ref in ipam_refs: subnets = ipam_ref['attr'].get_ipam_subnets() for subnet in subnets: - print 'Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), + logger.debug('Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), subnet.subnet.get_ip_prefix_len(), - subnet.get_default_gateway()) + subnet.get_default_gateway())) #cleanup - print 'Cleaning up' + logger.debug('Cleaning up') self._vnc_lib.instance_ip_delete(id=ip_id1) self._vnc_lib.instance_ip_delete(id=ip_id2) self._vnc_lib.virtual_machine_interface_delete(id=port_obj1.uuid) @@ -140,26 +140,26 @@ def test_ip_alloction(self): #end def test_ip_alloction_pools(self): - print 'test ip allocation' + logger.debug('test ip allocation') # Create Domain domain = Domain('my-v4-v6-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('my-v4-v6-proj', domain) self._vnc_lib.project_create(project) - print 'Created Project' + logger.debug('Created Project') # Create NetworkIpam ipam = NetworkIpam('default-network-ipam', project, IpamType("dhcp")) self._vnc_lib.network_ipam_create(ipam) - print 'Created network ipam' + logger.debug('Created network ipam') ipam = self._vnc_lib.network_ipam_read(fq_name=['my-v4-v6-domain', 'my-v4-v6-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') # Create subnets alloc_pool_list = [] @@ -177,18 +177,18 @@ def test_ip_alloction_pools(self): vn = VirtualNetwork('my-v4-v6-vn', project) vn.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4, ipam_sn_v6])) self._vnc_lib.virtual_network_create(vn) - print 'Created Virtual Network object', vn.uuid + logger.debug('Created Virtual Network object %s', vn.uuid) net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid) # Create v4 Ip object ip_obj1 = InstanceIp(name=str(uuid.uuid4()), instance_ip_family='v4') ip_obj1.uuid = ip_obj1.name - print 'Created Instance IP object 1 ', ip_obj1.uuid + logger.debug('Created Instance IP object 1 %s', ip_obj1.uuid) # Create v6 Ip object ip_obj2 = InstanceIp(name=str(uuid.uuid4()), instance_ip_family='v6') ip_obj2.uuid = ip_obj2.name - print 'Created Instance IP object 2', ip_obj2.uuid + logger.debug('Created Instance IP object 2 %s', ip_obj2.uuid) # Create VM vm_inst_obj1 = VirtualMachine(str(uuid.uuid4())) @@ -206,35 +206,35 @@ def test_ip_alloction_pools(self): ip_obj2.set_virtual_network(net_obj) port_id1 = self._vnc_lib.virtual_machine_interface_create(port_obj1) - print 'Allocating an IP4 address for first VM' + logger.debug('Allocating an IP4 address for first VM') ip_id1 = self._vnc_lib.instance_ip_create(ip_obj1) ip_obj1 = self._vnc_lib.instance_ip_read(id=ip_id1) ip_addr1 = ip_obj1.get_instance_ip_address() - print 'got v4 IP Address for first instance', ip_addr1 + logger.debug('got v4 IP Address for first instance %s', ip_addr1) if ip_addr1 != '11.1.1.20': - print 'Allocation failed, expected v4 IP Address 11.1.1.20' - - print 'Allocating an IP6 address for first VM' + logger.debug('Allocation failed, expected v4 IP Address 11.1.1.20') + + logger.debug('Allocating an IP6 address for first VM') ip_id2 = self._vnc_lib.instance_ip_create(ip_obj2) ip_obj2 = self._vnc_lib.instance_ip_read(id=ip_id2) ip_addr2 = ip_obj2.get_instance_ip_address() - print 'got v6 IP Address for first instance', ip_addr2 + logger.debug('got v6 IP Address for first instance %s', ip_addr2) if ip_addr2 != 'fd14::30': - print 'Allocation failed, expected v6 IP Address fd14::30' + logger.debug('Allocation failed, expected v6 IP Address fd14::30') # Read gateway ip address - print 'Read default gateway ip address' + logger.debug('Read default gateway ip address' ) ipam_refs = net_obj.get_network_ipam_refs() for ipam_ref in ipam_refs: subnets = ipam_ref['attr'].get_ipam_subnets() for subnet in subnets: - print 'Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), + logger.debug('Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), subnet.subnet.get_ip_prefix_len(), - subnet.get_default_gateway()) + subnet.get_default_gateway())) #cleanup - print 'Cleaning up' + logger.debug('Cleaning up') #cleanup subnet and allocation pools self._vnc_lib.instance_ip_delete(id=ip_id1) self._vnc_lib.instance_ip_delete(id=ip_id2) @@ -247,26 +247,26 @@ def test_ip_alloction_pools(self): #end def test_subnet_gateway_ip_alloc(self): - print 'test ip allocation' + logger.debug('test ip allocation') # Create Domain domain = Domain('my-v4-v6-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('my-v4-v6-proj', domain) self._vnc_lib.project_create(project) - print 'Created Project' + logger.debug('Created Project') # Create NetworkIpam ipam = NetworkIpam('default-network-ipam', project, IpamType("dhcp")) self._vnc_lib.network_ipam_create(ipam) - print 'Created network ipam' + logger.debug('Created network ipam') ipam = self._vnc_lib.network_ipam_read(fq_name=['my-v4-v6-domain', 'my-v4-v6-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') # Create subnets alloc_pool_list = [] @@ -284,28 +284,28 @@ def test_subnet_gateway_ip_alloc(self): vn = VirtualNetwork('my-v4-v6-vn', project) vn.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4, ipam_sn_v6])) self._vnc_lib.virtual_network_create(vn) - print 'Created Virtual Network object', vn.uuid + logger.debug('Created Virtual Network object %s', vn.uuid) net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid) # Read gateway ip address - print 'Read default gateway ip address' + logger.debug('Read default gateway ip address') ipam_refs = net_obj.get_network_ipam_refs() for ipam_ref in ipam_refs: subnets = ipam_ref['attr'].get_ipam_subnets() for subnet in subnets: - print 'Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), + logger.debug('Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), subnet.subnet.get_ip_prefix_len(), - subnet.get_default_gateway()) + subnet.get_default_gateway())) if subnet.subnet.get_ip_prefix() == '11.1.1.0': if subnet.get_default_gateway() != '11.1.1.1': - print ' Failure, expected gateway ip address 11.1.1.1' + logger.debug(' Failure, expected gateway ip address 11.1.1.1') if subnet.subnet.get_ip_prefix() == 'fd14::': if subnet.get_default_gateway() != 'fd14::1': - print ' Failure, expected gateway ip address fd14::1' + logger.debug(' Failure, expected gateway ip address fd14::1') #cleanup - print 'Cleaning up' + logger.debug('Cleaning up') self._vnc_lib.virtual_network_delete(id=vn.uuid) self._vnc_lib.network_ipam_delete(id=ipam.uuid) self._vnc_lib.project_delete(id=project.uuid) @@ -313,26 +313,26 @@ def test_subnet_gateway_ip_alloc(self): #end def test_v4_ip_allocation_exhaust(self): - print 'test ip allocation to cover all ip addresses' + logger.debug('test ip allocation to cover all ip addresses') # Create Domain domain = Domain('v4-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('v4-proj', domain) self._vnc_lib.project_create(project) - print 'Created Project' + logger.debug('Created Project') # Create NetworkIpam ipam = NetworkIpam('default-network-ipam', project, IpamType("dhcp")) self._vnc_lib.network_ipam_create(ipam) - print 'Created network ipam' + logger.debug('Created network ipam') ipam = self._vnc_lib.network_ipam_read(fq_name=['v4-domain', 'v4-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') ip_alloc_from_start = [True, False] for from_start in ip_alloc_from_start: @@ -367,12 +367,12 @@ def test_v4_ip_allocation_exhaust(self): ip_addr_list.reverse() total_addr = len(ip_addr_list) - print 'ip address alloc list:', ip_addr_list[0:total_addr] + logger.debug('ip address alloc list:%s ', ip_addr_list[0:total_addr]) # Create VN vn = VirtualNetwork('v4-vn', project) vn.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4])) self._vnc_lib.virtual_network_create(vn) - print 'Created Virtual Network object', vn.uuid + logger.debug('Created Virtual Network object %s', vn.uuid) net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid) # Create v4 Ip object for all possible addresses in alloc_pool @@ -382,7 +382,7 @@ def test_v4_ip_allocation_exhaust(self): v4_ip_obj_list.append( InstanceIp(name=str(uuid.uuid4()), instance_ip_family='v4')) v4_ip_obj_list[idx].uuid = v4_ip_obj_list[idx].name - print 'Created Instance IP object',idx, v4_ip_obj_list[idx].uuid + logger.debug('Created Instance IP object %s, %s' ,idx, v4_ip_obj_list[idx].uuid) # Create number of VMs to assign ip addresses # to use all addresses in alloc_pool @@ -407,16 +407,16 @@ def test_v4_ip_allocation_exhaust(self): self._vnc_lib.virtual_machine_interface_create(port_list[idx])) ip_ids = [] - print 'Allocating an IP4 address for VMs' + logger.debug('Allocating an IP4 address for VMs') for idx, val in enumerate(ip_addr_list): ip_ids.append( self._vnc_lib.instance_ip_create(v4_ip_obj_list[idx])) v4_ip_obj_list[idx] = self._vnc_lib.instance_ip_read( id=ip_ids[idx]) ip_addr = v4_ip_obj_list[idx].get_instance_ip_address() - print 'got v4 IP Address for instance',idx,':', ip_addr + logger.debug('got v4 IP Address for instance %s:%s' ,idx, ip_addr) if ip_addr != ip_addr_list[idx]: - print 'Allocation failed, expected v4 IP Address:', ip_addr_list[idx] + logger.debug('Allocation failed, expected v4 IP Address: %s', ip_addr_list[idx]) # Delete 2 VMs (With First and Last IP), associated Ports # and instanace IPs, @@ -426,7 +426,7 @@ def test_v4_ip_allocation_exhaust(self): to_modifies = [[0, total_ip_addr-1], [total_ip_addr/2 -1, total_ip_addr/2]] for to_modify in to_modifies: - print 'Delete Instances', to_modify[0], to_modify[1] + logger.debug('Delete Instances %s, %s', to_modify[0], to_modify[1]) for idx, val in enumerate(to_modify): self._vnc_lib.instance_ip_delete(id=ip_ids[val]) ip_ids[val] = None @@ -439,7 +439,7 @@ def test_v4_ip_allocation_exhaust(self): vm_list_v4[val] = None v4_ip_obj_list[val] = None ip_ids[val] = None - print 'Deleted instance',val + logger.debug('Deleted instance %s', val) # Re-create two VMs and assign IP addresses # these should get first and last ip. @@ -460,7 +460,7 @@ def test_v4_ip_allocation_exhaust(self): port_list[val]) v4_ip_obj_list[val].set_virtual_network(net_obj) port_id_list[val] = self._vnc_lib.virtual_machine_interface_create(port_list[val]) - print 'Created instance',val + logger.debug('Created instance %s', val) # Allocate IPs to modified VMs for idx, val in enumerate(to_modify): @@ -468,19 +468,19 @@ def test_v4_ip_allocation_exhaust(self): v4_ip_obj_list[val] = self._vnc_lib.instance_ip_read( id=ip_ids[val]) ip_addr = v4_ip_obj_list[val].get_instance_ip_address() - print 'got v4 IP Address for instance',val,':', ip_addr + logger.debug('got v4 IP Address for instance %s:%s', val, ip_addr) if ip_addr != ip_addr_list[val]: - print 'Allocation failed, expected v4 IP Address:', ip_addr_list[val] + logger.debug('Allocation failed, expected v4 IP Address: %s', ip_addr_list[val]) # negative test. # Create a new VM and try getting a new instance_ip # we should get an exception as alloc_pool is fully exhausted. - print 'Negative Test to create extra instance and try assigning IP address' + logger.debug('Negative Test to create extra instance and try assigning IP address') # Create v4 Ip object ip_obj1 = InstanceIp(name=str(uuid.uuid4()), instance_ip_family='v4') ip_obj1.uuid = ip_obj1.name - print 'Created new Instance IP object', ip_obj1.uuid + logger.debug('Created new Instance IP object %s', ip_obj1.uuid) # Create VM vm_inst_obj1 = VirtualMachine(str(uuid.uuid4())) @@ -495,13 +495,13 @@ def test_v4_ip_allocation_exhaust(self): ip_obj1.set_virtual_machine_interface(port_obj1) ip_obj1.set_virtual_network(net_obj) port_id1 = self._vnc_lib.virtual_machine_interface_create(port_obj1) - print 'Created extra instance' + logger.debug('Created extra instance') - print 'Allocating an IP4 address for extra instance' + logger.debug('Allocating an IP4 address for extra instance') try: ip_id1 = self._vnc_lib.instance_ip_create(ip_obj1) except HttpError: - print 'alloc pool is exhausted' + logger.debug('alloc pool is exhausted') pass # cleanup for negative test @@ -518,7 +518,7 @@ def test_v4_ip_allocation_exhaust(self): instance_ip_address='11.1.1.1', instance_ip_family='v4') ip_obj2.uuid = ip_obj2.name - print 'Created new Instance IP object', ip_obj2.uuid + logger.debug('Created new Instance IP object %s', ip_obj2.uuid) # Create VM vm_inst_obj2 = VirtualMachine(str(uuid.uuid4())) @@ -551,34 +551,34 @@ def test_v4_ip_allocation_exhaust(self): self._vnc_lib.virtual_network_delete(id=vn.uuid) # end of from_start - print 'Cleaning up' + logger.debug('Cleaning up') self._vnc_lib.network_ipam_delete(id=ipam.uuid) self._vnc_lib.project_delete(id=project.uuid) self._vnc_lib.domain_delete(id=domain.uuid) #end def test_req_ip_allocation(self): - print 'test requested ip allocation' + logger.debug('test requested ip allocation') # Create Domain domain = Domain('my-v4-v6-req-ip-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('my-v4-v6-req-ip-proj', domain) self._vnc_lib.project_create(project) - print 'Created Project' + logger.debug('Created Project') # Create NetworkIpam ipam = NetworkIpam('default-network-ipam', project, IpamType("dhcp")) self._vnc_lib.network_ipam_create(ipam) - print 'Created network ipam' + logger.debug('Created network ipam') ipam = self._vnc_lib.network_ipam_read(fq_name=['my-v4-v6-req-ip-domain', 'my-v4-v6-req-ip-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') # Create subnets ipam_sn_v4 = IpamSubnetType(subnet=SubnetType('11.1.1.0', 24)) @@ -588,20 +588,20 @@ def test_req_ip_allocation(self): vn = VirtualNetwork('my-v4-v6-vn', project) vn.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4, ipam_sn_v6])) self._vnc_lib.virtual_network_create(vn) - print 'Created Virtual Network object', vn.uuid + logger.debug('Created Virtual Network object %s', vn.uuid) net_obj = self._vnc_lib.virtual_network_read(id = vn.uuid) # Create v4 Ip object, with v4 requested ip ip_obj1 = InstanceIp(name=str(uuid.uuid4()), instance_ip_address='11.1.1.4', instance_ip_family='v4') ip_obj1.uuid = ip_obj1.name - print 'Created Instance IP object 1 ', ip_obj1.uuid + logger.debug('Created Instance IP object 1 %s', ip_obj1.uuid) # Create v6 Ip object with v6 requested ip ip_obj2 = InstanceIp(name=str(uuid.uuid4()), instance_ip_address='fd14::4', instance_ip_family='v6') ip_obj2.uuid = ip_obj2.name - print 'Created Instance IP object 2', ip_obj2.uuid + logger.debug('Created Instance IP object 2 %s', ip_obj2.uuid) # Create VM vm_inst_obj1 = VirtualMachine(str(uuid.uuid4())) @@ -619,35 +619,35 @@ def test_req_ip_allocation(self): ip_obj2.set_virtual_network(net_obj) port_id1 = self._vnc_lib.virtual_machine_interface_create(port_obj1) - print 'Allocating an IP4 address for first VM' + logger.debug('Allocating an IP4 address for first VM') ip_id1 = self._vnc_lib.instance_ip_create(ip_obj1) ip_obj1 = self._vnc_lib.instance_ip_read(id=ip_id1) ip_addr1 = ip_obj1.get_instance_ip_address() - print ' got v4 IP Address for first instance', ip_addr1 + logger.debug(' got v4 IP Address for first instance %s', ip_addr1) if ip_addr1 != '11.1.1.4': - print 'Allocation failed, expected v4 IP Address 11.1.1.4' + logger.debug('Allocation failed, expected v4 IP Address 11.1.1.4') - print 'Allocating an IP6 address for first VM' + logger.debug('Allocating an IP6 address for first VM') ip_id2 = self._vnc_lib.instance_ip_create(ip_obj2) ip_obj2 = self._vnc_lib.instance_ip_read(id=ip_id2) ip_addr2 = ip_obj2.get_instance_ip_address() - print ' got v6 IP Address for first instance', ip_addr2 + logger.debug(' got v6 IP Address for first instance %s', ip_addr2) if ip_addr2 != 'fd14::4': - print 'Allocation failed, expected v6 IP Address fd14::4' + logger.debug('Allocation failed, expected v6 IP Address fd14::4') # Read gateway ip address - print 'Read default gateway ip address' + logger.debug('Read default gateway ip address') ipam_refs = net_obj.get_network_ipam_refs() for ipam_ref in ipam_refs: subnets = ipam_ref['attr'].get_ipam_subnets() for subnet in subnets: - print 'Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), + logger.debug('Gateway for subnet (%s/%s) is (%s)' %(subnet.subnet.get_ip_prefix(), subnet.subnet.get_ip_prefix_len(), - subnet.get_default_gateway()) + subnet.get_default_gateway())) #cleanup - print 'Cleaning up' + logger.debug('Cleaning up') self._vnc_lib.instance_ip_delete(id=ip_id1) self._vnc_lib.instance_ip_delete(id=ip_id2) self._vnc_lib.virtual_machine_interface_delete(id=port_obj1.uuid) diff --git a/src/config/api-server/tests/test_kombu.py b/src/config/api-server/tests/test_kombu.py index f34748c55de..174455710cb 100644 --- a/src/config/api-server/tests/test_kombu.py +++ b/src/config/api-server/tests/test_kombu.py @@ -38,7 +38,7 @@ def setUp(self): self.db_client_mgr = flexmock(operational=True, _sandesh=None, config_log=lambda *args, **kwargs: None, get_server_port=lambda: 8082) - self._url_template = "pyamqp://%s:%s@%s:%d/%s/" + self._url_template = "pyamqp://%s:%s@%s:%d/%s" self.mock_producer = flexmock(operational = True) self.mock_consumer = flexmock(operational = True) flexmock(vnc_kombu.kombu.Connection, __new__ = lambda *args, **kwargs: self.mock_connect) diff --git a/src/config/api-server/vnc_auth_keystone.py b/src/config/api-server/vnc_auth_keystone.py index d2c7a805e1f..3636bc652fb 100644 --- a/src/config/api-server/vnc_auth_keystone.py +++ b/src/config/api-server/vnc_auth_keystone.py @@ -17,8 +17,11 @@ try: from keystoneclient.middleware import auth_token -except Exception: - pass +except ImportError: + try: + from keystonemiddleware import auth_token + except ImportError: + pass from pysandesh.gen_py.sandesh.ttypes import SandeshLevel from vnc_bottle import get_bottle_server diff --git a/src/config/api-server/vnc_cfg_api_server.py b/src/config/api-server/vnc_cfg_api_server.py index 90bf4aeae2d..5c7b22679b6 100644 --- a/src/config/api-server/vnc_cfg_api_server.py +++ b/src/config/api-server/vnc_cfg_api_server.py @@ -424,23 +424,26 @@ def set_admin_role(*args, **kwargs): # end __init__ def _extensions_transform_request(self, request): - if not self._extension_mgrs['resourceApi'].names(): + extensions = self._extension_mgrs.get('resourceApi') + if not extensions or not extensions.names(): return None - return self._extension_mgrs['resourceApi'].map_method( + return extensions.map_method( 'transform_request', request) # end _extensions_transform_request def _extensions_validate_request(self, request): - if not self._extension_mgrs['resourceApi'].names(): + extensions = self._extension_mgrs.get('resourceApi') + if not extensions or not extensions.names(): return None - return self._extension_mgrs['resourceApi'].map_method( + return extensions.map_method( 'validate_request', request) # end _extensions_validate_request def _extensions_transform_response(self, request, response): - if not self._extension_mgrs['resourceApi'].names(): + extensions = self._extension_mgrs.get('resourceApi') + if not extensions or not extensions.names(): return None - return self._extension_mgrs['resourceApi'].map_method( + return extensions.map_method( 'transform_response', request, response) # end _extensions_transform_response diff --git a/src/config/common/test-requirements.txt b/src/config/common/test-requirements.txt index f73f17260b8..932a8957f78 100644 --- a/src/config/common/test-requirements.txt +++ b/src/config/common/test-requirements.txt @@ -1,2 +1 @@ mock -distribute>=0.7.3 diff --git a/src/config/common/tests/tools/colorizer.py b/src/config/common/tests/tools/colorizer.py index a49abb14176..4eb900447fe 100755 --- a/src/config/common/tests/tools/colorizer.py +++ b/src/config/common/tests/tools/colorizer.py @@ -202,7 +202,11 @@ def _addResult(self, test, *args): name = test.id() except AttributeError: name = 'Unknown.unknown' - test_class, test_name = name.rsplit('.', 1) + try: + test_class, test_name = name.rsplit('.', 1) + except: + test_class = name + test_name = name elapsed = (self._now() - self.start_time).total_seconds() item = (elapsed, test_class, test_name) diff --git a/src/config/device-manager/run_tests.sh b/src/config/device-manager/run_tests.sh index e290952990b..29229887b67 100755 --- a/src/config/device-manager/run_tests.sh +++ b/src/config/device-manager/run_tests.sh @@ -154,9 +154,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/config/device-manager/setup.py b/src/config/device-manager/setup.py index 1d19701401a..2b9e142c3f5 100644 --- a/src/config/device-manager/setup.py +++ b/src/config/device-manager/setup.py @@ -13,7 +13,9 @@ def initialize_options(self): def finalize_options(self): self.cwd = os.getcwd() def run(self): - os.system('./run_tests.sh -V') + rc_sig = os.system('./run_tests.sh -V') + if rc_sig >> 8: + os._exit(rc_sig>>8) with open('test.log') as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/config/schema-transformer/run_tests.sh b/src/config/schema-transformer/run_tests.sh index 3eca5c612c0..a7d452eecf8 100755 --- a/src/config/schema-transformer/run_tests.sh +++ b/src/config/schema-transformer/run_tests.sh @@ -153,9 +153,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/config/schema-transformer/setup.py b/src/config/schema-transformer/setup.py index 8e831ed0c3b..0a0719f09d1 100644 --- a/src/config/schema-transformer/setup.py +++ b/src/config/schema-transformer/setup.py @@ -12,7 +12,9 @@ def initialize_options(self): def finalize_options(self): self.cwd = os.getcwd() def run(self): - os.system('./run_tests.sh -V') + rc_sig = os.system('./run_tests.sh -V') + if rc_sig >> 8: + os._exit(rc_sig>>8) with open('test.log') as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/config/schema-transformer/test-requirements.txt b/src/config/schema-transformer/test-requirements.txt index 76ad5f8c3c3..e3654eb3436 100644 --- a/src/config/schema-transformer/test-requirements.txt +++ b/src/config/schema-transformer/test-requirements.txt @@ -4,10 +4,10 @@ flexmock coverage pyaml python-keystoneclient +keystonemiddleware webtest kazoo jsonpickle -distribute>=0.7.3 ../common/dist/cfgm_common-0.1dev.tar.gz ../../api-lib/dist/vnc_api-0.1dev.tar.gz ../../discovery/client/dist/discoveryclient-0.1dev.tar.gz diff --git a/src/config/svc-monitor/run_tests.sh b/src/config/svc-monitor/run_tests.sh index efb72c7e6c9..ae4929fd67f 100755 --- a/src/config/svc-monitor/run_tests.sh +++ b/src/config/svc-monitor/run_tests.sh @@ -153,9 +153,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/config/svc-monitor/setup.py b/src/config/svc-monitor/setup.py index fb05349f821..1d0a1d68963 100644 --- a/src/config/svc-monitor/setup.py +++ b/src/config/svc-monitor/setup.py @@ -13,7 +13,9 @@ def initialize_options(self): def finalize_options(self): self.cwd = os.getcwd() def run(self): - os.system('./run_tests.sh -V') + rc_sig = os.system('./run_tests.sh -V') + if rc_sig >> 8: + os._exit(rc_sig>>8) with open('test.log') as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/config/svc-monitor/svc_monitor/tests/test_snat.py b/src/config/svc-monitor/svc_monitor/tests/test_snat.py index 050eb224a0a..8142d11b3e7 100644 --- a/src/config/svc-monitor/svc_monitor/tests/test_snat.py +++ b/src/config/svc-monitor/svc_monitor/tests/test_snat.py @@ -73,9 +73,33 @@ def vr_read(vm_id): vr_obj['fq_name'] = ['fake-vr-uuid'] return True, [vr_obj] + def vmi_db_read(vmi_id): + vmi_obj = {} + vmi_obj['uuid'] = 'fake-vmi-uuid' + vmi_obj['fq_name'] = ['fake-vmi-uuid'] + vmi_obj['parent_type'] = 'project' + vmi_obj['parent_uuid'] = 'fake-project' + return True, [vmi_obj] + + def iip_db_read(iip_id): + iip_obj = {} + iip_obj['uuid'] = 'fake-vmi-uuid' + iip_obj['fq_name'] = ['fake-iip-uuid'] + return True, [iip_obj] + + def iip_create(iip_obj): + iip_obj.uuid = 'fake-iip-uuid' + return iip_obj.uuid + VirtualMachineSM._cassandra = mock.MagicMock() VirtualMachineSM._cassandra._cassandra_virtual_machine_read = vm_read + VirtualMachineInterfaceSM._cassandra = mock.MagicMock() + VirtualMachineInterfaceSM._cassandra._cassandra_virtual_machine_interface_read = vmi_db_read + + InstanceIpSM._cassandra = mock.MagicMock() + InstanceIpSM._cassandra._cassandra_instance_ip_read = iip_db_read + VirtualRouterSM._cassandra = mock.MagicMock() VirtualRouterSM._cassandra._cassandra_virtual_router_read = vr_read @@ -86,6 +110,7 @@ def vr_read(vm_id): self.mocked_vnc.fq_name_to_id = get_vn_id self.mocked_vnc.virtual_machine_interface_create = vmi_create self.mocked_vnc.virtual_network_create = vn_create + self.mocked_vnc.instance_ip_create = iip_create self.nova_mock = mock.MagicMock() self.mocked_db = mock.MagicMock() @@ -99,9 +124,18 @@ def vr_read(vm_id): nova_client=self.nova_mock, args=self.mocked_args) def tearDown(self): - ServiceTemplateSM.delete('fake-st-uuid') - ServiceInstanceSM.delete('fake-si-uuid') - pass + ServiceTemplateSM.reset() + ServiceInstanceSM.reset() + InstanceIpSM.reset() + del InstanceIpSM._cassandra + VirtualMachineInterfaceSM.reset() + del VirtualMachineInterfaceSM._cassandra + VirtualMachineSM.reset() + del VirtualMachineSM._cassandra + VirtualRouterSM.reset() + del VirtualRouterSM._cassandra + VirtualNetworkSM.reset() + del VirtualNetworkSM._cassandra def create_test_project(self, fq_name_str): proj_obj = {} @@ -193,4 +227,7 @@ def create_fake_virtual_machine(fq_name_str): self.netns_manager._vnc_lib.virtual_machine_delete\ .assert_called_with(id='fake-vm-uuid') - mocked_vr.del_virtual_machine.assert_called_with(VMObjMatcher('fake-vm-uuid', True)) + self.netns_manager._vnc_lib.ref_update.\ + assert_called_with('virtual-router', 'fake-vr-uuid', + 'virtual-machine', 'fake-vm-uuid', None, 'DELETE') + #mocked_vr.del_virtual_machine.assert_called_with(VMObjMatcher('fake-vm-uuid', True)) diff --git a/src/config/svc-monitor/svc_monitor/tests/test_virtual_machine_manager.py b/src/config/svc-monitor/svc_monitor/tests/test_virtual_machine_manager.py index 60dae8a212a..62ac4904425 100644 --- a/src/config/svc-monitor/svc_monitor/tests/test_virtual_machine_manager.py +++ b/src/config/svc-monitor/svc_monitor/tests/test_virtual_machine_manager.py @@ -4,6 +4,13 @@ from svc_monitor.virtual_machine_manager import VirtualMachineManager from svc_monitor.config_db import * + +def test_get_instance_name(si, inst_count): + name = si.name + '__' + str(inst_count + 1) + instance_name = "__".join(si.fq_name[:-1] + [name]) + return instance_name + + class VMObjMatcher(object): """ Object for assert_called_with to check if vm object is created properly @@ -54,14 +61,57 @@ def vn_create(vn_obj): VirtualNetworkSM.locate(vn_obj.uuid, vn) return + def vm_read(vm_id): + class SI(object): + def __init__(self, name, fq_name): + self.name = name + self.fq_name = fq_name + + vm_obj = {} + vm_obj['uuid'] = 'fake-vm-uuid' + vm_obj['fq_name'] = ['fake-vm-uuid'] + fq_name = ['fake-domain', 'fake-project', 'fake-snat-instance'] + name = 'fake-snat-instance' + si = SI(name, fq_name) + instance_name = test_get_instance_name(si, 0) + vm_obj['display_name'] = instance_name + '__' + 'network-namespace' + return True, [vm_obj] + def vmi_create(vmi_obj): vmi_obj.uuid = 'fake-vmi-uuid' return + def vmi_db_read(vmi_id): + vmi_obj = {} + vmi_obj['uuid'] = 'fake-vmi-uuid' + vmi_obj['fq_name'] = ['fake-vmi-uuid'] + vmi_obj['parent_type'] = 'project' + vmi_obj['parent_uuid'] = 'fake-project' + return True, [vmi_obj] + + def iip_db_read(iip_id): + iip_obj = {} + iip_obj['uuid'] = 'fake-vmi-uuid' + iip_obj['fq_name'] = ['fake-iip-uuid'] + return True, [iip_obj] + + def iip_create(iip_obj): + iip_obj.uuid = 'fake-iip-uuid' + return iip_obj.uuid + + VirtualMachineSM._cassandra = mock.MagicMock() + VirtualMachineSM._cassandra._cassandra_virtual_machine_read = vm_read + + VirtualMachineInterfaceSM._cassandra = mock.MagicMock() + VirtualMachineInterfaceSM._cassandra._cassandra_virtual_machine_interface_read = vmi_db_read + + InstanceIpSM._cassandra = mock.MagicMock() + InstanceIpSM._cassandra._cassandra_instance_ip_read = iip_db_read self.mocked_vnc = mock.MagicMock() self.mocked_vnc.fq_name_to_id = get_vn_id self.mocked_vnc.virtual_network_create = vn_create self.mocked_vnc.virtual_machine_interface_create = vmi_create + self.mocked_vnc.instance_ip_create = iip_create self.nova_mock = mock.MagicMock() self.mocked_db = mock.MagicMock() @@ -75,9 +125,12 @@ def vmi_create(vmi_obj): nova_client=self.nova_mock, args=self.mocked_args) def tearDown(self): - ServiceTemplateSM.delete('fake-st-uuid') - ServiceInstanceSM.delete('fake-si-uuid') - pass + ServiceTemplateSM.reset() + ServiceInstanceSM.reset() + InstanceIpSM.reset() + VirtualMachineInterfaceSM.reset() + VirtualMachineSM.reset() + del VirtualMachineSM._cassandra def create_test_project(self, fq_name_str): proj_obj = {} diff --git a/src/config/svc-monitor/svc_monitor/tests/test_vrouter_instance_manager.py b/src/config/svc-monitor/svc_monitor/tests/test_vrouter_instance_manager.py index 7f5dbe42e4a..27cd3364580 100644 --- a/src/config/svc-monitor/svc_monitor/tests/test_vrouter_instance_manager.py +++ b/src/config/svc-monitor/svc_monitor/tests/test_vrouter_instance_manager.py @@ -58,6 +58,14 @@ def vmi_create(vmi_obj): vmi_obj.uuid = 'fake-vmi-uuid' return + def vmi_db_read(vmi_id): + vmi_obj = {} + vmi_obj['uuid'] = 'fake-vmi-uuid' + vmi_obj['fq_name'] = ['fake-vmi-uuid'] + vmi_obj['parent_type'] = 'project' + vmi_obj['parent_uuid'] = 'fake-project' + return True, [vmi_obj] + def vm_read(vm_id): class SI(object): def __init__(self, name, fq_name): @@ -80,15 +88,32 @@ def vr_read(vm_id): vr_obj['fq_name'] = ['fake-vr-uuid'] return True, [vr_obj] + def iip_db_read(iip_id): + iip_obj = {} + iip_obj['uuid'] = 'fake-vmi-uuid' + iip_obj['fq_name'] = ['fake-iip-uuid'] + return True, [iip_obj] + + def iip_create(iip_obj): + iip_obj.uuid = 'fake-iip-uuid' + return iip_obj.uuid + VirtualMachineSM._cassandra = mock.MagicMock() VirtualMachineSM._cassandra._cassandra_virtual_machine_read = vm_read + VirtualMachineInterfaceSM._cassandra = mock.MagicMock() + VirtualMachineInterfaceSM._cassandra._cassandra_virtual_machine_interface_read = vmi_db_read + + InstanceIpSM._cassandra = mock.MagicMock() + InstanceIpSM._cassandra._cassandra_instance_ip_read = iip_db_read + VirtualRouterSM._cassandra = mock.MagicMock() VirtualRouterSM._cassandra._cassandra_virtual_router_read = vr_read self.mocked_vnc = mock.MagicMock() self.mocked_vnc.fq_name_to_id = get_vn_id self.mocked_vnc.virtual_machine_interface_create = vmi_create + self.mocked_vnc.instance_ip_create = iip_create self.nova_mock = mock.MagicMock() self.mocked_db = mock.MagicMock() @@ -102,9 +127,15 @@ def vr_read(vm_id): nova_client=self.nova_mock, args=self.mocked_args) def tearDown(self): - ServiceTemplateSM.delete('fake-st-uuid') - ServiceInstanceSM.delete('fake-si-uuid') - pass + ServiceTemplateSM.reset() + ServiceInstanceSM.reset() + InstanceIpSM.reset() + del InstanceIpSM._cassandra + VirtualMachineInterfaceSM.reset() + del VirtualMachineInterfaceSM._cassandra + VirtualMachineSM.reset() + del VirtualMachineSM._cassandra + del VirtualRouterSM._cassandra def create_test_project(self, fq_name_str): proj_obj = {} @@ -193,4 +224,6 @@ def create_fake_virtual_machine(fq_name_str): self.vrouter_manager._vnc_lib.virtual_machine_delete\ .assert_called_with(id='fake-vm-uuid') - mocked_vr.del_virtual_machine.assert_called_with(VMObjMatcher('fake-vm-uuid', True)) + self.vrouter_manager._vnc_lib.ref_update.\ + assert_called_with('virtual-router', 'fake-vr-uuid', + 'virtual-machine', 'fake-vm-uuid', None, 'DELETE') diff --git a/src/config/svc-monitor/test-requirements.txt b/src/config/svc-monitor/test-requirements.txt index 84d93deaaa2..9350cb3db82 100644 --- a/src/config/svc-monitor/test-requirements.txt +++ b/src/config/svc-monitor/test-requirements.txt @@ -6,7 +6,6 @@ bitarray geventhttpclient psutil bottle -distribute>=0.7.3 ../../../debug/config/common/dist/cfgm_common-0.1dev.tar.gz ../../../debug/api-lib/dist/vnc_api-0.1dev.tar.gz ../../../debug/discovery/client/dist/discoveryclient-0.1dev.tar.gz diff --git a/src/config/vnc_openstack/run_tests.sh b/src/config/vnc_openstack/run_tests.sh index 29b0783c58b..1245bc5fe1d 100755 --- a/src/config/vnc_openstack/run_tests.sh +++ b/src/config/vnc_openstack/run_tests.sh @@ -152,9 +152,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/config/vnc_openstack/setup.py b/src/config/vnc_openstack/setup.py index e917ff6af87..ebe9f5e0cc9 100644 --- a/src/config/vnc_openstack/setup.py +++ b/src/config/vnc_openstack/setup.py @@ -15,7 +15,9 @@ def initialize_options(self): def finalize_options(self): self.cwd = os.getcwd() def run(self): - os.system('./run_tests.sh -V') + rc_sig = os.system('./run_tests.sh -V') + if rc_sig >> 8: + os._exit(rc_sig>>8) with open('test.log') as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/config/vnc_openstack/test-requirements.txt b/src/config/vnc_openstack/test-requirements.txt index 192fe3b6558..798f2c94ea3 100644 --- a/src/config/vnc_openstack/test-requirements.txt +++ b/src/config/vnc_openstack/test-requirements.txt @@ -6,7 +6,7 @@ webtest pyaml python-keystoneclient lxml>=2.3.3 -gevent +gevent==1.1a2 geventhttpclient==1.0a pycassa>=1.7.2 netaddr>=0.7.5 @@ -17,7 +17,6 @@ kombu netifaces stevedore testscenarios -distribute>=0.7.3 ../../../../third_party/ifmap-python-client ../../../../distro/third_party/kazoo ../../../../build/debug/config/common/dist/cfgm_common-0.1dev.tar.gz diff --git a/src/discovery/run_tests.sh b/src/discovery/run_tests.sh index 665677aff28..aefe0cd3e3e 100755 --- a/src/discovery/run_tests.sh +++ b/src/discovery/run_tests.sh @@ -153,9 +153,9 @@ function run_tests { then # subunit-2to1 is present, testr subunit stream should be in version 2 # format. Convert to version one before colorizing. - bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} ${tools_path}/tools/colorizer.py" else - bash -c "${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" + bash -c "set -o pipefail && ${wrapper} $TESTRTESTS | ${wrapper} ${tools_path}/tools/colorizer.py" fi RESULT=$? set -e diff --git a/src/discovery/setup.py b/src/discovery/setup.py index 403341dc2ee..9cb79ecf7b3 100644 --- a/src/discovery/setup.py +++ b/src/discovery/setup.py @@ -23,7 +23,9 @@ def run(self): if self.coverage: logfname = 'coveragetest.log' args += ' -c' - os.system('./run_tests.sh %s' % args) + rc_sig = os.system('./run_tests.sh %s' % args) + if rc_sig >> 8: + os._exit(rc_sig>>8) with open(logfname) as f: if not re.search('\nOK', ''.join(f.readlines())): os._exit(1) diff --git a/src/discovery/test-requirements.txt b/src/discovery/test-requirements.txt index 38e72d363ca..779c53ddba9 100644 --- a/src/discovery/test-requirements.txt +++ b/src/discovery/test-requirements.txt @@ -5,7 +5,6 @@ flexmock coverage webtest pyaml -distribute>=0.7.3 lxml kombu kazoo