Skip to content

Commit

Permalink
chore: improve e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-greffe committed Apr 8, 2024
1 parent d920255 commit 76678ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 38 deletions.
21 changes: 3 additions & 18 deletions e2e-tests.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ ARG APP
ARG NODE_APP_INSTANCE
ARG SUBDOMAIN
ARG HEADLESS
ARG SLACK_WEBHOOK_APPS

ENV APP=$APP
ENV NODE_APP_INSTANCE=$NODE_APP_INSTANCE
ENV SUBDOMAIN=$SUBDOMAIN
ENV HEADLESS=$HEADLESS
ENV SLACK_WEBHOOK_APPS=$SLACK_WEBHOOK_APPS

# Test environment configuration
WORKDIR /opt/kalisio/
Expand All @@ -38,19 +36,17 @@ ARG APP
ARG NODE_APP_INSTANCE
ARG SUBDOMAIN
ARG HEADLESS
ARG SLACK_WEBHOOK_APPS

ENV APP=$APP
ENV NODE_APP_INSTANCE=$NODE_APP_INSTANCE
ENV SUBDOMAIN=$SUBDOMAIN
ENV HEADLESS=$HEADLESS
ENV SLACK_WEBHOOK_APPS=$SLACK_WEBHOOK_APPS

# Setup Puppeteer
# Setup Puppeteer & Rclone
# https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y wget gnupg curl zip unzip \
&& apt-get install -y wget gnupg curl zip unzip rclone \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
Expand All @@ -69,17 +65,6 @@ RUN export DEBIAN_FRONTEND=noninteractive \
libxext-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# Install Rclone
RUN curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip \
&& unzip rclone-current-linux-amd64.zip \
&& cd rclone-*-linux-amd64 \
&& cp rclone /usr/bin/ \
&& chown root:root /usr/bin/rclone \
&& chmod 755 /usr/bin/rclone \
&& mkdir -p /usr/local/share/man/man1 \
&& cp rclone.1 /usr/local/share/man/man1/ \
&& mandb

# Copy Puppeteer cache from builder
COPY --from=Builder --chown=node:node /root/.cache/puppeteer /home/node/.cache/puppeteer
Expand All @@ -101,4 +86,4 @@ RUN chmod +x run_e2e_test.sh

# Run tests
WORKDIR /opt/kalisio/$APP
CMD ["bash", "-c", "/opt/kalisio/$APP/scripts/run_e2e_test.sh $APP $SLACK_WEBHOOK_APPS"]
CMD ["bash", "-c", "/opt/kalisio/$APP/scripts/run_e2e_test.sh $APP"]
2 changes: 1 addition & 1 deletion scripts/kash
Submodule kash updated 1 files
+83 −5 kash.sh
39 changes: 20 additions & 19 deletions scripts/run_e2e_test.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail
set -uo pipefail
# set -x

APP=$1
SLACK_WEBHOOK=$2

GOOGLE_LOGS_LINK="https://github.com/kalisio"
SCREEN_LINK="https://github.com/kalisio"

CURRENT_DATE=$(date +"%d-%m-%Y")

THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}")
THIS_DIR=$(dirname "$THIS_FILE")
ROOT_DIR=$(dirname "$THIS_DIR")

. "$THIS_DIR/kash/kash.sh"

## Report outcome to slack
##

trap 'slack_e2e_report "$APP" "$?" "$SLACK_WEBHOOK" "$GOOGLE_LOGS_LINK" "$SCREEN_LINK"' EXIT

## Run tests & redirect output to a log file
##

# Chrome
mkdir -p "$ROOT_DIR/test/run/chrome"
yarn test:client > "$ROOT_DIR/test/run/chrome/google_logs.txt" 2>&1
yarn test:client > "$ROOT_DIR/test/run/chrome/chrome_logs.txt" 2>&1
RET_CODE=$?

# Firefox
# PUPPETEER_PRODUCT=firefox yarn add puppeteer
# yarn link "@kalisio/kdk" --link-folder /opt/kalisio/yarn-links
# yarn link "@kalisio/kdk" --link-folder /opt/kalisio/yarn-links
# export BROWSER="firefox"bucket
# mkdir -p "$ROOT_DIR/test/run/firefox"
# yarn test:client
# yarn test:client > "$ROOT_DIR/test/run/chrome/firefox_logs.txt" 2>&1

## Upload logs & screenshots to S3
##

zip -r "$ROOT_DIR/test/screenshots.zip" run
CURRENT_DATE=$(date +"%d-%m-%Y")
CHROME_LOGS_LINK=""
SCREEN_LINK=""

zip -r "$ROOT_DIR/test/screenshots.zip" "$ROOT_DIR/test/run"

rclone copy "$ROOT_DIR/test/run/chrome/google_logs.txt" "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE"
GOOGLE_LOGS_LINK=$(rclone link "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE/google_logs.txt")
rclone copy "$ROOT_DIR/test/run/chrome/chrome_logs.txt" "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE"
CHROME_LOGS_LINK=$(rclone link "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE/chrome_logs.txt")

rclone copy "$ROOT_DIR/test/screenshots.zip" "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE"
SCREEN_LINK=$(rclone link "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE/screenshots.zip")
SCREEN_LINK=$(rclone link "ovh-s3:/dev/e2e-tests/$APP/$CURRENT_DATE/screenshots.zip")

## Report outcome to slack
##

slack_e2e_report "$APP" "$RET_CODE" "$SLACK_WEBHOOK" "$CHROME_LOGS_LINK" "$SCREEN_LINK"

0 comments on commit 76678ab

Please sign in to comment.