Skip to content

Commit

Permalink
[APM] Don’t run eslint on cypress snapshots (elastic#67451)
Browse files Browse the repository at this point in the history
* [APM] Don’t run eslint on cypress snapshots

* ignore cypress videos

* Fix interactive command

* Fix gitignore

* Use echo everywhere

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
sorenlouv and elasticmachine committed May 29, 2020
1 parent 6288096 commit fbb5f31
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ target
/src/plugins/vis_type_timelion/public/_generated_/**
/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.*
/x-pack/legacy/plugins/**/__tests__/fixtures/**
/x-pack/plugins/apm/e2e/cypress/**/snapshots.js
/x-pack/plugins/apm/e2e/**/snapshots.js
/x-pack/plugins/apm/e2e/tmp/*
/x-pack/plugins/canvas/canvas_plugin
/x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts
/x-pack/plugins/canvas/shareable_runtime/build
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ package-lock.json
*.sublime-*
npm-debug.log*
.tern-project
x-pack/plugins/apm/tsconfig.json
apm.tsconfig.json
/x-pack/legacy/plugins/apm/e2e/snapshots.js
/x-pack/plugins/apm/e2e/snapshots.js
.nyc_output

# apm plugin
/x-pack/plugins/apm/tsconfig.json
apm.tsconfig.json
3 changes: 2 additions & 1 deletion x-pack/plugins/apm/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cypress/screenshots/*
cypress/videos/*
cypress/test-results
cypress/videos/*
/snapshots.js
tmp
72 changes: 50 additions & 22 deletions x-pack/plugins/apm/e2e/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ cd ${E2E_DIR}
#
# Ask user to start Kibana
##################################################
echo "\n${bold}To start Kibana please run the following command:${normal}
echo "" # newline
echo "${bold}To start Kibana please run the following command:${normal}
node ./scripts/kibana --no-base-path --dev --no-dev-config --config x-pack/plugins/apm/e2e/ci/kibana.e2e.yml"

#
# Create tmp folder
##################################################
echo "\n${bold}Temporary folder${normal}"
echo "Temporary files will be stored in: ${TMP_DIR}"
echo "" # newline
echo "${bold}Temporary folder${normal}"
echo "Temporary files will be stored in: ${E2E_DIR}${TMP_DIR}"
mkdir -p ${TMP_DIR}

#
# apm-integration-testing
##################################################
printf "\n${bold}apm-integration-testing (logs: ${TMP_DIR}/apm-it.log)\n${normal}"
echo "" # newline
echo "${bold}apm-integration-testing (logs: ${E2E_DIR}${TMP_DIR}/apm-it.log)${normal}"

# pull if folder already exists
if [ -d ${APM_IT_DIR} ]; then
Expand All @@ -54,7 +57,7 @@ fi

# Stop if clone/pull failed
if [ $? -ne 0 ]; then
printf "\n⚠️ Initializing apm-integration-testing failed. \n"
echo "⚠️ Initializing apm-integration-testing failed."
exit 1
fi

Expand All @@ -71,23 +74,34 @@ ${APM_IT_DIR}/scripts/compose.py start master \

# Stop if apm-integration-testing failed to start correctly
if [ $? -ne 0 ]; then
printf "⚠️ apm-integration-testing could not be started.\n"
printf "Please see the logs in ${TMP_DIR}/apm-it.log\n\n"
printf "As a last resort, reset docker with:\n\n cd ${APM_IT_DIR} && scripts/compose.py stop && docker system prune --all --force --volumes\n"
echo "⚠️ apm-integration-testing could not be started"
echo "" # newline
echo "As a last resort, reset docker with:"
echo "" # newline
echo "cd ${E2E_DIR}${APM_IT_DIR} && scripts/compose.py stop && docker system prune --all --force --volumes"
echo "" # newline

# output logs for excited docker containers
cd ${APM_IT_DIR} && docker-compose ps --filter "status=exited" -q | xargs -L1 docker logs --tail=10 && cd -

echo "" # newline
echo "Find the full logs in ${E2E_DIR}${TMP_DIR}/apm-it.log"
exit 1
fi

#
# Cypress
##################################################
echo "\n${bold}Cypress (logs: ${TMP_DIR}/e2e-yarn.log)${normal}"
echo "" # newline
echo "${bold}Cypress (logs: ${E2E_DIR}${TMP_DIR}/e2e-yarn.log)${normal}"
echo "Installing cypress dependencies "
yarn &> ${TMP_DIR}/e2e-yarn.log

#
# Static mock data
##################################################
printf "\n${bold}Static mock data (logs: ${TMP_DIR}/ingest-data.log)\n${normal}"
echo "" # newline
echo "${bold}Static mock data (logs: ${E2E_DIR}${TMP_DIR}/ingest-data.log)${normal}"

# Download static data if not already done
if [ ! -e "${TMP_DIR}/events.json" ]; then
Expand All @@ -102,29 +116,46 @@ curl --silent --user admin:changeme -XDELETE "localhost:${ELASTICSEARCH_PORT}/ap
# Ingest data into APM Server
node ingest-data/replay.js --server-url http://localhost:$APM_SERVER_PORT --events ${TMP_DIR}/events.json 2>> ${TMP_DIR}/ingest-data.log

# Stop if not all events were ingested correctly
# Abort if not all events were ingested correctly
if [ $? -ne 0 ]; then
printf "\n⚠️ Not all events were ingested correctly. This might affect test tests. \n"
echo "⚠️ Not all events were ingested correctly. This might affect test tests."
echo "Aborting. Please try again."
echo "" # newline
echo "Full logs in ${E2E_DIR}${TMP_DIR}/ingest-data.log:"

# output logs for excited docker containers
cd ${APM_IT_DIR} && docker-compose ps --filter "status=exited" -q | xargs -L1 docker logs --tail=3 && cd -

# stop docker containers
cd ${APM_IT_DIR} && ./scripts/compose.py stop > /dev/null && cd -
exit 1
fi

# create empty snapshot file if it doesn't exist
SNAPSHOTS_FILE=cypress/integration/snapshots.js
if [ ! -f ${SNAPSHOTS_FILE} ]; then
echo "{}" > ${SNAPSHOTS_FILE}
fi

#
# Wait for Kibana to start
##################################################
echo "\n${bold}Waiting for Kibana to start...${normal}"
echo "" # newline
echo "${bold}Waiting for Kibana to start...${normal}"
echo "Note: you need to start Kibana manually. Find the instructions at the top."
yarn wait-on -i 500 -w 500 http-get://admin:changeme@localhost:$KIBANA_PORT/api/status > /dev/null

## Workaround to wait for the http server running
## See: https://github.com/elastic/kibana/issues/66326
if [ -e kibana.log ] ; then
grep -m 1 "http server running" <(tail -f -n +1 kibana.log)
echo "\n✅ Kibana server running...\n"
echo "✅ Kibana server running..."
grep -m 1 "bundles compiled successfully" <(tail -f -n +1 kibana.log)
echo "\n✅ Kibana bundles have been compiled...\n"
echo "✅ Kibana bundles have been compiled..."
fi

echo "\n✅ Setup completed successfully. Running tests...\n"

echo "✅ Setup completed successfully. Running tests..."

#
# run cypress tests
Expand All @@ -134,9 +165,6 @@ yarn cypress run --config pageLoadTimeout=100000,watchForFileChanges=true
#
# Run interactively
##################################################
echo "
${bold}If you want to run the test interactively, run:${normal}
yarn cypress open --config pageLoadTimeout=100000,watchForFileChanges=true
"
echo "${bold}If you want to run the test interactively, run:${normal}"
echo "" # newline
echo "cd ${E2E_DIR} && yarn cypress open --config pageLoadTimeout=100000,watchForFileChanges=true"

0 comments on commit fbb5f31

Please sign in to comment.