<commit_before>---
version: '1.0'

input:
  - host_ip
  - st2_auth_token
  - websocket
  - slack_channel
  - slack_bot_username
  - slack_bot_api_token
  - slack_user_username
  - slack_user_api_token

tasks:
  # Configure st2chatops.env and restart st2chatops
  # This is separate from the setup action because it does (and MUST) require
  # root privileges
  configure:
    action: st2cd.st2_chatops_configure_e2e_tests_with_slack
    input:
      hosts: <% ctx().host_ip %>
      env:
        SLACK_BOT_API_TOKEN: <% ctx().slack_bot_api_token %>
    next:
      - when: <% succeeded() %>
        do:
          - run
  # Run the tests with Slack
  run:
    action: core.remote
    input:
      hosts: <% ctx().host_ip %>
      timeout: 2400  # seconds
      # Workaround for https://github.com/StackStorm/st2/issues/4676
      # cmd: st2 run --inherit-env tests.test_aliases_with_slack
      # env:
      #   ST2_AUTH_TOKEN: <% ctx().st2_auth_token %>
      #   WEBSOCKET_CLIENT_CA_BUNDLE: <% ctx().websocket %>
      #   SLACK_CHANNEL: <% ctx().slack_channel %>
      #   SLACK_BOT_USERNAME: <% ctx().slack_bot_username %>
      #   SLACK_USER_USERNAME: <% ctx().slack_user_username %>
      #   SLACK_USER_API_TOKEN: <% ctx().slack_user_api_token %>
      cmd: |
        export ST2_AUTH_TOKEN=<% ctx().st2_auth_token %>;
        export WEBSOCKET_CLIENT_CA_BUNDLE=<% ctx().websocket %>;
        export SLACK_CHANNEL=<% ctx().slack_channel %>;
        export SLACK_BOT_USERNAME=<% ctx().slack_bot_username %>;
        export SLACK_USER_USERNAME=<% ctx().slack_user_username %>;
        export SLACK_USER_API_TOKEN=<% ctx().slack_user_api_token %>;
        . /opt/stackstorm/virtualenvs/tests/bin/activate;
        python /opt/stackstorm/packs/tests/actions/test_aliases_with_slack.py
    next:
      - do:
          - reset
      - when: <% failed() %>
        do:
          - fail
  # Reset st2chatops.env and restart st2chatops
  # This is separate from the teardown action because it does (and MUST) require
  # root privileges
  reset:
    action: st2cd.st2_chatops_reset_e2e_tests_with_slack
    input:
      hosts: <% ctx().host_ip %><commit_msg>Run ChatOps end-to-end tests twice<commit_after>---
version: '1.0'

input:
  - host_ip
  - st2_auth_token
  - websocket
  - slack_channel
  - slack_bot_username
  - slack_bot_api_token
  - slack_user_username
  - slack_user_api_token

tasks:
  # Configure st2chatops.env and restart st2chatops
  # This is separate from the setup action because it does (and MUST) require
  # root privileges
  configure:
    action: st2cd.st2_chatops_configure_e2e_tests_with_slack
    input:
      hosts: <% ctx().host_ip %>
      env:
        SLACK_BOT_API_TOKEN: <% ctx().slack_bot_api_token %>
    next:
      - when: <% succeeded() %>
        do:
          - run_with_small_timeout
  # Run the tests with Slack
  # Default SLACK_DONT_WAIT_FOR_MESSAGES_TIMEOUT value is 8 (seconds)
  run_with_small_timeout:
    action: core.remote
    input:
      hosts: <% ctx().host_ip %>
      timeout: 2400  # seconds
      # Workaround for https://github.com/StackStorm/st2/issues/4676
      # cmd: st2 run --inherit-env tests.test_aliases_with_slack
      # env:
      #   ST2_AUTH_TOKEN: <% ctx().st2_auth_token %>
      #   WEBSOCKET_CLIENT_CA_BUNDLE: <% ctx().websocket %>
      #   SLACK_CHANNEL: <% ctx().slack_channel %>
      #   SLACK_BOT_USERNAME: <% ctx().slack_bot_username %>
      #   SLACK_USER_USERNAME: <% ctx().slack_user_username %>
      #   SLACK_USER_API_TOKEN: <% ctx().slack_user_api_token %>
      cmd: |
        export ST2_AUTH_TOKEN=<% ctx().st2_auth_token %>;
        export WEBSOCKET_CLIENT_CA_BUNDLE=<% ctx().websocket %>;
        export SLACK_CHANNEL=<% ctx().slack_channel %>;
        export SLACK_BOT_USERNAME=<% ctx().slack_bot_username %>;
        export SLACK_USER_USERNAME=<% ctx().slack_user_username %>;
        export SLACK_USER_API_TOKEN=<% ctx().slack_user_api_token %>;
        . /opt/stackstorm/virtualenvs/tests/bin/activate;
        python /opt/stackstorm/packs/tests/actions/test_aliases_with_slack.py
    next:
      - do:
          - reset
      - when: <% failed() %>
        do:
          - run_with_large_timeout
  # Run the tests with Slack
  # This runs the tests slower and gives the ST2 IUT more time to respond
  run_with_large_timeout:
    action: core.remote
    input:
      hosts: <% ctx().host_ip %>
      timeout: 4800  # seconds
      # Workaround for https://github.com/StackStorm/st2/issues/4676
      # cmd: st2 run --inherit-env tests.test_aliases_with_slack
      # env:
      #   ST2_AUTH_TOKEN: <% ctx().st2_auth_token %>
      #   WEBSOCKET_CLIENT_CA_BUNDLE: <% ctx().websocket %>
      #   SLACK_CHANNEL: <% ctx().slack_channel %>
      #   SLACK_BOT_USERNAME: <% ctx().slack_bot_username %>
      #   SLACK_USER_USERNAME: <% ctx().slack_user_username %>
      #   SLACK_USER_API_TOKEN: <% ctx().slack_user_api_token %>
      #   SLACK_DONT_WAIT_FOR_MESSAGES_TIMEOUT: 120
      cmd: |
        export ST2_AUTH_TOKEN=<% ctx().st2_auth_token %>;
        export WEBSOCKET_CLIENT_CA_BUNDLE=<% ctx().websocket %>;
        export SLACK_CHANNEL=<% ctx().slack_channel %>;
        export SLACK_BOT_USERNAME=<% ctx().slack_bot_username %>;
        export SLACK_USER_USERNAME=<% ctx().slack_user_username %>;
        export SLACK_USER_API_TOKEN=<% ctx().slack_user_api_token %>;
        export SLACK_DONT_WAIT_FOR_MESSAGES_TIMEOUT=120;
        . /opt/stackstorm/virtualenvs/tests/bin/activate;
        python /opt/stackstorm/packs/tests/actions/test_aliases_with_slack.py
    next:
      - do:
          - reset
      - when: <% failed() %>
        do:
          - fail
  # Reset st2chatops.env and restart st2chatops
  # This is separate from the teardown action because it does (and MUST) require
  # root privileges
  reset:
    action: st2cd.st2_chatops_reset_e2e_tests_with_slack
    input:
      hosts: <% ctx().host_ip %>
{'fraction_non_alphanumeric': 0.11398176291793313, 'fraction_numerical': 0.012833502195204323, 'mean_word_length': 2.8237572627501613, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '132910', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2105, 'n_words': 366}