diff --git a/src/analytics/contrail-broadview/test-requirements.txt b/src/analytics/contrail-broadview/test-requirements.txt index 642c748e3cd..1bca86bd267 100644 --- a/src/analytics/contrail-broadview/test-requirements.txt +++ b/src/analytics/contrail-broadview/test-requirements.txt @@ -16,7 +16,6 @@ mock==1.0.1 kafka-python==0.9.2 kazoo stevedore -distribute>=0.7.3 ../opserver ../sandesh/common/dist/sandesh-common-0.1dev.tar.gz ../tools/sandesh/library/python/dist/sandesh-0.1dev.tar.gz diff --git a/src/analytics/contrail-snmp-collector/test-requirements.txt b/src/analytics/contrail-snmp-collector/test-requirements.txt index d0e752c4508..19fa6f6ebc7 100644 --- a/src/analytics/contrail-snmp-collector/test-requirements.txt +++ b/src/analytics/contrail-snmp-collector/test-requirements.txt @@ -9,7 +9,6 @@ mock==1.0.1 kafka-python==0.9.2 kazoo stevedore -distribute>=0.7.3 ../opserver ../sandesh/common/dist/sandesh-common-0.1dev.tar.gz ../tools/sandesh/library/python/dist/sandesh-0.1dev.tar.gz diff --git a/src/analytics/contrail-topology/test-requirements.txt b/src/analytics/contrail-topology/test-requirements.txt index 642c748e3cd..1bca86bd267 100644 --- a/src/analytics/contrail-topology/test-requirements.txt +++ b/src/analytics/contrail-topology/test-requirements.txt @@ -16,7 +16,6 @@ mock==1.0.1 kafka-python==0.9.2 kazoo stevedore -distribute>=0.7.3 ../opserver ../sandesh/common/dist/sandesh-common-0.1dev.tar.gz ../tools/sandesh/library/python/dist/sandesh-0.1dev.tar.gz diff --git a/src/api-lib/run_tests.sh b/src/api-lib/run_tests.sh index 4a7bce98de3..fea6b036339 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_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/api-lib/setup.py b/src/api-lib/setup.py index a6d242b8d39..4bf0cb430b7 100644 --- a/src/api-lib/setup.py +++ b/src/api-lib/setup.py @@ -22,7 +22,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/api-lib/test-requirements.txt b/src/api-lib/test-requirements.txt index 0b94c454dc8..fa70c69d66e 100644 --- a/src/api-lib/test-requirements.txt +++ b/src/api-lib/test-requirements.txt @@ -4,5 +4,4 @@ flexmock coverage pyaml httpretty==0.8.10 -distribute>=0.7.3 diff --git a/src/config/api-server/run_tests.sh b/src/config/api-server/run_tests.sh index a0b4e04f02c..c2c25d5fd84 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 221b6c9099e..74896b96e17 100644 --- a/src/config/api-server/setup.py +++ b/src/config/api-server/setup.py @@ -22,7 +22,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/config/api-server/test-requirements.txt b/src/config/api-server/test-requirements.txt index a2a57334019..e37629c8c1c 100644 --- a/src/config/api-server/test-requirements.txt +++ b/src/config/api-server/test-requirements.txt @@ -6,3 +6,4 @@ 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 46a19da6fa0..4edf4e30d70 100644 --- a/src/config/api-server/tests/test_crud_basic.py +++ b/src/config/api-server/tests/test_crud_basic.py @@ -1023,7 +1023,7 @@ def test_sandesh_trace(self): traces = requests.get('http://localhost:%s/Snh_SandeshTraceRequest?x=IfmapTraceBuf' %(introspect_port)) self.assertThat(traces.status_code, Equals(200)) top_elem = etree.fromstring(traces.text) - print top_elem[0][0][-1].text + logger.info("Top Elem: %s" % top_elem[0][0][-1].text) self.assertThat(top_elem[0][0][-1].text, Contains('delete')) self.assertThat(top_elem[0][0][-1].text, Contains(test_obj.name)) @@ -1933,7 +1933,7 @@ def setUpClass(cls): super(TestVncCfgApiServerRequests, cls).setUpClass( extra_config_knobs=[('DEFAULTS', 'max_requests', 10)]) - def api_requests(self, orig_vn_read, count): + def api_requests(self, orig_vn_read, count, vn_name): api_server = test_common.vnc_cfg_api_server.server self.blocked = True def slow_response_on_vn_read(obj_type, *args, **kwargs): @@ -1945,7 +1945,7 @@ def slow_response_on_vn_read(obj_type, *args, **kwargs): api_server._db_conn._cassandra_db.object_read = slow_response_on_vn_read logger.info("Creating a test VN object.") - test_obj = self._create_test_object() + test_obj = self.create_virtual_network(vn_name, '1.1.1.0/24') logger.info("Making max_requests(%s) to api server" % (count - 1)) def vn_read(): self._vnc_lib.virtual_network_read(id=test_obj.uuid) @@ -1955,7 +1955,8 @@ def vn_read(): gevent.spawn(vn_read) gevent.sleep(1) - def test_within_max_api_requests(self): + def test_max_api_requests(self): + # Test to make sure api-server accepts requests within max_api_requests self.wait_till_api_server_idle() # when there are pipe-lined requests, responses have content-length @@ -1971,9 +1972,10 @@ def reset_response_content_length(): api_server = test_common.vnc_cfg_api_server.server orig_vn_read = api_server._db_conn._cassandra_db.object_read try: - self.api_requests(orig_vn_read, 5) + vn_name = self.id() + '5testvn1' + self.api_requests(orig_vn_read, 5, vn_name) logger.info("Making one more requests well within the max_requests to api server") - vn_name = self.id() + 'testvn' + vn_name = self.id() + 'testvn1' try: greenlet = gevent.spawn(self.create_virtual_network, vn_name, '10.1.1.0/24') gevent.sleep(0) @@ -1986,15 +1988,17 @@ def reset_response_content_length(): api_server._db_conn._cassandra_db.object_read = orig_vn_read self.blocked = False - def test_err_on_max_api_requests(self): + # Test to make sure api-server rejects requests over max_api_requests self.wait_till_api_server_idle() api_server = test_common.vnc_cfg_api_server.server orig_vn_read = api_server._db_conn._cassandra_db.object_read try: - self.api_requests(orig_vn_read, 11) + vn_name = self.id() + '11testvn2' + self.api_requests(orig_vn_read, 11, vn_name) logger.info("Making one more requests (max_requests + 1) to api server") try: - greenlet = gevent.spawn(self.create_virtual_network, 'testvn', '10.1.1.0/24') + vn_name = self.id() + 'testvn2' + greenlet = gevent.spawn(self.create_virtual_network, vn_name, '10.1.1.0/24') gevent.sleep(0) greenlet.get(timeout=3) except gevent.timeout.Timeout as e: @@ -2013,7 +2017,7 @@ class TestLocalAuth(test_case.ApiServerTestCase): _rbac_role = 'admin' @classmethod def setUpClass(cls): - from keystoneclient.middleware import auth_token + from keystonemiddleware import auth_token class FakeAuthProtocol(object): _test_case = cls def __init__(self, app, *args, **kwargs): diff --git a/src/config/api-server/tests/test_logical_router.py b/src/config/api-server/tests/test_logical_router.py index 1e007ae5952..5b7cefaa0f0 100644 --- a/src/config/api-server/tests/test_logical_router.py +++ b/src/config/api-server/tests/test_logical_router.py @@ -45,26 +45,26 @@ class TestLogicalRouter(test_case.ApiServerTestCase): def test_lr_v4_subnets(self): - print '*** test logical router creation and interface-add of v4 subnets ***' + logger.debug('*** test logical router creation and interface-add of v4 subnets ***') # Create Domain domain = Domain('my-lr-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('my-lr-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-lr-domain', 'my-lr-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') # Create subnets ipam_sn_v4_vn1 = IpamSubnetType(subnet=SubnetType('11.1.1.0', 24)) @@ -76,20 +76,20 @@ def test_lr_v4_subnets(self): vn1 = VirtualNetwork('my-vn-1', project) vn1.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4_vn1, ipam_sn_v6_vn1])) self._vnc_lib.virtual_network_create(vn1) - print 'Created Virtual Network object for my-vn-1 ', vn1.uuid + logger.debug('Created Virtual Network object for my-vn-1: %s', vn1.uuid) net_obj1 = self._vnc_lib.virtual_network_read(id = vn1.uuid) # Create VN my-vn-2 vn2 = VirtualNetwork('my-vn-2', project) vn2.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4_vn2, ipam_sn_v6_vn2])) self._vnc_lib.virtual_network_create(vn2) - print 'Created Virtual Network object for my-vn-2 ', vn2.uuid + logger.debug('Created Virtual Network object for my-vn-2: %s', vn2.uuid) net_obj2 = self._vnc_lib.virtual_network_read(id = vn2.uuid) # Create Logical Router lr = LogicalRouter('router-test-v4', project) lr_uuid = self._vnc_lib.logical_router_create(lr) - print 'Created Logical Router ' + logger.debug('Created Logical Router') # Create a Virtual Machine Interface belonging to my-vn-1 id_perms = IdPermsType(enable=True) @@ -107,9 +107,9 @@ def test_lr_v4_subnets(self): subnet.subnet.get_ip_prefix_len()) if IPNetwork(cidr).version is 4: gateway_ip = subnet.get_default_gateway() - print ' *** subnet gateway (%s)' %(gateway_ip) + logger.debug(' *** subnet gateway (%s)', gateway_ip) port_id1 = self._vnc_lib.virtual_machine_interface_create(port_obj1) - print 'Created Virtual Machine Interface' + logger.debug('Created Virtual Machine Interface') # Create v4 Ip object ip_obj1 = InstanceIp(name=str(uuid.uuid4()), instance_ip_address=gateway_ip, @@ -122,7 +122,7 @@ def test_lr_v4_subnets(self): # Add Router Interface (test being subnet) lr.add_virtual_machine_interface(port_obj1) self._vnc_lib.logical_router_update(lr) - print 'Linked VMI object (VN1) and LR object' + logger.debug('Linked VMI object (VN1) and LR object') # Create a Virtual Machine Interface belonging to my-vn-2 port_obj2 = VirtualMachineInterface( @@ -139,9 +139,9 @@ def test_lr_v4_subnets(self): subnet.subnet.get_ip_prefix_len()) if IPNetwork(cidr).version is 4: gateway_ip = subnet.get_default_gateway() - print ' *** subnet gateway (%s)' %(gateway_ip) + logger.debug(' *** subnet gateway (%s)', gateway_ip) port_id2 = self._vnc_lib.virtual_machine_interface_create(port_obj2) - print 'Created Virtual Machine Interface' + logger.debug('Created Virtual Machine Interface') # Create v4 Ip object ip_obj2 = InstanceIp(name=str(uuid.uuid4()), instance_ip_address=gateway_ip, @@ -154,7 +154,7 @@ def test_lr_v4_subnets(self): # Add Router Interface (test being subnet) lr.add_virtual_machine_interface(port_obj2) self._vnc_lib.logical_router_update(lr) - print 'Linked VMI object (VN2) and LR object' + logger.debug('Linked VMI object (VN2) and LR object') # Verify logical-router dumps lr.dump() @@ -164,22 +164,22 @@ def test_lr_v4_subnets(self): # Verify Route Target Creation rt_refs = lr.get_route_target_refs() if not rt_refs: - print ' !!! Schema Transformer not integrated in test yet !!!' - print ' !!! route-target not associated to Logical Router' + logger.debug(' !!! Schema Transformer not integrated in test yet !!!') + logger.debug(' !!! route-target not associated to Logical Router') else: for rt_ref in rt_refs: - print ' Route Target (%s)' %(rt_ref['to']) + logger.debug(' Route Target (%s)', rt_ref['to']) rt_obj = self._vnc_lib.route_target_read(id=rt_ref['uuid']) ri_refs = rt_obj.get_routing_instance_back_refs() for ri_ref in ri_refs: ri_obj = self.vnc_lib.routing_instance_read(id=ri_ref['uuid']) ri_name = ri_obj.get_display_name() - print ' Routing Instance (%s)' %(ri_name) + logger.debug(' Routing Instance (%s)', ri_name) if ((ri_name != 'my-vn-1') and (ri_name != 'my-vn-2')): - print ' Failure, Logical-Router not associated to expected VN' + logger.debug(' Failure, Logical-Router not associated to expected VN') #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.logical_router_delete(id=lr_uuid) @@ -193,26 +193,26 @@ def test_lr_v4_subnets(self): #end def test_lr_v6_subnets(self): - print '*** test logical router creation and interface-add of v6 subnets ***' + logger.debug('*** test logical router creation and interface-add of v6 subnets ***') # Create Domain domain = Domain('my-lr-domain') self._vnc_lib.domain_create(domain) - print 'Created domain ' + logger.debug('Created domain ') # Create Project project = Project('my-lr-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-lr-domain', 'my-lr-proj', 'default-network-ipam']) - print 'Read network ipam' + logger.debug('Read network ipam') # Create subnets ipam_sn_v4_vn1 = IpamSubnetType(subnet=SubnetType('11.1.1.0', 24)) @@ -224,20 +224,20 @@ def test_lr_v6_subnets(self): vn1 = VirtualNetwork('my-vn-1', project) vn1.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4_vn1, ipam_sn_v6_vn1])) self._vnc_lib.virtual_network_create(vn1) - print 'Created Virtual Network object for my-vn-1 ', vn1.uuid + logger.debug('Created Virtual Network object for my-vn-1: %s', vn1.uuid) net_obj1 = self._vnc_lib.virtual_network_read(id = vn1.uuid) # Create VN my-vn-2 vn2 = VirtualNetwork('my-vn-2', project) vn2.add_network_ipam(ipam, VnSubnetsType([ipam_sn_v4_vn2, ipam_sn_v6_vn2])) self._vnc_lib.virtual_network_create(vn2) - print 'Created Virtual Network object for my-vn-2 ', vn2.uuid + logger.debug('Created Virtual Network object for my-vn-2: %s', vn2.uuid) net_obj2 = self._vnc_lib.virtual_network_read(id = vn2.uuid) # Create Logical Router lr = LogicalRouter('router-test-v6', project) lr_uuid = self._vnc_lib.logical_router_create(lr) - print 'Created Logical Router ' + logger.debug('Created Logical Router') # Create a Virtual Machine Interface belonging to my-vn-1 id_perms = IdPermsType(enable=True) @@ -255,9 +255,9 @@ def test_lr_v6_subnets(self): subnet.subnet.get_ip_prefix_len()) if IPNetwork(cidr).version is 6: gateway_ip = subnet.get_default_gateway() - print ' *** subnet gateway (%s)' %(gateway_ip) + logger.debug(' *** subnet gateway (%s)', gateway_ip) port_id1 = self._vnc_lib.virtual_machine_interface_create(port_obj1) - print 'Created Virtual Machine Interface' + logger.debug('Created Virtual Machine Interface') # Create v6 Ip object ip_obj1 = InstanceIp(name=str(uuid.uuid4()), instance_ip_address=gateway_ip, @@ -271,7 +271,7 @@ def test_lr_v6_subnets(self): lr.add_virtual_machine_interface(port_obj1) lr_obj = self._vnc_lib.logical_router_read(id=lr_uuid) self._vnc_lib.logical_router_update(lr_obj) - print 'Linked VMI object (VN1) and LR object' + logger.debug('Linked VMI object (VN1) and LR object') # Create a Virtual Machine Interface belonging to my-vn-2 port_obj2 = VirtualMachineInterface( @@ -288,9 +288,9 @@ def test_lr_v6_subnets(self): subnet.subnet.get_ip_prefix_len()) if IPNetwork(cidr).version is 6: gateway_ip = subnet.get_default_gateway() - print ' *** subnet gateway (%s)' %(gateway_ip) + logger.debug(' *** subnet gateway (%s)', gateway_ip) port_id2 = self._vnc_lib.virtual_machine_interface_create(port_obj2) - print 'Created Virtual Machine Interface' + logger.debug('Created Virtual Machine Interface') # Create v6 Ip object ip_obj2 = InstanceIp(name=str(uuid.uuid4()), instance_ip_address=gateway_ip, @@ -304,7 +304,7 @@ def test_lr_v6_subnets(self): lr.add_virtual_machine_interface(port_obj2) lr_obj = self._vnc_lib.logical_router_read(id=lr_uuid) self._vnc_lib.logical_router_update(lr_obj) - print 'Linked VMI object (VN2) and LR object' + logger.debug('Linked VMI object (VN2) and LR object') # Verify logical-router dumps lr.dump() @@ -314,23 +314,23 @@ def test_lr_v6_subnets(self): # Verify Route Target Creation rt_refs = lr.get_route_target_refs() if not rt_refs: - print ' !!! Schema Transformer not integrated in test yet !!!' - print ' !!! route-target not associated to Logical Router' + logger.debug(' !!! Schema Transformer not integrated in test yet !!!') + logger.debug(' !!! route-target not associated to Logical Router') else: for rt_ref in rt_refs: - print ' Route Target (%s)' %(rt_ref['to']) + logger.debug(' Route Target (%s)', rt_ref['to']) rt_obj = self._vnc_lib.route_target_read(id=rt_ref['uuid']) ri_refs = rt_obj.get_routing_instance_back_refs() for ri_ref in ri_refs: ri_obj = self.vnc_lib.routing_instance_read(id=ri_ref['uuid']) ri_name = ri_obj.get_display_name() - print ' Routing Instance (%s)' %(ri_name) + logger.debug(' Routing Instance (%s)', ri_name) if ((ri_name() != 'my-vn-1') and (ri_name() != 'my-vn-2')): - print ' Failure, Logical-Router not associated to expected VN' + logger.debug(' Failure, Logical-Router not associated to expected VN') #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_perms2.py b/src/config/api-server/tests/test_perms2.py index bf425b649be..5073ff80d7f 100644 --- a/src/config/api-server/tests/test_perms2.py +++ b/src/config/api-server/tests/test_perms2.py @@ -27,9 +27,9 @@ import stevedore from vnc_api.vnc_api import * -import keystoneclient.apiclient.exceptions as kc_exceptions +import keystoneclient.exceptions as kc_exceptions import keystoneclient.v2_0.client as keystone -from keystoneclient.middleware import auth_token +from keystonemiddleware import auth_token from cfgm_common import rest, utils import cfgm_common @@ -322,7 +322,8 @@ class TestPermissions(test_case.ApiServerTestCase): fqdn = [domain_name] vn_name='alice-vn' - def setUp(self): + @classmethod + def setUpClass(cls): extra_mocks = [(keystone.Client, '__new__', test_utils.FakeKeystoneClient), (vnc_api.vnc_api.VncApi, @@ -333,9 +334,11 @@ def setUp(self): ('DEFAULTS', 'multi_tenancy_with_rbac', 'True'), ('DEFAULTS', 'auth', 'keystone'), ] - super(TestPermissions, self).setUp(extra_mocks=extra_mocks, + super(TestPermissions, cls).setUpClass(extra_mocks=extra_mocks, extra_config_knobs=extra_config_knobs) + def setUp(self): + super(TestPermissions, self).setUp() ip = self._api_server_ip port = self._api_server_port # kc = test_utils.get_keystone_client() diff --git a/src/config/api-server/tests/test_perms2_target.py b/src/config/api-server/tests/test_perms2_target.py index 96bc4b37f49..d5770a130a7 100644 --- a/src/config/api-server/tests/test_perms2_target.py +++ b/src/config/api-server/tests/test_perms2_target.py @@ -5,7 +5,7 @@ from vnc_api.vnc_api import * import uuid import argparse -import keystoneclient.apiclient.exceptions as kc_exceptions +import keystoneclient.exceptions as kc_exceptions import cfgm_common import pprint diff --git a/src/config/api-server/vnc_auth_keystone.py b/src/config/api-server/vnc_auth_keystone.py index 4427898d582..921efe7fafe 100644 --- a/src/config/api-server/vnc_auth_keystone.py +++ b/src/config/api-server/vnc_auth_keystone.py @@ -17,6 +17,8 @@ try: from keystoneclient.middleware import auth_token +except ImportError: + from keystonemiddleware import auth_token except Exception: pass @@ -119,9 +121,9 @@ def __call__(self, env, start_response): if 'HTTP_X_ROLE' in env: roles = env['HTTP_X_ROLE'].split(',') if not 'admin' in [x.lower() for x in roles]: - resp = auth_token.MiniResp('Permission Denied', env) - start_response('403 Permission Denied', resp.headers) - return resp.body + start_response('403 Permission Denied', + [('Content-type', 'text/plain')]) + return ['403 Permission Denied'] return self.app(env, start_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/test_utils.py b/src/config/common/tests/test_utils.py index be68e385b38..d5928522c2f 100644 --- a/src/config/common/tests/test_utils.py +++ b/src/config/common/tests/test_utils.py @@ -994,7 +994,7 @@ def __init__(self, app, conf, *args, **kwargs): auth_protocol = conf['auth_protocol'] auth_host = conf['auth_host'] auth_port = conf['auth_port'] - self.delay_auth_decision = conf['delay_auth_decision'] + self.delay_auth_decision = conf.get('delay_auth_decision', False) self.request_uri = '%s://%s:%s' % (auth_protocol, auth_host, auth_port) self.auth_uri = self.request_uri # print 'FakeAuthProtocol init: auth-uri %s, conf %s' % (self.auth_uri, self.conf) diff --git a/src/config/common/tests/tools/install_venv_common.py b/src/config/common/tests/tools/install_venv_common.py index ef8cd7d73e8..3a29518c78f 100644 --- a/src/config/common/tests/tools/install_venv_common.py +++ b/src/config/common/tests/tools/install_venv_common.py @@ -30,6 +30,15 @@ import os import subprocess import sys +import fnmatch +import re + + +def find_files(directory, file_pattern): + for root, dirs, files in os.walk(directory): + for afile in files: + if fnmatch.fnmatch(afile, file_pattern): + yield os.path.join(root, afile) class InstallVenv(object): @@ -115,6 +124,33 @@ def pip_install(self, find_links, *args): self.run_command(cmd_array + list(args), redirect_output=False) + def get_requirements(self): + with open(self.requirements, 'r+') as fd: + reqs = [req.strip() for req in fd.readlines()] + gteq_or_lteq_or_eqeq = re.compile('(.*)[>=<]+[>=<]+') + gt_or_lt_or_eq = re.compile('(.*)[>=<]+') + requirements = [] + for req in reqs: + for regexp in [gteq_or_lteq_or_eqeq, gt_or_lt_or_eq]: + match = regexp.match(req) + if match: + requirements.append(match.group(1)) + continue + else: + requirements.append(req) + return requirements + + def pip_clear_cache(self, find_links): + contrail_reqs = [] + for req in self.get_requirements(): + for find_link in find_links: + if find_files(find_link, req): + contrail_reqs.append(req) + for contrail_req in contrail_reqs: + cache_dir = os.path.expanduser('~/.cache/pip') + for cachefile in find_files(cache_dir, contrail_req): + os.remove(cachefile) + def install_dependencies(self, find_links): print('Installing dependencies with pip (this can take a while)...') @@ -124,6 +160,7 @@ def install_dependencies(self, find_links): self.pip_install(find_links, 'setuptools') self.pip_install(find_links, 'pbr') + self.pip_clear_cache(find_links) self.pip_install(find_links, '-r', self.requirements, '-r', self.test_requirements, '--pre') diff --git a/src/config/device-manager/run_tests.sh b/src/config/device-manager/run_tests.sh index 860da74aa9d..0ffedeb3e67 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 edf5399b778..f54291c882e 100644 --- a/src/config/device-manager/setup.py +++ b/src/config/device-manager/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/config/schema-transformer/run_tests.sh b/src/config/schema-transformer/run_tests.sh index a0b4e04f02c..c2c25d5fd84 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 6c5df6fb31b..62cd7f9722d 100644 --- a/src/config/schema-transformer/setup.py +++ b/src/config/schema-transformer/setup.py @@ -22,7 +22,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/config/schema-transformer/test-requirements.txt b/src/config/schema-transformer/test-requirements.txt index f7982fe75be..4359d364d5c 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 cfgm_common vnc_api discoveryclient diff --git a/src/config/svc-monitor/run_tests.sh b/src/config/svc-monitor/run_tests.sh index e674ff48a68..2e29383c078 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 312a6a66be6..8dc7868a3b3 100644 --- a/src/config/svc-monitor/setup.py +++ b/src/config/svc-monitor/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/config/svc-monitor/test-requirements.txt b/src/config/svc-monitor/test-requirements.txt index b0568a53752..e6fb7453a76 100644 --- a/src/config/svc-monitor/test-requirements.txt +++ b/src/config/svc-monitor/test-requirements.txt @@ -10,7 +10,6 @@ psutil>=0.6.0 bottle amqp kombu -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 0bcc84c6324..98eea04ac17 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 60886896e09..3968009aa55 100644 --- a/src/config/vnc_openstack/setup.py +++ b/src/config/vnc_openstack/setup.py @@ -26,7 +26,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/config/vnc_openstack/test-requirements.txt b/src/config/vnc_openstack/test-requirements.txt index 31997b7578f..74b4f76ee7f 100644 --- a/src/config/vnc_openstack/test-requirements.txt +++ b/src/config/vnc_openstack/test-requirements.txt @@ -17,7 +17,6 @@ kombu netifaces stevedore testscenarios -distribute>=0.7.3 kazoo ../../../../third_party/ifmap-python-client ../../../../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 39cea7bcbef..82ba4d768f4 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 diff --git a/src/opserver/test-requirements.txt b/src/opserver/test-requirements.txt index 1cd1c6af0a4..0f0fc205026 100644 --- a/src/opserver/test-requirements.txt +++ b/src/opserver/test-requirements.txt @@ -10,7 +10,6 @@ flexmock==0.9.7 kafka-python==0.9.2 kazoo stevedore -distribute>=0.7.3 cassandra-driver ../../../controller/src/analytics/test/utils/mockredis ../../../controller/src/analytics/test/utils/mockcassandra