-
-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new "st2 action-alias execute-and-format" command for easier ChatOps alias development and testing #5143
Add new "st2 action-alias execute-and-format" command for easier ChatOps alias development and testing #5143
Conversation
to execute an action alias and render the result and display it. This will display the same message which would otherwise have been displayed in chat. This should make testing various aliases easier and faster.
@StackStorm/maintainers any suggestions for a better command line option name? Maybe |
I assume it's useful for testing purposes. Maybe just |
Added basic unit test (it's mock based so it's not ideal, but I dont have access nor time for end to end test at this point which would likely be a multi day commitment). Docs are available at StackStorm/st2docs#1053. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, but...f-strings!
Adding end-to-end tests for this should actually be pretty easy and straightforward: Drop a BATS file into here: https://github.com/StackStorm/st2tests/tree/master/cli There are plenty of examples in that directory to draw from. |
Drop a BATS file into here: https://github.com/StackStorm/st2tests/tree/master/cli
Yeah, the problem is that "easy" and "fast" are not always synonyms :D Adding a test may be easy, but based on my previous experience, the end to end develop + test feedback loop is quite slow and it can easily take multiple hours (and that's an optimistic estimate) to get things developed and tested end to end. |
Since this is for st2client, which is entirely user-facing code, I think end-to-end tests would be good to include for it. If it's worth writing, it's worth writing tests to make sure it doesn't break in the future. |
end to end tests on PRs have been temporary disabled so I probably won't get to that until they are enabled again to run on each PR / on demand (technically I could manually run it, but that's even slower, especially since whole st2web on cicd is so darn slow). So for the time being we either need to accept and live just with the unit tests or wait until end to end tests are re-enabled again. |
Co-authored-by: blag <[email protected]>
…hub.com:StackStorm/st2 into add_new_action_alias_execute_and_format_command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nits.
Also, what did we decide about E2E tests? Are we running them now that we've got some AWS credits?
I'm guessing this will move to 3.7.0 unless it is really close to done.
Re style - as mentioned in my previous comment to blag, I just followed the existing code style in the file - which I think it's the best course of actions since we all have our different opinions on style, but automatically enforcing them (to the extend possible) and being consistent is the most important. As far as end to end tests go, I don't think those will happen any time soon. |
@cognifloyd I synced this branch with latest master and resolved conflicts so this should hopefully merge cleanly now. |
Follow code style introduced in #5333
…hub.com:StackStorm/st2 into add_new_action_alias_execute_and_format_command
For now I kept the code as it to ensure consistency with the existing code base.
Now that v3.6.0 merge freeze is over, I will go ahead and merge it into master. |
This pull request adds new
st2 action-alias execute-and-format
(open to a better name) command which should make testing ChatOps aliases easier.It allows user to simulate ChatOps command using the CLI by performing the match and rendering / formatting + printing the result.
For example:
Background, Context
Currently StackStorm offers
match
andexecute
commands. The latter performs matching and if a matching alias is found, parameters are parsed and new action execution is created.That's all good since matching a command is usually first part of developing and troubleshooting an alias. But second part of developing an alias is verifying returned data is formatted correctly.
Right now there is no easy way to test that, but to do it directly in the chat which can be slow and cumbersome.
This proposed changes improves on that story that by adding a new command which allows user to simulate ChatOps actions via StackStorm CLI.
TODO