Add "description" to task config

Fetch "description" from scenario doc string if no user specified
description then add it to the task config. String "description"
property will be added to the config.

Partial-bug: #1447496

Co-Authored-By: Andrey Kurilin <andr.kurilin@gmail.com>

Change-Id: I882938e86d6c8209b669d7220285e8aa05bdd3e3
This commit is contained in:
liyingjun 2015-09-23 09:29:57 +08:00 committed by Hai Shi
parent b5c8d4e088
commit 9efe822991
8 changed files with 56 additions and 10 deletions

View File

@ -298,6 +298,7 @@
max_degradation: 50
-
description: "Check 'constant' runner."
args:
sleep: 0.25
runner:
@ -310,6 +311,7 @@
max: 0
-
description: "Check 'constant_for_duration' runner."
args:
sleep: 0.1
runner:
@ -321,6 +323,7 @@
max: 0
-
description: "Check 'rps' runner."
args:
sleep: 0.001
runner:
@ -332,6 +335,7 @@
max: 0
-
description: "Check 'rps' runner with float value of requests per second."
args:
sleep: 0.1
runner:
@ -354,6 +358,7 @@
max: 0
-
description: "Check 'max_concurrency' and 'max_cpu_count' properties of 'rps' runner."
args:
sleep: 0.001
runner:
@ -367,6 +372,7 @@
max: 0
-
description: "Check 'serial' runner."
args:
sleep: 0.1
runner:
@ -390,6 +396,7 @@
failure_rate:
max: 0
-
description: "Check 'quotas' context."
args:
sleep: 0.01
runner:

View File

@ -229,6 +229,7 @@ class Connection(object):
"updated_at": workload.updated_at,
"key": {
"name": workload.name,
"description": workload.description,
"pos": workload.position,
"kw": {
"args": workload.args,
@ -420,6 +421,7 @@ class Connection(object):
subtask_uuid=subtask_uuid)
workload.update({
"name": key["name"],
"description": key["description"],
"position": key["pos"],
"runner": key["kw"]["runner"],
"runner_type": key["kw"]["runner"]["type"],

View File

@ -491,6 +491,9 @@ class TaskConfig(object):
"type": "object",
"properties": {
"args": {"type": "object"},
"description": {
"type": "string"
},
"runner": {
"type": "object",
"properties": {"type": {"type": "string"}},
@ -544,6 +547,7 @@ class TaskConfig(object):
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"args": {"type": "object"},
"runner": {
@ -664,6 +668,15 @@ class Workload(object):
"""
def __init__(self, config, pos):
self.name = config["name"]
self.description = config.get("description", "")
if not self.description:
try:
self.description = scenario.Scenario.get(
self.name).get_info()["title"]
except (exceptions.PluginNotFound,
exceptions.MultipleMatchesFound):
# let's fail an issue with loading plugin at a validation step
pass
self.runner = config.get("runner", {})
self.sla = config.get("sla", {})
self.hooks = config.get("hooks", [])
@ -702,6 +715,7 @@ class Workload(object):
def make_key(self):
return {"name": self.name,
"description": self.description,
"pos": self.pos,
"kw": self.to_task()}

View File

@ -140,6 +140,7 @@ def _process_scenario(data, pos):
"runner": kw["runner"]["type"],
"config": json.dumps({data["key"]["name"]: [kw]}, indent=2),
"hooks": _process_hooks(data["hooks"]),
"description": data["key"].get("description", ""),
"iterations": {
"iter": main_area.render(),
"pie": [("success", (data["info"]["iterations_count"]

View File

@ -473,6 +473,9 @@
<div ng-show="view.is_scenario">
<h1>{{scenario.cls}}.<wbr>{{scenario.name}} ({{scenario.full_duration | number:3}}s)</h1>
<div ng-show="scenario.description" style="margin-bottom: 20px;">
<i>{{scenario.description}}</i>
</div>
<ul class="tabs">
<li ng-repeat="t in tabs"
ng-show="t.isVisible()"

View File

@ -215,6 +215,7 @@ class TasksTestCase(test.DBTestCase):
task_id = self._create_task()["uuid"]
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -270,6 +271,7 @@ class TasksTestCase(test.DBTestCase):
task2 = self._create_task()["uuid"]
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"task_id": "task_id"},
@ -313,6 +315,7 @@ class TasksTestCase(test.DBTestCase):
"tag": "bar"})
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -362,6 +365,7 @@ class TasksTestCase(test.DBTestCase):
task1 = self._create_task()
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -408,6 +412,7 @@ class TasksTestCase(test.DBTestCase):
task_id = self._create_task()["uuid"]
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -457,6 +462,7 @@ class TasksTestCase(test.DBTestCase):
task_id = self._create_task()["uuid"]
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -552,6 +558,7 @@ class WorkloadTestCase(test.DBTestCase):
def test_workload_create(self):
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -562,6 +569,7 @@ class WorkloadTestCase(test.DBTestCase):
}
workload = db.workload_create(self.task_uuid, self.subtask_uuid, key)
self.assertEqual("atata", workload["name"])
self.assertEqual("tatata", workload["description"])
self.assertEqual(0, workload["position"])
self.assertEqual({"a": "A"}, workload["args"])
self.assertEqual({"c": "C"}, workload["context"])
@ -574,6 +582,7 @@ class WorkloadTestCase(test.DBTestCase):
def test_workload_set_results_with_raw_data(self):
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -603,6 +612,7 @@ class WorkloadTestCase(test.DBTestCase):
db.workload_data_create(self.task_uuid, workload["uuid"], 0, raw_data)
workload = db.workload_set_results(workload["uuid"], data)
self.assertEqual("atata", workload["name"])
self.assertEqual("tatata", workload["description"])
self.assertEqual(0, workload["position"])
self.assertEqual({"a": "A"}, workload["args"])
self.assertEqual({"c": "C"}, workload["context"])
@ -624,6 +634,7 @@ class WorkloadTestCase(test.DBTestCase):
def test_workload_set_results_empty_raw_data(self):
key = {
"name": "atata",
"description": "tatata",
"pos": 0,
"kw": {
"args": {"a": "A"},
@ -645,6 +656,7 @@ class WorkloadTestCase(test.DBTestCase):
workload = db.workload_create(self.task_uuid, self.subtask_uuid, key)
workload = db.workload_set_results(workload["uuid"], data)
self.assertEqual("atata", workload["name"])
self.assertEqual("tatata", workload["description"])
self.assertEqual(0, workload["position"])
self.assertEqual({"a": "A"}, workload["args"])
self.assertEqual({"c": "C"}, workload["context"])
@ -672,8 +684,8 @@ class WorkloadDataTestCase(test.DBTestCase):
self.task_uuid = self.task["uuid"]
self.subtask = db.subtask_create(self.task_uuid, title="foo")
self.subtask_uuid = self.subtask["uuid"]
self.key = {"name": "atata", "pos": 0, "kw": {"runner": {"r": "R",
"type": "T"}}}
self.key = {"name": "atata", "description": "tatata",
"pos": 0, "kw": {"runner": {"r": "R", "type": "T"}}}
self.workload = db.workload_create(self.task_uuid, self.subtask_uuid,
self.key)
self.workload_uuid = self.workload["uuid"]

View File

@ -46,8 +46,8 @@ class PlotTestCase(test.TestCase):
"output": {"additive": [], "complete": []},
"atomic_actions": {"foo_action": i + 10}} for i in range(10)]
data = {"iterations": iterations, "sla": [],
"key": {"kw": {"runner": {"type": "constant"}},
"name": "Foo.bar", "pos": 0},
"key": {"kw": {"runner": {"type": "constant"}}, "pos": 0,
"name": "Foo.bar", "description": "Description!!"},
"info": {"atomic": {"foo_action": {"max_duration": 19,
"min_duration": 10}},
"full_duration": 40, "load_duration": 32,
@ -60,7 +60,8 @@ class PlotTestCase(test.TestCase):
result = plot._process_scenario(data, 1)
self.assertEqual(
{"cls": "Foo", "met": "bar", "name": "bar [2]", "pos": "1",
{"cls": "Foo", "met": "bar", "pos": "1",
"name": "bar [2]", "description": "Description!!",
"runner": "constant", "config": json.dumps(
{"Foo.bar": [{"runner": {"type": "constant"}}]},
indent=2),

View File

@ -372,9 +372,11 @@ class TaskEngineTestCase(test.TestCase):
mock_subtask = mock.MagicMock()
mock_subtask.workloads = [
engine.Workload(
{"name": "a.task", "context": {"context_a": {"a": 1}}}, 0),
{"name": "a.task", "description": "foo",
"context": {"context_a": {"a": 1}}}, 0),
engine.Workload(
{"name": "b.task", "context": {"context_b": {"b": 2}}}, 1)
{"name": "b.task", "description": "foo",
"context": {"context_b": {"b": 2}}}, 1)
]
mock_task_instance.subtasks = [mock_subtask]
@ -403,9 +405,12 @@ class TaskEngineTestCase(test.TestCase):
False,
True]
config = {
"a.task": [{"runner": {"type": "a", "b": 1}}],
"b.task": [{"runner": {"type": "a", "b": 1}}],
"c.task": [{"runner": {"type": "a", "b": 1}}]
"a.task": [{"runner": {"type": "a", "b": 1},
"description": "foo"}],
"b.task": [{"runner": {"type": "a", "b": 1},
"description": "bar"}],
"c.task": [{"runner": {"type": "a", "b": 1},
"description": "xxx"}]
}
fake_runner_cls = mock.MagicMock()
fake_runner = mock.MagicMock()
@ -969,6 +974,7 @@ class WorkloadTestCase(test.TestCase):
def test_make_key(self):
expected_key = {
"name": "n",
"description": "",
"pos": 0,
"kw": {
"runner": "r",