Merge "Add task_execution_id to workflow execution in CLI"
This commit is contained in:
@@ -37,6 +37,7 @@ def format(execution=None, lister=False):
|
|||||||
'ID',
|
'ID',
|
||||||
'Workflow',
|
'Workflow',
|
||||||
'Description',
|
'Description',
|
||||||
|
'Task Execution ID',
|
||||||
'State',
|
'State',
|
||||||
'State info',
|
'State info',
|
||||||
'Created at',
|
'Created at',
|
||||||
@@ -52,6 +53,7 @@ def format(execution=None, lister=False):
|
|||||||
execution.id,
|
execution.id,
|
||||||
execution.workflow_name,
|
execution.workflow_name,
|
||||||
execution.description,
|
execution.description,
|
||||||
|
execution.task_execution_id or '<none>',
|
||||||
execution.state,
|
execution.state,
|
||||||
state_info,
|
state_info,
|
||||||
execution.created_at,
|
execution.created_at,
|
||||||
|
@@ -22,20 +22,41 @@ from mistralclient.api.v2 import executions
|
|||||||
from mistralclient.commands.v2 import executions as execution_cmd
|
from mistralclient.commands.v2 import executions as execution_cmd
|
||||||
from mistralclient.tests.unit import base
|
from mistralclient.tests.unit import base
|
||||||
|
|
||||||
EXECUTION = executions.Execution(mock, {
|
EXEC = executions.Execution(
|
||||||
'id': '123',
|
mock,
|
||||||
'workflow_name': 'some',
|
{
|
||||||
'description': '',
|
'id': '123',
|
||||||
'state': 'RUNNING',
|
'workflow_name': 'some',
|
||||||
'state_info': None,
|
'description': '',
|
||||||
'created_at': '1',
|
'state': 'RUNNING',
|
||||||
'updated_at': '1'
|
'state_info': None,
|
||||||
})
|
'created_at': '1',
|
||||||
|
'updated_at': '1',
|
||||||
|
'task_execution_id': None
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
SUB_WF_EXEC = executions.Execution(
|
||||||
|
mock,
|
||||||
|
{
|
||||||
|
'id': '456',
|
||||||
|
'workflow_name': 'some_sub_wf',
|
||||||
|
'description': '',
|
||||||
|
'state': 'RUNNING',
|
||||||
|
'state_info': None,
|
||||||
|
'created_at': '1',
|
||||||
|
'updated_at': '1',
|
||||||
|
'task_execution_id': 'abc'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
EX_RESULT = ('123', 'some', '', '<none>', 'RUNNING', None, '1', '1')
|
||||||
|
SUB_WF_EX_RESULT = ('456', 'some_sub_wf', '', 'abc', 'RUNNING', None, '1', '1')
|
||||||
|
|
||||||
|
|
||||||
class TestCLIExecutionsV2(base.BaseCommandTest):
|
class TestCLIExecutionsV2(base.BaseCommandTest):
|
||||||
def test_create_wf_input_string(self):
|
def test_create_wf_input_string(self):
|
||||||
self.client.executions.create.return_value = EXECUTION
|
self.client.executions.create.return_value = EXEC
|
||||||
|
|
||||||
result = self.call(
|
result = self.call(
|
||||||
execution_cmd.Create,
|
execution_cmd.Create,
|
||||||
@@ -43,12 +64,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_wf_input_file(self):
|
def test_create_wf_input_file(self):
|
||||||
self.client.executions.create.return_value = EXECUTION
|
self.client.executions.create.return_value = EXEC
|
||||||
|
|
||||||
path = pkg.resource_filename(
|
path = pkg.resource_filename(
|
||||||
'mistralclient',
|
'mistralclient',
|
||||||
@@ -61,12 +82,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_with_description(self):
|
def test_create_with_description(self):
|
||||||
self.client.executions.create.return_value = EXECUTION
|
self.client.executions.create.return_value = EXEC
|
||||||
|
|
||||||
result = self.call(
|
result = self.call(
|
||||||
execution_cmd.Create,
|
execution_cmd.Create,
|
||||||
@@ -74,12 +95,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_update_state(self):
|
def test_update_state(self):
|
||||||
self.client.executions.update.return_value = EXECUTION
|
self.client.executions.update.return_value = EXEC
|
||||||
|
|
||||||
result = self.call(
|
result = self.call(
|
||||||
execution_cmd.Update,
|
execution_cmd.Update,
|
||||||
@@ -87,12 +108,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_resume_update_env(self):
|
def test_resume_update_env(self):
|
||||||
self.client.executions.update.return_value = EXECUTION
|
self.client.executions.update.return_value = EXEC
|
||||||
|
|
||||||
result = self.call(
|
result = self.call(
|
||||||
execution_cmd.Update,
|
execution_cmd.Update,
|
||||||
@@ -100,12 +121,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_update_description(self):
|
def test_update_description(self):
|
||||||
self.client.executions.update.return_value = EXECUTION
|
self.client.executions.update.return_value = EXEC
|
||||||
|
|
||||||
result = self.call(
|
result = self.call(
|
||||||
execution_cmd.Update,
|
execution_cmd.Update,
|
||||||
@@ -113,22 +134,22 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
self.client.executions.list.return_value = (EXECUTION,)
|
self.client.executions.list.return_value = (EXEC, SUB_WF_EXEC)
|
||||||
|
|
||||||
result = self.call(execution_cmd.List)
|
result = self.call(execution_cmd.List)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[('123', 'some', '', 'RUNNING', None, '1', '1')],
|
[EX_RESULT, SUB_WF_EX_RESULT],
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_list_with_pagination(self):
|
def test_list_with_pagination(self):
|
||||||
self.client.executions.list.return_value = (EXECUTION,)
|
self.client.executions.list.return_value = (EXEC,)
|
||||||
|
|
||||||
self.call(execution_cmd.List)
|
self.call(execution_cmd.List)
|
||||||
self.client.executions.list.assert_called_once_with(
|
self.client.executions.list.assert_called_once_with(
|
||||||
@@ -156,12 +177,22 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
self.client.executions.get.return_value = EXECUTION
|
self.client.executions.get.return_value = EXEC
|
||||||
|
|
||||||
result = self.call(execution_cmd.Get, app_args=['id'])
|
result = self.call(execution_cmd.Get, app_args=['id'])
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
('123', 'some', '', 'RUNNING', None, '1', '1'),
|
EX_RESULT,
|
||||||
|
result[1]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_get_sub_wf_ex(self):
|
||||||
|
self.client.executions.get.return_value = SUB_WF_EXEC
|
||||||
|
|
||||||
|
result = self.call(execution_cmd.Get, app_args=['id'])
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
SUB_WF_EX_RESULT,
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -35,6 +35,19 @@ EXEC = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SUB_WF_EXEC = {
|
||||||
|
'id': "456",
|
||||||
|
'workflow_name': 'my_sub_wf',
|
||||||
|
'task_execution_id': "abc",
|
||||||
|
'description': '',
|
||||||
|
'state': 'RUNNING',
|
||||||
|
'input': {
|
||||||
|
"person": {
|
||||||
|
"first_name": "John",
|
||||||
|
"last_name": "Doe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
URL_TEMPLATE = '/executions'
|
URL_TEMPLATE = '/executions'
|
||||||
URL_TEMPLATE_ID = '/executions/%s'
|
URL_TEMPLATE_ID = '/executions/%s'
|
||||||
@@ -124,15 +137,22 @@ class TestExecutionsV2(base.BaseClientV2Test):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
mock = self.mock_http_get(content={'executions': [EXEC]})
|
mock = self.mock_http_get(content={'executions': [EXEC, SUB_WF_EXEC]})
|
||||||
|
|
||||||
execution_list = self.executions.list()
|
execution_list = self.executions.list()
|
||||||
|
|
||||||
self.assertEqual(1, len(execution_list))
|
self.assertEqual(2, len(execution_list))
|
||||||
ex = execution_list[0]
|
|
||||||
|
self.assertEqual(
|
||||||
|
executions.Execution(self.executions, EXEC).to_dict(),
|
||||||
|
execution_list[0].to_dict()
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
executions.Execution(self.executions, SUB_WF_EXEC).to_dict(),
|
||||||
|
execution_list[1].to_dict()
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(executions.Execution(self.executions, EXEC).to_dict(),
|
|
||||||
ex.to_dict())
|
|
||||||
mock.assert_called_once_with(URL_TEMPLATE)
|
mock.assert_called_once_with(URL_TEMPLATE)
|
||||||
|
|
||||||
def test_list_with_pagination(self):
|
def test_list_with_pagination(self):
|
||||||
@@ -165,6 +185,18 @@ class TestExecutionsV2(base.BaseClientV2Test):
|
|||||||
|
|
||||||
mock.assert_called_once_with(URL_TEMPLATE_ID % EXEC['id'])
|
mock.assert_called_once_with(URL_TEMPLATE_ID % EXEC['id'])
|
||||||
|
|
||||||
|
def test_get_sub_wf_ex(self):
|
||||||
|
mock = self.mock_http_get(content=SUB_WF_EXEC)
|
||||||
|
|
||||||
|
ex = self.executions.get(SUB_WF_EXEC['id'])
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
executions.Execution(self.executions, SUB_WF_EXEC).to_dict(),
|
||||||
|
ex.to_dict()
|
||||||
|
)
|
||||||
|
|
||||||
|
mock.assert_called_once_with(URL_TEMPLATE_ID % SUB_WF_EXEC['id'])
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
mock = self.mock_http_delete(status_code=204)
|
mock = self.mock_http_delete(status_code=204)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user