CLD-6297 - E2E tests improvements (#24541)

* Improve e2etests readme, remove unused apt install
* Add testing E2E Tests MultiOS
* Get rid of deprecation warning
* Smart selection of docker network driver for different OSes
* Unify makefile invocation for windows as well
* Tune JVM for ES and Keycloak
* fix: Made required changes to run locally on arm MacOS
* fix: FIxed network command and removed dashboard node user as it is not needed
* fix: make dashboard work for Mac
* Make runs without dashboard work again, make BROWSE tunable and document it

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>
Этот коммит содержится в:
Mario Vitale
2023-09-25 17:01:01 +02:00
коммит произвёл GitHub
родитель 1fc6b96c1b
Коммит 1e121eb7f3
13 изменённых файлов: 124 добавлений и 78 удалений

Просмотреть файл

@@ -3,12 +3,24 @@
export MME2E_DC_SERVER="docker compose -p mmserver -f $(readlink -f ../../server/build/gitlab-dc.postgres.yml) -f $(readlink -f ./server.override.yml)"
export MME2E_DC_DASHBOARD="docker compose -p mmdashboard -f $(readlink -f ./dashboard/docker/docker-compose.yml) -f $(readlink -f ./dashboard.override.yml)"
export MME2E_UID=$(id -u)
# Default the optional variables that are used in the docker-compose file
export SERVER_IMAGE_DEFAULT="mattermostdevelopment/mm-ee-test:$(git rev-parse --short=7 HEAD)"
export SERVER_IMAGE=${SERVER_IMAGE:-$SERVER_IMAGE_DEFAULT}
export MME2E_OSTYPE=$(docker version -f '{{ .Client.Os }}')
export MME2E_ARCHTYPE=$(docker version -f '{{ .Client.Arch }}')
export NODE_VERSION_REQUIRED=$(cat ../../.nvmrc)
# Default values for optional variables
export SERVER_IMAGE_DEFAULT="mattermostdevelopment/mm-ee-test:$(git rev-parse --short=7 HEAD)"
export BROWSER_DEFAULT="chrome"
case $MME2E_OSTYPE in
# OS specific defaults overrides
darwin )
BROWSER_DEFAULT="electron" ;;
* )
esac
# Populate the optional variables that are used in the docker-compose file
export SERVER_IMAGE=${SERVER_IMAGE:-$SERVER_IMAGE_DEFAULT}
export BROWSER=${BROWSER:-$BROWSER_DEFAULT}
# Function definitions
mme2e_log () { echo "[$(date +%Y-%m-%dT%H:%M:%S%Z)]" "$@"; }
mme2e_get_current_shopt_arg () {
@@ -70,7 +82,14 @@ mme2e_legacy_setup () {
# These functions are needed until every pipeline depending on the `server/build/gitlab-dc.*.yml` files is adapted to not use external docker networking anymore
# After that is fixed, this function and the external network in the docker-compose files may be removed
export COMPOSE_PROJECT_NAME=mmserver_legacy
docker network inspect ${COMPOSE_PROJECT_NAME} >/dev/null 2>&1 || docker network create ${COMPOSE_PROJECT_NAME}
case $MME2E_OSTYPE in
windows )
# https://learn.microsoft.com/en-us/virtualization/windowscontainers/container-networking/network-drivers-topologies
DOCKER_NETWORK_DRIVER="nat" ;;
* )
DOCKER_NETWORK_DRIVER="bridge" ;;
esac
docker network inspect ${COMPOSE_PROJECT_NAME} >/dev/null 2>&1 || docker network create --driver=${DOCKER_NETWORK_DRIVER} ${COMPOSE_PROJECT_NAME}
}
# Utility alias, for interactive shell usage. Can be reversed with 'unalias docker-compose' in your shell

Просмотреть файл

@@ -1,24 +1,23 @@
---
version: '3.1'
version: "3.1"
services:
dashboard:
image: mattermostdevelopment/mirrored-node:16.17.0
environment:
PG_URI: postgres://mmuser:mostest@db:5432/automation_dashboard_db
JWT_SECRET: s8gGBA3ujKRohSw1L8HLOY7Jjnu2ZYv8 # Generated with e.g. `dd if=/dev/urandom count=24 bs=1 2>/dev/null | base64 -w0`
JWT_USER: cypress-test
JWT_ROLE: integration
JWT_ALG: HS256
JWT_EXPIRES_IN: 365d
ALLOWED_USER: cypress-test
ALLOWED_ROLE: integration
user: "${MME2E_UID}"
volumes:
- "../:/app"
- "../../dashboard.entrypoint.sh:/usr/local/bin/dashboard.entrypoint.sh:ro"
- "../../.env.dashboard:/var/local/.env.dashboard:rw"
working_dir: /app
entrypoint: /usr/local/bin/dashboard.entrypoint.sh
ports:
- 4000:4000
dashboard:
image: mattermostdevelopment/mirrored-node:18.17
environment:
PG_URI: postgres://mmuser:mostest@db:5432/automation_dashboard_db
JWT_SECRET: s8gGBA3ujKRohSw1L8HLOY7Jjnu2ZYv8 # Generated with e.g. `dd if=/dev/urandom count=24 bs=1 2>/dev/null | base64 -w0`
JWT_USER: cypress-test
JWT_ROLE: integration
JWT_ALG: HS256
JWT_EXPIRES_IN: 365d
ALLOWED_USER: cypress-test
ALLOWED_ROLE: integration
volumes:
- "../:/app"
- "../../dashboard.entrypoint.sh:/usr/local/bin/dashboard.entrypoint.sh:ro"
- "../../.env.dashboard:/var/local/.env.dashboard:rw"
working_dir: /app
entrypoint: /usr/local/bin/dashboard.entrypoint.sh
ports:
- 4000:4000

Просмотреть файл

@@ -18,13 +18,18 @@ mme2e_log "Starting the dashboard"
${MME2E_DC_DASHBOARD} up -d db dashboard
mme2e_log "Generating the dashboard's local URL"
MME2E_DC_DASHBOARD_NETWORK=$(${MME2E_DC_DASHBOARD} ps -q dashboard | xargs -l docker inspect | jq -r '.[0].NetworkSettings.Networks | (keys|.[0])')
MME2E_DC_DASHBOARD_GATEWAY=$(docker network inspect $MME2E_DC_DASHBOARD_NETWORK | jq -r '.[0].IPAM.Config[0].Gateway')
AUTOMATION_DASHBOARD_URL="http://${MME2E_DC_DASHBOARD_GATEWAY}:4000/api"
case $MME2E_OSTYPE in
darwin )
AUTOMATION_DASHBOARD_IP=$(ifconfig $(route get 1.1.1.1 | grep interface | awk '{print $2}') | grep -w inet | awk '{print $2}') ;;
* )
MME2E_DC_DASHBOARD_NETWORK=$(docker inspect $(${MME2E_DC_DASHBOARD} ps -q dashboard) | jq -r '.[0].NetworkSettings.Networks | (keys|.[0])')
AUTOMATION_DASHBOARD_IP=$(docker network inspect $MME2E_DC_DASHBOARD_NETWORK | jq -r '.[0].IPAM.Config[0].Gateway')
esac
AUTOMATION_DASHBOARD_URL="http://${AUTOMATION_DASHBOARD_IP}:4000/api"
mme2e_log "Generating a signed JWT token for accessing the dashboard"
${MME2E_DC_DASHBOARD} exec -T -u $MME2E_UID dashboard npm i
AUTOMATION_DASHBOARD_TOKEN=$(${MME2E_DC_DASHBOARD} exec -T -u $MME2E_UID dashboard node script/sign.js | awk '{ print $2; }') # The token secret is specified in the dashboard.override.yml file
${MME2E_DC_DASHBOARD} exec -T dashboard npm i
AUTOMATION_DASHBOARD_TOKEN=$(${MME2E_DC_DASHBOARD} exec -T dashboard node script/sign.js | awk '{ print $2; }') # The token secret is specified in the dashboard.override.yml file
mme2e_log "Generating the .env.dashboard file, to point Cypress to the dashboard URL"
mme2e_generate_envfile_from_var_names >.env.dashboard <<EOF

Просмотреть файл

@@ -1,9 +1,8 @@
---
# Image hashes in this file are for amd64 systems
# NB: paths relative to the `server/build` directory, which contains the original compose file that this yaml is overriding
version: '2.4'
version: "2.4"
services:
server:
image: "${SERVER_IMAGE}"
restart: always
@@ -28,7 +27,7 @@ services:
MM_FEATUREFLAGS_ONBOARDINGTOURTIPS: "false"
MM_SERVICEENVIRONMENT: "test"
volumes:
- "server-config:/mattermost/config"
- "server-config:/mattermost/config"
ports:
- "8065:8065"
depends_on:
@@ -54,12 +53,12 @@ services:
condition: service_healthy
webhook-interactions:
image: mattermostdevelopment/mirrored-node:${NODE_VERSION_REQUIRED}
image: mattermostdevelopment/mirrored-node:${NODE_VERSION_REQUIRED}
command: sh -c "npm install -g axios express client-oauth2@larkox/js-client-oauth2#e24e2eb5dfcbbbb3a59d095e831dbe0012b0ac49 && exec node webhook_serve.js"
environment:
NODE_PATH: /usr/local/lib/node_modules/
healthcheck:
test: [ "CMD", "curl", "-s", "-o/dev/null", "127.0.0.1:3000" ]
test: ["CMD", "curl", "-s", "-o/dev/null", "127.0.0.1:3000"]
interval: 10s
timeout: 15s
retries: 12
@@ -72,16 +71,17 @@ services:
- webhook-interactions
cypress:
image: "mattermostdevelopment/mirrored-cypress-browsers-public:node-18.16.1-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1"
entrypoint: [ "/bin/bash", "-c" ]
command: [ "until [ -f /var/run/mm_terminate ]; do sleep 5; done" ]
image: "cypress/browsers:node-18.16.1-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1"
### Temorarily disabling this image, until both the amd64 and arm64 version are mirrored
# image: "mattermostdevelopment/mirrored-cypress-browsers-public:node-18.16.1-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1"
entrypoint: ["/bin/bash", "-c"]
command: ["until [ -f /var/run/mm_terminate ]; do sleep 5; done"]
env_file:
- "../../e2e-tests/.ci/.env.dashboard"
- "../../e2e-tests/.ci/.env.cypress"
environment:
REPO: "mattermost-server"
# Cypress configuration
BROWSER: "chrome"
HEADLESS: "true"
CYPRESS_baseUrl: "http://server:8065"
CYPRESS_dbConnection: "postgres://mmuser:mostest@postgres:5432/mattermost_test?sslmode=disable&connect_timeout=10"
@@ -118,14 +118,14 @@ services:
utils:
image: "mattermost/mattermost-build-server:20230904_golang-1.20.7"
entrypoint: [ "/bin/bash", "-c" ]
command: [ "until [ -f /var/run/mm_terminate ]; do sleep 5; done" ]
entrypoint: ["/bin/bash", "-c"]
command: ["until [ -f /var/run/mm_terminate ]; do sleep 5; done"]
environment:
MM_SERVICEENVIRONMENT: "test" # Currently required for running the config_generator with the right environment
working_dir: "/opt/mattermost-server"
volumes:
- "../../:/opt/mattermost-server"
- "server-config:/opt/server-config"
- "../../:/opt/mattermost-server"
- "server-config:/opt/server-config"
volumes:
server-config:

Просмотреть файл

@@ -29,6 +29,7 @@ mme2e_generate_envfile_from_var_names >.env.cypress <<EOF
BRANCH
BUILD_ID
CI_BASE_URL
BROWSER
AUTOMATION_DASHBOARD_URL
AUTOMATION_DASHBOARD_TOKEN
EOF
@@ -42,7 +43,6 @@ mme2e_log "Creating E2E containers and generating server config"
${MME2E_DC_SERVER} create
${MME2E_DC_SERVER} up -d -- utils
${MME2E_DC_SERVER} exec -T -w /opt/mattermost-server/server -- utils bash <<EOF
apt update && apt install -y jq
OUTPUT_CONFIG=/tmp/config_generated.json go run scripts/config_generator/main.go
jq "
.ServiceSettings.SiteURL=\"http://server:8065\"