aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/install_trex/tasks
diff options
context:
space:
mode:
authorVolodymyr Mytnyk <volodymyrx.mytnyk@intel.com>2019-02-05 12:56:33 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-02-05 12:56:33 +0000
commit0e79473ddc9d5185185f555303d40fdc075c9920 (patch)
tree733c6a5f52b766299e41e9d4500ee939d355a583 /ansible/roles/install_trex/tasks
parentdeea27f8e9c99b0a547b4c8c2f39dd99d5c4f1a8 (diff)
parent1d8674c2108b03dbb75713a7cd0b224edebb284f (diff)
Merge "Add vBNG test cases stats processing functionality"
Diffstat (limited to 'ansible/roles/install_trex/tasks')
0 files changed, 0 insertions, 0 deletions
font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
##############################################################################
# Copyright (c) 2017 Huawei Technologies Co.,Ltd.
#
# 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
##############################################################################
import os
import errno
import logging

import yaml

from api import ApiResource
from yardstick.common.utils import result_handler
from yardstick.common import constants as consts
from yardstick.benchmark.core.testsuite import Testsuite
from yardstick.benchmark.core import Param

LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)


class V2Testsuites(ApiResource):

    def get(self):
        param = Param({})
        testsuite_list = Testsuite().list_all(param)

        data = {
            'testsuites': testsuite_list
        }

        return result_handler(consts.API_SUCCESS, data)

    def post(self):
        return self._dispatch_post()

    def create_suite(self, args):
        try:
            suite_name = args['name']
        except KeyError:
            return result_handler(consts.API_ERROR, 'name must be provided')

        try:
            testcases = args['testcases']
        except KeyError:
            return result_handler(consts.API_ERROR, 'testcases must be provided')

        testcases = [{'file_name': '{}.yaml'.format(t)} for t in testcases]

        suite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name))
        suite_content = {
            'schema': 'yardstick:suite:0.1',
            'name': suite_name,
            'test_cases_dir': 'tests/opnfv/test_cases/',
            'test_cases': testcases
        }

        LOG.info('write test suite')
        with open(suite, 'w') as f:
            yaml.dump(suite_content, f, default_flow_style=False)

        return result_handler(consts.API_SUCCESS, {'suite': suite_name})


class V2Testsuite(ApiResource):

    def get(self, suite_name):
        suite_path = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name))
        try:
            with open(suite_path) as f:
                data = f.read()
        except IOError as e:
            if e.errno == errno.ENOENT:
                return result_handler(consts.API_ERROR, 'suite does not exist')

        return result_handler(consts.API_SUCCESS, {'testsuite': data})

    def delete(self, suite_name):
        suite_path = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name))
        try:
            os.remove(suite_path)
        except IOError as e:
            if e.errno == errno.ENOENT:
                return result_handler(consts.API_ERROR, 'suite does not exist')

        return result_handler(consts.API_SUCCESS, {'testsuite': suite_name})