Fix CE tests for travis (#7218)

* Fix CE tests for travis

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>

* Start app in CE too

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>

* Cleanup

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre BODIN 2020-07-29 13:24:27 +02:00 committed by GitHub
parent efdf03cf6d
commit 7394a35c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 42 deletions

View File

@ -23,11 +23,66 @@ cache:
# end to end testing template
e2e_tests: &e2e_tests
stage: 'End to End tests'
stage: 'End to End tests CE'
script:
- STRAPI_DISABLE_EE=true yarn run -s test:generate-app -- $DB_STRING
- STRAPI_DISABLE_EE=true yarn run -s test:start-app & wait-on http://localhost:1337
- STRAPI_DISABLE_EE=true yarn run -s test:e2e
# end to end testing template
e2e_tests_ee: &e2e_tests_ee
stage: 'End to End tests EE'
script:
- yarn run -s test:generate-app -- $DB_STRING
- yarn run -s test:start-app & wait-on http://localhost:1337
- yarn run -s test:e2e
if: fork = false
pg_test: &pg_test
name: 'E2E Postgresql'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- sudo apt-get update
- sudo apt-get --yes remove postgresql-*
- sudo apt-get install -y postgresql-11 postgresql-client-11
- sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
- sudo service postgresql restart 11
- psql -c 'create database strapi_test;' -U postgres
env:
- DB_STRING='--dbclient=postgres --dbhost=localhost --dbport=5433 --dbname=strapi_test --dbusername=postgres --dbpassword='
mysql_test: &mysql_test
name: 'E2E Mysql'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- sudo cp $TRAVIS_BUILD_DIR/_travis/mysql.cnf /etc/mysql/conf.d/
- sudo service mysql restart
- mysql -e 'CREATE DATABASE strapi_test;'
env:
- DB_STRING='--dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=travis --dbpassword='
sqlite_test: &sqlite_test
name: 'E2E Sqlite'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
env:
- DB_STRING='--dbclient=sqlite --dbfile=./tmp/data.db'
mongo_test: &mongo_test
name: 'E2E MongoDB'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.6.tgz
- tar -zxvf mongodb-linux-x86_64-3.6.6.tgz
- mkdir -p ./data/db/27017
- mkdir -p ./data/db/27000
- ./mongodb-linux-x86_64-3.6.6/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
env:
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test --dbusername= --dbpassword='
before_script:
- yarn build
@ -55,47 +110,25 @@ jobs:
- yarn run -s test:front && codecov -C -F front
- <<: *e2e_tests
name: 'E2E Postgresql'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- sudo apt-get update
- sudo apt-get --yes remove postgresql-*
- sudo apt-get install -y postgresql-11 postgresql-client-11
- sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
- sudo service postgresql restart 11
- psql -c 'create database strapi_test;' -U postgres
env:
- DB_STRING='--dbclient=postgres --dbhost=localhost --dbport=5433 --dbname=strapi_test --dbusername=postgres --dbpassword='
<<: *pg_test
- <<: *e2e_tests
name: 'E2E Mysql'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- sudo cp $TRAVIS_BUILD_DIR/_travis/mysql.cnf /etc/mysql/conf.d/
- sudo service mysql restart
- mysql -e 'CREATE DATABASE strapi_test;'
env:
- DB_STRING='--dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=travis --dbpassword='
<<: *mysql_test
- <<: *e2e_tests
name: 'E2E Sqlite'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
env:
- DB_STRING='--dbclient=sqlite --dbfile=./tmp/data.db'
<<: *sqlite_test
- <<: *e2e_tests
name: 'E2E MongoDB'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.6.tgz
- tar -zxvf mongodb-linux-x86_64-3.6.6.tgz
- mkdir -p ./data/db/27017
- mkdir -p ./data/db/27000
- ./mongodb-linux-x86_64-3.6.6/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
env:
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test --dbusername= --dbpassword='
<<: *mongo_test
- <<: *e2e_tests_ee
<<: *pg_test
- <<: *e2e_tests_ee
<<: *mysql_test
- <<: *e2e_tests_ee
<<: *sqlite_test
- <<: *e2e_tests_ee
<<: *mongo_test

View File

@ -4,6 +4,8 @@
const { registerAndLogin } = require('../../../test/helpers/auth');
const { createAuthRequest } = require('../../../test/helpers/request');
const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';
let rq;
const createAuthRole = async () => {
@ -42,7 +44,17 @@ describe('Admin Auth End to End', () => {
beforeAll(async () => {
const token = await registerAndLogin();
rq = createAuthRequest(token);
if (edition === 'EE') {
internals.role = await createAuthRole();
} else {
internals.role = (
await rq({
url: '/admin/roles',
method: 'GET',
})
).body.data[0];
}
}, 60000);
afterAll(async () => {

View File

@ -5,6 +5,8 @@ const { login, registerAndLogin, getUser } = require('../../../test/helpers/auth
const { createAuthRequest } = require('../../../test/helpers/request');
const { SUPER_ADMIN_CODE } = require('../services/constants');
const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';
const omitTimestamps = obj => _.omit(obj, ['updatedAt', 'createdAt', 'updated_at', 'created_at']);
const getAuthToken = async () => {
@ -85,7 +87,18 @@ describe('Admin User CRUD (e2e)', () => {
beforeAll(async () => {
const token = await getAuthToken();
rq = createAuthRequest(token);
if (edition === 'EE') {
testData.role = await createUserRole();
} else {
testData.role = (
await rq({
url: '/admin/roles',
method: 'GET',
})
).body.data[0];
}
testData.firstSuperAdminUser = await getUser();
testData.superAdminRole = await getSuperAdminRole();
});

View File

@ -65,9 +65,13 @@ const generateTestApp = async ({ appName, database }) => {
* @param {string} options.appName - Name of the app / folder in which run the start script
*/
const startTestApp = ({ appName }) => {
return execa.shell('BROWSER=none strapi develop --no-build', {
return execa('strapi', ['develop', '--no-build'], {
stdio: 'inherit',
cwd: path.resolve(appName),
env: {
FORCE_COLOR: 1,
BROWSER: 'none',
},
});
};