Skip to content

Commit

Permalink
[MM-59996] Make stats and client logs more easily accessible (#861)
Browse files Browse the repository at this point in the history
* [MM-59996] Make stats and client logs more easily accessible through slash commands (#840)

* Make stats and client logs more easily accessible through slash commands

* Util function

* Command response wrapper

* Fix e2e

* Revert "Fix e2e"

This reverts commit 7710471.

* Use Playbooks v2

* Fix e2e tests pipeline (#859)

* update e2e test pipeline
  • Loading branch information
streamer45 authored Sep 18, 2024
1 parent d01f4db commit eb9c42a
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 89 deletions.
48 changes: 45 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,33 @@ jobs:
compression-level: 0
retention-days: 1

build-calls-transcriber:
runs-on: ubuntu-22.04
steps:
- name: e2e/checkout-transcriber-repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: mattermost/calls-transcriber
path: calls-transcriber

- name: e2e/setup-docker-buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0

- name: e2e/build-image
working-directory: ./calls-transcriber
run: |
make docker-build CI=false
docker save --output calls-transcriber.tar calls-transcriber:master
- name: e2e/persist-mattermost-calls-transcriber-image
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: mattermost-plugin-calls-transcriber-image
path: ${{ github.workspace }}/calls-transcriber/calls-transcriber.tar
if-no-files-found: error
compression-level: 0
retention-days: 1

generate-matrix:
runs-on: ubuntu-22.04
outputs:
Expand All @@ -68,14 +95,14 @@ jobs:
runs-on: ubuntu-22.04
needs:
- build-mattermost-plugin-calls
- build-calls-transcriber
- generate-matrix
env:
COMPOSE_PROJECT_NAME: playwright_tests
DOCKER_NETWORK: playwright_tests
CONTAINER_SERVER: playwright_tests_server
IMAGE_CALLS_OFFLOADER: mattermost/calls-offloader:v0.8.0
IMAGE_CALLS_RECORDER: mattermost/calls-recorder:v0.7.3
IMAGE_CALLS_TRANSCRIBER: mattermost/calls-transcriber:v0.3.1
IMAGE_CALLS_RECORDER: mattermost/calls-recorder:v0.7.5
IMAGE_SERVER: mattermostdevelopment/mattermost-enterprise-edition:master
IMAGE_CURL: curlimages/curl:8.7.1
CI_NODE_INDEX: ${{ matrix.run_id }}
Expand Down Expand Up @@ -122,13 +149,27 @@ jobs:
name: mattermost-plugin-calls-package
path: dist

- name: e2e/download-calls-transcriber-image
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: mattermost-plugin-calls-transcriber-image
path: ${{ github.workspace }}

- name: e2e/docker-login
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
# Do not authenticate on Forks
if: github.event.pull_request.head.repo.full_name == github.repository
with:
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}

- name: e2e/prepare-server
env:
DOCKER_CLIENT_TIMEOUT: 120
COMPOSE_HTTP_TIMEOUT: 120
## Should relative to mattermost/server/build/
DOCKER_COMPOSE_FILE: gitlab-dc.postgres.yml
DOCKER_COMPOSE_TEST_DATA: ../tests/test-data.ldif
TRANSCRIBER_IMAGE_PATH: ${{ github.workspace }}/calls-transcriber.tar
run: |
mkdir -p ${{ github.workspace }}/logs
mkdir -p ${{ github.workspace }}/config
Expand All @@ -143,6 +184,7 @@ jobs:
echo "MM_LICENSE=${{ secrets.MM_PLUGIN_CALLS_TEST_LICENSE }}" >> dotenv/app.private.env
echo "MM_FEATUREFLAGS_BoardsProduct=true" >> dotenv/app.private.env
echo "MM_SERVICEENVIRONMENT=test" >> dotenv/app.private.env
echo "MM_CALLS_JOB_SERVICE_URL=http://calls-offloader:4545" >> dotenv/app.private.env
sudo chown -R 2000:2000 ${{ github.workspace }}/logs
sudo chown -R 2000:2000 ${{ github.workspace }}/config
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/generate-e2e-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
steps:
- name: e2e-report/checkout-mattermost-plugin-calls-repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.workflow_run.head_sha }}

- name: e2e-report/download-paywright-report-results
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
Expand Down
9 changes: 9 additions & 0 deletions e2e/config-patch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"PluginSettings": {
"Plugins": {
"com.mattermost.calls": {
"enablerecordings": true
}
}
}
}
16 changes: 2 additions & 14 deletions e2e/overlay-config.jq
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,10 @@
"EmailSettings": {
"SMTPServer": "inbucket"
},
# Disable automatic installation of prepackaged plugins
"PluginSettings": {
"EnableUploads": true,
"AutomaticPrepackagedPlugins": false,
"Plugins": {
"com.mattermost.calls": {
"icehostoverride": "",
"iceserversconfigs": "",
"enablerecordings": true,
"defaultenabled": true,
"jobserviceurl": "http://calls-offloader:4545"
}
}
# Disable automatic installation of prepackaged plugins
"AutomaticPrepackagedPlugins": false
},
"ServiceSettings": {
"SiteURL": "http://mm-server:8065",
Expand All @@ -47,9 +38,6 @@
"UserNoticesEnabled": false,
"AdminNoticesEnabled": false
},
"FeatureFlags": {
"CallsEnabled": true
},
"ExperimentalSettings": {
"DisableAppBar": false
},
Expand Down
21 changes: 12 additions & 9 deletions e2e/scripts/prepare-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ docker network create ${DOCKER_NETWORK}

# Start server dependencies
echo "Starting server dependencies ... "
docker-compose -f ${DOCKER_COMPOSE_FILE} run -d --rm start_dependencies
timeout --foreground 90s bash -c "until docker-compose -f ${DOCKER_COMPOSE_FILE} exec -T postgres pg_isready ; do sleep 5 ; done"
docker compose -f ${DOCKER_COMPOSE_FILE} run -d --rm start_dependencies
timeout --foreground 90s bash -c "until docker compose -f ${DOCKER_COMPOSE_FILE} exec -T postgres pg_isready ; do sleep 5 ; done"
docker compose -f ${DOCKER_COMPOSE_FILE} exec -d -T minio sh -c 'mkdir -p /data/mattermost-test'

cat ${DOCKER_COMPOSE_TEST_DATA} | docker-compose -f ${DOCKER_COMPOSE_FILE} exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest'
docker-compose -f ${DOCKER_COMPOSE_FILE} exec -d -T minio sh -c 'mkdir -p /data/mattermost-test'
echo "Pulling ${IMAGE_CALLS_RECORDER} in order to be quickly accessible ... "
# Pull calls-recorder image to be used by calls-offloader.
docker pull ${IMAGE_CALLS_RECORDER}

## Load calls-transcriber image
docker load --input ${TRANSCRIBER_IMAGE_PATH}

echo "Pulling ${IMAGE_CALLS_RECORDER} and ${IMAGE_CALLS_TRANSCRIBER} in order to be quickly accessible ... "
# Pull calls-recorder and calls-transcriber images to be used by calls-offloader.
docker pull --quiet ${IMAGE_CALLS_RECORDER}
docker pull --quiet ${IMAGE_CALLS_TRANSCRIBER}
# We retag the official images so they can be run instead of the expected local
# one (DEV_MODE=true). Alternatively we'd have to build our own image from scratch or make
# some CI specific changes on the offloader.
docker image tag ${IMAGE_CALLS_RECORDER} calls-recorder:master
docker image tag ${IMAGE_CALLS_TRANSCRIBER} calls-transcriber:master

## Print images info
docker images

echo "Spawning calls-offloader service with docker host access ..."
# Spawn calls offloader image as root to access local docker socket
Expand Down
30 changes: 29 additions & 1 deletion e2e/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ set -o pipefail
echo "Installing playbooks ..."
docker exec \
${CONTAINER_SERVER} \
sh -c "/mattermost/bin/mmctl --local plugin add /mattermost/prepackaged_plugins/mattermost-plugin-playbooks-*.tar.gz && /mattermost/bin/mmctl --local plugin enable playbooks"
sh -c "/mattermost/bin/mmctl --local plugin add /mattermost/prepackaged_plugins/mattermost-plugin-playbooks-v2*.tar.gz && /mattermost/bin/mmctl --local plugin enable playbooks"

# Copy built plugin into server
echo "Copying calls plugin into ${CONTAINER_SERVER} server container ..."
docker cp dist/*.tar.gz ${CONTAINER_SERVER}:/mattermost/bin/calls

# Copy config patch into server container
echo "Copying calls config patch into ${CONTAINER_SERVER} server container ..."
docker cp e2e/config-patch.json ${CONTAINER_SERVER}:/mattermost

# Install Calls
echo "Installing calls ..."
docker exec \
${CONTAINER_SERVER} \
sh -c "/mattermost/bin/mmctl --local plugin add bin/calls"

# Patch config
echo "Patching calls config ..."
docker exec \
${CONTAINER_SERVER} \
sh -c "/mattermost/bin/mmctl --local plugin disable com.mattermost.calls && /mattermost/bin/mmctl --local config patch /mattermost/config-patch.json && /mattermost/bin/mmctl --local plugin enable com.mattermost.calls"

# Generates a sysadmin that Playwright can use
echo "Generating sample data with mmctl ..."
docker exec \
Expand All @@ -41,6 +51,24 @@ docker run -d --name playwright-e2e \

docker logs -f playwright-e2e

# Log all containers
docker ps -a

# Offloader logs
docker logs "${COMPOSE_PROJECT_NAME}_callsoffloader"

# Print transcriber job logs in case of failure.
for ID in $(docker ps -a --filter=ancestor="calls-transcriber:master" --format "{{.ID}}")
do
docker logs $ID
done

# Print recorder job logs in case of failure.
for ID in $(docker ps -a --filter=ancestor="calls-recorder:master" --format "{{.ID}}")
do
docker logs $ID
done

docker cp playwright-e2e:/usr/src/calls-e2e/test-results results/test-results-${CI_NODE_INDEX}
docker cp playwright-e2e:/usr/src/calls-e2e/playwright-report results/playwright-report-${CI_NODE_INDEX}
docker cp playwright-e2e:/usr/src/calls-e2e/pw-results.json results/pw-results-${CI_NODE_INDEX}.json
43 changes: 43 additions & 0 deletions e2e/tests/desktop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,47 @@ test.describe('desktop', () => {
// Verify error is getting sent
expect(desktopAPICalls.leaveCall).toBe(true);
});

test('desktop: /call stats command', async ({page}) => {
// start call in global widget
const devPage = new PlaywrightDevPage(page);
await devPage.openWidget(getChannelNamesForTest()[0]);
await devPage.leaveCall();

// Need to wait a moment since the the leave call happens in
// a setTimeout handler.
await devPage.wait(500);

// Go back to center channel view
await devPage.goto();

// Issue slash command
await devPage.sendSlashCommand('/call stats');
await devPage.wait(500);

// Veirfy call stats have been returned
await expect(page.locator('.post__body').last()).toContainText('"initTime"');
await expect(page.locator('.post__body').last()).toContainText('"callID"');
});

test('desktop: /call logs command', async ({page}) => {
// start call in global widget
const devPage = new PlaywrightDevPage(page);
await devPage.openWidget(getChannelNamesForTest()[0]);
await devPage.leaveCall();

// Need to wait a moment since the the leave call happens in
// a setTimeout handler.
await devPage.wait(500);

// Go back to center channel view
await devPage.goto();

// Issue slash command
await devPage.sendSlashCommand('/call logs');
await devPage.wait(500);

// Veirfy call logs have been returned
await expect(page.locator('.post__body').last()).toContainText('join ack received, initializing connection');
});
});
Loading

0 comments on commit eb9c42a

Please sign in to comment.