Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge branch '456-unit-test-for-signature-transaction' of github.com:…
Browse files Browse the repository at this point in the history
…LiskHQ/lisk into 456-unit-test-for-signature-transaction
  • Loading branch information
Usman Khan committed Oct 5, 2017
2 parents 9cf17f7 + a1ede26 commit 0cd51dd
Show file tree
Hide file tree
Showing 30 changed files with 349 additions and 215 deletions.
24 changes: 21 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ module.exports = function (grunt) {
},

coverageSingle: {
command: 'export NODE_ENV=TEST && node_modules/.bin/istanbul cover --dir test/.coverage-unit --include-pid ./node_modules/.bin/_mocha $TEST -- --grep @slow --invert',
maxBuffer: maxBufferSize
},

coverageSingleExtensive: {
command: 'export NODE_ENV=TEST && node_modules/.bin/istanbul cover --dir test/.coverage-unit --include-pid ./node_modules/.bin/_mocha $TEST',
maxBuffer: maxBufferSize
},
Expand All @@ -77,8 +82,18 @@ module.exports = function (grunt) {
maxBuffer: maxBufferSize
},

testFunctional: {
command: './node_modules/.bin/mocha test/api/index.js',
coverageUnitSlow: {
command: 'node_modules/.bin/istanbul cover --dir test/.coverage-unit ./node_modules/.bin/_mocha test/unit/index.slow.js',
maxBuffer: maxBufferSize
},

testFunctionalWs: {
command: './node_modules/.bin/_mocha test/functional/ws/index.js',
maxBuffer: maxBufferSize
},

testFunctionalHttp: {
command: './node_modules/.bin/_mocha test/functional/http/index.js',
maxBuffer: maxBufferSize
},

Expand Down Expand Up @@ -143,11 +158,14 @@ module.exports = function (grunt) {
grunt.registerTask('default', ['release']);
grunt.registerTask('release', ['exec:folder', 'obfuscator', 'exec:createBundles', 'exec:package', 'exec:build', 'compress']);
grunt.registerTask('jenkins', ['exec:coverageSingle']);
grunt.registerTask('jenkins-extensive', ['exec:coverageSingleExtensive']);
grunt.registerTask('coverageReport', ['exec:coverageReport']);
grunt.registerTask('eslint-nofix', ['eslint']);
grunt.registerTask('test', ['eslint', 'exec:coverage']);
grunt.registerTask('test-unit', ['eslint', 'exec:coverageUnit']);
grunt.registerTask('test-functional', ['eslint', 'exec:testFunctional']);
grunt.registerTask('test-unit-slow', ['eslint', 'exec:coverageUnitSlow']);
grunt.registerTask('test-functional-ws', ['eslint', 'exec:testFunctionalWs']);
grunt.registerTask('test-functional-http', ['eslint', 'exec:testFunctionalHttp']);
grunt.registerTask('test-integration', ['eslint', 'exec:testIntegration']);

grunt.registerTask('eslint-fix', 'Run eslint and fix formatting', function () {
Expand Down
128 changes: 82 additions & 46 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initBuild() {

def buildDependency() {
try {
sh '''#!/bin/bash
# Install Deps
sh '''
rsync -axl -e "ssh -oUser=jenkins" master-01:/var/lib/jenkins/lisk/node_modules/ "$WORKSPACE/node_modules/"
npm install
'''
} catch (err) {
Expand Down Expand Up @@ -53,8 +53,26 @@ def report(){
}

lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) {

properties([
parameters([
string(name: 'JENKINS_PROFILE', defaultValue: 'jenkins', description: 'To build cache dependencies and run slow test, change this value to jenkins-extensive.', )
])
])

stage ('Prepare Workspace') {
parallel(
"Build cached dependencies" : {
node('master-01'){
sh '''#!/bin/bash -xe
if [ $JENKINS_PROFILE == "jenkins-extensive" ]; then
rm -Rf "$WORKSPACE/node_modules/"
npm install
rsync -axl --delete "$WORKSPACE/node_modules/" /var/lib/jenkins/lisk/node_modules/
fi
'''
}
},
"Build Node-01" : {
node('node-01'){
initBuild()
Expand Down Expand Up @@ -155,129 +173,129 @@ lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) {
"Functional Accounts" : {
node('node-01'){
sh '''
export TEST=test/api/accounts.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/accounts.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Blocks" : {
node('node-01'){
sh '''
export TEST=test/api/blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Delegates" : {
"Functional Dapps" : {
node('node-01'){
sh '''
export TEST=test/api/delegates.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/dapps.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Dapps" : {
"Functional Delegates" : {
node('node-01'){
sh '''
export TEST=test/api/dapps.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/delegates.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Loader" : {
node('node-01'){
sh '''
export TEST=test/api/loader.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/loader.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Transport - Handshake" : {
node('node-02'){
"Functional Multisignatures" : {
node('node-01'){
sh '''
export TEST=test/api/transport/transport.handshake.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/multisignatures.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Multisignatures" : {
"Functional Multisignatures post" : {
node('node-01'){
sh '''
export TEST=test/api/multisignatures.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/multisignatures.post.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Multisignatures POST" : {
"Functional Transactions" : {
node('node-01'){
sh '''
export TEST=test/api/multisignatures.post.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/transactions.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Transactions" : {
node('node-01'){
"Functional Peers" : {
node('node-02'){
sh '''
export TEST=test/api/transactions.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/http/get/peers.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
}, //End node-01 functional tests
}, // End node-01 functional tests
"Functional Transport - Main" : {
node('node-02'){
sh '''
export TEST=test/api/transport/transport.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/ws/transport.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Transport - Blocks" : {
node('node-02'){
sh '''
export TEST=test/api/transport/transport.blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/ws/transport.blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Transport - Client" : {
node('node-02'){
sh '''
export TEST=test/api/transport/transport.client.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/ws/transport.client.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Transport - Transactions Main" : {
"Functional Transport - Handshake" : {
node('node-02'){
sh '''
export TEST=test/api/transport/transport.transactions.main.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/ws/transport.handshake.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
},
"Functional Transport - Peers" : {
"Functional Transport - Transactions" : {
node('node-02'){
sh '''
export TEST=test/api/peers.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/ws/transport.transactions.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
}, // End Node-02 functional tests
}, // End Node-02 Tests
"Unit Tests" : {
node('node-03'){
sh '''
Expand All @@ -286,16 +304,34 @@ lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) {
npm run test-unit
'''
}
}, // End Node-03 unit tests
},
"Unit Tests - sql blockRewards" : {
node('node-03'){
sh '''
export TEST=test/unit/sql/blockRewards.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run $JENKINS_PROFILE
'''
}
},
"Unit Tests - logic blockReward" : {
node('node-03'){
sh '''
export TEST=test/unit/logic/blockReward.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run $JENKINS_PROFILE
'''
}
},// End Node-03 unit tests
"Functional Stress - Transactions" : {
node('node-04'){
sh '''
export TEST=test/api/transport/transport.transactions.stress.js TEST_TYPE='FUNC' NODE_ENV='TEST'
export TEST=test/functional/ws/transport.transactions.stress.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run jenkins
npm run $JENKINS_PROFILE
'''
}
}
} // End Node-04
) // End Parallel
}

Expand Down
5 changes: 5 additions & 0 deletions Jenkinsfile.extensive
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node {
stage('Build extensive testsuite') {
build job: "lisk-core/${env.BRANCH_NAME}", parameters: [string(name: 'JENKINS_PROFILE', value: 'jenkins-extensive')]
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
"scripts": {
"start": "node app.js",
"jenkins": "./node_modules/.bin/grunt jenkins --verbose",
"jenkins-extensive": "./node_modules/.bin/grunt jenkins-extensive --verbose",
"eslint": "./node_modules/.bin/grunt eslint-nofix --verbose",
"fetchCoverage": "./node_modules/.bin/grunt exec:fetchCoverage --verbose",
"coverageReport": "./node_modules/.bin/grunt coverageReport --verbose",
"test": "./node_modules/.bin/grunt test --verbose",
"test-unit": "./node_modules/.bin/grunt test-unit --verbose",
"test-unit-slow": "./node_modules/.bin/grunt test-unit-slow --verbose",
"test-integration": "grunt test-integration",
"test-functional": "grunt test-functional",
"test-functional-ws": "grunt test-functional-ws",
"test-functional-http": "grunt test-functional-http",
"jsdoc": "jsdoc -c docs/conf.json --verbose --pedantic",
"create-bundles": "webpack",
"server-docs": "npm run jsdoc && http-server docs/jsdoc/",
Expand Down
14 changes: 0 additions & 14 deletions test/api/index.js

This file was deleted.

Loading

0 comments on commit 0cd51dd

Please sign in to comment.