-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Cloud Slack Dev E2E tests and fix migration test
- Loading branch information
Showing
19 changed files
with
2,888 additions
and
67 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
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,104 @@ | ||
name: CLI Migration E2E tests | ||
|
||
concurrency: | ||
group: cli-migration-e2e | ||
cancel-in-progress: false | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' # TODO: Ensure it runs after branch build | ||
- 'cloud-slack-dev-e2e' # TODO: Remove before merge | ||
repository_dispatch: | ||
types: [ trigger-e2e-tests ] | ||
|
||
env: | ||
HELM_VERSION: v3.9.0 | ||
K3D_VERSION: v5.4.6 | ||
IMAGE_REGISTRY: "ghcr.io" | ||
IMAGE_REPOSITORY: "kubeshop/botkube" | ||
IMAGE_TAG: v9.99.9-dev # TODO: Use commit hash tag to make the predictable builds for each commit on branch | ||
|
||
jobs: | ||
migration-e2e-test: | ||
name: Migration e2e test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: read | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
e2e: | ||
- discord | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: Install GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
install-only: true | ||
version: latest | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: true | ||
- name: Run GoReleaser | ||
run: make release-snapshot-cli | ||
- name: Add botkube alias | ||
run: | | ||
echo BOTKUBE_BINARY_PATH="$PWD/dist/botkube-cli_linux_amd64_v1/botkube" >> $GITHUB_ENV | ||
- name: Install Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
- name: Download k3d | ||
run: "wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash" | ||
- name: Create k3d cluster | ||
run: "k3d cluster create migration-test-cluster --wait --timeout=5m" | ||
- name: Run e2e tests for botkube client | ||
env: | ||
DISCORD_BOT_ID: ${{ secrets.DISCORD_BOT_ID }} | ||
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }} | ||
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }} | ||
DISCORD_TESTER_APP_TOKEN: ${{ secrets.DISCORD_TESTER_APP_TOKEN }} | ||
BOTKUBE_CLOUD_DEV_GQL_ENDPOINT: ${{ secrets.BOTKUBE_CLOUD_DEV_GQL_ENDPOINT }} | ||
BOTKUBE_CLOUD_DEV_REFRESH_TOKEN: ${{ secrets.BOTKUBE_CLOUD_DEV_REFRESH_TOKEN }} | ||
BOTKUBE_CLOUD_DEV_AUTH0_CLIENT_ID: ${{ secrets.BOTKUBE_CLOUD_DEV_AUTH0_CLIENT_ID }} | ||
run: | | ||
KUBECONFIG=$(k3d kubeconfig write migration-test-cluster) \ | ||
make test-migration-tool | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ always() }} | ||
with: | ||
name: screenshots_dump_${{github.sha}} | ||
path: ${{ runner.temp }}/screenshots | ||
retention-days: 5 | ||
|
||
- name: Dump cluster state | ||
if: ${{ failure() }} | ||
uses: ./.github/actions/dump-cluster | ||
|
||
# TODO: Uncomment | ||
# slackNotification: | ||
# name: Slack Notification | ||
# runs-on: ubuntu-latest | ||
# needs: [ e2e ] | ||
# if: failure() | ||
# steps: | ||
# - name: Slack Notification | ||
# uses: rtCamp/action-slack-notify@v2 | ||
# env: | ||
# SLACK_USERNAME: Botkube Cloud CI | ||
# SLACK_COLOR: 'red' | ||
# SLACK_TITLE: 'Message' | ||
# SLACK_CHANNEL: 'botkube-cloud-ci-alerts' | ||
# SLACK_MESSAGE: 'CLI Migration E2E tests failed :scream:' | ||
# SLACK_ICON_EMOJI: ':this-is-fine-fire:' | ||
# SLACK_FOOTER: "Fingers crossed it's just an outdated/flaky test..." | ||
# SLACK_WEBHOOK: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }} |
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,73 @@ | ||
name: Botkube Cloud Slack Dev E2E | ||
|
||
concurrency: | ||
group: cloud-slack-dev-e2e | ||
cancel-in-progress: false | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' # TODO: Ensure it runs after branch build | ||
- 'cloud-slack-dev-e2e' # TODO: Remove before merge | ||
repository_dispatch: | ||
types: [ trigger-e2e-tests ] | ||
|
||
jobs: | ||
e2e: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Kubernetes | ||
uses: medyagh/setup-minikube@latest | ||
|
||
- name: Setup Helm | ||
uses: azure/setup-helm@v3 | ||
|
||
- name: Run e2e tests | ||
env: | ||
SLACK_WORKSPACE_NAME: ${{ secrets.E2E_DEV_SLACK_WORKSPACE_NAME }} | ||
SLACK_EMAIL: ${{ secrets.E2E_DEV_SLACK_EMAIL }} | ||
SLACK_PASSWORD: ${{ secrets.E2E_DEV_SLACK_USER_PASSWORD }} | ||
SLACK_TESTER_TESTER_BOT_TOKEN: ${{ secrets.E2E_DEV_SLACK_TESTER_BOT_TOKEN }} | ||
SLACK_TESTER_BOT_NAME: botkubedev | ||
BOTKUBE_CLOUD_EMAIL: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_EMAIL }} | ||
BOTKUBE_CLOUD_PASSWORD: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }} | ||
BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }} | ||
BOTKUBE_CLOUD_FREE_ORGANIZATION_ID: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_FREE_ORGANIZATION_ID }} | ||
SCREENSHOTS_DIR: ${{ runner.temp }}/screenshots | ||
DEBUG_MODE: true | ||
run: | ||
make test-cloud-slack-dev-e2e | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ always() }} | ||
with: | ||
name: screenshots_dump_${{github.sha}} | ||
path: ${{ runner.temp }}/screenshots | ||
retention-days: 5 | ||
|
||
- name: Dump cluster state | ||
if: ${{ failure() }} | ||
uses: ./.github/actions/dump-cluster | ||
|
||
# TODO: Uncomment | ||
# slackNotification: | ||
# name: Slack Notification | ||
# runs-on: ubuntu-latest | ||
# needs: [ e2e ] | ||
# if: failure() | ||
# steps: | ||
# - name: Slack Notification | ||
# uses: rtCamp/action-slack-notify@v2 | ||
# env: | ||
# SLACK_USERNAME: Botkube Cloud CI | ||
# SLACK_COLOR: 'red' | ||
# SLACK_TITLE: 'Message' | ||
# SLACK_CHANNEL: 'botkube-cloud-ci-alerts' | ||
# SLACK_MESSAGE: 'Cloud Slack Dev E2E tests failed :scream:' | ||
# SLACK_ICON_EMOJI: ':this-is-fine-fire:' | ||
# SLACK_FOOTER: "Fingers crossed it's just an outdated/flaky test..." | ||
# SLACK_WEBHOOK: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }} |
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
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
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
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 |
---|---|---|
|
@@ -198,3 +198,56 @@ kubectl delete cm botkube-system -n botkube # or the namespace where Botkube is | |
``` | ||
|
||
If you don't remove the ConfigMap, any e2e tests looking to verify that a help message is displayed will error. This also stops the rest of the e2e tests from running. | ||
|
||
## Testing Cloud Slack end-to-end with Botkube Cloud | ||
|
||
You can test Botkube Cloud Slack with Botkube Cloud. Follow the instructions below to set up the test environment and run the tests. | ||
|
||
### Setting up test environment | ||
|
||
1. Create Slack user for testing purposes with access to a given Slack workspace. | ||
1. Create Botkube Cloud user with two organizations: FREE and TEAM one (with Cloud Slack quota). | ||
1. Follow the [Testing Slack](#testing-slack) instructions to set up "Tester" bot. | ||
|
||
### Running tests | ||
|
||
To run the tests, get all the noted data from previous steps and export them as environment variables. | ||
|
||
```bash | ||
# Required | ||
export SLACK_WORKSPACE_NAME="" # e.g. my-workspace | ||
# The test log ins to the Slack workspace using the credentials below | ||
export SLACK_EMAIL="" # e.g. [email protected] | ||
export SLACK_PASSWORD="" | ||
export SLACK_TESTER_BOT_NAME="" # e.g. botkubedev | ||
export SLACK_TESTER_TESTER_BOT_TOKEN="" # e.g. xoxb-... | ||
export BOTKUBE_CLOUD_EMAIL="" # e.g. [email protected] | ||
export BOTKUBE_CLOUD_PASSWORD="" | ||
export BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID="" # e.g. 204a2d86-265c-4ae2-89a8-928f823ec4da | ||
export BOTKUBE_CLOUD_FREE_ORGANIZATION_ID="" # e.g. c03bd605-7b8d-490f-b4d5-57c8a0560e83 | ||
# Optional - useful for running tests locally | ||
export KUBECONFIG="" # path to your kubeconfig | ||
export BOTKUBE_CLOUD_API_BASE_URL="" e.g. http://localhost:8080 | ||
export BOTKUBE_CLOUD_API_SLACK_APP_INSTALLATION_BASE_URL_OVERRIDE="" # provide if necessary e.g. using ngrok: https://d5ac-194-33-77-250.ngrok-free.app | ||
export SLACK_BOT_DISPLAY_NAME="" # e.g. BotkubeDev | ||
export SLACK_WORKSPACE_ALREADY_CONNECTED="true" | ||
export SLACK_DISCONNECT_WORKSPACE_AFTER_TESTS="false" | ||
export PAGE_TIMEOUT="1m" | ||
export SCREENSHOTS_ENABLED="false" # disable screenshots | ||
``` | ||
|
||
To run the test in headless mode (without browser window), run: | ||
|
||
```shell | ||
make test-cloud-slack-dev-e2e | ||
``` | ||
|
||
To run the tests with Chromium browser window visible, run: | ||
|
||
```shell | ||
test-cloud-slack-dev-e2e-show-browser | ||
``` | ||
|
||
Refer to the `E2ESlackConfig` (`./cloud-slack-dev-e2e/e2e_test.go`) for all possible environment variables. | ||
|
Oops, something went wrong.