diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/ci/load_images.sh | 19 | ||||
-rw-r--r-- | tests/unit/benchmark/core/test_report.py | 72 |
2 files changed, 82 insertions, 9 deletions
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh index ee46962b5..a326458a9 100755 --- a/tests/ci/load_images.sh +++ b/tests/ci/load_images.sh @@ -15,21 +15,22 @@ set -e YARD_IMG_ARCH=amd64 export YARD_IMG_ARCH -HW_FW_TYPE="" -if [ "${YARD_IMG_ARCH}" == "arm64" ]; then - HW_FW_TYPE=uefi -fi -export HW_FW_TYPE - if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" | sudo tee -a /etc/sudoers fi -ARCH_SCRIPT="test -f /etc/fuel_openstack_arch && grep -q arm64 /etc/fuel_openstack_arch" +# Look for a compute node, that is online, and check if it is aarch64 +ARCH_SCRIPT="ssh \$(fuel2 node list | awk -F'|' '\$6 ~ /compute/ && \$11 ~ /rue/ {print \$7; exit;}') uname -m 2>/dev/null | grep -q aarch64" if [ "$INSTALLER_TYPE" == "fuel" ]; then sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root "${INSTALLER_IP}" "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64 fi +HW_FW_TYPE="" +if [ "${YARD_IMG_ARCH}" == "arm64" ]; then + HW_FW_TYPE=uefi +fi +export HW_FW_TYPE + UCA_HOST="cloud-images.ubuntu.com" if [ "${YARD_IMG_ARCH}" == "arm64" ]; then export CLOUD_IMG_URL="http://${UCA_HOST}/${release}/current/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz" @@ -236,8 +237,8 @@ main() build_yardstick_image load_yardstick_image if [ "${YARD_IMG_ARCH}" == "arm64" ]; then - sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \ - samples/ping.yaml + sed -i 's/image: {{image}}/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml + sed -i 's/image: cirros-0.3.3/image: TestVM/g' samples/ping.yaml #We have overlapping IP with the real network for filename in tests/opnfv/test_cases/*; do sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}" diff --git a/tests/unit/benchmark/core/test_report.py b/tests/unit/benchmark/core/test_report.py new file mode 100644 index 000000000..69546928c --- /dev/null +++ b/tests/unit/benchmark/core/test_report.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +############################################################################## +# Copyright (c) 2017 Rajesh Kudaka. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Unittest for yardstick.benchmark.core.report + +from __future__ import print_function + +from __future__ import absolute_import + +import unittest +import uuid + +try: + from unittest import mock +except ImportError: + import mock + +from yardstick.benchmark.core import report +from yardstick.cmd.commands import change_osloobj_to_paras + +FAKE_YAML_NAME = 'fake_name' +FAKE_TASK_ID = str(uuid.uuid4()) +FAKE_DB_FIELDKEYS = [{'fieldKey': 'fake_key'}] +FAKE_TIME = '0000-00-00T00:00:00.000000Z' +FAKE_DB_TASK = [{'fake_key': 0.000, 'time': FAKE_TIME}] +FAKE_TIMESTAMP = ['fake_time'] +DUMMY_TASK_ID = 'aaaaaa-aaaaaaaa-aaaaaaaaaa-aaaaaa' + + +class ReportTestCase(unittest.TestCase): + + def setUp(self): + super(ReportTestCase, self).setUp() + self.param = change_osloobj_to_paras({}) + self.param.yaml_name = [FAKE_YAML_NAME] + self.param.task_id = [FAKE_TASK_ID] + self.rep = report.Report() + + @mock.patch('yardstick.benchmark.core.report.Report._get_tasks') + @mock.patch('yardstick.benchmark.core.report.Report._get_fieldkeys') + @mock.patch('yardstick.benchmark.core.report.Report._validate') + def test_generate_success(self, mock_valid, mock_keys, mock_tasks): + mock_tasks.return_value = FAKE_DB_TASK + mock_keys.return_value = FAKE_DB_FIELDKEYS + self.rep.generate(self.param) + mock_valid.assert_called_once_with(FAKE_YAML_NAME, FAKE_TASK_ID) + self.assertEqual(1, mock_tasks.call_count) + self.assertEqual(1, mock_keys.call_count) + + def test_invalid_yaml_name(self): + self.assertRaisesRegexp(ValueError, "yaml*", self.rep._validate, + 'F@KE_NAME', FAKE_TASK_ID) + + def test_invalid_task_id(self): + self.assertRaisesRegexp(ValueError, "task*", self.rep._validate, + FAKE_YAML_NAME, DUMMY_TASK_ID) + + @mock.patch('api.utils.influx.query') + def test_task_not_found(self, mock_query): + mock_query.return_value = [] + self.rep.yaml_name = FAKE_YAML_NAME + self.rep.task_id = FAKE_TASK_ID + self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_fieldkeys) + self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_tasks) |