Merge "Add "description" to task config"

This commit is contained in:
Jenkins 2017-03-25 11:00:43 +00:00 committed by Gerrit Code Review
commit 44047515ab
8 changed files with 56 additions and 10 deletions

View File

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

View File

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

View File

@ -491,6 +491,9 @@ class TaskConfig(object):
"type": "object", "type": "object",
"properties": { "properties": {
"args": {"type": "object"}, "args": {"type": "object"},
"description": {
"type": "string"
},
"runner": { "runner": {
"type": "object", "type": "object",
"properties": {"type": {"type": "string"}}, "properties": {"type": {"type": "string"}},
@ -544,6 +547,7 @@ class TaskConfig(object):
"type": "object", "type": "object",
"properties": { "properties": {
"name": {"type": "string"}, "name": {"type": "string"},
"description": {"type": "string"},
"args": {"type": "object"}, "args": {"type": "object"},
"runner": { "runner": {
@ -664,6 +668,15 @@ class Workload(object):
""" """
def __init__(self, config, pos): def __init__(self, config, pos):
self.name = config["name"] 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.runner = config.get("runner", {})
self.sla = config.get("sla", {}) self.sla = config.get("sla", {})
self.hooks = config.get("hooks", []) self.hooks = config.get("hooks", [])
@ -702,6 +715,7 @@ class Workload(object):
def make_key(self): def make_key(self):
return {"name": self.name, return {"name": self.name,
"description": self.description,
"pos": self.pos, "pos": self.pos,
"kw": self.to_task()} "kw": self.to_task()}

View File

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

View File

@ -473,6 +473,9 @@
<div ng-show="view.is_scenario"> <div ng-show="view.is_scenario">
<h1>{{scenario.cls}}.<wbr>{{scenario.name}} ({{scenario.full_duration | number:3}}s)</h1> <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"> <ul class="tabs">
<li ng-repeat="t in tabs" <li ng-repeat="t in tabs"
ng-show="t.isVisible()" ng-show="t.isVisible()"

View File

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

View File

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

View File

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