| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import time |
| 17 |
|
| 18 |
from tempest.lib import exceptions |
| 19 |
|
| 20 |
from mistralclient.tests.functional.cli import base |
| 21 |
from mistralclient.tests.functional.cli.v2 import base_v2 |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
MISTRAL_URL = "http://localhost/workflow/v2" |
| 27 |
|
| 28 |
|
| 29 |
class SimpleMistralCLITests(base.MistralCLIAuth): |
| 30 |
"""Basic tests, check '-list', '-help' commands.""" |
| 31 |
|
| 32 |
_mistral_url = MISTRAL_URL |
| 33 |
|
| 34 |
@classmethod |
| 35 |
def setUpClass(cls): |
| 36 |
super(SimpleMistralCLITests, cls).setUpClass() |
| 37 |
|
| 38 |
def test_workbooks_list(self): |
| 39 |
workbooks = self.parser.listing(self.mistral('workbook-list')) |
| 40 |
|
| 41 |
self.assertTableStruct( |
| 42 |
workbooks, |
| 43 |
['Name', 'Tags', 'Created at', 'Updated at'] |
| 44 |
) |
| 45 |
|
| 46 |
def test_workflow_list(self): |
| 47 |
workflows = self.parser.listing(self.mistral('workflow-list')) |
| 48 |
|
| 49 |
self.assertTableStruct( |
| 50 |
workflows, |
| 51 |
['ID', 'Name', 'Tags', 'Input', 'Scope', 'Created at', |
| 52 |
'Updated at'] |
| 53 |
) |
| 54 |
|
| 55 |
def test_executions_list(self): |
| 56 |
executions = self.parser.listing(self.mistral('execution-list')) |
| 57 |
|
| 58 |
self.assertTableStruct( |
| 59 |
executions, |
| 60 |
['ID', 'Workflow name', 'Workflow ID', 'State', 'Created at', |
| 61 |
'Updated at'] |
| 62 |
) |
| 63 |
|
| 64 |
def test_tasks_list(self): |
| 65 |
tasks = self.parser.listing(self.mistral('task-list')) |
| 66 |
|
| 67 |
self.assertTableStruct( |
| 68 |
tasks, |
| 69 |
['ID', 'Name', 'Workflow name', 'Workflow Execution ID', 'State'] |
| 70 |
) |
| 71 |
|
| 72 |
def test_cron_trigger_list(self): |
| 73 |
triggers = self.parser.listing(self.mistral('cron-trigger-list')) |
| 74 |
|
| 75 |
self.assertTableStruct( |
| 76 |
triggers, |
| 77 |
['Name', 'Workflow', 'Pattern', 'Next execution time', |
| 78 |
'Remaining executions', 'Created at', 'Updated at'] |
| 79 |
) |
| 80 |
|
| 81 |
def test_event_trigger_list(self): |
| 82 |
triggers = self.parser.listing(self.mistral('event-trigger-list')) |
| 83 |
|
| 84 |
self.assertTableStruct( |
| 85 |
triggers, |
| 86 |
['ID', 'Name', 'Workflow ID', 'Exchange', 'Topic', 'Event', |
| 87 |
'Created at', 'Updated at'] |
| 88 |
) |
| 89 |
|
| 90 |
def test_actions_list(self): |
| 91 |
actions = self.parser.listing(self.mistral('action-list')) |
| 92 |
|
| 93 |
self.assertTableStruct( |
| 94 |
actions, |
| 95 |
['Name', 'Is system', 'Input', 'Description', |
| 96 |
'Tags', 'Created at', 'Updated at'] |
| 97 |
) |
| 98 |
|
| 99 |
def test_environments_list(self): |
| 100 |
envs = self.parser.listing(self.mistral('environment-list')) |
| 101 |
|
| 102 |
self.assertTableStruct( |
| 103 |
envs, |
| 104 |
['Name', 'Description', 'Scope', 'Created at', 'Updated at'] |
| 105 |
) |
| 106 |
|
| 107 |
def test_action_execution_list(self): |
| 108 |
act_execs = self.parser.listing(self.mistral('action-execution-list')) |
| 109 |
|
| 110 |
self.assertTableStruct( |
| 111 |
act_execs, |
| 112 |
['ID', 'Name', 'Workflow name', 'State', 'Accepted'] |
| 113 |
) |
| 114 |
|
| 115 |
def test_action_execution_list_with_limit(self): |
| 116 |
act_execs = self.parser.listing( |
| 117 |
self.mistral( |
| 118 |
'action-execution-list', |
| 119 |
params='--limit 1' |
| 120 |
) |
| 121 |
) |
| 122 |
|
| 123 |
self.assertEqual(1, len(act_execs)) |
| 124 |
|
| 125 |
|
| 126 |
class WorkbookCLITests(base_v2.MistralClientTestBase): |
| 127 |
"""Test suite checks commands to work with workbooks.""" |
| 128 |
|
| 129 |
@classmethod |
| 130 |
def setUpClass(cls): |
| 131 |
super(WorkbookCLITests, cls).setUpClass() |
| 132 |
|
| 133 |
def test_workbook_create_delete(self): |
| 134 |
wb = self.mistral_admin('workbook-create', params=self.wb_def) |
| 135 |
|
| 136 |
wb_name = self.get_field_value(wb, "Name") |
| 137 |
|
| 138 |
self.assertTableStruct(wb, ['Field', 'Value']) |
| 139 |
|
| 140 |
wbs = self.mistral_admin('workbook-list') |
| 141 |
self.assertIn(wb_name, [w['Name'] for w in wbs]) |
| 142 |
|
| 143 |
wbs = self.mistral_admin('workbook-list') |
| 144 |
self.assertIn(wb_name, [w['Name'] for w in wbs]) |
| 145 |
|
| 146 |
self.mistral_admin('workbook-delete', params=wb_name) |
| 147 |
|
| 148 |
wbs = self.mistral_admin('workbook-list') |
| 149 |
self.assertNotIn(wb_name, [w['Name'] for w in wbs]) |
| 150 |
|
| 151 |
def test_workbook_create_with_tags(self): |
| 152 |
wb = self.workbook_create(self.wb_with_tags_def) |
| 153 |
|
| 154 |
self.assertIn('tag', self.get_field_value(wb, 'Tags')) |
| 155 |
|
| 156 |
def test_workbook_update(self): |
| 157 |
wb = self.workbook_create(self.wb_def) |
| 158 |
|
| 159 |
wb_name = self.get_field_value(wb, "Name") |
| 160 |
|
| 161 |
init_update_at = self.get_field_value(wb, "Updated at") |
| 162 |
tags = self.get_field_value(wb, 'Tags') |
| 163 |
|
| 164 |
self.assertNotIn('tag', tags) |
| 165 |
|
| 166 |
wb = self.mistral_admin('workbook-update', params=self.wb_def) |
| 167 |
|
| 168 |
update_at = self.get_field_value(wb, "Updated at") |
| 169 |
name = self.get_field_value(wb, 'Name') |
| 170 |
tags = self.get_field_value(wb, 'Tags') |
| 171 |
|
| 172 |
self.assertEqual(wb_name, name) |
| 173 |
self.assertNotIn('tag', tags) |
| 174 |
self.assertEqual(init_update_at, update_at) |
| 175 |
|
| 176 |
wb = self.mistral_admin( |
| 177 |
'workbook-update', |
| 178 |
params=self.wb_with_tags_def |
| 179 |
) |
| 180 |
|
| 181 |
self.assertTableStruct(wb, ['Field', 'Value']) |
| 182 |
|
| 183 |
update_at = self.get_field_value(wb, "Updated at") |
| 184 |
name = self.get_field_value(wb, 'Name') |
| 185 |
tags = self.get_field_value(wb, 'Tags') |
| 186 |
|
| 187 |
self.assertEqual(wb_name, name) |
| 188 |
self.assertIn('tag', tags) |
| 189 |
self.assertNotEqual(init_update_at, update_at) |
| 190 |
|
| 191 |
def test_workbook_get(self): |
| 192 |
created = self.workbook_create(self.wb_with_tags_def) |
| 193 |
|
| 194 |
wb_name = self.get_field_value(created, "Name") |
| 195 |
|
| 196 |
fetched = self.mistral_admin('workbook-get', params=wb_name) |
| 197 |
|
| 198 |
created_wb_name = self.get_field_value(created, 'Name') |
| 199 |
fetched_wb_name = self.get_field_value(fetched, 'Name') |
| 200 |
|
| 201 |
self.assertEqual(created_wb_name, fetched_wb_name) |
| 202 |
|
| 203 |
created_wb_tag = self.get_field_value(created, 'Tags') |
| 204 |
fetched_wb_tag = self.get_field_value(fetched, 'Tags') |
| 205 |
|
| 206 |
self.assertEqual(created_wb_tag, fetched_wb_tag) |
| 207 |
|
| 208 |
def test_workbook_get_definition(self): |
| 209 |
wb = self.workbook_create(self.wb_def) |
| 210 |
|
| 211 |
wb_name = self.get_field_value(wb, "Name") |
| 212 |
|
| 213 |
definition = self.mistral_admin( |
| 214 |
'workbook-get-definition', |
| 215 |
params=wb_name |
| 216 |
) |
| 217 |
|
| 218 |
self.assertNotIn('404 Not Found', definition) |
| 219 |
|
| 220 |
def test_workbook_validate_with_valid_def(self): |
| 221 |
wb = self.mistral_admin('workbook-validate', params=self.wb_def) |
| 222 |
|
| 223 |
wb_valid = self.get_field_value(wb, 'Valid') |
| 224 |
wb_error = self.get_field_value(wb, 'Error') |
| 225 |
|
| 226 |
self.assertEqual('True', wb_valid) |
| 227 |
self.assertEqual('None', wb_error) |
| 228 |
|
| 229 |
def test_workbook_validate_with_invalid_def(self): |
| 230 |
self.create_file('wb.yaml', 'name: wb\n') |
| 231 |
|
| 232 |
wb = self.mistral_admin('workbook-validate', params='wb.yaml') |
| 233 |
|
| 234 |
wb_valid = self.get_field_value(wb, 'Valid') |
| 235 |
wb_error = self.get_field_value(wb, 'Error') |
| 236 |
|
| 237 |
self.assertEqual('False', wb_valid) |
| 238 |
self.assertNotEqual('None', wb_error) |
| 239 |
|
| 240 |
|
| 241 |
class WorkflowCLITests(base_v2.MistralClientTestBase): |
| 242 |
"""Test suite checks commands to work with workflows.""" |
| 243 |
|
| 244 |
@classmethod |
| 245 |
def setUpClass(cls): |
| 246 |
super(WorkflowCLITests, cls).setUpClass() |
| 247 |
|
| 248 |
def test_workflow_create_delete(self): |
| 249 |
init_wfs = self.mistral_admin('workflow-create', params=self.wf_def) |
| 250 |
|
| 251 |
wf_names = [wf['Name'] for wf in init_wfs] |
| 252 |
|
| 253 |
self.assertTableStruct(init_wfs, ['Name', 'Created at', 'Updated at']) |
| 254 |
|
| 255 |
wfs = self.mistral_admin('workflow-list') |
| 256 |
self.assertIn(wf_names[0], [workflow['Name'] for workflow in wfs]) |
| 257 |
|
| 258 |
for wf_name in wf_names: |
| 259 |
self.mistral_admin('workflow-delete', params=wf_name) |
| 260 |
|
| 261 |
wfs = self.mistral_admin('workflow-list') |
| 262 |
for wf in wf_names: |
| 263 |
self.assertNotIn(wf, [workflow['Name'] for workflow in wfs]) |
| 264 |
|
| 265 |
def test_workflow_within_namespace_create_delete(self): |
| 266 |
params = self.wf_def + ' --namespace abcdef' |
| 267 |
init_wfs = self.mistral_admin('workflow-create', params=params) |
| 268 |
|
| 269 |
wf_names = [wf['Name'] for wf in init_wfs] |
| 270 |
|
| 271 |
self.assertTableStruct(init_wfs, ['Name', 'Created at', 'Updated at']) |
| 272 |
|
| 273 |
wfs = self.mistral_admin('workflow-list') |
| 274 |
self.assertIn(wf_names[0], [workflow['Name'] for workflow in wfs]) |
| 275 |
|
| 276 |
for wf_name in wf_names: |
| 277 |
self.mistral_admin( |
| 278 |
'workflow-delete', |
| 279 |
params=wf_name + ' --namespace abcdef' |
| 280 |
) |
| 281 |
|
| 282 |
wfs = self.mistral_admin('workflow-list') |
| 283 |
for wf in wf_names: |
| 284 |
self.assertNotIn(wf, [workflow['Name'] for workflow in wfs]) |
| 285 |
|
| 286 |
init_wfs = self.mistral_admin('workflow-create', params=params) |
| 287 |
wf_ids = [wf['ID'] for wf in init_wfs] |
| 288 |
for wf_id in wf_ids: |
| 289 |
self.mistral_admin('workflow-delete', params=wf_id) |
| 290 |
|
| 291 |
for wf in wf_names: |
| 292 |
self.assertNotIn(wf, [workflow['Name'] for workflow in wfs]) |
| 293 |
|
| 294 |
def test_create_wf_with_tags(self): |
| 295 |
init_wfs = self.workflow_create(self.wf_def) |
| 296 |
wf_name = init_wfs[1]['Name'] |
| 297 |
|
| 298 |
self.assertTableStruct( |
| 299 |
init_wfs, |
| 300 |
['Name', 'Created at', 'Updated at', 'Tags'] |
| 301 |
) |
| 302 |
|
| 303 |
created_wf_info = self.get_item_info( |
| 304 |
get_from=init_wfs, |
| 305 |
get_by='Name', |
| 306 |
value=wf_name |
| 307 |
) |
| 308 |
|
| 309 |
self.assertEqual('tag', created_wf_info['Tags']) |
| 310 |
|
| 311 |
def test_workflow_update(self): |
| 312 |
wf = self.workflow_create(self.wf_def) |
| 313 |
|
| 314 |
wf_name = wf[0]['Name'] |
| 315 |
wf_id = wf[0]['ID'] |
| 316 |
|
| 317 |
created_wf_info = self.get_item_info( |
| 318 |
get_from=wf, |
| 319 |
get_by='Name', |
| 320 |
value=wf_name |
| 321 |
) |
| 322 |
|
| 323 |
|
| 324 |
upd_wf = self.mistral_admin( |
| 325 |
'workflow-update', |
| 326 |
params='{0}'.format(self.wf_def) |
| 327 |
) |
| 328 |
|
| 329 |
self.assertTableStruct(upd_wf, ['Name', 'Created at', 'Updated at']) |
| 330 |
|
| 331 |
updated_wf_info = self.get_item_info( |
| 332 |
get_from=upd_wf, |
| 333 |
get_by='Name', |
| 334 |
value=wf_name |
| 335 |
) |
| 336 |
|
| 337 |
self.assertEqual(wf_name, upd_wf[0]['Name']) |
| 338 |
self.assertEqual( |
| 339 |
created_wf_info['Created at'].split(".")[0], |
| 340 |
updated_wf_info['Created at'] |
| 341 |
) |
| 342 |
self.assertEqual( |
| 343 |
created_wf_info['Updated at'], |
| 344 |
updated_wf_info['Updated at'] |
| 345 |
) |
| 346 |
|
| 347 |
|
| 348 |
upd_wf = self.mistral_admin( |
| 349 |
'workflow-update', |
| 350 |
params='{0}'.format(self.wf_with_delay_def) |
| 351 |
) |
| 352 |
|
| 353 |
self.assertTableStruct(upd_wf, ['Name', 'Created at', 'Updated at']) |
| 354 |
|
| 355 |
updated_wf_info = self.get_item_info( |
| 356 |
get_from=upd_wf, |
| 357 |
get_by='Name', |
| 358 |
value=wf_name |
| 359 |
) |
| 360 |
|
| 361 |
self.assertEqual(wf_name, upd_wf[0]['Name']) |
| 362 |
self.assertEqual( |
| 363 |
created_wf_info['Created at'].split(".")[0], |
| 364 |
updated_wf_info['Created at'] |
| 365 |
) |
| 366 |
self.assertNotEqual( |
| 367 |
created_wf_info['Updated at'], |
| 368 |
updated_wf_info['Updated at'] |
| 369 |
) |
| 370 |
|
| 371 |
|
| 372 |
upd_wf = self.mistral_admin( |
| 373 |
'workflow-update', |
| 374 |
params='{0} --id {1}'.format(self.wf_with_delay_def, wf_id) |
| 375 |
) |
| 376 |
|
| 377 |
self.assertTableStruct(upd_wf, ['Name', 'Created at', 'Updated at']) |
| 378 |
|
| 379 |
updated_wf_info = self.get_item_info( |
| 380 |
get_from=upd_wf, |
| 381 |
get_by='ID', |
| 382 |
value=wf_id |
| 383 |
) |
| 384 |
|
| 385 |
self.assertEqual(wf_name, upd_wf[0]['Name']) |
| 386 |
self.assertEqual( |
| 387 |
created_wf_info['Created at'].split(".")[0], |
| 388 |
updated_wf_info['Created at'] |
| 389 |
) |
| 390 |
self.assertNotEqual( |
| 391 |
created_wf_info['Updated at'], |
| 392 |
updated_wf_info['Updated at'] |
| 393 |
) |
| 394 |
|
| 395 |
def test_workflow_update_within_namespace(self): |
| 396 |
namespace = 'abc' |
| 397 |
wf = self.workflow_create(self.wf_def, namespace=namespace) |
| 398 |
|
| 399 |
wf_name = wf[0]['Name'] |
| 400 |
wf_id = wf[0]['ID'] |
| 401 |
wf_namespace = wf[0]['Namespace'] |
| 402 |
created_wf_info = self.get_item_info( |
| 403 |
get_from=wf, |
| 404 |
get_by='Name', |
| 405 |
value=wf_name |
| 406 |
) |
| 407 |
|
| 408 |
|
| 409 |
upd_wf = self.mistral_admin( |
| 410 |
'workflow-update', |
| 411 |
params='{0} --namespace {1}'.format(self.wf_def, namespace) |
| 412 |
) |
| 413 |
|
| 414 |
self.assertTableStruct(upd_wf, ['Name', 'Created at', 'Updated at']) |
| 415 |
|
| 416 |
updated_wf_info = self.get_item_info( |
| 417 |
get_from=upd_wf, |
| 418 |
get_by='Name', |
| 419 |
value=wf_name |
| 420 |
) |
| 421 |
|
| 422 |
self.assertEqual(wf_name, upd_wf[0]['Name']) |
| 423 |
self.assertEqual(namespace, wf_namespace) |
| 424 |
self.assertEqual(wf_namespace, upd_wf[0]['Namespace']) |
| 425 |
self.assertEqual( |
| 426 |
created_wf_info['Created at'].split(".")[0], |
| 427 |
updated_wf_info['Created at'] |
| 428 |
) |
| 429 |
self.assertEqual( |
| 430 |
created_wf_info['Updated at'], |
| 431 |
updated_wf_info['Updated at'] |
| 432 |
) |
| 433 |
|
| 434 |
|
| 435 |
upd_wf = self.mistral_admin( |
| 436 |
'workflow-update', |
| 437 |
params='{0} --namespace {1}'.format( |
| 438 |
self.wf_with_delay_def, |
| 439 |
namespace |
| 440 |
) |
| 441 |
) |
| 442 |
|
| 443 |
self.assertTableStruct(upd_wf, ['Name', 'Created at', 'Updated at']) |
| 444 |
|
| 445 |
updated_wf_info = self.get_item_info( |
| 446 |
get_from=upd_wf, |
| 447 |
get_by='Name', |
| 448 |
value=wf_name |
| 449 |
) |
| 450 |
|
| 451 |
self.assertEqual(wf_name, upd_wf[0]['Name']) |
| 452 |
self.assertEqual( |
| 453 |
created_wf_info['Created at'].split(".")[0], |
| 454 |
updated_wf_info['Created at'] |
| 455 |
) |
| 456 |
self.assertNotEqual( |
| 457 |
created_wf_info['Updated at'], |
| 458 |
updated_wf_info['Updated at'] |
| 459 |
) |
| 460 |
|
| 461 |
|
| 462 |
upd_wf = self.mistral_admin( |
| 463 |
'workflow-update', |
| 464 |
params='{0} --id {1}'.format(self.wf_with_delay_def, wf_id) |
| 465 |
) |
| 466 |
|
| 467 |
self.assertTableStruct(upd_wf, ['Name', 'Created at', 'Updated at']) |
| 468 |
|
| 469 |
updated_wf_info = self.get_item_info( |
| 470 |
get_from=upd_wf, |
| 471 |
get_by='ID', |
| 472 |
value=wf_id |
| 473 |
) |
| 474 |
|
| 475 |
self.assertEqual(wf_name, upd_wf[0]['Name']) |
| 476 |
self.assertEqual( |
| 477 |
created_wf_info['Created at'].split(".")[0], |
| 478 |
updated_wf_info['Created at'] |
| 479 |
) |
| 480 |
self.assertNotEqual( |
| 481 |
created_wf_info['Updated at'], |
| 482 |
updated_wf_info['Updated at'] |
| 483 |
) |
| 484 |
|
| 485 |
def test_workflow_update_truncate_input(self): |
| 486 |
input_value = "very_long_input_parameter_name_that_should_be_truncated" |
| 487 |
|
| 488 |
wf_def = """ |
| 489 |
version: "2.0" |
| 490 |
workflow1: |
| 491 |
input: |
| 492 |
- {0} |
| 493 |
tasks: |
| 494 |
task1: |
| 495 |
action: std.noop |
| 496 |
""".format(input_value) |
| 497 |
|
| 498 |
self.create_file('wf.yaml', wf_def) |
| 499 |
self.workflow_create('wf.yaml') |
| 500 |
|
| 501 |
updated_wf = self.mistral_admin('workflow-update', params='wf.yaml') |
| 502 |
|
| 503 |
updated_wf_info = self.get_item_info( |
| 504 |
get_from=updated_wf, |
| 505 |
get_by='Name', |
| 506 |
value='workflow1' |
| 507 |
) |
| 508 |
|
| 509 |
self.assertEqual(updated_wf_info['Input'][:-3], input_value[:25]) |
| 510 |
|
| 511 |
def test_workflow_get(self): |
| 512 |
created = self.workflow_create(self.wf_def) |
| 513 |
|
| 514 |
wf_name = created[0]['Name'] |
| 515 |
|
| 516 |
fetched = self.mistral_admin('workflow-get', params=wf_name) |
| 517 |
fetched_wf_name = self.get_field_value(fetched, 'Name') |
| 518 |
|
| 519 |
self.assertEqual(wf_name, fetched_wf_name) |
| 520 |
|
| 521 |
def test_workflow_get_with_id(self): |
| 522 |
created = self.workflow_create(self.wf_def) |
| 523 |
|
| 524 |
wf_name = created[0]['Name'] |
| 525 |
wf_id = created[0]['ID'] |
| 526 |
|
| 527 |
fetched = self.mistral_admin('workflow-get', params=wf_id) |
| 528 |
fetched_wf_name = self.get_field_value(fetched, 'Name') |
| 529 |
|
| 530 |
self.assertEqual(wf_name, fetched_wf_name) |
| 531 |
|
| 532 |
def test_workflow_get_definition(self): |
| 533 |
wf = self.workflow_create(self.wf_def) |
| 534 |
|
| 535 |
wf_name = wf[0]['Name'] |
| 536 |
|
| 537 |
definition = self.mistral_admin( |
| 538 |
'workflow-get-definition', |
| 539 |
params=wf_name |
| 540 |
) |
| 541 |
|
| 542 |
self.assertNotIn('404 Not Found', definition) |
| 543 |
|
| 544 |
def test_workflow_validate_with_valid_def(self): |
| 545 |
wf = self.mistral_admin('workflow-validate', params=self.wf_def) |
| 546 |
|
| 547 |
wf_valid = self.get_field_value(wf, 'Valid') |
| 548 |
wf_error = self.get_field_value(wf, 'Error') |
| 549 |
|
| 550 |
self.assertEqual('True', wf_valid) |
| 551 |
self.assertEqual('None', wf_error) |
| 552 |
|
| 553 |
def test_workflow_validate_with_invalid_def(self): |
| 554 |
self.create_file('wf.yaml', 'name: wf\n') |
| 555 |
|
| 556 |
wf = self.mistral_admin('workflow-validate', params='wf.yaml') |
| 557 |
|
| 558 |
wf_valid = self.get_field_value(wf, 'Valid') |
| 559 |
wf_error = self.get_field_value(wf, 'Error') |
| 560 |
|
| 561 |
self.assertEqual('False', wf_valid) |
| 562 |
self.assertNotEqual('None', wf_error) |
| 563 |
|
| 564 |
def test_workflow_list_with_filter(self): |
| 565 |
self.workflow_create(self.wf_def) |
| 566 |
workflows = self.parser.listing(self.mistral('workflow-list')) |
| 567 |
|
| 568 |
self.assertTableStruct( |
| 569 |
workflows, |
| 570 |
['ID', 'Name', 'Tags', 'Input', 'Scope', 'Created at', |
| 571 |
'Updated at'] |
| 572 |
) |
| 573 |
|
| 574 |
|
| 575 |
self.assertGreaterEqual(len(workflows), 2) |
| 576 |
|
| 577 |
|
| 578 |
workflows = self.parser.listing( |
| 579 |
self.mistral( |
| 580 |
'workflow-list', |
| 581 |
params='--filter name=eq:wf1' |
| 582 |
) |
| 583 |
) |
| 584 |
|
| 585 |
self.assertTableStruct( |
| 586 |
workflows, |
| 587 |
['ID', 'Name', 'Tags', 'Input', 'Scope', 'Created at', |
| 588 |
'Updated at'] |
| 589 |
) |
| 590 |
|
| 591 |
self.assertEqual(1, len(workflows)) |
| 592 |
|
| 593 |
self.assertEqual('wf1', workflows[0]['Name']) |
| 594 |
|
| 595 |
|
| 596 |
class ExecutionCLITests(base_v2.MistralClientTestBase): |
| 597 |
"""Test suite checks commands to work with executions.""" |
| 598 |
|
| 599 |
@classmethod |
| 600 |
def setUpClass(cls): |
| 601 |
super(ExecutionCLITests, cls).setUpClass() |
| 602 |
|
| 603 |
def setUp(self): |
| 604 |
super(ExecutionCLITests, self).setUp() |
| 605 |
|
| 606 |
wfs = self.workflow_create(self.wf_def) |
| 607 |
self.async_wf = self.workflow_create(self.async_wf_def)[0] |
| 608 |
|
| 609 |
self.direct_wf = wfs[0] |
| 610 |
self.reverse_wf = wfs[1] |
| 611 |
|
| 612 |
self.create_file('input', '{\n "farewell": "Bye"\n}\n') |
| 613 |
self.create_file('task_name', '{\n "task_name": "goodbye"\n}\n') |
| 614 |
|
| 615 |
def test_execution_by_id_of_workflow_within_namespace(self): |
| 616 |
namespace = 'abc' |
| 617 |
|
| 618 |
wfs = self.workflow_create(self.lowest_level_wf, namespace=namespace) |
| 619 |
|
| 620 |
wf_def_name = wfs[0]['Name'] |
| 621 |
wf_id = wfs[0]['ID'] |
| 622 |
|
| 623 |
execution = self.execution_create(wf_id) |
| 624 |
|
| 625 |
self.assertTableStruct(execution, ['Field', 'Value']) |
| 626 |
|
| 627 |
wf_name = self.get_field_value(execution, 'Workflow name') |
| 628 |
wf_namespace = self.get_field_value(execution, 'Workflow namespace') |
| 629 |
wf_id = self.get_field_value(execution, 'Workflow ID') |
| 630 |
|
| 631 |
self.assertEqual(wf_def_name, wf_name) |
| 632 |
self.assertEqual(namespace, wf_namespace) |
| 633 |
self.assertIsNotNone(wf_id) |
| 634 |
|
| 635 |
def test_execution_within_namespace_create_delete(self): |
| 636 |
namespace = 'abc' |
| 637 |
|
| 638 |
self.workflow_create(self.lowest_level_wf) |
| 639 |
self.workflow_create(self.lowest_level_wf, namespace=namespace) |
| 640 |
self.workflow_create(self.middle_wf, namespace=namespace) |
| 641 |
self.workflow_create(self.top_level_wf) |
| 642 |
wfs = self.workflow_create(self.top_level_wf, namespace=namespace) |
| 643 |
|
| 644 |
top_wf_name = wfs[0]['Name'] |
| 645 |
execution = self.mistral_admin( |
| 646 |
'execution-create', |
| 647 |
params='{0} --namespace {1}'.format(top_wf_name, namespace) |
| 648 |
) |
| 649 |
exec_id = self.get_field_value(execution, 'ID') |
| 650 |
|
| 651 |
self.assertTableStruct(execution, ['Field', 'Value']) |
| 652 |
|
| 653 |
wf_name = self.get_field_value(execution, 'Workflow name') |
| 654 |
wf_namespace = self.get_field_value(execution, 'Workflow namespace') |
| 655 |
wf_id = self.get_field_value(execution, 'Workflow ID') |
| 656 |
created_at = self.get_field_value(execution, 'Created at') |
| 657 |
|
| 658 |
self.assertEqual(top_wf_name, wf_name) |
| 659 |
self.assertEqual(namespace, wf_namespace) |
| 660 |
self.assertIsNotNone(wf_id) |
| 661 |
self.assertIsNotNone(created_at) |
| 662 |
|
| 663 |
execs = self.mistral_admin('execution-list') |
| 664 |
|
| 665 |
self.assertIn(exec_id, [ex['ID'] for ex in execs]) |
| 666 |
self.assertIn(wf_name, [ex['Workflow name'] for ex in execs]) |
| 667 |
self.assertIn(namespace, [ex['Workflow namespace'] for ex in execs]) |
| 668 |
|
| 669 |
params = "{} --force".format(exec_id) |
| 670 |
self.mistral_admin('execution-delete', params=params) |
| 671 |
|
| 672 |
def test_execution_create_delete(self): |
| 673 |
|
| 674 |
execution = self.mistral_admin( |
| 675 |
'execution-create', |
| 676 |
params='{0} -d "execution test"'.format(self.direct_wf['Name']) |
| 677 |
) |
| 678 |
|
| 679 |
exec_id = self.get_field_value(execution, 'ID') |
| 680 |
|
| 681 |
self.assertTableStruct(execution, ['Field', 'Value']) |
| 682 |
|
| 683 |
wf_name = self.get_field_value(execution, 'Workflow name') |
| 684 |
wf_id = self.get_field_value(execution, 'Workflow ID') |
| 685 |
created_at = self.get_field_value(execution, 'Created at') |
| 686 |
description = self.get_field_value(execution, 'Description') |
| 687 |
|
| 688 |
self.assertEqual(self.direct_wf['Name'], wf_name) |
| 689 |
self.assertIsNotNone(wf_id) |
| 690 |
self.assertIsNotNone(created_at) |
| 691 |
self.assertEqual("execution test", description) |
| 692 |
|
| 693 |
execs = self.mistral_admin('execution-list') |
| 694 |
|
| 695 |
self.assertIn(exec_id, [ex['ID'] for ex in execs]) |
| 696 |
self.assertIn(wf_name, [ex['Workflow name'] for ex in execs]) |
| 697 |
|
| 698 |
params = "{} --force".format(exec_id) |
| 699 |
self.mistral_admin('execution-delete', params=params) |
| 700 |
|
| 701 |
def test_execution_create_with_input_and_start_task(self): |
| 702 |
execution = self.execution_create( |
| 703 |
"%s input task_name" % self.reverse_wf['Name'] |
| 704 |
) |
| 705 |
|
| 706 |
exec_id = self.get_field_value(execution, 'ID') |
| 707 |
|
| 708 |
result = self.wait_execution_success(exec_id) |
| 709 |
|
| 710 |
self.assertTrue(result) |
| 711 |
|
| 712 |
def test_execution_update(self): |
| 713 |
execution = self.execution_create(self.async_wf['Name']) |
| 714 |
|
| 715 |
exec_id = self.get_field_value(execution, 'ID') |
| 716 |
status = self.get_field_value(execution, 'State') |
| 717 |
|
| 718 |
self.assertEqual('RUNNING', status) |
| 719 |
|
| 720 |
|
| 721 |
execution = self.mistral_admin( |
| 722 |
'execution-update', |
| 723 |
params='{0} -s PAUSED'.format(exec_id)) |
| 724 |
|
| 725 |
updated_exec_id = self.get_field_value(execution, 'ID') |
| 726 |
status = self.get_field_value(execution, 'State') |
| 727 |
|
| 728 |
self.assertEqual(exec_id, updated_exec_id) |
| 729 |
self.assertEqual('PAUSED', status) |
| 730 |
|
| 731 |
|
| 732 |
execution = self.mistral_admin( |
| 733 |
'execution-update', |
| 734 |
params='{0} -d "execution update test"'.format(exec_id) |
| 735 |
) |
| 736 |
|
| 737 |
description = self.get_field_value(execution, 'Description') |
| 738 |
|
| 739 |
self.assertEqual("execution update test", description) |
| 740 |
|
| 741 |
def test_execution_get(self): |
| 742 |
execution = self.execution_create(self.direct_wf['Name']) |
| 743 |
|
| 744 |
exec_id = self.get_field_value(execution, 'ID') |
| 745 |
|
| 746 |
execution = self.mistral_admin( |
| 747 |
'execution-get', |
| 748 |
params='{0}'.format(exec_id) |
| 749 |
) |
| 750 |
|
| 751 |
gotten_id = self.get_field_value(execution, 'ID') |
| 752 |
wf_name = self.get_field_value(execution, 'Workflow name') |
| 753 |
wf_id = self.get_field_value(execution, 'Workflow ID') |
| 754 |
|
| 755 |
self.assertIsNotNone(wf_id) |
| 756 |
self.assertEqual(exec_id, gotten_id) |
| 757 |
self.assertEqual(self.direct_wf['Name'], wf_name) |
| 758 |
|
| 759 |
def test_execution_get_input(self): |
| 760 |
execution = self.execution_create(self.direct_wf['Name']) |
| 761 |
exec_id = self.get_field_value(execution, 'ID') |
| 762 |
|
| 763 |
ex_input = self.mistral_admin('execution-get-input', params=exec_id) |
| 764 |
|
| 765 |
self.assertEqual([], ex_input) |
| 766 |
|
| 767 |
def test_execution_get_output(self): |
| 768 |
execution = self.execution_create(self.direct_wf['Name']) |
| 769 |
|
| 770 |
exec_id = self.get_field_value(execution, 'ID') |
| 771 |
|
| 772 |
ex_output = self.mistral_admin('execution-get-output', params=exec_id) |
| 773 |
|
| 774 |
self.assertEqual([], ex_output) |
| 775 |
|
| 776 |
def test_executions_list_with_task(self): |
| 777 |
wrapping_wf = self.workflow_create(self.wf_wrapping_wf) |
| 778 |
decoy = self.execution_create(wrapping_wf[-1]['Name']) |
| 779 |
wrapping_wf_ex = self.execution_create(wrapping_wf[-1]['Name']) |
| 780 |
|
| 781 |
wrapping_wf_ex_id = self.get_field_value(wrapping_wf_ex, 'ID') |
| 782 |
|
| 783 |
self.assertIsNot(wrapping_wf_ex_id, self.get_field_value(decoy, 'ID')) |
| 784 |
|
| 785 |
tasks = self.mistral_admin('task-list', params=wrapping_wf_ex_id) |
| 786 |
|
| 787 |
wrapping_task_id = tasks[-1]['ID'] |
| 788 |
|
| 789 |
wf_execs = self.mistral_cli( |
| 790 |
True, |
| 791 |
'execution-list', |
| 792 |
params="--task {}".format(wrapping_task_id) |
| 793 |
) |
| 794 |
|
| 795 |
self.assertEqual(1, len(wf_execs)) |
| 796 |
|
| 797 |
wf_exec = wf_execs[0] |
| 798 |
|
| 799 |
self.assertEqual(wrapping_task_id, wf_exec['Task Execution ID']) |
| 800 |
|
| 801 |
def test_executions_list_with_pagination(self): |
| 802 |
|
| 803 |
ex1 = self.execution_create( |
| 804 |
params='{0} -d "a"'.format(self.direct_wf['Name']) |
| 805 |
) |
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
time.sleep(1) |
| 812 |
ex2 = self.execution_create( |
| 813 |
params='{0} -d "b"'.format(self.direct_wf['Name']) |
| 814 |
) |
| 815 |
|
| 816 |
all_wf_ids = [ |
| 817 |
self.get_field_value(ex1, 'ID'), |
| 818 |
self.get_field_value(ex2, 'ID'), |
| 819 |
] |
| 820 |
|
| 821 |
|
| 822 |
wf_execs = self.mistral_cli(True, 'execution-list') |
| 823 |
|
| 824 |
|
| 825 |
self.assertEqual(2, len(wf_execs)) |
| 826 |
|
| 827 |
|
| 828 |
self.assertEqual( |
| 829 |
set(all_wf_ids), |
| 830 |
set([ex['ID'] for ex in wf_execs]) |
| 831 |
) |
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
wf_execs = self.mistral_cli( |
| 840 |
True, |
| 841 |
'execution-list', |
| 842 |
params="--oldest --limit 1" |
| 843 |
) |
| 844 |
|
| 845 |
|
| 846 |
self.assertEqual(1, len(wf_execs)) |
| 847 |
|
| 848 |
|
| 849 |
not_expected = wf_execs[0]['ID'] |
| 850 |
expected = [ex for ex in all_wf_ids if ex != wf_execs[0]['ID']][0] |
| 851 |
wf_execs = self.mistral_cli( |
| 852 |
True, |
| 853 |
'execution-list', |
| 854 |
params="--marker %s" % not_expected |
| 855 |
) |
| 856 |
|
| 857 |
|
| 858 |
self.assertNotIn( |
| 859 |
not_expected, |
| 860 |
[ex['ID'] for ex in wf_execs] |
| 861 |
) |
| 862 |
self.assertIn( |
| 863 |
expected, |
| 864 |
[ex['ID'] for ex in wf_execs] |
| 865 |
) |
| 866 |
|
| 867 |
|
| 868 |
wf_execs = self.mistral_cli( |
| 869 |
True, |
| 870 |
'execution-list', |
| 871 |
params="--sort_keys Description" |
| 872 |
) |
| 873 |
|
| 874 |
|
| 875 |
self.assertEqual( |
| 876 |
set(all_wf_ids), |
| 877 |
set([ex['ID'] for ex in wf_execs]) |
| 878 |
) |
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
wf_ex1_index = -1 |
| 883 |
wf_ex2_index = -1 |
| 884 |
for idx, ex in enumerate(wf_execs): |
| 885 |
if ex['ID'] == all_wf_ids[0]: |
| 886 |
wf_ex1_index = idx |
| 887 |
elif ex['ID'] == all_wf_ids[1]: |
| 888 |
wf_ex2_index = idx |
| 889 |
self.assertLess(wf_ex1_index, wf_ex2_index) |
| 890 |
|
| 891 |
|
| 892 |
wf_execs = self.mistral_cli( |
| 893 |
True, |
| 894 |
'execution-list', |
| 895 |
params="--sort_keys Description --sort_dirs=desc" |
| 896 |
) |
| 897 |
|
| 898 |
self.assertEqual( |
| 899 |
set(all_wf_ids), |
| 900 |
set([ex['ID'] for ex in wf_execs]) |
| 901 |
) |
| 902 |
|
| 903 |
wf_ex1_index = -1 |
| 904 |
wf_ex2_index = -1 |
| 905 |
for idx, ex in enumerate(wf_execs): |
| 906 |
if ex['ID'] == all_wf_ids[0]: |
| 907 |
wf_ex1_index = idx |
| 908 |
elif ex['ID'] == all_wf_ids[1]: |
| 909 |
wf_ex2_index = idx |
| 910 |
self.assertGreater(wf_ex1_index, wf_ex2_index) |
| 911 |
|
| 912 |
def test_execution_list_with_filter(self): |
| 913 |
wf_ex1 = self.execution_create( |
| 914 |
params='{0} -d "a"'.format(self.direct_wf['Name']) |
| 915 |
) |
| 916 |
|
| 917 |
wf_ex1_id = self.get_field_value(wf_ex1, 'ID') |
| 918 |
|
| 919 |
self.execution_create( |
| 920 |
params='{0} -d "b"'.format(self.direct_wf['Name']) |
| 921 |
) |
| 922 |
|
| 923 |
|
| 924 |
wf_execs = self.mistral_cli(True, 'execution-list') |
| 925 |
|
| 926 |
self.assertTableStruct( |
| 927 |
wf_execs, |
| 928 |
['ID', 'Workflow name', 'Workflow ID', 'State', 'Created at', |
| 929 |
'Updated at'] |
| 930 |
) |
| 931 |
|
| 932 |
self.assertEqual(2, len(wf_execs)) |
| 933 |
|
| 934 |
|
| 935 |
wf_execs = self.mistral_cli( |
| 936 |
True, |
| 937 |
'execution-list', |
| 938 |
params='--filter description=a' |
| 939 |
) |
| 940 |
|
| 941 |
self.assertTableStruct( |
| 942 |
wf_execs, |
| 943 |
['ID', 'Workflow name', 'Workflow ID', 'State', 'Created at', |
| 944 |
'Updated at'] |
| 945 |
) |
| 946 |
|
| 947 |
self.assertEqual(1, len(wf_execs)) |
| 948 |
|
| 949 |
self.assertEqual(wf_ex1_id, wf_execs[0]['ID']) |
| 950 |
self.assertEqual('a', wf_execs[0]['Description']) |
| 951 |
|
| 952 |
def test_executions_list_with_rootsonly(self): |
| 953 |
wrapping_wf = self.workflow_create(self.wf_wrapping_wf) |
| 954 |
wrapping_wf_ex = self.execution_create(wrapping_wf[-1]['Name']) |
| 955 |
|
| 956 |
wrapping_wf_ex_id = self.get_field_value(wrapping_wf_ex, 'ID') |
| 957 |
|
| 958 |
wf_execs = self.mistral_cli( |
| 959 |
True, |
| 960 |
'execution-list', |
| 961 |
params="--rootsonly" |
| 962 |
) |
| 963 |
|
| 964 |
self.assertEqual(1, len(wf_execs)) |
| 965 |
wf_exec = wf_execs[0] |
| 966 |
self.assertEqual(wrapping_wf_ex_id, wf_exec['ID']) |
| 967 |
|
| 968 |
|
| 969 |
class CronTriggerCLITests(base_v2.MistralClientTestBase): |
| 970 |
"""Test suite checks commands to work with cron-triggers.""" |
| 971 |
|
| 972 |
@classmethod |
| 973 |
def setUpClass(cls): |
| 974 |
super(CronTriggerCLITests, cls).setUpClass() |
| 975 |
|
| 976 |
def setUp(self): |
| 977 |
super(CronTriggerCLITests, self).setUp() |
| 978 |
|
| 979 |
wf = self.workflow_create(self.wf_def) |
| 980 |
|
| 981 |
self.wf_name = wf[0]['Name'] |
| 982 |
|
| 983 |
def test_cron_trigger_create_delete(self): |
| 984 |
trigger = self.mistral_admin( |
| 985 |
'cron-trigger-create', |
| 986 |
params=('trigger %s {} --pattern "5 * * * *" --count 5' |
| 987 |
' --first-time "4242-12-25 13:37" --utc' % self.wf_name) |
| 988 |
) |
| 989 |
|
| 990 |
self.assertTableStruct(trigger, ['Field', 'Value']) |
| 991 |
|
| 992 |
tr_name = self.get_field_value(trigger, 'Name') |
| 993 |
wf_name = self.get_field_value(trigger, 'Workflow') |
| 994 |
created_at = self.get_field_value(trigger, 'Created at') |
| 995 |
remain = self.get_field_value(trigger, 'Remaining executions') |
| 996 |
next_time = self.get_field_value(trigger, 'Next execution time') |
| 997 |
|
| 998 |
self.assertEqual('trigger', tr_name) |
| 999 |
self.assertEqual(self.wf_name, wf_name) |
| 1000 |
self.assertIsNotNone(created_at) |
| 1001 |
self.assertEqual("4242-12-25 13:37:00", next_time) |
| 1002 |
self.assertEqual("5", remain) |
| 1003 |
|
| 1004 |
triggers = self.mistral_admin('cron-trigger-list') |
| 1005 |
|
| 1006 |
self.assertIn(tr_name, [tr['Name'] for tr in triggers]) |
| 1007 |
self.assertIn(wf_name, [tr['Workflow'] for tr in triggers]) |
| 1008 |
|
| 1009 |
self.mistral('cron-trigger-delete', params=tr_name) |
| 1010 |
|
| 1011 |
triggers = self.mistral_admin('cron-trigger-list') |
| 1012 |
|
| 1013 |
self.assertNotIn(tr_name, [tr['Name'] for tr in triggers]) |
| 1014 |
|
| 1015 |
def test_two_cron_triggers_for_one_wf(self): |
| 1016 |
self.cron_trigger_create('trigger1', self.wf_name, '{}', "5 * * * *") |
| 1017 |
|
| 1018 |
self.cron_trigger_create('trigger2', self.wf_name, '{}', "15 * * * *") |
| 1019 |
|
| 1020 |
triggers = self.mistral_admin('cron-trigger-list') |
| 1021 |
|
| 1022 |
self.assertIn("trigger1", [tr['Name'] for tr in triggers]) |
| 1023 |
self.assertIn("trigger2", [tr['Name'] for tr in triggers]) |
| 1024 |
|
| 1025 |
def test_cron_trigger_get(self): |
| 1026 |
trigger = self.cron_trigger_create( |
| 1027 |
'trigger', |
| 1028 |
self.wf_name, |
| 1029 |
'{}', |
| 1030 |
"5 * * * *" |
| 1031 |
) |
| 1032 |
|
| 1033 |
self.assertTableStruct(trigger, ['Field', 'Value']) |
| 1034 |
|
| 1035 |
fetched_tr = self.mistral_admin( |
| 1036 |
'cron-trigger-get', |
| 1037 |
params='trigger' |
| 1038 |
) |
| 1039 |
|
| 1040 |
self.assertTableStruct(trigger, ['Field', 'Value']) |
| 1041 |
|
| 1042 |
tr_name = self.get_field_value(fetched_tr, 'Name') |
| 1043 |
wf_name = self.get_field_value(fetched_tr, 'Workflow') |
| 1044 |
created_at = self.get_field_value(fetched_tr, 'Created at') |
| 1045 |
|
| 1046 |
self.assertEqual('trigger', tr_name) |
| 1047 |
self.assertEqual(self.wf_name, wf_name) |
| 1048 |
self.assertIsNotNone(created_at) |
| 1049 |
|
| 1050 |
|
| 1051 |
class EventTriggerCLITests(base_v2.MistralClientTestBase): |
| 1052 |
"""Test suite checks commands to work with event-triggers.""" |
| 1053 |
|
| 1054 |
@classmethod |
| 1055 |
def setUpClass(cls): |
| 1056 |
super(EventTriggerCLITests, cls).setUpClass() |
| 1057 |
|
| 1058 |
def setUp(self): |
| 1059 |
super(EventTriggerCLITests, self).setUp() |
| 1060 |
|
| 1061 |
wf = self.workflow_create(self.wf_def) |
| 1062 |
|
| 1063 |
self.wf_id = wf[0]['ID'] |
| 1064 |
|
| 1065 |
def test_event_trigger_create_delete(self): |
| 1066 |
trigger = self.mistral_admin( |
| 1067 |
'event-trigger-create', |
| 1068 |
params=('trigger %s dummy_exchange dummy_topic event.dummy {}' % |
| 1069 |
self.wf_id)) |
| 1070 |
|
| 1071 |
self.assertTableStruct(trigger, ['Field', 'Value']) |
| 1072 |
|
| 1073 |
tr_id = self.get_field_value(trigger, 'ID') |
| 1074 |
tr_name = self.get_field_value(trigger, 'Name') |
| 1075 |
wf_id = self.get_field_value(trigger, 'Workflow ID') |
| 1076 |
created_at = self.get_field_value(trigger, 'Created at') |
| 1077 |
|
| 1078 |
self.assertEqual('trigger', tr_name) |
| 1079 |
self.assertEqual(self.wf_id, wf_id) |
| 1080 |
self.assertIsNotNone(created_at) |
| 1081 |
|
| 1082 |
triggers = self.mistral_admin('event-trigger-list') |
| 1083 |
|
| 1084 |
self.assertIn(tr_name, [tr['Name'] for tr in triggers]) |
| 1085 |
self.assertIn(wf_id, [tr['Workflow ID'] for tr in triggers]) |
| 1086 |
|
| 1087 |
self.mistral('event-trigger-delete', params=tr_id) |
| 1088 |
|
| 1089 |
triggers = self.mistral_admin('event-trigger-list') |
| 1090 |
|
| 1091 |
self.assertNotIn(tr_name, [tr['Name'] for tr in triggers]) |
| 1092 |
|
| 1093 |
def test_two_event_triggers_for_one_wf(self): |
| 1094 |
self.event_trigger_create('trigger1', |
| 1095 |
self.wf_id, |
| 1096 |
'dummy_exchange', |
| 1097 |
'dummy_topic', |
| 1098 |
'event.dummy', |
| 1099 |
'{}') |
| 1100 |
|
| 1101 |
self.event_trigger_create('trigger2', |
| 1102 |
self.wf_id, |
| 1103 |
'dummy_exchange', |
| 1104 |
'dummy_topic', |
| 1105 |
'dummy.event', |
| 1106 |
'{}') |
| 1107 |
|
| 1108 |
triggers = self.mistral_admin('event-trigger-list') |
| 1109 |
|
| 1110 |
self.assertIn('trigger1', [tr['Name'] for tr in triggers]) |
| 1111 |
self.assertIn('trigger2', [tr['Name'] for tr in triggers]) |
| 1112 |
|
| 1113 |
def test_event_trigger_get(self): |
| 1114 |
trigger = self.event_trigger_create('trigger', |
| 1115 |
self.wf_id, |
| 1116 |
'dummy_exchange', |
| 1117 |
'dummy_topic', |
| 1118 |
'event.dummy.other', |
| 1119 |
'{}') |
| 1120 |
|
| 1121 |
self.assertTableStruct(trigger, ['Field', 'Value']) |
| 1122 |
|
| 1123 |
ev_tr_id = self.get_field_value(trigger, 'ID') |
| 1124 |
fetched_tr = self.mistral_admin('event-trigger-get', params=ev_tr_id) |
| 1125 |
|
| 1126 |
self.assertTableStruct(trigger, ['Field', 'Value']) |
| 1127 |
|
| 1128 |
tr_name = self.get_field_value(fetched_tr, 'Name') |
| 1129 |
wf_id = self.get_field_value(fetched_tr, 'Workflow ID') |
| 1130 |
created_at = self.get_field_value(fetched_tr, 'Created at') |
| 1131 |
|
| 1132 |
self.assertEqual('trigger', tr_name) |
| 1133 |
self.assertEqual(self.wf_id, wf_id) |
| 1134 |
self.assertIsNotNone(created_at) |
| 1135 |
|
| 1136 |
|
| 1137 |
class TaskCLITests(base_v2.MistralClientTestBase): |
| 1138 |
"""Test suite checks commands to work with tasks.""" |
| 1139 |
|
| 1140 |
def setUp(self): |
| 1141 |
super(TaskCLITests, self).setUp() |
| 1142 |
|
| 1143 |
wfs = self.workflow_create(self.wf_def) |
| 1144 |
|
| 1145 |
self.direct_wf = wfs[0] |
| 1146 |
self.reverse_wf = wfs[1] |
| 1147 |
|
| 1148 |
self.create_file('input', '{\n "farewell": "Bye"\n}\n') |
| 1149 |
self.create_file('task_name', '{\n "task_name": "goodbye"\n}\n') |
| 1150 |
|
| 1151 |
def test_task_get(self): |
| 1152 |
wf_ex = self.execution_create(self.direct_wf['Name']) |
| 1153 |
|
| 1154 |
wf_ex_id = self.get_field_value(wf_ex, 'ID') |
| 1155 |
|
| 1156 |
tasks = self.mistral_admin('task-list', params=wf_ex_id) |
| 1157 |
|
| 1158 |
created_task_id = tasks[-1]['ID'] |
| 1159 |
|
| 1160 |
fetched_task = self.mistral_admin('task-get', params=created_task_id) |
| 1161 |
fetched_task_id = self.get_field_value(fetched_task, 'ID') |
| 1162 |
fetched_task_wf_namespace = self.get_field_value( |
| 1163 |
fetched_task, |
| 1164 |
'Workflow namespace' |
| 1165 |
) |
| 1166 |
task_execution_id = self.get_field_value(fetched_task, |
| 1167 |
'Workflow Execution ID') |
| 1168 |
|
| 1169 |
self.assertEqual(created_task_id, fetched_task_id) |
| 1170 |
self.assertEqual('', fetched_task_wf_namespace) |
| 1171 |
self.assertEqual(wf_ex_id, task_execution_id) |
| 1172 |
|
| 1173 |
def test_task_get_list_within_namespace(self): |
| 1174 |
namespace = 'aaa' |
| 1175 |
self.workflow_create(self.wf_def, namespace=namespace) |
| 1176 |
wf_ex = self.execution_create( |
| 1177 |
self.direct_wf['Name'] + ' --namespace ' + namespace |
| 1178 |
) |
| 1179 |
|
| 1180 |
wf_ex_id = self.get_field_value(wf_ex, 'ID') |
| 1181 |
|
| 1182 |
tasks = self.mistral_admin('task-list', params=wf_ex_id) |
| 1183 |
|
| 1184 |
created_task_id = tasks[-1]['ID'] |
| 1185 |
created_wf_namespace = tasks[-1]['Workflow namespace'] |
| 1186 |
|
| 1187 |
fetched_task = self.mistral_admin('task-get', params=created_task_id) |
| 1188 |
fetched_task_id = self.get_field_value(fetched_task, 'ID') |
| 1189 |
fetched_task_wf_namespace = self.get_field_value( |
| 1190 |
fetched_task, |
| 1191 |
'Workflow namespace' |
| 1192 |
) |
| 1193 |
task_execution_id = self.get_field_value(fetched_task, |
| 1194 |
'Workflow Execution ID') |
| 1195 |
|
| 1196 |
self.assertEqual(created_task_id, fetched_task_id) |
| 1197 |
self.assertEqual(namespace, created_wf_namespace) |
| 1198 |
self.assertEqual(created_wf_namespace, fetched_task_wf_namespace) |
| 1199 |
self.assertEqual(wf_ex_id, task_execution_id) |
| 1200 |
|
| 1201 |
def test_task_list_with_filter(self): |
| 1202 |
wf_exec = self.execution_create( |
| 1203 |
"%s input task_name" % self.reverse_wf['Name'] |
| 1204 |
) |
| 1205 |
|
| 1206 |
exec_id = self.get_field_value(wf_exec, 'ID') |
| 1207 |
|
| 1208 |
self.assertTrue(self.wait_execution_success(exec_id)) |
| 1209 |
|
| 1210 |
|
| 1211 |
tasks = self.parser.listing(self.mistral('task-list')) |
| 1212 |
|
| 1213 |
self.assertTableStruct( |
| 1214 |
tasks, |
| 1215 |
['ID', 'Name', 'Workflow name', 'Workflow Execution ID', 'State'] |
| 1216 |
) |
| 1217 |
|
| 1218 |
self.assertEqual(2, len(tasks)) |
| 1219 |
|
| 1220 |
|
| 1221 |
tasks = self.parser.listing( |
| 1222 |
self.mistral( |
| 1223 |
'task-list', |
| 1224 |
params='--filter name=goodbye' |
| 1225 |
) |
| 1226 |
) |
| 1227 |
|
| 1228 |
self.assertTableStruct( |
| 1229 |
tasks, |
| 1230 |
['ID', 'Name', 'Workflow name', 'Workflow Execution ID', 'State'] |
| 1231 |
) |
| 1232 |
|
| 1233 |
self.assertEqual(1, len(tasks)) |
| 1234 |
|
| 1235 |
self.assertEqual('goodbye', tasks[0]['Name']) |
| 1236 |
|
| 1237 |
def test_task_list_with_limit(self): |
| 1238 |
wf_exec = self.execution_create( |
| 1239 |
"%s input task_name" % self.reverse_wf['Name'] |
| 1240 |
) |
| 1241 |
|
| 1242 |
exec_id = self.get_field_value(wf_exec, 'ID') |
| 1243 |
|
| 1244 |
self.assertTrue(self.wait_execution_success(exec_id)) |
| 1245 |
|
| 1246 |
tasks = self.parser.listing(self.mistral('task-list')) |
| 1247 |
|
| 1248 |
tasks = self.parser.listing( |
| 1249 |
self.mistral( |
| 1250 |
'task-list', |
| 1251 |
params='--limit 1' |
| 1252 |
) |
| 1253 |
) |
| 1254 |
|
| 1255 |
self.assertEqual(1, len(tasks)) |
| 1256 |
|
| 1257 |
|
| 1258 |
class ActionCLITests(base_v2.MistralClientTestBase): |
| 1259 |
"""Test suite checks commands to work with actions.""" |
| 1260 |
|
| 1261 |
@classmethod |
| 1262 |
def setUpClass(cls): |
| 1263 |
super(ActionCLITests, cls).setUpClass() |
| 1264 |
|
| 1265 |
def test_action_create_delete(self): |
| 1266 |
init_acts = self.mistral_admin('action-create', params=self.act_def) |
| 1267 |
|
| 1268 |
self.assertTableStruct( |
| 1269 |
init_acts, |
| 1270 |
[ |
| 1271 |
'Name', 'Is system', 'Input', 'Description', 'Tags', |
| 1272 |
'Created at', 'Updated at' |
| 1273 |
] |
| 1274 |
) |
| 1275 |
|
| 1276 |
self.assertIn('greeting', [action['Name'] for action in init_acts]) |
| 1277 |
self.assertIn('farewell', [action['Name'] for action in init_acts]) |
| 1278 |
|
| 1279 |
action_1 = self.get_item_info( |
| 1280 |
get_from=init_acts, |
| 1281 |
get_by='Name', |
| 1282 |
value='greeting' |
| 1283 |
) |
| 1284 |
action_2 = self.get_item_info( |
| 1285 |
get_from=init_acts, |
| 1286 |
get_by='Name', |
| 1287 |
value='farewell' |
| 1288 |
) |
| 1289 |
|
| 1290 |
self.assertEqual('<none>', action_1['Tags']) |
| 1291 |
self.assertEqual('<none>', action_2['Tags']) |
| 1292 |
|
| 1293 |
self.assertEqual('False', action_1['Is system']) |
| 1294 |
self.assertEqual('False', action_2['Is system']) |
| 1295 |
|
| 1296 |
self.assertEqual('name', action_1['Input']) |
| 1297 |
self.assertEqual('None', action_2['Input']) |
| 1298 |
|
| 1299 |
acts = self.mistral_admin('action-list') |
| 1300 |
|
| 1301 |
self.assertIn(action_1['Name'], [action['Name'] for action in acts]) |
| 1302 |
self.assertIn(action_2['Name'], [action['Name'] for action in acts]) |
| 1303 |
|
| 1304 |
self.mistral_admin( |
| 1305 |
'action-delete', |
| 1306 |
params='{0}'.format(action_1['Name']) |
| 1307 |
) |
| 1308 |
self.mistral_admin( |
| 1309 |
'action-delete', |
| 1310 |
params='{0}'.format(action_2['Name']) |
| 1311 |
) |
| 1312 |
|
| 1313 |
acts = self.mistral_admin('action-list') |
| 1314 |
|
| 1315 |
self.assertNotIn(action_1['Name'], [action['Name'] for action in acts]) |
| 1316 |
self.assertNotIn(action_2['Name'], [action['Name'] for action in acts]) |
| 1317 |
|
| 1318 |
def test_action_update(self): |
| 1319 |
actions = self.action_create(self.act_def) |
| 1320 |
|
| 1321 |
created_action = self.get_item_info( |
| 1322 |
get_from=actions, |
| 1323 |
get_by='Name', |
| 1324 |
value='greeting' |
| 1325 |
) |
| 1326 |
|
| 1327 |
actions = self.mistral_admin('action-update', params=self.act_def) |
| 1328 |
|
| 1329 |
updated_action = self.get_item_info( |
| 1330 |
get_from=actions, |
| 1331 |
get_by='Name', |
| 1332 |
value='greeting' |
| 1333 |
) |
| 1334 |
|
| 1335 |
self.assertEqual( |
| 1336 |
created_action['Created at'].split(".")[0], |
| 1337 |
updated_action['Created at'] |
| 1338 |
) |
| 1339 |
self.assertEqual(created_action['Name'], updated_action['Name']) |
| 1340 |
self.assertEqual( |
| 1341 |
created_action['Updated at'], |
| 1342 |
updated_action['Updated at'] |
| 1343 |
) |
| 1344 |
|
| 1345 |
actions = self.mistral_admin('action-update', params=self.act_tag_def) |
| 1346 |
|
| 1347 |
updated_action = self.get_item_info( |
| 1348 |
get_from=actions, |
| 1349 |
get_by='Name', |
| 1350 |
value='greeting' |
| 1351 |
) |
| 1352 |
|
| 1353 |
self.assertEqual('tag, tag1', updated_action['Tags']) |
| 1354 |
self.assertEqual( |
| 1355 |
created_action['Created at'].split(".")[0], |
| 1356 |
updated_action['Created at'] |
| 1357 |
) |
| 1358 |
self.assertEqual(created_action['Name'], updated_action['Name']) |
| 1359 |
self.assertNotEqual( |
| 1360 |
created_action['Updated at'], |
| 1361 |
updated_action['Updated at'] |
| 1362 |
) |
| 1363 |
|
| 1364 |
def test_action_update_with_id(self): |
| 1365 |
acts = self.action_create(self.act_def) |
| 1366 |
|
| 1367 |
created_action = self.get_item_info( |
| 1368 |
get_from=acts, |
| 1369 |
get_by='Name', |
| 1370 |
value='greeting' |
| 1371 |
) |
| 1372 |
|
| 1373 |
action_id = created_action['ID'] |
| 1374 |
|
| 1375 |
params = '{0} --id {1}'.format(self.act_tag_def, action_id) |
| 1376 |
acts = self.mistral_admin('action-update', params=params) |
| 1377 |
|
| 1378 |
updated_action = self.get_item_info( |
| 1379 |
get_from=acts, |
| 1380 |
get_by='ID', |
| 1381 |
value=action_id |
| 1382 |
) |
| 1383 |
|
| 1384 |
self.assertEqual( |
| 1385 |
created_action['Created at'].split(".")[0], |
| 1386 |
updated_action['Created at'] |
| 1387 |
) |
| 1388 |
self.assertEqual(created_action['Name'], updated_action['Name']) |
| 1389 |
self.assertNotEqual( |
| 1390 |
created_action['Updated at'], |
| 1391 |
updated_action['Updated at'] |
| 1392 |
) |
| 1393 |
|
| 1394 |
def test_action_update_truncate_input(self): |
| 1395 |
input_value = "very_long_input_parameter_name_that_should_be_truncated" |
| 1396 |
|
| 1397 |
act_def = """ |
| 1398 |
version: "2.0" |
| 1399 |
action1: |
| 1400 |
input: |
| 1401 |
- {0} |
| 1402 |
base: std.noop |
| 1403 |
""".format(input_value) |
| 1404 |
|
| 1405 |
self.create_file('action.yaml', act_def) |
| 1406 |
self.action_create('action.yaml') |
| 1407 |
|
| 1408 |
updated_act = self.mistral_admin('action-update', params='action.yaml') |
| 1409 |
|
| 1410 |
updated_act_info = self.get_item_info( |
| 1411 |
get_from=updated_act, |
| 1412 |
get_by='Name', |
| 1413 |
value='action1' |
| 1414 |
) |
| 1415 |
|
| 1416 |
self.assertEqual(updated_act_info['Input'][:-3], input_value[:25]) |
| 1417 |
|
| 1418 |
def test_action_get_definition(self): |
| 1419 |
self.action_create(self.act_def) |
| 1420 |
|
| 1421 |
definition = self.mistral_admin( |
| 1422 |
'action-get-definition', |
| 1423 |
params='greeting' |
| 1424 |
) |
| 1425 |
|
| 1426 |
self.assertNotIn('404 Not Found', definition) |
| 1427 |
|
| 1428 |
def test_action_get_definition_with_namespace(self): |
| 1429 |
self.action_create(self.act_def) |
| 1430 |
|
| 1431 |
definition = self.mistral_admin( |
| 1432 |
'action-get-definition', |
| 1433 |
params='greeting --namespace test_namespace' |
| 1434 |
) |
| 1435 |
|
| 1436 |
self.assertNotIn('404 Not Found', definition) |
| 1437 |
|
| 1438 |
def test_action_get_with_name(self): |
| 1439 |
created = self.action_create(self.act_def) |
| 1440 |
|
| 1441 |
action_name = created[0]['Name'] |
| 1442 |
|
| 1443 |
fetched = self.mistral_admin('action-get', params=action_name) |
| 1444 |
|
| 1445 |
fetched_action_name = self.get_field_value(fetched, 'Name') |
| 1446 |
|
| 1447 |
self.assertEqual(action_name, fetched_action_name) |
| 1448 |
|
| 1449 |
def test_action_list_with_filter(self): |
| 1450 |
actions = self.parser.listing(self.mistral('action-list')) |
| 1451 |
|
| 1452 |
self.assertTableStruct( |
| 1453 |
actions, |
| 1454 |
['Name', 'Is system', 'Input', 'Description', |
| 1455 |
'Tags', 'Created at', 'Updated at'] |
| 1456 |
) |
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
unfiltered_len = len(actions) |
| 1468 |
|
| 1469 |
self.assertGreater(unfiltered_len, 0) |
| 1470 |
|
| 1471 |
|
| 1472 |
actions = self.parser.listing( |
| 1473 |
self.mistral( |
| 1474 |
'action-list', |
| 1475 |
params='--filter name=in:std.echo,std.noop' |
| 1476 |
) |
| 1477 |
) |
| 1478 |
|
| 1479 |
self.assertTableStruct( |
| 1480 |
actions, |
| 1481 |
['Name', 'Is system', 'Input', 'Description', |
| 1482 |
'Tags', 'Created at', 'Updated at'] |
| 1483 |
) |
| 1484 |
|
| 1485 |
self.assertGreater(unfiltered_len, len(actions)) |
| 1486 |
|
| 1487 |
action_names = [a['Name'] for a in actions] |
| 1488 |
|
| 1489 |
self.assertIn('std.echo', action_names) |
| 1490 |
self.assertIn('std.noop', action_names) |
| 1491 |
self.assertNotIn('std.ssh', action_names) |
| 1492 |
|
| 1493 |
|
| 1494 |
class EnvironmentCLITests(base_v2.MistralClientTestBase): |
| 1495 |
"""Test suite checks commands to work with environments.""" |
| 1496 |
|
| 1497 |
def setUp(self): |
| 1498 |
super(EnvironmentCLITests, self).setUp() |
| 1499 |
|
| 1500 |
self.create_file( |
| 1501 |
'env.yaml', |
| 1502 |
'name: env\n' |
| 1503 |
'description: Test env\n' |
| 1504 |
'variables:\n' |
| 1505 |
' var: "value"' |
| 1506 |
) |
| 1507 |
|
| 1508 |
def test_environment_create(self): |
| 1509 |
env = self.mistral_admin('environment-create', params='env.yaml') |
| 1510 |
|
| 1511 |
env_name = self.get_field_value(env, 'Name') |
| 1512 |
env_desc = self.get_field_value(env, 'Description') |
| 1513 |
|
| 1514 |
self.assertTableStruct(env, ['Field', 'Value']) |
| 1515 |
|
| 1516 |
envs = self.mistral_admin('environment-list') |
| 1517 |
|
| 1518 |
self.assertIn(env_name, [en['Name'] for en in envs]) |
| 1519 |
self.assertIn(env_desc, [en['Description'] for en in envs]) |
| 1520 |
|
| 1521 |
self.mistral_admin('environment-delete', params=env_name) |
| 1522 |
|
| 1523 |
envs = self.mistral_admin('environment-list') |
| 1524 |
|
| 1525 |
self.assertNotIn(env_name, [en['Name'] for en in envs]) |
| 1526 |
|
| 1527 |
def test_environment_create_without_description(self): |
| 1528 |
self.create_file( |
| 1529 |
'env_without_des.yaml', |
| 1530 |
'name: env\n' |
| 1531 |
'variables:\n' |
| 1532 |
' var: "value"' |
| 1533 |
) |
| 1534 |
|
| 1535 |
env = self.mistral_admin( |
| 1536 |
'environment-create', |
| 1537 |
params='env_without_des.yaml' |
| 1538 |
) |
| 1539 |
|
| 1540 |
env_name = self.get_field_value(env, 'Name') |
| 1541 |
env_desc = self.get_field_value(env, 'Description') |
| 1542 |
|
| 1543 |
self.assertTableStruct(env, ['Field', 'Value']) |
| 1544 |
|
| 1545 |
envs = self.mistral_admin('environment-list') |
| 1546 |
|
| 1547 |
self.assertIn(env_name, [en['Name'] for en in envs]) |
| 1548 |
self.assertIn(env_desc, 'None') |
| 1549 |
|
| 1550 |
self.mistral_admin('environment-delete', params='env') |
| 1551 |
|
| 1552 |
envs = self.mistral_admin('environment-list') |
| 1553 |
|
| 1554 |
self.assertNotIn(env_name, [en['Name'] for en in envs]) |
| 1555 |
|
| 1556 |
def test_environment_update(self): |
| 1557 |
env = self.environment_create('env.yaml') |
| 1558 |
|
| 1559 |
env_name = self.get_field_value(env, 'Name') |
| 1560 |
env_desc = self.get_field_value(env, 'Description') |
| 1561 |
env_created_at = self.get_field_value(env, 'Created at') |
| 1562 |
env_updated_at = self.get_field_value(env, 'Updated at') |
| 1563 |
|
| 1564 |
self.assertIsNotNone(env_created_at) |
| 1565 |
self.assertEqual('None', env_updated_at) |
| 1566 |
|
| 1567 |
self.create_file( |
| 1568 |
'env_upd.yaml', |
| 1569 |
'name: env\n' |
| 1570 |
'description: Updated env\n' |
| 1571 |
'variables:\n' |
| 1572 |
' var: "value"' |
| 1573 |
) |
| 1574 |
|
| 1575 |
env = self.mistral_admin('environment-update', params='env_upd.yaml') |
| 1576 |
|
| 1577 |
self.assertTableStruct(env, ['Field', 'Value']) |
| 1578 |
|
| 1579 |
updated_env_name = self.get_field_value(env, 'Name') |
| 1580 |
updated_env_desc = self.get_field_value(env, 'Description') |
| 1581 |
updated_env_created_at = self.get_field_value(env, 'Created at') |
| 1582 |
updated_env_updated_at = self.get_field_value(env, 'Updated at') |
| 1583 |
|
| 1584 |
self.assertEqual(env_name, updated_env_name) |
| 1585 |
self.assertNotEqual(env_desc, updated_env_desc) |
| 1586 |
self.assertEqual('Updated env', updated_env_desc) |
| 1587 |
self.assertEqual(env_created_at.split('.')[0], updated_env_created_at) |
| 1588 |
self.assertIsNotNone(updated_env_updated_at) |
| 1589 |
|
| 1590 |
def test_environment_get(self): |
| 1591 |
env = self.environment_create('env.yaml') |
| 1592 |
|
| 1593 |
env_name = self.get_field_value(env, 'Name') |
| 1594 |
env_desc = self.get_field_value(env, 'Description') |
| 1595 |
|
| 1596 |
env = self.mistral_admin('environment-get', params=env_name) |
| 1597 |
|
| 1598 |
fetched_env_name = self.get_field_value(env, 'Name') |
| 1599 |
fetched_env_desc = self.get_field_value(env, 'Description') |
| 1600 |
|
| 1601 |
self.assertTableStruct(env, ['Field', 'Value']) |
| 1602 |
self.assertEqual(env_name, fetched_env_name) |
| 1603 |
self.assertEqual(env_desc, fetched_env_desc) |
| 1604 |
|
| 1605 |
def test_environment_get_export(self): |
| 1606 |
env = self.environment_create('env.yaml') |
| 1607 |
|
| 1608 |
env_name = self.get_field_value(env, 'Name') |
| 1609 |
env_desc = self.get_field_value(env, 'Description') |
| 1610 |
|
| 1611 |
env = self.mistral_admin('environment-get', |
| 1612 |
params='--export {0}'.format(env_name)) |
| 1613 |
|
| 1614 |
fetched_env_name = self.get_field_value(env, 'name') |
| 1615 |
fetched_env_desc = self.get_field_value(env, 'description') |
| 1616 |
|
| 1617 |
self.assertTableStruct(env, ['Field', 'Value']) |
| 1618 |
self.assertEqual(env_name, fetched_env_name) |
| 1619 |
self.assertEqual(env_desc, fetched_env_desc) |
| 1620 |
|
| 1621 |
|
| 1622 |
class ActionExecutionCLITests(base_v2.MistralClientTestBase): |
| 1623 |
"""Test suite checks commands to work with action executions.""" |
| 1624 |
|
| 1625 |
def setUp(self): |
| 1626 |
super(ActionExecutionCLITests, self).setUp() |
| 1627 |
|
| 1628 |
wfs = self.workflow_create(self.wf_def) |
| 1629 |
|
| 1630 |
self.direct_wf = wfs[0] |
| 1631 |
|
| 1632 |
direct_wf_exec = self.execution_create(self.direct_wf['Name']) |
| 1633 |
|
| 1634 |
self.direct_ex_id = self.get_field_value(direct_wf_exec, 'ID') |
| 1635 |
|
| 1636 |
def test_act_execution_get(self): |
| 1637 |
self.wait_execution_success(self.direct_ex_id) |
| 1638 |
|
| 1639 |
task = self.mistral_admin('task-list', params=self.direct_ex_id)[0] |
| 1640 |
|
| 1641 |
act_ex_from_list = self.mistral_admin( |
| 1642 |
'action-execution-list', |
| 1643 |
params=task['ID'] |
| 1644 |
)[0] |
| 1645 |
|
| 1646 |
act_ex = self.mistral_admin( |
| 1647 |
'action-execution-get', |
| 1648 |
params=act_ex_from_list['ID'] |
| 1649 |
) |
| 1650 |
|
| 1651 |
wf_name = self.get_field_value(act_ex, 'Workflow name') |
| 1652 |
state = self.get_field_value(act_ex, 'State') |
| 1653 |
|
| 1654 |
self.assertEqual( |
| 1655 |
act_ex_from_list['ID'], |
| 1656 |
self.get_field_value(act_ex, 'ID') |
| 1657 |
) |
| 1658 |
self.assertEqual(self.direct_wf['Name'], wf_name) |
| 1659 |
self.assertEqual('SUCCESS', state) |
| 1660 |
|
| 1661 |
def test_act_execution_list_with_limit(self): |
| 1662 |
self.wait_execution_success(self.direct_ex_id) |
| 1663 |
|
| 1664 |
act_execs = self.mistral_admin('action-execution-list') |
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
self.assertGreater(len(act_execs), 1) |
| 1669 |
|
| 1670 |
act_execs = self.mistral_admin( |
| 1671 |
'action-execution-list', |
| 1672 |
params="--limit 1" |
| 1673 |
) |
| 1674 |
|
| 1675 |
self.assertEqual(len(act_execs), 1) |
| 1676 |
|
| 1677 |
act_ex = act_execs[0] |
| 1678 |
|
| 1679 |
self.assertEqual(self.direct_wf['Name'], act_ex['Workflow name']) |
| 1680 |
self.assertEqual('SUCCESS', act_ex['State']) |
| 1681 |
|
| 1682 |
def test_act_execution_get_list_within_namespace(self): |
| 1683 |
namespace = 'bbb' |
| 1684 |
self.workflow_create(self.wf_def, namespace=namespace) |
| 1685 |
wf_ex = self.execution_create( |
| 1686 |
self.direct_wf['Name'] + ' --namespace ' + namespace |
| 1687 |
) |
| 1688 |
exec_id = self.get_field_value(wf_ex, 'ID') |
| 1689 |
self.wait_execution_success(exec_id) |
| 1690 |
task = self.mistral_admin('task-list', params=exec_id)[0] |
| 1691 |
|
| 1692 |
act_ex_from_list = self.mistral_admin( |
| 1693 |
'action-execution-list', |
| 1694 |
params=task['ID'] |
| 1695 |
)[0] |
| 1696 |
|
| 1697 |
act_ex = self.mistral_admin( |
| 1698 |
'action-execution-get', |
| 1699 |
params=act_ex_from_list['ID'] |
| 1700 |
) |
| 1701 |
|
| 1702 |
wf_name = self.get_field_value(act_ex, 'Workflow name') |
| 1703 |
wf_namespace = self.get_field_value(act_ex, 'Workflow namespace') |
| 1704 |
status = self.get_field_value(act_ex, 'State') |
| 1705 |
|
| 1706 |
self.assertEqual( |
| 1707 |
act_ex_from_list['ID'], |
| 1708 |
self.get_field_value(act_ex, 'ID') |
| 1709 |
) |
| 1710 |
self.assertEqual(self.direct_wf['Name'], wf_name) |
| 1711 |
self.assertEqual('SUCCESS', status) |
| 1712 |
self.assertEqual(namespace, wf_namespace) |
| 1713 |
self.assertEqual(namespace, act_ex_from_list['Workflow namespace']) |
| 1714 |
|
| 1715 |
def test_act_execution_create_delete(self): |
| 1716 |
action_ex = self.mistral_admin( |
| 1717 |
'run-action', |
| 1718 |
params="std.echo '{0}' --save-result".format( |
| 1719 |
'{"output": "Hello!"}') |
| 1720 |
) |
| 1721 |
|
| 1722 |
action_ex_id = self.get_field_value(action_ex, 'ID') |
| 1723 |
|
| 1724 |
self.assertTableStruct(action_ex, ['Field', 'Value']) |
| 1725 |
|
| 1726 |
name = self.get_field_value(action_ex, 'Name') |
| 1727 |
wf_name = self.get_field_value(action_ex, 'Workflow name') |
| 1728 |
task_name = self.get_field_value(action_ex, 'Task name') |
| 1729 |
|
| 1730 |
self.assertEqual('std.echo', name) |
| 1731 |
self.assertEqual('None', wf_name) |
| 1732 |
self.assertEqual('None', task_name) |
| 1733 |
|
| 1734 |
action_exs = self.mistral_admin('action-execution-list') |
| 1735 |
|
| 1736 |
self.assertIn(action_ex_id, [ex['ID'] for ex in action_exs]) |
| 1737 |
|
| 1738 |
self.mistral_admin('action-execution-delete', params=action_ex_id) |
| 1739 |
|
| 1740 |
action_exs = self.mistral_admin('action-execution-list') |
| 1741 |
|
| 1742 |
self.assertNotIn(action_ex_id, [ex['ID'] for ex in action_exs]) |
| 1743 |
|
| 1744 |
|
| 1745 |
class NegativeCLITests(base_v2.MistralClientTestBase): |
| 1746 |
"""This class contains negative tests.""" |
| 1747 |
|
| 1748 |
def test_wb_list_extra_param(self): |
| 1749 |
self.assertRaises( |
| 1750 |
exceptions.CommandFailed, |
| 1751 |
self.mistral_admin, |
| 1752 |
'workbook-list', |
| 1753 |
params='param' |
| 1754 |
) |
| 1755 |
|
| 1756 |
def test_wb_get_unexist_wb(self): |
| 1757 |
self.assertRaises( |
| 1758 |
exceptions.CommandFailed, |
| 1759 |
self.mistral_admin, |
| 1760 |
'workbook-get', |
| 1761 |
params='wb' |
| 1762 |
) |
| 1763 |
|
| 1764 |
def test_wb_get_without_param(self): |
| 1765 |
self.assertRaises( |
| 1766 |
exceptions.CommandFailed, |
| 1767 |
self.mistral_admin, |
| 1768 |
'workbook-get' |
| 1769 |
) |
| 1770 |
|
| 1771 |
def test_wb_create_same_name(self): |
| 1772 |
self.workbook_create(self.wb_def) |
| 1773 |
|
| 1774 |
self.assertRaises( |
| 1775 |
exceptions.CommandFailed, |
| 1776 |
self.workbook_create, |
| 1777 |
self.wb_def |
| 1778 |
) |
| 1779 |
|
| 1780 |
def test_wb_create_with_wrong_path_to_definition(self): |
| 1781 |
self.assertRaises( |
| 1782 |
exceptions.CommandFailed, |
| 1783 |
self.mistral_admin, |
| 1784 |
'workbook_create', |
| 1785 |
'wb' |
| 1786 |
) |
| 1787 |
|
| 1788 |
def test_wb_delete_unexist_wb(self): |
| 1789 |
self.assertRaises( |
| 1790 |
exceptions.CommandFailed, |
| 1791 |
self.mistral_admin, |
| 1792 |
'workbook-delete', |
| 1793 |
params='wb' |
| 1794 |
) |
| 1795 |
|
| 1796 |
def test_wb_update_wrong_path_to_def(self): |
| 1797 |
self.assertRaises( |
| 1798 |
exceptions.CommandFailed, |
| 1799 |
self.mistral_admin, |
| 1800 |
'workbook-update', |
| 1801 |
params='wb' |
| 1802 |
) |
| 1803 |
|
| 1804 |
def test_wb_update_nonexistant_wb(self): |
| 1805 |
self.assertRaises( |
| 1806 |
exceptions.CommandFailed, |
| 1807 |
self.mistral_admin, |
| 1808 |
'workbook-update', |
| 1809 |
params=self.wb_with_tags_def |
| 1810 |
) |
| 1811 |
|
| 1812 |
def test_wb_create_empty_def(self): |
| 1813 |
self.create_file('empty') |
| 1814 |
|
| 1815 |
self.assertRaises( |
| 1816 |
exceptions.CommandFailed, |
| 1817 |
self.mistral_admin, |
| 1818 |
'workbook-create', |
| 1819 |
params='empty' |
| 1820 |
) |
| 1821 |
|
| 1822 |
def test_wb_update_empty_def(self): |
| 1823 |
self.create_file('empty') |
| 1824 |
|
| 1825 |
self.assertRaises( |
| 1826 |
exceptions.CommandFailed, |
| 1827 |
self.mistral_admin, |
| 1828 |
'workbook-update', |
| 1829 |
params='empty' |
| 1830 |
) |
| 1831 |
|
| 1832 |
def test_wb_get_definition_unexist_wb(self): |
| 1833 |
self.assertRaises( |
| 1834 |
exceptions.CommandFailed, |
| 1835 |
self.mistral_admin, |
| 1836 |
'workbook-get-definition', |
| 1837 |
params='wb' |
| 1838 |
) |
| 1839 |
|
| 1840 |
def test_wb_create_invalid_def(self): |
| 1841 |
self.assertRaises( |
| 1842 |
exceptions.CommandFailed, |
| 1843 |
self.mistral_admin, |
| 1844 |
'workbook-create', |
| 1845 |
params=self.wf_def |
| 1846 |
) |
| 1847 |
|
| 1848 |
def test_wb_update_invalid_def(self): |
| 1849 |
self.assertRaises( |
| 1850 |
exceptions.CommandFailed, |
| 1851 |
self.mistral_admin, |
| 1852 |
'workbook-update', |
| 1853 |
params=self.wf_def |
| 1854 |
) |
| 1855 |
|
| 1856 |
def test_wb_update_without_def(self): |
| 1857 |
self.assertRaises( |
| 1858 |
exceptions.CommandFailed, |
| 1859 |
self.mistral_admin, |
| 1860 |
'workbook-update' |
| 1861 |
) |
| 1862 |
|
| 1863 |
def test_wf_list_extra_param(self): |
| 1864 |
self.assertRaises( |
| 1865 |
exceptions.CommandFailed, |
| 1866 |
self.mistral_admin, |
| 1867 |
'workflow-list', |
| 1868 |
params='param' |
| 1869 |
) |
| 1870 |
|
| 1871 |
def test_wf_get_unexist_wf(self): |
| 1872 |
self.assertRaises( |
| 1873 |
exceptions.CommandFailed, |
| 1874 |
self.mistral_admin, |
| 1875 |
'workflow-get', |
| 1876 |
params='wf' |
| 1877 |
) |
| 1878 |
|
| 1879 |
def test_wf_get_without_param(self): |
| 1880 |
self.assertRaises( |
| 1881 |
exceptions.CommandFailed, |
| 1882 |
self.mistral_admin, |
| 1883 |
'workflow-get' |
| 1884 |
) |
| 1885 |
|
| 1886 |
def test_wf_create_without_definition(self): |
| 1887 |
self.assertRaises( |
| 1888 |
exceptions.CommandFailed, |
| 1889 |
self.mistral_admin, |
| 1890 |
'workflow-create', |
| 1891 |
params='' |
| 1892 |
) |
| 1893 |
|
| 1894 |
def test_wf_create_with_wrong_path_to_definition(self): |
| 1895 |
self.assertRaises( |
| 1896 |
exceptions.CommandFailed, |
| 1897 |
self.mistral_admin, |
| 1898 |
'workflow-create', |
| 1899 |
params='wf' |
| 1900 |
) |
| 1901 |
|
| 1902 |
def test_wf_delete_unexist_wf(self): |
| 1903 |
self.assertRaises( |
| 1904 |
exceptions.CommandFailed, |
| 1905 |
self.mistral_admin, |
| 1906 |
'workflow-delete', |
| 1907 |
params='wf' |
| 1908 |
) |
| 1909 |
|
| 1910 |
def test_wf_update_unexist_wf(self): |
| 1911 |
self.assertRaises( |
| 1912 |
exceptions.CommandFailed, |
| 1913 |
self.mistral_admin, |
| 1914 |
'workflow-update', |
| 1915 |
params='wf' |
| 1916 |
) |
| 1917 |
|
| 1918 |
def test_wf_get_definition_unexist_wf(self): |
| 1919 |
self.assertRaises( |
| 1920 |
exceptions.CommandFailed, |
| 1921 |
self.mistral_admin, |
| 1922 |
'workflow-get-definition', |
| 1923 |
params='wf' |
| 1924 |
) |
| 1925 |
|
| 1926 |
def test_wf_get_definition_missed_param(self): |
| 1927 |
self.assertRaises( |
| 1928 |
exceptions.CommandFailed, |
| 1929 |
self.mistral_admin, |
| 1930 |
'workflow-get-definition' |
| 1931 |
) |
| 1932 |
|
| 1933 |
def test_wf_create_invalid_def(self): |
| 1934 |
self.assertRaises( |
| 1935 |
exceptions.CommandFailed, |
| 1936 |
self.mistral_admin, |
| 1937 |
'workflow-create', |
| 1938 |
params=self.wb_def |
| 1939 |
) |
| 1940 |
|
| 1941 |
def test_wf_update_invalid_def(self): |
| 1942 |
self.assertRaises( |
| 1943 |
exceptions.CommandFailed, |
| 1944 |
self.mistral_admin, |
| 1945 |
'workflow-update', |
| 1946 |
params=self.wb_def |
| 1947 |
) |
| 1948 |
|
| 1949 |
def test_wf_create_empty_def(self): |
| 1950 |
self.create_file('empty') |
| 1951 |
|
| 1952 |
self.assertRaises( |
| 1953 |
exceptions.CommandFailed, |
| 1954 |
self.mistral_admin, |
| 1955 |
'workflow-create', |
| 1956 |
params='empty' |
| 1957 |
) |
| 1958 |
|
| 1959 |
def test_wf_update_empty_def(self): |
| 1960 |
self.create_file('empty') |
| 1961 |
|
| 1962 |
self.assertRaises( |
| 1963 |
exceptions.CommandFailed, |
| 1964 |
self.mistral_admin, |
| 1965 |
'workflow-update', |
| 1966 |
params='empty' |
| 1967 |
) |
| 1968 |
|
| 1969 |
def test_ex_list_extra_param(self): |
| 1970 |
self.assertRaises( |
| 1971 |
exceptions.CommandFailed, |
| 1972 |
self.mistral_admin, |
| 1973 |
'execution-list', |
| 1974 |
params='param' |
| 1975 |
) |
| 1976 |
|
| 1977 |
def test_ex_create_unexist_wf(self): |
| 1978 |
self.assertRaises( |
| 1979 |
exceptions.CommandFailed, |
| 1980 |
self.mistral_admin, |
| 1981 |
'execution-create', |
| 1982 |
params='wf' |
| 1983 |
) |
| 1984 |
|
| 1985 |
def test_ex_create_unexist_task(self): |
| 1986 |
wf = self.workflow_create(self.wf_def) |
| 1987 |
|
| 1988 |
self.assertRaises( |
| 1989 |
exceptions.CommandFailed, |
| 1990 |
self.mistral_admin, |
| 1991 |
'execution-create', |
| 1992 |
params='%s param {}' % wf[0]['Name'] |
| 1993 |
) |
| 1994 |
|
| 1995 |
def test_ex_create_with_invalid_input(self): |
| 1996 |
wf = self.workflow_create(self.wf_def) |
| 1997 |
|
| 1998 |
self.assertRaises( |
| 1999 |
exceptions.CommandFailed, |
| 2000 |
self.mistral_admin, |
| 2001 |
'execution-create', |
| 2002 |
params="%s input" % wf[0]['Name'] |
| 2003 |
) |
| 2004 |
|
| 2005 |
def test_ex_get_nonexist_execution(self): |
| 2006 |
wf = self.workflow_create(self.wf_def) |
| 2007 |
|
| 2008 |
self.assertRaises( |
| 2009 |
exceptions.CommandFailed, |
| 2010 |
self.mistral_admin, |
| 2011 |
'execution-get', |
| 2012 |
params='%s id' % wf[0]['Name'] |
| 2013 |
) |
| 2014 |
|
| 2015 |
def test_ex_create_without_wf_name(self): |
| 2016 |
self.assertRaises( |
| 2017 |
exceptions.CommandFailed, |
| 2018 |
self.mistral_admin, |
| 2019 |
'execution-create' |
| 2020 |
) |
| 2021 |
|
| 2022 |
def test_ex_create_reverse_wf_without_start_task(self): |
| 2023 |
wf = self.workflow_create(self.wf_def) |
| 2024 |
|
| 2025 |
self.create_file('input', '{\n "farewell": "Bye"\n}\n') |
| 2026 |
|
| 2027 |
self.assertRaises( |
| 2028 |
exceptions.CommandFailed, |
| 2029 |
self.mistral_admin, |
| 2030 |
'execution-create ', |
| 2031 |
params=wf[1]['Name'] |
| 2032 |
) |
| 2033 |
|
| 2034 |
def test_ex_create_missed_input(self): |
| 2035 |
self.create_file('empty') |
| 2036 |
|
| 2037 |
wf = self.workflow_create(self.wf_def) |
| 2038 |
|
| 2039 |
self.assertRaises( |
| 2040 |
exceptions.CommandFailed, |
| 2041 |
self.mistral_admin, |
| 2042 |
'execution-create empty', |
| 2043 |
params=wf[1]['Name'] |
| 2044 |
) |
| 2045 |
|
| 2046 |
def test_ex_update_both_state_and_description(self): |
| 2047 |
wf = self.workflow_create(self.wf_def) |
| 2048 |
execution = self.execution_create(params=wf[0]['Name']) |
| 2049 |
|
| 2050 |
exec_id = self.get_field_value(execution, 'ID') |
| 2051 |
|
| 2052 |
self.assertRaises( |
| 2053 |
exceptions.CommandFailed, |
| 2054 |
self.mistral_admin, |
| 2055 |
'execution-update', |
| 2056 |
params='%s -s ERROR -d update' % exec_id |
| 2057 |
) |
| 2058 |
|
| 2059 |
def test_ex_delete_nonexistent_execution(self): |
| 2060 |
self.assertRaises( |
| 2061 |
exceptions.CommandFailed, |
| 2062 |
self.mistral_admin, |
| 2063 |
'execution-delete', |
| 2064 |
params='1a2b3c' |
| 2065 |
) |
| 2066 |
|
| 2067 |
def test_tr_create_without_pattern(self): |
| 2068 |
wf = self.workflow_create(self.wf_def) |
| 2069 |
|
| 2070 |
self.assertRaises( |
| 2071 |
exceptions.CommandFailed, |
| 2072 |
self.mistral_admin, |
| 2073 |
'cron-trigger-create', |
| 2074 |
params='tr %s {}' % wf[0]['Name'] |
| 2075 |
) |
| 2076 |
|
| 2077 |
def test_tr_create_invalid_pattern(self): |
| 2078 |
wf = self.workflow_create(self.wf_def) |
| 2079 |
|
| 2080 |
self.assertRaises( |
| 2081 |
exceptions.CommandFailed, |
| 2082 |
self.mistral_admin, |
| 2083 |
'cron-trigger-create', |
| 2084 |
params='tr %s {} --pattern "q"' % wf[0]['Name'] |
| 2085 |
) |
| 2086 |
|
| 2087 |
def test_tr_create_invalid_pattern_value_out_of_range(self): |
| 2088 |
wf = self.workflow_create(self.wf_def) |
| 2089 |
|
| 2090 |
self.assertRaises( |
| 2091 |
exceptions.CommandFailed, |
| 2092 |
self.mistral_admin, |
| 2093 |
'cron-trigger-create', |
| 2094 |
params='tr %s {} --pattern "80 * * * *"' % wf[0]['Name'] |
| 2095 |
) |
| 2096 |
|
| 2097 |
def test_tr_create_nonexistent_wf(self): |
| 2098 |
self.assertRaises( |
| 2099 |
exceptions.CommandFailed, |
| 2100 |
self.mistral_admin, |
| 2101 |
'cron-trigger-create', |
| 2102 |
params='tr wb.wf1 {} --pattern "* * * * *"' |
| 2103 |
) |
| 2104 |
|
| 2105 |
def test_tr_delete_nonexistant_tr(self): |
| 2106 |
self.assertRaises( |
| 2107 |
exceptions.CommandFailed, |
| 2108 |
self.mistral_admin, |
| 2109 |
'cron-trigger-delete', |
| 2110 |
params='tr' |
| 2111 |
) |
| 2112 |
|
| 2113 |
def test_tr_get_nonexistant_tr(self): |
| 2114 |
self.assertRaises( |
| 2115 |
exceptions.CommandFailed, |
| 2116 |
self.mistral_admin, |
| 2117 |
'cron-trigger-get', |
| 2118 |
params='tr' |
| 2119 |
) |
| 2120 |
|
| 2121 |
def test_tr_create_invalid_count(self): |
| 2122 |
self.assertRaises( |
| 2123 |
exceptions.CommandFailed, |
| 2124 |
self.mistral_admin, |
| 2125 |
'cron-trigger-create', |
| 2126 |
params='tr wb.wf1 {} --pattern "* * * * *" --count q' |
| 2127 |
) |
| 2128 |
|
| 2129 |
def test_tr_create_negative_count(self): |
| 2130 |
self.assertRaises( |
| 2131 |
exceptions.CommandFailed, |
| 2132 |
self.mistral_admin, |
| 2133 |
'cron-trigger-create', |
| 2134 |
params='tr wb.wf1 {} --pattern "* * * * *" --count -1') |
| 2135 |
|
| 2136 |
def test_tr_create_invalid_first_date(self): |
| 2137 |
self.assertRaises( |
| 2138 |
exceptions.CommandFailed, |
| 2139 |
self.mistral_admin, |
| 2140 |
'cron-trigger-create', |
| 2141 |
params='tr wb.wf1 {} --pattern "* * * * *" --first-date "q"' |
| 2142 |
) |
| 2143 |
|
| 2144 |
def test_tr_create_count_only(self): |
| 2145 |
self.assertRaises( |
| 2146 |
exceptions.CommandFailed, |
| 2147 |
self.mistral_admin, |
| 2148 |
'cron-trigger-create', |
| 2149 |
params='tr wb.wf1 {} --count 42' |
| 2150 |
) |
| 2151 |
|
| 2152 |
def test_tr_create_date_and_count_without_pattern(self): |
| 2153 |
self.assertRaises( |
| 2154 |
exceptions.CommandFailed, |
| 2155 |
self.mistral_admin, |
| 2156 |
'cron-trigger-create', |
| 2157 |
params='tr wb.wf1 {} --count 42 --first-time "4242-12-25 13:37"' |
| 2158 |
) |
| 2159 |
|
| 2160 |
def test_event_tr_create_missing_argument(self): |
| 2161 |
wf = self.workflow_create(self.wf_def) |
| 2162 |
|
| 2163 |
self.assertRaises( |
| 2164 |
exceptions.CommandFailed, |
| 2165 |
self.mistral_admin, |
| 2166 |
'event-trigger-create', |
| 2167 |
params='tr %s exchange topic' % wf[0]['ID'] |
| 2168 |
) |
| 2169 |
|
| 2170 |
def test_event_tr_create_nonexistent_wf(self): |
| 2171 |
self.assertRaises( |
| 2172 |
exceptions.CommandFailed, |
| 2173 |
self.mistral_admin, |
| 2174 |
'event-trigger-create', |
| 2175 |
params='456 4307362e-4a4a-4021-aa58-0fab23c9c751 ' |
| 2176 |
'exchange topic event {} ' |
| 2177 |
) |
| 2178 |
|
| 2179 |
def test_event_tr_delete_nonexistent_tr(self): |
| 2180 |
self.assertRaises( |
| 2181 |
exceptions.CommandFailed, |
| 2182 |
self.mistral_admin, |
| 2183 |
'event-trigger-delete', |
| 2184 |
params='789' |
| 2185 |
) |
| 2186 |
|
| 2187 |
def test_event_tr_get_nonexistent_tr(self): |
| 2188 |
self.assertRaises( |
| 2189 |
exceptions.CommandFailed, |
| 2190 |
self.mistral_admin, |
| 2191 |
'event-trigger-get', |
| 2192 |
params='789' |
| 2193 |
) |
| 2194 |
|
| 2195 |
def test_action_get_nonexistent(self): |
| 2196 |
self.assertRaises( |
| 2197 |
exceptions.CommandFailed, |
| 2198 |
self.mistral, |
| 2199 |
'action-get', |
| 2200 |
params='nonexist' |
| 2201 |
) |
| 2202 |
|
| 2203 |
def test_action_double_creation(self): |
| 2204 |
self.action_create(self.act_def) |
| 2205 |
|
| 2206 |
self.assertRaises( |
| 2207 |
exceptions.CommandFailed, |
| 2208 |
self.mistral_admin, |
| 2209 |
'action-create', |
| 2210 |
params='{0}'.format(self.act_def) |
| 2211 |
) |
| 2212 |
|
| 2213 |
def test_action_create_without_def(self): |
| 2214 |
self.assertRaises( |
| 2215 |
exceptions.CommandFailed, |
| 2216 |
self.mistral_admin, |
| 2217 |
'action-create', |
| 2218 |
params='' |
| 2219 |
) |
| 2220 |
|
| 2221 |
def test_action_create_invalid_def(self): |
| 2222 |
self.assertRaises( |
| 2223 |
exceptions.CommandFailed, |
| 2224 |
self.mistral_admin, |
| 2225 |
'action-create', |
| 2226 |
params='{0}'.format(self.wb_def) |
| 2227 |
) |
| 2228 |
|
| 2229 |
def test_action_delete_nonexistent_act(self): |
| 2230 |
self.assertRaises( |
| 2231 |
exceptions.CommandFailed, |
| 2232 |
self.mistral_admin, |
| 2233 |
'action-delete', |
| 2234 |
params='nonexist' |
| 2235 |
) |
| 2236 |
|
| 2237 |
def test_action_delete_standard_action(self): |
| 2238 |
self.assertRaises( |
| 2239 |
exceptions.CommandFailed, |
| 2240 |
self.mistral_admin, |
| 2241 |
'action-delete', |
| 2242 |
params='heat.events_get' |
| 2243 |
) |
| 2244 |
|
| 2245 |
def test_action_get_definition_nonexistent_action(self): |
| 2246 |
self.assertRaises( |
| 2247 |
exceptions.CommandFailed, |
| 2248 |
self.mistral_admin, |
| 2249 |
'action-get-definition', |
| 2250 |
params='nonexist' |
| 2251 |
) |
| 2252 |
|
| 2253 |
def test_task_get_nonexistent_task(self): |
| 2254 |
self.assertRaises( |
| 2255 |
exceptions.CommandFailed, |
| 2256 |
self.mistral_admin, |
| 2257 |
'task-get', |
| 2258 |
params='nonexist' |
| 2259 |
) |
| 2260 |
|
| 2261 |
def test_env_get_without_param(self): |
| 2262 |
self.assertRaises( |
| 2263 |
exceptions.CommandFailed, |
| 2264 |
self.mistral_admin, |
| 2265 |
'environment-get' |
| 2266 |
) |
| 2267 |
|
| 2268 |
def test_env_get_nonexistent(self): |
| 2269 |
self.assertRaises( |
| 2270 |
exceptions.CommandFailed, |
| 2271 |
self.mistral_admin, |
| 2272 |
'environment-get', |
| 2273 |
params='nonexist' |
| 2274 |
) |
| 2275 |
|
| 2276 |
def test_env_create_same_name(self): |
| 2277 |
self.create_file( |
| 2278 |
'env.yaml', |
| 2279 |
'name: env\n' |
| 2280 |
'description: Test env\n' |
| 2281 |
'variables:\n' |
| 2282 |
' var: "value"' |
| 2283 |
) |
| 2284 |
|
| 2285 |
self.environment_create('env.yaml') |
| 2286 |
|
| 2287 |
self.assertRaises( |
| 2288 |
exceptions.CommandFailed, |
| 2289 |
self.environment_create, |
| 2290 |
'env.yaml' |
| 2291 |
) |
| 2292 |
|
| 2293 |
def test_env_create_empty(self): |
| 2294 |
self.create_file('env.yaml') |
| 2295 |
|
| 2296 |
self.assertRaises( |
| 2297 |
exceptions.CommandFailed, |
| 2298 |
self.environment_create, |
| 2299 |
'env.yaml' |
| 2300 |
) |
| 2301 |
|
| 2302 |
def test_env_create_with_wrong_path_to_definition(self): |
| 2303 |
self.assertRaises( |
| 2304 |
exceptions.CommandFailed, |
| 2305 |
self.mistral_admin, |
| 2306 |
'execution_create', |
| 2307 |
'env' |
| 2308 |
) |
| 2309 |
|
| 2310 |
def test_env_delete_unexist_env(self): |
| 2311 |
self.assertRaises( |
| 2312 |
exceptions.CommandFailed, |
| 2313 |
self.mistral_admin, |
| 2314 |
'environment-delete', |
| 2315 |
params='env' |
| 2316 |
) |
| 2317 |
|
| 2318 |
def test_env_update_wrong_path_to_def(self): |
| 2319 |
self.assertRaises( |
| 2320 |
exceptions.CommandFailed, |
| 2321 |
self.mistral_admin, |
| 2322 |
'environment-update', |
| 2323 |
params='env' |
| 2324 |
) |
| 2325 |
|
| 2326 |
def test_env_update_empty(self): |
| 2327 |
self.create_file('env.yaml') |
| 2328 |
|
| 2329 |
self.assertRaises( |
| 2330 |
exceptions.CommandFailed, |
| 2331 |
self.mistral_admin, |
| 2332 |
'environment-update', |
| 2333 |
params='env' |
| 2334 |
) |
| 2335 |
|
| 2336 |
def test_env_update_nonexistant_env(self): |
| 2337 |
self.create_file( |
| 2338 |
'env.yaml', |
| 2339 |
'name: env' |
| 2340 |
'variables:\n var: "value"' |
| 2341 |
) |
| 2342 |
|
| 2343 |
self.assertRaises( |
| 2344 |
exceptions.CommandFailed, |
| 2345 |
self.mistral_admin, |
| 2346 |
'environment-update', |
| 2347 |
params='env.yaml' |
| 2348 |
) |
| 2349 |
|
| 2350 |
def test_env_create_without_name(self): |
| 2351 |
self.create_file('env.yaml', 'variables:\n var: "value"') |
| 2352 |
|
| 2353 |
self.assertRaises( |
| 2354 |
exceptions.CommandFailed, |
| 2355 |
self.mistral_admin, |
| 2356 |
'environment-create', |
| 2357 |
params='env.yaml' |
| 2358 |
) |
| 2359 |
|
| 2360 |
def test_env_create_without_variables(self): |
| 2361 |
self.create_file('env.yaml', 'name: env') |
| 2362 |
|
| 2363 |
self.assertRaises( |
| 2364 |
exceptions.CommandFailed, |
| 2365 |
self.mistral_admin, |
| 2366 |
'environment-create', |
| 2367 |
params='env.yaml' |
| 2368 |
) |
| 2369 |
|
| 2370 |
def test_action_execution_get_without_params(self): |
| 2371 |
self.assertRaises( |
| 2372 |
exceptions.CommandFailed, |
| 2373 |
self.mistral_admin, |
| 2374 |
'action-execution-get' |
| 2375 |
) |
| 2376 |
|
| 2377 |
def test_action_execution_get_unexistent_obj(self): |
| 2378 |
self.assertRaises( |
| 2379 |
exceptions.CommandFailed, |
| 2380 |
self.mistral_admin, |
| 2381 |
'action-execution-get', |
| 2382 |
params='123456' |
| 2383 |
) |
| 2384 |
|
| 2385 |
def test_action_execution_update(self): |
| 2386 |
wfs = self.workflow_create(self.wf_def) |
| 2387 |
direct_wf_exec = self.execution_create(wfs[0]['Name']) |
| 2388 |
|
| 2389 |
direct_ex_id = self.get_field_value(direct_wf_exec, 'ID') |
| 2390 |
|
| 2391 |
self.assertRaises( |
| 2392 |
exceptions.CommandFailed, |
| 2393 |
self.mistral_admin, |
| 2394 |
'action-execution-update', |
| 2395 |
params='%s ERROR' % direct_ex_id |
| 2396 |
) |
| 2397 |
|
| 2398 |
def test_target_action_execution(self): |
| 2399 |
command = ( |
| 2400 |
'--debug ' |
| 2401 |
'--os-target-tenant-name={tenantname} ' |
| 2402 |
'--os-target-username={username} ' |
| 2403 |
'--os-target-password="{password}" ' |
| 2404 |
'--os-target-auth-url="{auth_url}" ' |
| 2405 |
'--target_insecure ' |
| 2406 |
'run-action std.noop' |
| 2407 |
).format( |
| 2408 |
tenantname=self.clients.tenant_name, |
| 2409 |
username=self.clients.username, |
| 2410 |
password=self.clients.password, |
| 2411 |
auth_url=self.clients.uri |
| 2412 |
) |
| 2413 |
|
| 2414 |
self.mistral_alt_user(cmd=command) |