-
-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2829 from lakshmi-kannan/STORM-2236_chatops_impro…
…vements Chatops related improvements
- Loading branch information
Showing
13 changed files
with
382 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"action": { | ||
"ref": "core.http" | ||
}, | ||
"context": { | ||
"user": "st2admin" | ||
}, | ||
"end_timestamp": "2016-07-28T00:46:42.062470Z", | ||
"id": "579955f055fc8c2d33ac03e3", | ||
"liveaction": { | ||
"action": "core.http", | ||
"action_is_workflow": false, | ||
"callback": {}, | ||
"id": "579955f055fc8c2d33ac03e2", | ||
"parameters": { | ||
"url": "https://httpbin.org/" | ||
}, | ||
"runner_info": { | ||
"hostname": "st2test", | ||
"pid": 11330 | ||
} | ||
}, | ||
"parameters": { | ||
"url": "https://httpbin.org/" | ||
}, | ||
"result": { | ||
"body": "BLAH BLAH BLAH", | ||
"headers": { | ||
"Access-Control-Allow-Credentials": "true", | ||
"Access-Control-Allow-Origin": "*", | ||
"Connection": "keep-alive", | ||
"Content-Length": "12150", | ||
"Content-Type": "text/html; charset=utf-8", | ||
"Date": "Thu, 28 Jul 2016 00:51:25 GMT", | ||
"Server": "nginx" | ||
}, | ||
"parsed": false, | ||
"status_code": 200 | ||
}, | ||
"web_url": "https://localhost.localdomain/#/history/579955f055fc8c2d33ac03e3/general", | ||
"start_timestamp": "2016-07-28T00:46:40.822066Z", | ||
"status": "succeeded", | ||
"runner": { | ||
"enabled": true, | ||
"id": "54c6bb640640fd5211edef0b", | ||
"name": "http-request", | ||
"runner_module": "st2actions.runners.httprunner", | ||
"runner_parameters": { | ||
"url": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"action": { | ||
"ref": "core.local" | ||
}, | ||
"context": { | ||
"user": "st2admin" | ||
}, | ||
"end_timestamp": "2016-07-28T00:30:39.555229Z", | ||
"id": "5799522f55fc8c2d33ac03e0", | ||
"liveaction": { | ||
"action": "core.local", | ||
"action_is_workflow": false, | ||
"callback": {}, | ||
"id": "5799522f55fc8c2d33ac03df", | ||
"parameters": { | ||
"cmd": "date" | ||
}, | ||
"runner_info": { | ||
"hostname": "st2test", | ||
"pid": 11327 | ||
} | ||
}, | ||
"parameters": { | ||
"cmd": "date" | ||
}, | ||
"result": { | ||
"failed": false, | ||
"return_code": 0, | ||
"stderr": "", | ||
"stdout": "Thu Jul 28 00:30:39 UTC 2016", | ||
"succeeded": true | ||
}, | ||
"start_timestamp": "2016-07-28T00:30:39.268566Z", | ||
"status": "succeeded", | ||
"web_url": "https://localhost.localdomain/#/history/57967f9355fc8c19a96d9e4f/general", | ||
"runner": { | ||
"enabled": true, | ||
"id": "54c6bb640640fd5211edef0b", | ||
"name": "local-shell-cmd", | ||
"runner_module": "st2actions.runners.localrunner", | ||
"runner_parameters": { | ||
"cmd": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
contrib/chatops/tests/fixtures/python_action_execution.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"action": { | ||
"ref": "examples.isprime" | ||
}, | ||
"context": { | ||
"user": "st2admin" | ||
}, | ||
"end_timestamp": "2016-07-28T00:51:55.400941Z", | ||
"id": "5799572a55fc8c2d33ac03ec", | ||
"liveaction": { | ||
"action": "examples.isprime", | ||
"action_is_workflow": false, | ||
"callback": {}, | ||
"id": "5799572a55fc8c2d33ac03eb", | ||
"parameters": { | ||
"value": 7 | ||
}, | ||
"runner_info": { | ||
"hostname": "st2test", | ||
"pid": 11327 | ||
} | ||
}, | ||
"parameters": { | ||
"value": 7 | ||
}, | ||
"result": { | ||
"exit_code": 0, | ||
"result": true, | ||
"stderr": "st2.actions.python.PrimeCheckerAction: DEBUG value=7\n", | ||
"stdout": "" | ||
}, | ||
"start_timestamp": "2016-07-28T00:51:54.005500Z", | ||
"status": "succeeded", | ||
"web_url": "https://localhost.localdomain/#/history/5799572a55fc8c2d33ac03ec/general", | ||
"runner": { | ||
"enabled": true, | ||
"id": "54c6bb640640fd5211edef0b", | ||
"name": "python-script", | ||
"runner_module": "st2actions.runners.pythonrunner", | ||
"runner_parameters": { | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"action": { | ||
"ref": "core.remote" | ||
}, | ||
"context": { | ||
"user": "st2admin" | ||
}, | ||
"end_timestamp": "2016-07-25T21:07:33.957268Z", | ||
"id": "57967f9355fc8c19a96d9e4f", | ||
"liveaction": { | ||
"action": "core.remote", | ||
"action_is_workflow": true, | ||
"callback": {}, | ||
"id": "57967f9355fc8c19a96d9e4e", | ||
"notify": { | ||
"on-complete": { | ||
"data": { | ||
"source_channel": "chatops_ci", | ||
"user": "lakstorm" | ||
}, | ||
"routes": [ | ||
"hubot" | ||
] | ||
} | ||
}, | ||
"parameters": { | ||
"cmd": "date", | ||
"hosts": "localhost" | ||
}, | ||
"runner_info": { | ||
"hostname": "st2test", | ||
"pid": 5686 | ||
} | ||
}, | ||
"parameters": { | ||
"cmd": "date", | ||
"hosts": "localhost" | ||
}, | ||
"web_url": "https://localhost.localdomain/#/history/57967f9355fc8c19a96d9e4f/general", | ||
"result": { | ||
"localhost": { | ||
"failed": false, | ||
"return_code": 0, | ||
"stderr": "", | ||
"stdout": "Mon Jul 25 21:07:32 UTC 2016", | ||
"succeeded": true | ||
} | ||
}, | ||
"start_timestamp": "2016-07-25T21:07:31.900544Z", | ||
"status": "succeeded", | ||
"runner": { | ||
"enabled": true, | ||
"id": "54c6bb640640fd5211edef0b", | ||
"name": "remote-shell-cmd", | ||
"runner_module": "st2actions.runners.remote_command_runner", | ||
"runner_parameters": { | ||
"cmd": { | ||
"type": "string" | ||
}, | ||
"hosts": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import json | ||
import mock | ||
|
||
from st2tests.base import BaseActionTestCase | ||
|
||
from format_execution_result import FormatResultAction | ||
|
||
__all__ = [ | ||
'FormatResultActionTestCase' | ||
] | ||
|
||
|
||
class FormatResultActionTestCase(BaseActionTestCase): | ||
action_cls = FormatResultAction | ||
|
||
def test_rendering_works_remote_shell_cmd(self): | ||
remote_shell_cmd_execution_model = json.loads( | ||
self.get_fixture_content('remote_cmd_execution.json') | ||
) | ||
|
||
action = self.get_action_instance() | ||
action._get_execution = mock.MagicMock( | ||
return_value=remote_shell_cmd_execution_model | ||
) | ||
self.assertTrue(action.run(execution_id='57967f9355fc8c19a96d9e4f')) | ||
|
||
def test_rendering_local_shell_cmd(self): | ||
local_shell_cmd_execution_model = json.loads( | ||
self.get_fixture_content('local_cmd_execution.json') | ||
) | ||
|
||
action = self.get_action_instance() | ||
action._get_execution = mock.MagicMock( | ||
return_value=local_shell_cmd_execution_model | ||
) | ||
self.assertTrue(action.run(execution_id='5799522f55fc8c2d33ac03e0')) | ||
|
||
def test_rendering_http_request(self): | ||
http_execution_model = json.loads( | ||
self.get_fixture_content('http_execution.json') | ||
) | ||
|
||
action = self.get_action_instance() | ||
action._get_execution = mock.MagicMock( | ||
return_value=http_execution_model | ||
) | ||
self.assertTrue(action.run(execution_id='579955f055fc8c2d33ac03e3')) | ||
|
||
def test_rendering_python_action(self): | ||
python_action_execution_model = json.loads( | ||
self.get_fixture_content('python_action_execution.json') | ||
) | ||
|
||
action = self.get_action_instance() | ||
action._get_execution = mock.MagicMock( | ||
return_value=python_action_execution_model | ||
) | ||
self.assertTrue(action.run(execution_id='5799572a55fc8c2d33ac03ec')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: "remote_shell_cmd" | ||
action_ref: "core.remote" | ||
description: "Execute a command on a remote host via SSH." | ||
formats: | ||
- "run {{cmd}} on {{hosts}}" | ||
ack: | ||
format: "Hold tight while I run command: *{{execution.parameters.cmd}}* on hosts *{{execution.parameters.hosts}}*" | ||
result: | ||
format: | | ||
Ran command *{{execution.parameters.cmd}}* on *{{ execution.result | length }}* hosts. | ||
Details are as follows: | ||
{% for host in execution.result -%} | ||
Host: *{{host}}* | ||
---> stdout: {{execution.result[host].stdout}} | ||
---> stderr: {{execution.result[host].stderr}} | ||
{%+ endfor %} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.