From da62008a0a98cb8793ea42827a7da5e149edd144 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Mon, 26 Jun 2017 09:46:24 +0000 Subject: Call core code directly in the API of run test case JIRA: YARDSTICK-688 We need to call core code directly in the API of runTestCase. It would be more stable. Change-Id: I431a85ded7cd3b20da0462f947c25d91bb99decd Signed-off-by: chenjiankun --- yardstick/benchmark/core/runner.py | 2 +- yardstick/benchmark/core/scenario.py | 2 +- yardstick/benchmark/core/task.py | 9 ++++++++- yardstick/cmd/cli.py | 2 +- yardstick/cmd/commands/plugin.py | 2 +- yardstick/cmd/commands/report.py | 2 +- yardstick/cmd/commands/runner.py | 2 +- yardstick/cmd/commands/scenario.py | 2 +- yardstick/cmd/commands/task.py | 2 +- yardstick/common/constants.py | 3 +++ 10 files changed, 19 insertions(+), 9 deletions(-) (limited to 'yardstick') diff --git a/yardstick/benchmark/core/runner.py b/yardstick/benchmark/core/runner.py index b9c22cbc9..64acdaa99 100644 --- a/yardstick/benchmark/core/runner.py +++ b/yardstick/benchmark/core/runner.py @@ -15,7 +15,7 @@ from yardstick.benchmark.runners.base import Runner from yardstick.benchmark.core import print_hbar -class Runners(object): +class Runners(object): # pragma: no cover """Runner commands. Set of commands to discover and display runner types. diff --git a/yardstick/benchmark/core/scenario.py b/yardstick/benchmark/core/scenario.py index a9d933faf..cd119c24c 100644 --- a/yardstick/benchmark/core/scenario.py +++ b/yardstick/benchmark/core/scenario.py @@ -15,7 +15,7 @@ from yardstick.benchmark.scenarios.base import Scenario from yardstick.benchmark.core import print_hbar -class Scenarios(object): +class Scenarios(object): # pragma: no cover """Scenario commands. Set of commands to discover and display scenario types. diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index 478a51f9d..9c6caf03f 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -20,6 +20,8 @@ import time import logging import uuid import errno +import collections + from six.moves import filter from yardstick.benchmark.contexts.base import Context @@ -51,7 +53,8 @@ class Task(object): # pragma: no cover atexit.register(self.atexit_handler) - self.task_id = kwargs.get('task_id', str(uuid.uuid4())) + task_id = getattr(args, 'task_id') + self.task_id = task_id if task_id else str(uuid.uuid4()) check_environment() @@ -133,6 +136,7 @@ class Task(object): # pragma: no cover scenario['task_id'], scenario['tc']) print("Done, exiting") + return result def _init_output_config(self, output_config): output_config.setdefault('DEFAULT', {}) @@ -594,6 +598,9 @@ def print_invalid_header(source_name, args): def parse_task_args(src_name, args): + if isinstance(args, collections.Mapping): + return args + try: kw = args and yaml.safe_load(args) kw = {} if kw is None else kw diff --git a/yardstick/cmd/cli.py b/yardstick/cmd/cli.py index 79f66e574..d2c49e89b 100644 --- a/yardstick/cmd/cli.py +++ b/yardstick/cmd/cli.py @@ -53,7 +53,7 @@ def find_config_files(path_list): return None -class YardstickCLI(): +class YardstickCLI(): # pragma: no cover """Command-line interface to yardstick""" # Command categories diff --git a/yardstick/cmd/commands/plugin.py b/yardstick/cmd/commands/plugin.py index f97c490b7..b90ac15e6 100644 --- a/yardstick/cmd/commands/plugin.py +++ b/yardstick/cmd/commands/plugin.py @@ -17,7 +17,7 @@ from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras -class PluginCommands(object): +class PluginCommands(object): # pragma: no cover """Plugin commands. Set of commands to manage plugins. diff --git a/yardstick/cmd/commands/report.py b/yardstick/cmd/commands/report.py index 87ae7d5f7..47bf22a1f 100644 --- a/yardstick/cmd/commands/report.py +++ b/yardstick/cmd/commands/report.py @@ -19,7 +19,7 @@ from yardstick.cmd.commands import change_osloobj_to_paras from yardstick.common.utils import cliargs -class ReportCommands(object): +class ReportCommands(object): # pragma: no cover """Report commands. Set of commands to manage benchmark tasks. diff --git a/yardstick/cmd/commands/runner.py b/yardstick/cmd/commands/runner.py index b99ae789b..9ee99cf44 100644 --- a/yardstick/cmd/commands/runner.py +++ b/yardstick/cmd/commands/runner.py @@ -17,7 +17,7 @@ from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras -class RunnerCommands(object): +class RunnerCommands(object): # pragma: no cover """Runner commands. Set of commands to discover and display runner types. diff --git a/yardstick/cmd/commands/scenario.py b/yardstick/cmd/commands/scenario.py index 618ed2915..0e3f2c3be 100644 --- a/yardstick/cmd/commands/scenario.py +++ b/yardstick/cmd/commands/scenario.py @@ -16,7 +16,7 @@ from yardstick.common.utils import cliargs from yardstick.cmd.commands import change_osloobj_to_paras -class ScenarioCommands(object): +class ScenarioCommands(object): # pragma: no cover """Scenario commands. Set of commands to discover and display scenario types. diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 6384e6eb1..0f98cabdc 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -19,7 +19,7 @@ from yardstick.cmd.commands import change_osloobj_to_paras output_file_default = "/tmp/yardstick.out" -class TaskCommands(object): +class TaskCommands(object): # pragma: no cover """Task commands. Set of commands to manage benchmark tasks. diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index 47a519923..9edf78650 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -80,6 +80,9 @@ SQLITE = 'sqlite:////tmp/yardstick.db' API_SUCCESS = 1 API_ERROR = 2 +TASK_NOT_DONE = 0 +TASK_DONE = 1 +TASK_FAILED = 2 BASE_URL = 'http://localhost:5000' ENV_ACTION_API = BASE_URL + '/yardstick/env/action' -- cgit 1.2.3-korg