-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: reintroduce end-to-end UI tests with cypress
A recent commit [1] removed the stale, unused end-to-end tests. In their place, add newly-written tests that can run headlessly in TeamCity (via Docker) as a quick-failing health check and as a more exhaustive suite. [1] 3d171b2 (ui: remove unused end-to-end UI tests, 2022-07-25) Release note: None
- Loading branch information
Showing
25 changed files
with
3,140 additions
and
1 deletion.
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,20 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
source "$(dirname "${0}")/teamcity-support.sh" | ||
source "./ui_e2e_test_impl.sh" | ||
|
||
tc_prepare | ||
|
||
tc_start_block "Build Docker image" | ||
build_docker_image | ||
tc_end_block "Build Docker image" | ||
|
||
# TeamCity doesn't restore permissions for files retrieved from artifact | ||
# dependencies, so ensure the cockroach binary is executable before running it | ||
# in a Docker container. | ||
chmod a+x upstream_artifacts/cockroach | ||
|
||
tc_start_block "Run all Cypress tests" | ||
run_tests | ||
tc_end_block "Run all Cypress tests" |
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,20 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
source "$(dirname "${0}")/teamcity-support.sh" | ||
source "./ui_e2e_test_impl.sh" | ||
|
||
tc_prepare | ||
|
||
tc_start_block "Build Docker image" | ||
build_docker_image | ||
tc_end_block "Build Docker image" | ||
|
||
# TeamCity doesn't restore permissions for files retrieved from artifact | ||
# dependencies, so ensure the cockroach binary is executable before running it | ||
# in a Docker container. | ||
chmod a+x upstream_artifacts/cockroach | ||
|
||
tc_start_block "Run Cypress health checks" | ||
run_tests health | ||
tc_end_block "Run Cypress health checks" |
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,25 @@ | ||
#!/usr/bin/env bash | ||
function build_docker_image() { | ||
# Buffer noisy output and only print it on failure. | ||
DOCKER_BUILDKIT=1 run docker build \ | ||
-f ./pkg/ui/workspaces/e2e-tests/Dockerfile \ | ||
-t cockroachdb/cockroach-cypress \ | ||
--progress=plain \ | ||
$PWD &> artifacts/docker-build.log || (cat artifacts/docker-build.log && false) | ||
rm artifacts/docker-build.log | ||
} | ||
|
||
function run_tests() { | ||
SPEC_ARG="" | ||
if [ "health" = "${$1:='EMPTY'}" ]; then | ||
SPEC_ARG="--spec 'cypress/e2e/health-check/**'" | ||
fi | ||
|
||
run docker run \ | ||
--rm \ | ||
-v $PWD/upstream_artifacts:/upstream_artifacts \ | ||
-v $PWD/artifacts:/artifacts \ | ||
cockroachdb/cockroach-cypress \ | ||
--reporter teamcity \ | ||
$SPEC_ARG | ||
} |
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
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,10 @@ | ||
{ | ||
"root": true, | ||
"extends": "@cockroachlabs/eslint-config", | ||
"settings": { | ||
"react": { | ||
"pragma": "React", | ||
"version": "17.0" | ||
} | ||
} | ||
} |
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,2 @@ | ||
videos | ||
screenshots |
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,25 @@ | ||
load("@npm_e2e_tests//eslint:index.bzl", "eslint_test") | ||
|
||
eslint_test( | ||
name = "lint", | ||
data = [ | ||
".eslintrc.json", | ||
"cypress", | ||
"cypress.config.ts", | ||
"//pkg/ui/workspaces/eslint-plugin-crdb", | ||
"@npm_e2e_tests//@cockroachlabs/eslint-config", | ||
"@npm_e2e_tests//@typescript-eslint/eslint-plugin", | ||
"@npm_e2e_tests//@typescript-eslint/parser", | ||
"@npm_e2e_tests//eslint-plugin-prettier", | ||
"@npm_e2e_tests//eslint-plugin-react", | ||
"@npm_e2e_tests//eslint-plugin-react-hooks", | ||
"@npm_e2e_tests//prettier", | ||
], | ||
templated_args = [ | ||
"--ext .ts", | ||
"-c", | ||
"$$(rlocation $(rootpath .eslintrc.json))", | ||
"$$(rlocation $(rootpath cypress))", | ||
"$$(rlocation $(rootpath cypress.config.ts))", | ||
], | ||
) |
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,51 @@ | ||
# WARNING: | ||
# This Dockerfile must be built from the root of cockroachdb.git with a prebuilt | ||
# cockroach binary at ./upstream_artifactsl/cockroach. Running it from other | ||
# directories or without a prebuilt cockroach binary will cause errors. | ||
# | ||
# Build (from the root of cockroach.git): | ||
# $ DOCKER_BUILDKIT=1 docker build \ | ||
# -f ./pkg/ui/workspaces/e2e-tests/Dockerfile \ | ||
# -t cockroachdb/cockroach-ci-ui \ | ||
# $PWD | ||
# | ||
# Run Locally (from the root of cockroach.git): | ||
# $ docker run \ | ||
# --rm \ | ||
# -it \ | ||
# -v $PWD:/upstream_artifacts \ | ||
# -v $PWD/pkg/ui/workspaces/e2e-tests/cypress:/cypress | ||
# cockroachdb/cockroach-ci-ui | ||
# | ||
# Run in TeamCity (from the root of cockroach.git): | ||
# $ docker run \ | ||
# --rm \ | ||
# -it \ | ||
# -v $PWD/upstream_artifacts:/upstream_artifacts \ | ||
# -v $PWD/artifacts:/artifacts \ | ||
# cockroachdb/cockroach-ci-ui | ||
|
||
FROM cypress/browsers:node16.14.2-slim-chrome100-ff99-edge | ||
|
||
# Install CRDB prerequisites | ||
RUN apt install libresolv-wrapper | ||
|
||
# Add the tests and install NPM dependencies | ||
WORKDIR /cypress | ||
COPY --chown=node ./pkg/ui/yarn-vendor ./yarn-vendor/ | ||
COPY --chown=node ./pkg/ui/workspaces/e2e-tests ./ | ||
ADD ./pkg/ui/.yarnrc ./ | ||
RUN yarn install | ||
|
||
ENV IS_DOCKER=1 | ||
|
||
# Use the compiled CRDB binary from a previous TC job via Artifact Dependency: | ||
# TODO(barag): include a TC link here | ||
# bazel-bin/pkg/cmd/cockroach/cockroach_/cockroach=>upstream_artifacts | ||
ENV COCKROACH=/upstream_artifacts/cockroach | ||
|
||
VOLUME /artifacts | ||
|
||
# Execute 'yarn test' by default, allowing extra arguments to be appended during | ||
# 'docker run'. | ||
ENTRYPOINT ["/usr/local/bin/yarn", "test"] |
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,6 @@ | ||
**/* | ||
!upstream_artifacts | ||
!pkg/ui/.yarnrc | ||
!pkg/ui/yarn-vendor | ||
!pkg/ui/workspaces/e2e-tests | ||
pkg/ui/workspaces/e2e-tests/node_modules |
Oops, something went wrong.