Convert NFV unit tests from nose to stestr
stestr is the current openstack test framework. The unit tests are encapsulated within test classes so that global variables are not required. Some unit tests use fixtures while others are only mock. Tox targets based off unit tests such as coverage have also been updated. Story: 2003499 Task: 26531 Change-Id: Iaa95dcc592ee5ef17deb88f94e8f15239910e7ce Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
parent
76a213442d
commit
2d39affda2
|
@ -9,6 +9,7 @@
|
|||
.*.swp
|
||||
.coverage
|
||||
.installed.cfg
|
||||
.stestr
|
||||
.testrepository
|
||||
.tox
|
||||
.venv
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
[run]
|
||||
branch = True
|
||||
source = nfv_common,nfv_client,nfv_vim,nfv_plugins
|
||||
omit = nfv-tests/*
|
||||
|
||||
[report]
|
||||
ignore_errors = True
|
|
@ -0,0 +1,4 @@
|
|||
[DEFAULT]
|
||||
test_path=./nfv-tests/nfv_unit_tests/tests
|
||||
top_dir=.
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
[run]
|
||||
branch = True
|
||||
source =
|
||||
nfv-common
|
||||
nfv-plugins
|
||||
nfv-vim
|
||||
|
||||
[report]
|
||||
include =
|
||||
*nfv_vim/directors/_instance_director.py
|
|
@ -71,7 +71,7 @@ def is_instance_reboot_alarm(alarms, instance, guest_hb=False):
|
|||
"""
|
||||
Check if an instance reboot alarm has been raised
|
||||
"""
|
||||
expected_alarm = {'alarm_id': fm_constants.FM_ALARM_ID_VM_REBOOT,
|
||||
expected_alarm = {'alarm_id': fm_constants.FM_ALARM_ID_VM_REBOOTING,
|
||||
'severity': fm_constants.FM_ALARM_SEVERITY_CRITICAL}
|
||||
|
||||
return _instance_alarm_raised(alarms, expected_alarm, instance)
|
||||
|
@ -81,7 +81,7 @@ def is_instance_rebuild_alarm(alarms, instance, guest_hb=False):
|
|||
"""
|
||||
Check if an instance rebuild alarm has been raised
|
||||
"""
|
||||
expected_alarm = {'alarm_id': fm_constants.FM_ALARM_ID_VM_REBUILD,
|
||||
expected_alarm = {'alarm_id': fm_constants.FM_ALARM_ID_VM_REBUILDING,
|
||||
'severity': fm_constants.FM_ALARM_SEVERITY_CRITICAL}
|
||||
|
||||
return _instance_alarm_raised(alarms, expected_alarm, instance)
|
||||
|
|
|
@ -9,8 +9,12 @@ import subprocess
|
|||
from nfv_vim import database
|
||||
from nfv_vim import tables
|
||||
|
||||
from . import testcase
|
||||
|
||||
def test_nfv_vim_database_upgrade_from_18_03():
|
||||
|
||||
class TestNFVDatabaseUpgrade(testcase.NFVTestCase):
|
||||
|
||||
def test_nfv_vim_database_upgrade_from_18_03(self):
|
||||
"""
|
||||
Test VIM database upgrades from 18.03 GA
|
||||
"""
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import fixtures
|
||||
import uuid
|
||||
import mock
|
||||
|
||||
from nfv_common import config
|
||||
|
||||
|
@ -24,11 +24,24 @@ from nfv_vim.tables._instance_group_table import InstanceGroupTable
|
|||
|
||||
from nfv_vim.nfvi.objects import v1 as nfvi_objects
|
||||
|
||||
import utils
|
||||
from . import testcase
|
||||
from . import utils
|
||||
|
||||
# Constants
|
||||
|
||||
# Globals
|
||||
def fake_event_issue(a, b, c, d):
|
||||
"""
|
||||
Mock out the _event_issue function because it is being called when instance
|
||||
objects are created. It ends up trying to communicate with another thread
|
||||
(that doesn't exist) and this eventually leads to unit tests hanging if
|
||||
enough events are issued.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
# NOTE: The following testcases test the same scenarios as the testcases in
|
||||
# nova/tests/unit/virt/libvirt/test_driver.py
|
||||
class TestInstance(testcase.NFVTestCase):
|
||||
|
||||
_tenant_table = Table()
|
||||
_instance_type_table = InstanceTypeTable()
|
||||
_image_table = ImageTable()
|
||||
|
@ -48,23 +61,58 @@ _host_table.persist = False
|
|||
_host_group_table.persist = False
|
||||
_host_aggregate_table.persist = False
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Setup for testing.
|
||||
"""
|
||||
super(TestInstance, self).setUp()
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._tenant_table._tenant_table',
|
||||
self._tenant_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._host_table._host_table',
|
||||
self._host_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._instance_group_table._instance_group_table',
|
||||
self._instance_group_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._host_group_table._host_group_table',
|
||||
self._host_group_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._host_aggregate_table._host_aggregate_table',
|
||||
self._host_aggregate_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._instance_table._instance_table',
|
||||
self._instance_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._instance_type_table._instance_type_table',
|
||||
self._instance_type_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.tables._image_table._image_table',
|
||||
self._image_table))
|
||||
self.useFixture(fixtures.MonkeyPatch('nfv_vim.event_log._instance._event_issue',
|
||||
fake_event_issue))
|
||||
|
||||
def create_instance(instance_name, instance_type_name, image_name, host_name,
|
||||
def tearDown(self):
|
||||
"""
|
||||
Cleanup testing setup.
|
||||
"""
|
||||
super(TestInstance, self).tearDown()
|
||||
self._tenant_table.clear()
|
||||
self._instance_type_table.clear()
|
||||
self._image_table.clear()
|
||||
self._instance_table.clear()
|
||||
self._instance_group_table.clear()
|
||||
self._host_table.clear()
|
||||
self._host_group_table.clear()
|
||||
self._host_aggregate_table.clear()
|
||||
|
||||
def create_instance(self, instance_name, instance_type_name, image_name, host_name,
|
||||
admin_state=nfvi.objects.v1.INSTANCE_ADMIN_STATE.UNLOCKED,
|
||||
live_migration_timeout=None):
|
||||
"""
|
||||
Create an instance
|
||||
"""
|
||||
global _tenant_table, _instance_table, _image_table
|
||||
|
||||
tenant_uuid = str(uuid.uuid4())
|
||||
|
||||
tenant = objects.Tenant(tenant_uuid, "%s_name" % tenant_uuid, '', True)
|
||||
_tenant_table[tenant_uuid] = tenant
|
||||
self._tenant_table[tenant_uuid] = tenant
|
||||
|
||||
for instance_type in _instance_type_table.values():
|
||||
for instance_type in self._instance_type_table.values():
|
||||
if instance_type.name == instance_type_name:
|
||||
for image in _image_table.values():
|
||||
for image in self._image_table.values():
|
||||
if image.name == image_name:
|
||||
instance_uuid = str(uuid.uuid4())
|
||||
|
||||
|
@ -81,20 +129,16 @@ def create_instance(instance_name, instance_type_name, image_name, host_name,
|
|||
live_migration_timeout=live_migration_timeout)
|
||||
|
||||
instance = objects.Instance(nfvi_instance)
|
||||
_instance_table[instance.uuid] = instance
|
||||
self._instance_table[instance.uuid] = instance
|
||||
return instance
|
||||
|
||||
assert 0, "Unknown instance_type_name: %s" % instance_type_name
|
||||
|
||||
|
||||
def create_instance_type(instance_type_name, live_migration_timeout=None):
|
||||
def create_instance_type(self, instance_type_name, live_migration_timeout=None):
|
||||
"""
|
||||
Create an instance type
|
||||
"""
|
||||
global _instance_type_table
|
||||
|
||||
instance_type_uuid = str(uuid.uuid4())
|
||||
|
||||
instance_type = objects.InstanceType(instance_type_uuid,
|
||||
instance_type_name)
|
||||
instance_type.update_details(
|
||||
|
@ -104,17 +148,13 @@ def create_instance_type(instance_type_name, live_migration_timeout=None):
|
|||
live_migration_timeout=live_migration_timeout,
|
||||
live_migration_max_downtime=500,
|
||||
storage_type='local_image')
|
||||
_instance_type_table[instance_type_uuid] = instance_type
|
||||
self._instance_type_table[instance_type_uuid] = instance_type
|
||||
|
||||
|
||||
def create_image(image_name, properties=None):
|
||||
def create_image(self, image_name, properties=None):
|
||||
"""
|
||||
Create an instance type
|
||||
Create an image
|
||||
"""
|
||||
global _image_table
|
||||
|
||||
image_uuid = str(uuid.uuid4())
|
||||
|
||||
nfvi_image = nfvi_objects.Image(image_uuid, image_name, 'description',
|
||||
nfvi_objects.IMAGE_AVAIL_STATUS.AVAILABLE,
|
||||
nfvi_objects.IMAGE_ACTION.NONE,
|
||||
|
@ -126,18 +166,14 @@ def create_image(image_name, properties=None):
|
|||
False,
|
||||
properties=properties)
|
||||
image = objects.Image(nfvi_image)
|
||||
_image_table[image_uuid] = image
|
||||
self._image_table[image_uuid] = image
|
||||
|
||||
|
||||
def create_instance_group(name, members, policies):
|
||||
def create_instance_group(self, name, members, policies):
|
||||
"""
|
||||
Create an instance group
|
||||
"""
|
||||
global _instance_group_table
|
||||
|
||||
member_uuids = []
|
||||
|
||||
for instance_uuid, instance in _instance_table.iteritems():
|
||||
for instance_uuid, instance in self._instance_table.iteritems():
|
||||
if instance.name in members:
|
||||
member_uuids.append(instance_uuid)
|
||||
|
||||
|
@ -149,10 +185,9 @@ def create_instance_group(name, members, policies):
|
|||
)
|
||||
|
||||
instance_group = objects.InstanceGroup(nfvi_instance_group)
|
||||
_instance_group_table[instance_group.uuid] = instance_group
|
||||
self._instance_group_table[instance_group.uuid] = instance_group
|
||||
|
||||
|
||||
def create_host(host_name,
|
||||
def create_host(self, host_name,
|
||||
cpe=False,
|
||||
admin_state=nfvi.objects.v1.HOST_ADMIN_STATE.UNLOCKED,
|
||||
software_load='12.01',
|
||||
|
@ -160,9 +195,7 @@ def create_host(host_name,
|
|||
"""
|
||||
Create a host
|
||||
"""
|
||||
global _host_table
|
||||
personality = ''
|
||||
|
||||
if host_name.startswith('controller'):
|
||||
personality = HOST_PERSONALITY.CONTROLLER
|
||||
if cpe:
|
||||
|
@ -189,18 +222,14 @@ def create_host(host_name,
|
|||
|
||||
host = objects.Host(nfvi_host,
|
||||
initial_state=host_fsm.HOST_STATE.ENABLED)
|
||||
_host_table[host.name] = host
|
||||
self._host_table[host.name] = host
|
||||
|
||||
|
||||
def create_host_group(name, members, policies):
|
||||
def create_host_group(self, name, members, policies):
|
||||
"""
|
||||
Create a host group
|
||||
"""
|
||||
global _host_group_table
|
||||
|
||||
member_uuids = []
|
||||
|
||||
for instance_uuid, instance in _instance_table.iteritems():
|
||||
for instance_uuid, instance in self._instance_table.iteritems():
|
||||
if instance.name in members:
|
||||
member_uuids.append(instance_uuid)
|
||||
|
||||
|
@ -211,15 +240,12 @@ def create_host_group(name, members, policies):
|
|||
)
|
||||
|
||||
host_group = objects.HostGroup(nfvi_host_group)
|
||||
_host_group_table[host_group.name] = host_group
|
||||
self._host_group_table[host_group.name] = host_group
|
||||
|
||||
|
||||
def create_host_aggregate(name, host_names):
|
||||
def create_host_aggregate(self, name, host_names):
|
||||
"""
|
||||
Create a host aggregate
|
||||
"""
|
||||
global _host_aggregate_table
|
||||
|
||||
nfvi_host_aggregate = nfvi.objects.v1.HostAggregate(
|
||||
name=name,
|
||||
host_names=host_names,
|
||||
|
@ -227,84 +253,40 @@ def create_host_aggregate(name, host_names):
|
|||
)
|
||||
|
||||
host_aggregate = objects.HostAggregate(nfvi_host_aggregate)
|
||||
_host_aggregate_table[host_aggregate.name] = host_aggregate
|
||||
|
||||
|
||||
def fake_event_issue(a, b, c, d):
|
||||
"""
|
||||
Mock out the _event_issue function because it is being called when instance
|
||||
objects are created. It ends up trying to communicate with another thread
|
||||
(that doesn't exist) and this eventually leads to nosetests hanging if
|
||||
enough events are issued.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
@mock.patch('nfv_vim.event_log._instance._event_issue', fake_event_issue)
|
||||
@mock.patch('nfv_vim.tables._tenant_table._tenant_table', _tenant_table)
|
||||
@mock.patch('nfv_vim.tables._host_table._host_table', _host_table)
|
||||
@mock.patch('nfv_vim.tables._instance_group_table._instance_group_table', _instance_group_table)
|
||||
@mock.patch('nfv_vim.tables._host_group_table._host_group_table', _host_group_table)
|
||||
@mock.patch('nfv_vim.tables._host_aggregate_table._host_aggregate_table', _host_aggregate_table)
|
||||
@mock.patch('nfv_vim.tables._instance_table._instance_table', _instance_table)
|
||||
@mock.patch('nfv_vim.tables._instance_type_table._instance_type_table', _instance_type_table)
|
||||
@mock.patch('nfv_vim.tables._image_table._image_table', _image_table)
|
||||
class TestInstance(object):
|
||||
|
||||
def setup(self):
|
||||
"""
|
||||
Setup for testing.
|
||||
"""
|
||||
pass
|
||||
|
||||
def teardown(self):
|
||||
"""
|
||||
Cleanup testing setup.
|
||||
"""
|
||||
_tenant_table.clear()
|
||||
_instance_type_table.clear()
|
||||
_image_table.clear()
|
||||
_instance_table.clear()
|
||||
_instance_group_table.clear()
|
||||
_host_table.clear()
|
||||
_host_group_table.clear()
|
||||
_host_aggregate_table.clear()
|
||||
|
||||
# NOTE: The following testcases test the same scenarios as the testcases in
|
||||
# nova/tests/unit/virt/libvirt/test_driver.py
|
||||
self._host_aggregate_table[host_aggregate.name] = host_aggregate
|
||||
|
||||
def test_live_migration_completion_timeout(self):
|
||||
create_instance_type('small')
|
||||
create_image('image_0')
|
||||
instance = create_instance('test_instance_0',
|
||||
self.create_instance_type('small')
|
||||
self.create_image('image_0')
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
assert 800 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_from_flavor(self):
|
||||
create_instance_type('small', live_migration_timeout=300)
|
||||
create_image('image_0')
|
||||
instance = create_instance('test_instance_0',
|
||||
self.create_instance_type('small', live_migration_timeout=300)
|
||||
self.create_image('image_0')
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
assert 300 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_from_image(self):
|
||||
create_instance_type('small')
|
||||
create_image('image_0',
|
||||
self.create_instance_type('small')
|
||||
self.create_image('image_0',
|
||||
properties={nfvi_objects.IMAGE_PROPERTY.LIVE_MIGRATION_TIMEOUT: "400"})
|
||||
instance = create_instance('test_instance_0',
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
assert 400 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_from_instance(self):
|
||||
create_instance_type('small')
|
||||
create_image('image_0')
|
||||
instance = create_instance('test_instance_0',
|
||||
self.create_instance_type('small')
|
||||
self.create_image('image_0')
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0',
|
||||
|
@ -312,30 +294,30 @@ class TestInstance(object):
|
|||
assert 200 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_flavor_overwrite_image(self):
|
||||
create_instance_type('small', live_migration_timeout=300)
|
||||
create_image('image_0',
|
||||
self.create_instance_type('small', live_migration_timeout=300)
|
||||
self.create_image('image_0',
|
||||
properties={nfvi_objects.IMAGE_PROPERTY.LIVE_MIGRATION_TIMEOUT: "400"})
|
||||
instance = create_instance('test_instance_0',
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
assert 300 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_image_overwrite_flavor(self):
|
||||
create_instance_type('small', live_migration_timeout=300)
|
||||
create_image('image_0',
|
||||
self.create_instance_type('small', live_migration_timeout=300)
|
||||
self.create_image('image_0',
|
||||
properties={nfvi_objects.IMAGE_PROPERTY.LIVE_MIGRATION_TIMEOUT: "200"})
|
||||
instance = create_instance('test_instance_0',
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
assert 200 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_instance_overwrite_all(self):
|
||||
create_instance_type('small', live_migration_timeout=300)
|
||||
create_image('image_0',
|
||||
self.create_instance_type('small', live_migration_timeout=300)
|
||||
self.create_image('image_0',
|
||||
properties={nfvi_objects.IMAGE_PROPERTY.LIVE_MIGRATION_TIMEOUT: "200"})
|
||||
instance = create_instance('test_instance_0',
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0',
|
||||
|
@ -343,20 +325,20 @@ class TestInstance(object):
|
|||
assert 100 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
def test_live_migration_completion_timeout_overwrite_zero(self):
|
||||
create_instance_type('small', live_migration_timeout=300)
|
||||
create_image('image_0',
|
||||
self.create_instance_type('small', live_migration_timeout=300)
|
||||
self.create_image('image_0',
|
||||
properties={nfvi_objects.IMAGE_PROPERTY.LIVE_MIGRATION_TIMEOUT: "0"})
|
||||
instance = create_instance('test_instance_0',
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0',
|
||||
live_migration_timeout=400)
|
||||
assert 300 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
create_instance_type('small_2', live_migration_timeout=0)
|
||||
create_image('image_1',
|
||||
self.create_instance_type('small_2', live_migration_timeout=0)
|
||||
self.create_image('image_1',
|
||||
properties={nfvi_objects.IMAGE_PROPERTY.LIVE_MIGRATION_TIMEOUT: "200"})
|
||||
instance = create_instance('test_instance_0',
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small_2',
|
||||
'image_1',
|
||||
'compute-0')
|
||||
|
@ -367,17 +349,17 @@ class TestInstance(object):
|
|||
def test_live_migration_completion_timeout_out_of_range(self):
|
||||
config.CONF = {'instance-configuration': {}}
|
||||
|
||||
create_instance_type('small', live_migration_timeout=1000)
|
||||
create_image('image_0')
|
||||
instance = create_instance('test_instance_0',
|
||||
self.create_instance_type('small', live_migration_timeout=1000)
|
||||
self.create_image('image_0')
|
||||
instance = self.create_instance('test_instance_0',
|
||||
'small',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
assert 800 == instance.max_live_migrate_wait_in_secs
|
||||
|
||||
create_instance_type('small_2', live_migration_timeout=10)
|
||||
create_image('image_0')
|
||||
instance = create_instance('test_instance_1',
|
||||
self.create_instance_type('small_2', live_migration_timeout=10)
|
||||
self.create_image('image_0')
|
||||
instance = self.create_instance('test_instance_1',
|
||||
'small_2',
|
||||
'image_0',
|
||||
'compute-0')
|
||||
|
|
|
@ -3,17 +3,18 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import uuid
|
||||
import mock
|
||||
import nose
|
||||
import uuid
|
||||
|
||||
from nfv_vim import nfvi
|
||||
from nfv_vim import objects
|
||||
|
||||
from nfv_vim.tables._image_table import ImageTable
|
||||
from nfv_vim.tables._table import Table
|
||||
from nfv_vim.directors._instance_director import InstanceDirector
|
||||
|
||||
import utils
|
||||
from . import testcase
|
||||
from . import utils
|
||||
|
||||
# Constants
|
||||
_audit_interval = 330
|
||||
|
@ -23,26 +24,47 @@ _rebuild_timeout = 300
|
|||
_reboot_timeout = 300
|
||||
_migrate_timeout = 600
|
||||
|
||||
# Globals
|
||||
_tenant_table = Table()
|
||||
|
||||
def fake_timer(a, b, c, d):
|
||||
return 1234
|
||||
|
||||
|
||||
class TestInstanceDirector(testcase.NFVTestCase):
|
||||
_image_table = ImageTable()
|
||||
_instance_table = Table()
|
||||
_instance_type_table = Table()
|
||||
_tenant_table = Table()
|
||||
|
||||
# Don't attempt to write to the database while unit testing
|
||||
_image_table.persist = False
|
||||
_instance_table.persist = False
|
||||
_instance_type_table.persist = False
|
||||
_tenant_table.persist = False
|
||||
|
||||
_director = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestInstanceDirector, self).setUp()
|
||||
self.instance_setup_func()
|
||||
|
||||
def create_instance(instance_type_name, instance_name, recovery_priority=None):
|
||||
def tearDown(self):
|
||||
super(TestInstanceDirector, self).tearDown()
|
||||
self._tenant_table.clear()
|
||||
self._instance_table.clear()
|
||||
self._instance_type_table.clear()
|
||||
self._director = None
|
||||
|
||||
def create_instance(self, instance_type_name, instance_name, recovery_priority=None):
|
||||
"""
|
||||
Create an instance
|
||||
"""
|
||||
global _tenant_table
|
||||
|
||||
tenant_uuid = uuid.uuid4()
|
||||
image_uuid = uuid.uuid4()
|
||||
|
||||
tenant = objects.Tenant(tenant_uuid, "%s_name" % tenant_uuid, '', True)
|
||||
_tenant_table[tenant_uuid] = tenant
|
||||
self._tenant_table[tenant_uuid] = tenant
|
||||
|
||||
for instance_type in _instance_type_table.values():
|
||||
for instance_type in self._instance_type_table.values():
|
||||
if instance_type.name == instance_type_name:
|
||||
instance_uuid = uuid.uuid4()
|
||||
|
||||
|
@ -62,17 +84,14 @@ def create_instance(instance_type_name, instance_name, recovery_priority=None):
|
|||
|
||||
return None
|
||||
|
||||
|
||||
@mock.patch('nfv_common.timers.timers_create_timer')
|
||||
def instance_setup_func(timers_create_timer_mock):
|
||||
@mock.patch('nfv_common.timers.timers_create_timer', fake_timer)
|
||||
def instance_setup_func(self):
|
||||
"""
|
||||
Setup for testing.
|
||||
"""
|
||||
global _instance_table, _instance_type_table, _director
|
||||
|
||||
instance_type_uuid = uuid.uuid4()
|
||||
|
||||
if 0 == len(_instance_type_table):
|
||||
if 0 == len(self._instance_type_table):
|
||||
instance_type = objects.InstanceType(instance_type_uuid, 'small')
|
||||
instance_type.update_details(vcpus=1, mem_mb=64, disk_gb=1, ephemeral_gb=0,
|
||||
swap_gb=0, guest_services=None,
|
||||
|
@ -80,12 +99,12 @@ def instance_setup_func(timers_create_timer_mock):
|
|||
live_migration_timeout=800,
|
||||
live_migration_max_downtime=500,
|
||||
storage_type='local_image')
|
||||
_instance_type_table[instance_type_uuid] = instance_type
|
||||
self._instance_type_table[instance_type_uuid] = instance_type
|
||||
|
||||
_instance_table.clear()
|
||||
self._instance_table.clear()
|
||||
|
||||
if _director is None:
|
||||
_director = InstanceDirector(
|
||||
if self._director is None:
|
||||
self._director = InstanceDirector(
|
||||
max_concurrent_recovering_instances=4,
|
||||
max_concurrent_migrates_per_host=1,
|
||||
max_concurrent_evacuates_per_host=1,
|
||||
|
@ -101,39 +120,29 @@ def instance_setup_func(timers_create_timer_mock):
|
|||
max_throttled_recovering_instances=2
|
||||
)
|
||||
|
||||
|
||||
def instance_teardown_func():
|
||||
"""
|
||||
Cleanup testing setup.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@nose.with_setup(instance_setup_func, instance_teardown_func)
|
||||
@mock.patch('nfv_vim.tables.tables_get_tenant_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_instance_type_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_instance_table')
|
||||
def test_instance_director_recovery_list(
|
||||
tables_get_instance_table_mock, tables_get_instance_type_table_mock,
|
||||
def test_instance_director_recovery_list(self,
|
||||
tables_get_instance_table_mock,
|
||||
tables_get_instance_type_table_mock,
|
||||
tables_get_tenant_table_mock):
|
||||
"""
|
||||
Test the instance director recovery list logic
|
||||
"""
|
||||
global _tenant_table, _instance_table, _instance_type_table, _director
|
||||
tables_get_tenant_table_mock.return_value = self._tenant_table
|
||||
tables_get_instance_table_mock.return_value = self._instance_table
|
||||
tables_get_instance_type_table_mock.return_value = self._instance_type_table
|
||||
|
||||
tables_get_tenant_table_mock.return_value = _tenant_table
|
||||
tables_get_instance_table_mock.return_value = _instance_table
|
||||
tables_get_instance_type_table_mock.return_value = _instance_type_table
|
||||
|
||||
instance_1 = create_instance('small', 'instance_1')
|
||||
_instance_table[instance_1.uuid] = instance_1
|
||||
instance_1 = self.create_instance('small', 'instance_1')
|
||||
self._instance_table[instance_1.uuid] = instance_1
|
||||
|
||||
# Validate that the Instance Director recovery_list creation
|
||||
# -- with no instances in the failed state, verify that the list is
|
||||
# empty and the normal audit interval is returned
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _audit_interval
|
||||
assert 0 == len(instance_recovery_list)
|
||||
|
||||
|
@ -146,7 +155,7 @@ def test_instance_director_recovery_list(
|
|||
instance_1._elapsed_time_in_state = _recovery_cooldown - 1
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 0 == len(instance_recovery_list)
|
||||
|
||||
|
@ -157,29 +166,26 @@ def test_instance_director_recovery_list(
|
|||
instance_1._elapsed_time_in_state = _recovery_cooldown
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 1 == len(instance_recovery_list)
|
||||
assert instance_recovery_list[0].name == instance_1.name
|
||||
|
||||
|
||||
@nose.with_setup(instance_setup_func, instance_teardown_func)
|
||||
@mock.patch('nfv_vim.tables.tables_get_tenant_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_instance_type_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_instance_table')
|
||||
def test_instance_director_recovery_list_order(
|
||||
tables_get_instance_table_mock, tables_get_instance_type_table_mock,
|
||||
def test_instance_director_recovery_list_order(self,
|
||||
tables_get_instance_table_mock,
|
||||
tables_get_instance_type_table_mock,
|
||||
tables_get_tenant_table_mock):
|
||||
"""
|
||||
Test the instance director recovery list ordering
|
||||
"""
|
||||
global _tenant_table, _instance_table, _instance_type_table, _director
|
||||
tables_get_tenant_table_mock.return_value = self._tenant_table
|
||||
tables_get_instance_table_mock.return_value = self._instance_table
|
||||
tables_get_instance_type_table_mock.return_value = self._instance_type_table
|
||||
|
||||
tables_get_tenant_table_mock.return_value = _tenant_table
|
||||
tables_get_instance_table_mock.return_value = _instance_table
|
||||
tables_get_instance_type_table_mock.return_value = _instance_type_table
|
||||
|
||||
instance_1 = create_instance('small', 'instance_1')
|
||||
instance_1 = self.create_instance('small', 'instance_1')
|
||||
instance_1._elapsed_time_in_state = _recovery_cooldown
|
||||
instance_1._nfvi_instance.avail_status.append(
|
||||
nfvi.objects.v1.INSTANCE_AVAIL_STATUS.FAILED)
|
||||
|
@ -187,18 +193,18 @@ def test_instance_director_recovery_list_order(
|
|||
instance_1._nfvi_instance['instance_type']['ram'] = 32
|
||||
instance_1._nfvi_instance['instance_type']['disk'] = 2
|
||||
instance_1._nfvi_instance['instance_type']['swap'] = 0
|
||||
_instance_table[instance_1.uuid] = instance_1
|
||||
self._instance_table[instance_1.uuid] = instance_1
|
||||
|
||||
# Validate the Instance Director recovery_list order
|
||||
# -- with one instance in the failed state
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 1 == len(instance_recovery_list)
|
||||
assert instance_recovery_list[0].name == instance_1.name
|
||||
|
||||
instance_2 = create_instance('small', 'instance_2')
|
||||
instance_2 = self.create_instance('small', 'instance_2')
|
||||
instance_2._elapsed_time_in_state = _recovery_cooldown
|
||||
instance_2._nfvi_instance.avail_status.append(
|
||||
nfvi.objects.v1.INSTANCE_AVAIL_STATUS.FAILED)
|
||||
|
@ -206,19 +212,19 @@ def test_instance_director_recovery_list_order(
|
|||
instance_2._nfvi_instance['instance_type']['ram'] = 32
|
||||
instance_2._nfvi_instance['instance_type']['disk'] = 1
|
||||
instance_2._nfvi_instance['instance_type']['swap'] = 0
|
||||
_instance_table[instance_2.uuid] = instance_2
|
||||
self._instance_table[instance_2.uuid] = instance_2
|
||||
|
||||
# -- with two instances in the failed state
|
||||
# vcpus takes precedence over disk_gb
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 2 == len(instance_recovery_list)
|
||||
assert instance_recovery_list[0].name == instance_2.name
|
||||
assert instance_recovery_list[1].name == instance_1.name
|
||||
|
||||
instance_3 = create_instance('small', 'instance_3', recovery_priority=5)
|
||||
instance_3 = self.create_instance('small', 'instance_3', recovery_priority=5)
|
||||
instance_3._elapsed_time_in_state = _recovery_cooldown
|
||||
instance_3._nfvi_instance.avail_status.append(
|
||||
nfvi.objects.v1.INSTANCE_AVAIL_STATUS.FAILED)
|
||||
|
@ -226,20 +232,20 @@ def test_instance_director_recovery_list_order(
|
|||
instance_3._nfvi_instance['instance_type']['ram'] = 32
|
||||
instance_3._nfvi_instance['instance_type']['disk'] = 0
|
||||
instance_3._nfvi_instance['instance_type']['swap'] = 0
|
||||
_instance_table[instance_3.uuid] = instance_3
|
||||
self._instance_table[instance_3.uuid] = instance_3
|
||||
|
||||
# -- with three instances in the failed state
|
||||
# recovery_priority takes precedence over instance size
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 3 == len(instance_recovery_list)
|
||||
assert instance_recovery_list[0].name == instance_3.name
|
||||
assert instance_recovery_list[1].name == instance_2.name
|
||||
assert instance_recovery_list[2].name == instance_1.name
|
||||
|
||||
instance_4 = create_instance('small', 'instance_4', recovery_priority=1)
|
||||
instance_4 = self.create_instance('small', 'instance_4', recovery_priority=1)
|
||||
instance_4._elapsed_time_in_state = _recovery_cooldown
|
||||
instance_4._nfvi_instance.avail_status.append(
|
||||
nfvi.objects.v1.INSTANCE_AVAIL_STATUS.FAILED)
|
||||
|
@ -247,13 +253,13 @@ def test_instance_director_recovery_list_order(
|
|||
instance_4._nfvi_instance['instance_type']['ram'] = 32
|
||||
instance_4._nfvi_instance['instance_type']['disk'] = 0
|
||||
instance_4._nfvi_instance['instance_type']['swap'] = 0
|
||||
_instance_table[instance_4.uuid] = instance_4
|
||||
self._instance_table[instance_4.uuid] = instance_4
|
||||
|
||||
# -- with four instances in the failed state
|
||||
# recovery_priority sorts instances
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 4 == len(instance_recovery_list)
|
||||
assert instance_recovery_list[0].name == instance_4.name
|
||||
|
@ -261,7 +267,7 @@ def test_instance_director_recovery_list_order(
|
|||
assert instance_recovery_list[2].name == instance_2.name
|
||||
assert instance_recovery_list[3].name == instance_1.name
|
||||
|
||||
instance_5 = create_instance('small', 'instance_5', recovery_priority=10)
|
||||
instance_5 = self.create_instance('small', 'instance_5', recovery_priority=10)
|
||||
instance_5._elapsed_time_in_state = _recovery_cooldown
|
||||
instance_5._nfvi_instance.avail_status.append(
|
||||
nfvi.objects.v1.INSTANCE_AVAIL_STATUS.FAILED)
|
||||
|
@ -269,13 +275,13 @@ def test_instance_director_recovery_list_order(
|
|||
instance_5._nfvi_instance['instance_type']['ram'] = 32
|
||||
instance_5._nfvi_instance['instance_type']['disk'] = 0
|
||||
instance_5._nfvi_instance['instance_type']['swap'] = 0
|
||||
_instance_table[instance_5.uuid] = instance_5
|
||||
self._instance_table[instance_5.uuid] = instance_5
|
||||
|
||||
# -- with five instances in the failed state
|
||||
# no recovery_priority treated the same as priority 10
|
||||
(next_audit_interval, instance_recovery_list, instance_failed_list,
|
||||
instance_rebuilding_list, instance_migrating_list,
|
||||
instance_rebooting_list) = _director._get_instance_recovery_list()
|
||||
instance_rebooting_list) = self._director._get_instance_recovery_list()
|
||||
assert next_audit_interval == _recovery_cooldown
|
||||
assert 5 == len(instance_recovery_list)
|
||||
assert instance_recovery_list[0].name == instance_4.name
|
||||
|
@ -284,51 +290,52 @@ def test_instance_director_recovery_list_order(
|
|||
assert instance_recovery_list[3].name == instance_5.name
|
||||
assert instance_recovery_list[4].name == instance_1.name
|
||||
|
||||
|
||||
@nose.with_setup(instance_setup_func, instance_teardown_func)
|
||||
@mock.patch('nfv_vim.tables.tables_get_image_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_tenant_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_instance_type_table')
|
||||
@mock.patch('nfv_vim.tables.tables_get_instance_table')
|
||||
@mock.patch('nfv_vim.dor.system_is_stabilized')
|
||||
@mock.patch('nfv_vim.dor.dor_is_complete')
|
||||
def test_instance_director_recover_instance(
|
||||
dor_is_complete_mock, system_is_stabilized_mock,
|
||||
tables_get_instance_table_mock, tables_get_instance_type_table_mock,
|
||||
tables_get_tenant_table_mock):
|
||||
def test_instance_director_recover_instance(self,
|
||||
dor_is_complete_mock,
|
||||
system_is_stabilized_mock,
|
||||
tables_get_instance_table_mock,
|
||||
tables_get_instance_type_table_mock,
|
||||
tables_get_tenant_table_mock,
|
||||
tables_get_image_table_mock):
|
||||
"""
|
||||
Test the instance director recover instance logic
|
||||
"""
|
||||
global _instance_table, _instance_type_table, _director
|
||||
|
||||
tables_get_tenant_table_mock.return_value = _tenant_table
|
||||
tables_get_instance_table_mock.return_value = _instance_table
|
||||
tables_get_instance_type_table_mock.return_value = _instance_type_table
|
||||
tables_get_tenant_table_mock.return_value = self._tenant_table
|
||||
tables_get_instance_table_mock.return_value = self._instance_table
|
||||
tables_get_instance_type_table_mock.return_value = self._instance_type_table
|
||||
tables_get_image_table_mock.return_value = self._image_table
|
||||
|
||||
system_is_stabilized_mock.return_value = True
|
||||
dor_is_complete_mock.return_value = True
|
||||
|
||||
instance_1 = create_instance('small', 'instance_1')
|
||||
instance_1 = self.create_instance('small', 'instance_1')
|
||||
instance_1.fail = mock.Mock()
|
||||
instance_1.do_action = mock.Mock()
|
||||
instance_1._nfvi_instance.avail_status.append(
|
||||
nfvi.objects.v1.INSTANCE_AVAIL_STATUS.FAILED)
|
||||
|
||||
_director._is_host_enabled = mock.Mock(return_value=True)
|
||||
_director._is_hypervisor_enabled = mock.Mock(return_value=True)
|
||||
_director.upgrade_inprogress = mock.Mock(return_value=False)
|
||||
self._director._is_host_enabled = mock.Mock(return_value=True)
|
||||
self._director._is_hypervisor_enabled = mock.Mock(return_value=True)
|
||||
self._director.upgrade_inprogress = mock.Mock(return_value=False)
|
||||
|
||||
# Set_A
|
||||
# -- the first attempt to recover an instance that is failed on an
|
||||
# enabled host, verify a reboot is attempted
|
||||
_director.instance_recovered(instance_1)
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.instance_recovered(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBOOT,
|
||||
initiated_by='director')
|
||||
|
||||
# -- a subsequent attempt to recover an instance that is failed on an
|
||||
# enabled host and the instance has an image to rebuild from, verify
|
||||
# a rebuild is attempted
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBUILD,
|
||||
initiated_by='director')
|
||||
|
||||
|
@ -337,15 +344,15 @@ def test_instance_director_recover_instance(
|
|||
# enabled host, verify a reboot is attempted
|
||||
original_image_uuid = instance_1._nfvi_instance.image_uuid
|
||||
instance_1._nfvi_instance.image_uuid = None
|
||||
_director.instance_recovered(instance_1)
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.instance_recovered(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBOOT,
|
||||
initiated_by='director')
|
||||
|
||||
# -- a subsequent attempt to recover an instance that is failed on an
|
||||
# enabled host and the instance does not have an image to rebuild from,
|
||||
# verify a reboot is attempted
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBOOT,
|
||||
initiated_by='director')
|
||||
instance_1._nfvi_instance.image_uuid = original_image_uuid
|
||||
|
@ -353,9 +360,9 @@ def test_instance_director_recover_instance(
|
|||
# Set_C
|
||||
# -- instance is rebuilding or evacuating and the instance has an image
|
||||
# to rebuild from, verify that a rebuild is attempted
|
||||
_director.instance_recovered(instance_1)
|
||||
self._director.instance_recovered(instance_1)
|
||||
instance_1._nfvi_instance.action = nfvi.objects.v1.INSTANCE_ACTION.REBUILDING
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBUILD,
|
||||
initiated_by='director')
|
||||
|
||||
|
@ -364,7 +371,7 @@ def test_instance_director_recover_instance(
|
|||
# image to rebuild from, verify that a reboot is attempted
|
||||
original_image_uuid = instance_1._nfvi_instance.image_uuid
|
||||
instance_1._nfvi_instance.image_uuid = None
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBOOT,
|
||||
initiated_by='director')
|
||||
instance_1._nfvi_instance.image_uuid = original_image_uuid
|
||||
|
@ -373,9 +380,9 @@ def test_instance_director_recover_instance(
|
|||
# Set_E
|
||||
# -- instance is migrating and the instance has an image to rebuild from,
|
||||
# verify that a rebuild is attempted
|
||||
_director.instance_recovered(instance_1)
|
||||
self._director.instance_recovered(instance_1)
|
||||
instance_1._nfvi_instance.action = nfvi.objects.v1.INSTANCE_ACTION.MIGRATING
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBUILD,
|
||||
initiated_by='director')
|
||||
|
||||
|
@ -384,7 +391,7 @@ def test_instance_director_recover_instance(
|
|||
# rebuild from, verify that a reboot is attempted
|
||||
original_image_uuid = instance_1._nfvi_instance.image_uuid
|
||||
instance_1._nfvi_instance.image_uuid = None
|
||||
_director.recover_instance(instance_1)
|
||||
self._director.recover_instance(instance_1)
|
||||
instance_1.do_action.assert_called_with(objects.INSTANCE_ACTION_TYPE.REBOOT,
|
||||
initiated_by='director')
|
||||
instance_1._nfvi_instance.image_uuid = original_image_uuid
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Copyright (c) 2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import testtools
|
||||
|
||||
|
||||
class NFVTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NFVTestCase, self).setUp()
|
43
nfv/tox.ini
43
nfv/tox.ini
|
@ -25,12 +25,14 @@ nfv_client_dir = ./nfv-client
|
|||
nfv_common_dir = ./nfv-common
|
||||
nfv_plugins_dir = ./nfv-plugins
|
||||
nfv_vim_dir = ./nfv-vim
|
||||
nfv_test_dir = ./nfv-tests
|
||||
stx_fault_dir = ../../stx-fault
|
||||
|
||||
nfv_client_src_dir = {[nfv]nfv_client_dir}/nfv_client
|
||||
nfv_common_src_dir = {[nfv]nfv_common_dir}/nfv_common
|
||||
nfv_plugins_src_dir = {[nfv]nfv_plugins_dir}/nfv_plugins
|
||||
nfv_vim_src_dir = {[nfv]nfv_vim_dir}/nfv_vim
|
||||
nfv_test_src_dir = {[nfv]nfv_test_dir}
|
||||
|
||||
deps = {[nfv]nfv_client_dir}
|
||||
{[nfv]nfv_common_dir}
|
||||
|
@ -100,12 +102,17 @@ commands =
|
|||
|
||||
[testenv:pylint]
|
||||
deps = {[nfv]deps}
|
||||
fixtures
|
||||
jinja2
|
||||
mock
|
||||
testtools
|
||||
pylint
|
||||
basepython = python2.7
|
||||
commands = pylint {[nfv]nfv_client_src_dir} \
|
||||
{[nfv]nfv_common_src_dir} \
|
||||
{[nfv]nfv_plugins_src_dir} \
|
||||
{[nfv]nfv_vim_src_dir} \
|
||||
{[nfv]nfv_test_src_dir} \
|
||||
--rcfile=./pylint.rc
|
||||
|
||||
[bandit]
|
||||
|
@ -127,30 +134,44 @@ commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
|
|||
[testenv:py27]
|
||||
basepython = python2.7
|
||||
deps = {[nfv]deps}
|
||||
mock
|
||||
nose
|
||||
coverage
|
||||
fixtures
|
||||
mock
|
||||
stestr
|
||||
testtools
|
||||
setenv = PYTHONDONTWRITEBYTECODE=True
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
|
||||
{envbindir}/nosetests --exe -w {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests/ '{posargs}'
|
||||
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
|
||||
stestr slowest
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
deps = {[nfv]deps}
|
||||
mock
|
||||
nose
|
||||
coverage
|
||||
fixtures
|
||||
mock
|
||||
stestr
|
||||
testtools
|
||||
setenv = PYTHONDONTWRITEBYTECODE=True
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
|
||||
{envbindir}/nosetests --exe -w {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests/ '{posargs}'
|
||||
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
|
||||
stestr slowest
|
||||
|
||||
[testenv:cover]
|
||||
basepython = python2.7
|
||||
deps = {[nfv]deps}
|
||||
mock
|
||||
nose
|
||||
coverage
|
||||
setenv = PYTHONDONTWRITEBYTECODE=True
|
||||
fixtures
|
||||
mock
|
||||
stestr
|
||||
testtools
|
||||
setenv =
|
||||
PYTHON=coverage run --parallel-mode
|
||||
PYTHONDONTWRITEBYTECODE=True
|
||||
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
|
||||
{envbindir}/nosetests --exe --cover-erase --cover-branches \
|
||||
--cover-package=nfv_common,nfv_vim --with-coverage -w {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests/
|
||||
coverage erase
|
||||
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
|
||||
coverage combine
|
||||
coverage html -d cover
|
||||
coverage xml -o cover/coverage.xml
|
||||
coverage report
|
||||
|
|
Loading…
Reference in New Issue