mirror of https://github.com/apache/superset.git
feat: Added setup for running Cypress tests in docker locally (#11207)
* Working configuration * Fixes * Set database volume directory. Added info in CONTRIBUTING how to avoid malformed database in tests.
This commit is contained in:
parent
1afe91579e
commit
6311a9ec8c
|
@ -672,6 +672,30 @@ CYPRESS_BASE_URL=<your url> npm run cypress open
|
||||||
|
|
||||||
See [`superset-frontend/cypress_build.sh`](https://github.com/apache/incubator-superset/blob/master/superset-frontend/cypress_build.sh).
|
See [`superset-frontend/cypress_build.sh`](https://github.com/apache/incubator-superset/blob/master/superset-frontend/cypress_build.sh).
|
||||||
|
|
||||||
|
As an alternative you can use docker-compose environment for testing:
|
||||||
|
|
||||||
|
Make sure you have added below line to your /etc/hosts file:
|
||||||
|
```127.0.0.1 db```
|
||||||
|
|
||||||
|
If you already have launched Docker environment please use the following command to assure a fresh database instance:
|
||||||
|
```docker-compose down -v```
|
||||||
|
|
||||||
|
Launch environment:
|
||||||
|
|
||||||
|
CYPRESS_CONFIG=true docker-compose up
|
||||||
|
|
||||||
|
It will serve backend and frontend on port 8088.
|
||||||
|
|
||||||
|
Run Cypres tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd cypress-base
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
# run tests via headless Chrome browser (requires Chrome 64+)
|
||||||
|
npm run cypress-run-chrome
|
||||||
|
|
||||||
### Storybook
|
### Storybook
|
||||||
|
|
||||||
Superset includes a [Storybook](https://storybook.js.org/) to preview the layout/styling of various Superset components, and variations thereof. To open and view the Storybook:
|
Superset includes a [Storybook](https://storybook.js.org/) to preview the layout/styling of various Superset components, and variations thereof. To open and view the Storybook:
|
||||||
|
|
|
@ -24,6 +24,7 @@ x-superset-volumes: &superset-volumes
|
||||||
- ./superset:/app/superset
|
- ./superset:/app/superset
|
||||||
- ./superset-frontend:/app/superset-frontend
|
- ./superset-frontend:/app/superset-frontend
|
||||||
- superset_home:/app/superset_home
|
- superset_home:/app/superset_home
|
||||||
|
- ./tests:/app/tests
|
||||||
|
|
||||||
version: "3.7"
|
version: "3.7"
|
||||||
services:
|
services:
|
||||||
|
@ -57,6 +58,8 @@ services:
|
||||||
user: "root"
|
user: "root"
|
||||||
depends_on: *superset-depends-on
|
depends_on: *superset-depends-on
|
||||||
volumes: *superset-volumes
|
volumes: *superset-volumes
|
||||||
|
environment:
|
||||||
|
CYPRESS_CONFIG: "${CYPRESS_CONFIG}"
|
||||||
|
|
||||||
superset-init:
|
superset-init:
|
||||||
image: *superset-image
|
image: *superset-image
|
||||||
|
@ -66,6 +69,8 @@ services:
|
||||||
depends_on: *superset-depends-on
|
depends_on: *superset-depends-on
|
||||||
user: "root"
|
user: "root"
|
||||||
volumes: *superset-volumes
|
volumes: *superset-volumes
|
||||||
|
environment:
|
||||||
|
CYPRESS_CONFIG: "${CYPRESS_CONFIG}"
|
||||||
|
|
||||||
superset-node:
|
superset-node:
|
||||||
image: node:12
|
image: node:12
|
||||||
|
|
|
@ -42,3 +42,4 @@ REDIS_PORT=6379
|
||||||
FLASK_ENV=development
|
FLASK_ENV=development
|
||||||
SUPERSET_ENV=development
|
SUPERSET_ENV=development
|
||||||
SUPERSET_LOAD_EXAMPLES=yes
|
SUPERSET_LOAD_EXAMPLES=yes
|
||||||
|
CYPRESS_CONFIG=false
|
||||||
|
|
|
@ -19,7 +19,13 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
REQUIREMENTS_LOCAL="/app/docker/requirements-local.txt"
|
REQUIREMENTS_LOCAL="/app/docker/requirements-local.txt"
|
||||||
|
# If Cypress run – overwrite the password for admin and export env variables
|
||||||
|
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||||
|
export SUPERSET_CONFIG=tests.superset_test_config
|
||||||
|
export SUPERSET_TESTENV=true
|
||||||
|
export ENABLE_REACT_CRUD_VIEWS=true
|
||||||
|
export SUPERSET__SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://superset:superset@db:5432/superset
|
||||||
|
fi
|
||||||
#
|
#
|
||||||
# Make sure we have dev requirements installed
|
# Make sure we have dev requirements installed
|
||||||
#
|
#
|
||||||
|
|
|
@ -37,22 +37,29 @@ Init Step ${1}/${STEP_CNT} [${2}] -- ${3}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
ADMIN_PASSWORD="admin"
|
||||||
|
# If Cypress run – overwrite the password for admin and export env variables
|
||||||
|
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||||
|
ADMIN_PASSWORD="general"
|
||||||
|
export SUPERSET_CONFIG=tests.superset_test_config
|
||||||
|
export SUPERSET_TESTENV=true
|
||||||
|
export ENABLE_REACT_CRUD_VIEWS=true
|
||||||
|
export SUPERSET__SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://superset:superset@db:5432/superset
|
||||||
|
fi
|
||||||
# Initialize the database
|
# Initialize the database
|
||||||
echo_step "1" "Starting" "Applying DB migrations"
|
echo_step "1" "Starting" "Applying DB migrations"
|
||||||
superset db upgrade
|
superset db upgrade
|
||||||
echo_step "1" "Complete" "Applying DB migrations"
|
echo_step "1" "Complete" "Applying DB migrations"
|
||||||
|
|
||||||
# Create an admin user
|
# Create an admin user
|
||||||
echo_step "2" "Starting" "Setting up admin user ( admin / admin )"
|
echo_step "2" "Starting" "Setting up admin user ( admin / $ADMIN_PASSWORD )"
|
||||||
superset fab create-admin \
|
superset fab create-admin \
|
||||||
--username admin \
|
--username admin \
|
||||||
--firstname Superset \
|
--firstname Superset \
|
||||||
--lastname Admin \
|
--lastname Admin \
|
||||||
--email admin@superset.com \
|
--email admin@superset.com \
|
||||||
--password admin
|
--password $ADMIN_PASSWORD
|
||||||
echo_step "2" "Complete" "Setting up admin user"
|
echo_step "2" "Complete" "Setting up admin user"
|
||||||
|
|
||||||
# Create default roles and permissions
|
# Create default roles and permissions
|
||||||
echo_step "3" "Starting" "Setting up roles and perms"
|
echo_step "3" "Starting" "Setting up roles and perms"
|
||||||
superset init
|
superset init
|
||||||
|
@ -61,6 +68,12 @@ echo_step "3" "Complete" "Setting up roles and perms"
|
||||||
if [ "$SUPERSET_LOAD_EXAMPLES" = "yes" ]; then
|
if [ "$SUPERSET_LOAD_EXAMPLES" = "yes" ]; then
|
||||||
# Load some data to play with
|
# Load some data to play with
|
||||||
echo_step "4" "Starting" "Loading examples"
|
echo_step "4" "Starting" "Loading examples"
|
||||||
superset load_examples
|
# If Cypress run which consumes superset_test_config – load required data for tests
|
||||||
|
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||||
|
superset load_test_users
|
||||||
|
superset load_examples --load-test-data
|
||||||
|
else
|
||||||
|
superset load_examples
|
||||||
|
fi
|
||||||
echo_step "4" "Complete" "Loading examples"
|
echo_step "4" "Complete" "Loading examples"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue