Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions packs/tests/actions/chains/test_pack_install_tool_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
vars:
base_repo_url: "https://github.com/StackStorm"
# Note: Pack 1 should have no external dependencies beyond Python stdlib ones.
pack_to_install_1: "csv"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to add a version selector here (like csv=0.4.2) which will verify more complex examples alltogether, - something that was an issue in st2 PR that implemented this script.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, added in b6f66ec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(More tests for various edge cases also wouldn't hurt of course, hopefully I can come back to that in the near future)

pack_to_install_1_with_version: "csv=0.1.0"
pack_to_install_2: "some-pack-doesnt-exist"
test_timeout: 60

chain:
-
name: check_st2_pack_instal_tool_is_available
ref: core.local
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: 'test -f /opt/stackstorm/st2/bin/st2-pack-install'
on-success: install_pack_1
on-failure: skip_tests_tool_not_available
-
name: skip_tests_tool_not_available
ref: core.local
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: 'echo "st2-pack-install CLI tool not available, skipping tests..."'
-
name: cleanup
ref: core.local_sudo
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: 'rm -rf "/opt/stackstorm/packs/{{ pack_to_install_1 }}" ; rm -rf "/opt/stackstorm/virtualenvs/{{ pack_to_install_1 }}"'
on-success: install_pack_1
on-failure: error_handler
-
name: install_pack_1
ref: core.local_sudo
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: "/opt/stackstorm/st2/bin/st2-pack-install {{ pack_to_install_1_with_version }} --debug"
timeout: "{{test_timeout}}"
on-success: verify_pack_1_has_been_installed
on-failure: error_handler
-
name: verify_pack_1_has_been_installed
ref: core.local
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: "test -d /opt/stackstorm/packs/{{ pack_to_install_1 }} && test -d /opt/stackstorm/virtualenvs/{{ pack_to_install_1 }}"
timeout: "{{test_timeout}}"
on-success: install_pack_2
on-failure: error_handler
# NOTE: Installation of pack 2 should fail
-
name: install_pack_2
ref: core.local_sudo
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: '/opt/stackstorm/st2/bin/st2-pack-install {{ pack_to_install_2 }} --debug 2>&1 | grep "Failed to install pack" | grep "No record of the"'
timeout: "{{test_timeout}}"
on-success: success_handler
on-failure: error_handler
-
name: success_handler
ref: core.local
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: "echo st2-pack-install tests succeeded; exit 0"
-
name: error_handler
description: Error handler
ref: "core.local"
params:
env:
ST2_BASE_URL: "{{protocol}}://{{hostname}}"
ST2_AUTH_URL: "{{protocol}}://{{hostname}}:9100"
ST2_API_URL: "{{protocol}}://{{hostname}}:9101"
ST2_AUTH_TOKEN: "{{token}}"
cmd: "echo st2-pack-install tests failed; exit 1"
19 changes: 19 additions & 0 deletions packs/tests/actions/test_pack_install_tool_tests.meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: "test_pack_install_tool_tests"
description: "Test which verifies that st2-pack-install CLI tool works correctly out of the box."
runner_type: "action-chain"
enabled: true
entry_point: "chains/test_pack_install_tool_tests.yaml"
parameters:
token:
type: "string"
description: "st2 auth token"
default: ""
protocol:
type: "string"
description: "http/https"
default: "http"
hostname:
type: "string"
description: "St2 host to run tests against"
default: "127.0.0.1"