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:
parent
b5c8d4e088
commit
9efe822991
@ -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:
|
||||
|
@ -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"],
|
||||
|
@ -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()}
|
||||
|
||||
|
@ -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"]
|
||||
|
@ -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()"
|
||||
|
@ -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"]
|
||||
|
@ -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),
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user