summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/load_images.sh15
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_base.py34
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py73
3 files changed, 42 insertions, 80 deletions
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index e73d7e800..666a78b40 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -63,11 +63,14 @@ build_yardstick_image()
fi
else
if [ ! -f "${QCOW_IMAGE}" ];then
- local cmd
- cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
-
- # Build the image. Retry once if the build fails
- $cmd || $cmd
+ ANSIBLE_SCRIPTS="${0%/*}/../../ansible"
+ cd ${ANSIBLE_SCRIPTS} &&\
+ ansible-playbook \
+ -e img_modify_playbook='ubuntu_server_cloudimg_modify.yml' \
+ -e target_os='Ubuntu' \
+ -e YARD_IMG_ARCH='amd64' \
+ -e ubuntu_img_file="${QCOW_IMAGE}" \
+ -vvv -i inventory.ini build_yardstick_image.yml
if [ ! -f "${QCOW_IMAGE}" ]; then
echo "Failed building QCOW image"
@@ -209,7 +212,7 @@ create_nova_flavor()
echo
echo "========== Creating yardstick-flavor =========="
# Create the nova flavor used by some sample test cases
- openstack ${SECURE} flavor create --id 100 --ram 1024 --disk 3 --vcpus 1 yardstick-flavor
+ openstack ${SECURE} flavor create --id 100 --ram 1024 --disk 10 --vcpus 1 yardstick-flavor
# DPDK-enabled OVS requires guest memory to be backed by large pages
if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
openstack ${SECURE} flavor set --property hw:mem_page_size=large yardstick-flavor
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_base.py b/tests/unit/network_services/vnf_generic/vnf/test_base.py
index 478ce186b..f812d67ef 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_base.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_base.py
@@ -243,31 +243,13 @@ class TestGenericVNF(unittest.TestCase):
class TestGenericTrafficGen(unittest.TestCase):
- def test___init__(self):
- vnfd = TestGenericVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- generic_traffic_gen = GenericTrafficGen('vnf1', vnfd)
- assert generic_traffic_gen.name == "vnf1"
-
- def test_listen_traffic(self):
- vnfd = TestGenericVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- generic_traffic_gen = GenericTrafficGen('vnf1', vnfd)
- traffic_profile = {}
- self.assertIsNone(generic_traffic_gen.listen_traffic(traffic_profile))
-
- def test_run_traffic(self):
- vnfd = TestGenericVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- generic_traffic_gen = GenericTrafficGen('vnf1', vnfd)
- traffic_profile = {}
- self.assertRaises(NotImplementedError,
- generic_traffic_gen.run_traffic, traffic_profile)
-
- def test_terminate(self):
- vnfd = TestGenericVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- generic_traffic_gen = GenericTrafficGen('vnf1', vnfd)
- self.assertRaises(NotImplementedError, generic_traffic_gen.terminate)
- def test_verify_traffic(self):
+ def test_definition(self):
+ """Make sure that the abstract class cannot be instantiated"""
vnfd = TestGenericVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- generic_traffic_gen = GenericTrafficGen('vnf1', vnfd)
- traffic_profile = {}
- self.assertIsNone(generic_traffic_gen.verify_traffic(traffic_profile))
+ name = 'vnf1'
+ with self.assertRaises(TypeError) as exc:
+ GenericTrafficGen(name, vnfd)
+ msg = ("Can't instantiate abstract class GenericTrafficGen with "
+ "abstract methods run_traffic, terminate")
+ self.assertEqual(msg, str(exc.exception))
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index 57f9fac61..85b10c5a9 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
@@ -2022,55 +2022,32 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
sample_vnf_tg.terminate()
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.LOG')
- def test_wait_for_instantiate(self, mock_logger, mock_time):
+ def test__wait_for_process(self):
sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0)
- sample_vnf_tg._check_status = mock.Mock(side_effect=iter([1, 0]))
- sample_vnf_tg._tg_process = mock.Mock()
- sample_vnf_tg._tg_process.is_alive.return_value = True
- sample_vnf_tg._tg_process.exitcode = 234
-
- self.assertEqual(sample_vnf_tg.wait_for_instantiate(), 234)
-
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.LOG')
- def test_wait_for_instantiate_not_alive(self, mock_logger, mock_time):
+ with mock.patch.object(sample_vnf_tg, '_check_status',
+ return_value=0) as mock_status, \
+ mock.patch.object(sample_vnf_tg, '_tg_process') as mock_proc:
+ mock_proc.is_alive.return_value = True
+ mock_proc.exitcode = 234
+ self.assertEqual(sample_vnf_tg._wait_for_process(), 234)
+ mock_proc.is_alive.assert_called_once()
+ mock_status.assert_called_once()
+
+ def test__wait_for_process_not_alive(self):
sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0)
- sample_vnf_tg._check_status = mock.Mock(return_value=1)
- sample_vnf_tg._tg_process = mock.Mock()
- sample_vnf_tg._tg_process.is_alive.side_effect = iter([True, False])
- sample_vnf_tg._tg_process.exitcode = 234
-
- with self.assertRaises(RuntimeError):
- sample_vnf_tg.wait_for_instantiate()
-
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.LOG')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.Process')
- def test_wait_for_instantiate_delayed(self, mock_process, mock_logger, mock_time):
- class MockClientStarted(mock.Mock):
-
- def __init__(self, *args, **kwargs):
- super(MockClientStarted, self).__init__(*args, **kwargs)
- self.iter = iter([0, 0, 1])
-
- @property
- def value(self):
- return next(self.iter)
-
- mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
- mock_traffic_profile.get_traffic_definition.return_value = "64"
- mock_traffic_profile.execute_traffic.return_value = "64"
- mock_traffic_profile.params = self.TRAFFIC_PROFILE
+ with mock.patch.object(sample_vnf_tg, '_tg_process') as mock_proc:
+ mock_proc.is_alive.return_value = False
+ self.assertRaises(RuntimeError, sample_vnf_tg._wait_for_process)
+ mock_proc.is_alive.assert_called_once()
+ def test__wait_for_process_delayed(self):
sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0)
- sample_vnf_tg._check_status = mock.Mock(side_effect=iter([1, 0]))
- sample_vnf_tg._tg_process = mock.Mock()
- sample_vnf_tg._tg_process.is_alive.return_value = True
- sample_vnf_tg._tg_process.exitcode = 234
- sample_vnf_tg.resource_helper = mock.Mock()
- sample_vnf_tg.resource_helper.client_started = MockClientStarted()
-
- self.assertTrue(sample_vnf_tg.run_traffic(mock_traffic_profile))
- self.assertEqual(mock_time.sleep.call_count, 2)
+ with mock.patch.object(sample_vnf_tg, '_check_status',
+ side_effect=[1, 0]) as mock_status, \
+ mock.patch.object(sample_vnf_tg,
+ '_tg_process') as mock_proc:
+ mock_proc.is_alive.return_value = True
+ mock_proc.exitcode = 234
+ self.assertEqual(sample_vnf_tg._wait_for_process(), 234)
+ mock_proc.is_alive.assert_has_calls([mock.call(), mock.call()])
+ mock_status.assert_has_calls([mock.call(), mock.call()])