Skip to content

Commit

Permalink
Merge pull request #4024 from LiskHQ/3734-improve-e2e-test-suite
Browse files Browse the repository at this point in the history
Improve e2e test suite - Closes #3734
  • Loading branch information
reyraa authored Jan 11, 2022
2 parents 47770eb + 988be20 commit cf63445
Show file tree
Hide file tree
Showing 34 changed files with 5,359 additions and 49,873 deletions.
84 changes: 76 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
properties([disableConcurrentBuilds(), pipelineTriggers([])])
pipeline {
agent { node { label 'lisk-desktop' } }
options {
timeout(time: 30, unit: 'MINUTES')
ansiColor('xterm')
}
parameters {
string(name: 'CORE_VERSION', defaultValue: '3.0.2')
string(name: 'SERVICE_BRANCH_NAME', defaultValue: 'development')
}
stages {
stage('install') {
steps {
Expand All @@ -15,7 +23,10 @@ pipeline {
steps {
ansiColor('xterm') {
nvm(getNodejsVersion()) {
sh 'npm run lint'
sh '''
rm -rf lisk-service/ # linting will fail otherwise
npm run lint
'''
}
}
}
Expand Down Expand Up @@ -52,24 +63,81 @@ pipeline {
parallel (
// cypress
"end-to-end": {
dir('lisk-service') {
checkout([$class: 'GitSCM', branches: [[name: "$SERVICE_BRANCH_NAME" ]], userRemoteConfigs: [[url: 'https://github.com/LiskHQ/lisk-service']]])
}
nvm(getNodejsVersion()) {
ansiColor('xterm') {
wrap([$class: 'Xvfb']) {
sh 'CYPRESS_baseUrl=https://jenkins.lisk.com/test/${JOB_NAME%/*}/$BRANCH_NAME/#/ npm run cypress:run'
}
wrap([$class: 'Xvfb']) {
sh '''
# lisk-core
wget --no-verbose --continue https://downloads.lisk.com/lisk/testnet/$CORE_VERSION/lisk-core-v$CORE_VERSION-linux-x64.tar.gz.SHA256 https://downloads.lisk.com/lisk/testnet/$CORE_VERSION/lisk-core-v$CORE_VERSION-linux-x64.tar.gz
sha256sum -c lisk-core-v$CORE_VERSION-linux-x64.tar.gz.SHA256
rm -rf lisk-core/
tar xf lisk-core-v$CORE_VERSION-linux-x64.tar.gz
rm -rf ~/.lisk/
install -D test/dev_config_and_db/genesis_block.json ~/.lisk/lisk-core/config/devnet/genesis_block.json
./lisk-core/bin/lisk-core blockchain:import --force test/dev_config_and_db/tokens_unlocked_dev_blockchain.db.tar.gz
./lisk-core/bin/lisk-core forger-info:import --force test/dev_config_and_db/forger.db.tar.gz
nohup ./lisk-core/bin/lisk-core start --network=devnet --api-ws --api-ws-host=0.0.0.0 --api-ws-port=8080 --enable-forger-plugin --enable-http-api-plugin >lisk-core.out 2>lisk-core.err &
echo $! >lisk-core.pid
# wait for core to be up and running
set -e; while ! curl --silent --fail http://127.0.0.1:4000/api/node/info >/dev/null; do echo waiting; sleep 10; done; set +e
curl --verbose http://127.0.0.1:4000/api/node/info
# lisk-service
cp -f lisk-service/docker/example.env lisk-service/.env
# magic value for the above snapshot
echo GENESIS_HEIGHT=250 >>lisk-service/.env
make -C lisk-service up
# workaround for https://github.com/LiskHQ/lisk-service/issues/916
# until https://github.com/LiskHQ/lisk-service/issues/920 is resolved
docker exec --user root lisk-service_core_1 mkdir -p /home/lisk/lisk-service/export/data/static
docker exec --user root lisk-service_core_1 mkdir -p /home/lisk/lisk-service/export/data/partials
docker exec --user root lisk-service_core_1 chown lisk:lisk -R /home/lisk/lisk-service/export/data
# wait for service to be up and running
set -e; while ! curl --silent --fail http://127.0.0.1:9901/api/v2/blocks >/dev/null; do echo waiting; sleep 10; done; set +e
curl --verbose http://127.0.0.1:9901/api/v2/blocks
set -e; while ! curl --silent --fail http://127.0.0.1:9901/api/v2/network/status >/dev/null; do echo waiting; sleep 10; done; set +e
curl --verbose http://127.0.0.1:9901/api/v2/network/status
curl --verbose http://127.0.0.1:9901/api/v2/blocks
CYPRESS_baseUrl=https://jenkins.lisk.com/test/${JOB_NAME%/*}/$BRANCH_NAME/#/ \
CYPRESS_serviceUrl=http://127.0.0.1:9901 \
npm run cypress:run
'''
}
}
},
// jest
"unit": {
nvm(getNodejsVersion()) {
ansiColor('xterm') {
sh 'ON_JENKINS=true npm run test'
}
sh 'ON_JENKINS=true npm run test'
}
},
)
}
post {
failure {
archiveArtifacts artifacts: 'test/cypress/screenshots/', allowEmptyArchive: true
}
always {
sh '''
# lisk-service
make -C lisk-service logs
make -C lisk-service down
# lisk-core
kill $( cat lisk-core.pid ) || true
sleep 10
kill -9 $( cat lisk-core.pid ) || true
cat lisk-core.out
cat lisk-core.err
'''
}
}
}
}
}
Expand Down
Loading

0 comments on commit cf63445

Please sign in to comment.