Skip to content

Commit

Permalink
BE-648 Add e2e sanity check to the verification
Browse files Browse the repository at this point in the history
Change-Id: I7f9d4aebb648cce6ad94065defe778244e99dce5
Signed-off-by: Atsushi Neki <atsushin@fast.au.fujitsu.com>
  • Loading branch information
nekia committed May 28, 2019
1 parent 4adaef2 commit a21e534
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
19 changes: 19 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ node ('hyp-x') { // trigger build on x86_64 node
}
}

// Run npm tests
stage("E2E Tests for Sanity-check") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}") {
sh '''
npm install
npm run e2e-test-sanitycheck:ci
'''
}
}
catch (err) {
failure_stage = "e2e tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}

// Docs HTML Report
stage("Doc Output") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
Expand Down
7 changes: 7 additions & 0 deletions app/platform/fabric/e2e-test/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def before_scenario(context, scenario):


def after_scenario(context, scenario):

if scenario.status == "failed":
print("Explorer container log:")
subprocess.call("docker logs explorer.mynetwork.com 2>&1", shell=True)
print("Explorer-DB container log:")
subprocess.call("docker logs explorerdb.mynetwork.com 2>&1", shell=True)

# Display memory usage before tearing down the network
mem = psutil.virtual_memory()
print("Memory Info Before Network Teardown:\n\tFree: {}\n\tUsed: {}\n\tPercentage: {}\n".format(mem.free, mem.used, mem.percent))
Expand Down
1 change: 1 addition & 0 deletions app/platform/fabric/e2e-test/explorer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Feature: Bootstrapping Hyperledger Explorer
# Then JSON at path ".channels" should equal ["mychannel"]

@basic
@sanitycheck
# @doNotDecompose
Scenario Outline: [<network-type>] Bring up explorer with fabric-samples/<network-type> and send requests to the basic REST API functions successfully
# Start a fabric network by using fabric-samples/<network-type>
Expand Down
10 changes: 8 additions & 2 deletions app/platform/fabric/e2e-test/steps/explorer_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ def start_balancetransfer_impl(context):

try:
command = ["./runApp.sh"]
subprocess.Popen(command, shell=True, env=updated_env, stdout=FNULL)
p = subprocess.Popen(command, shell=True, env=updated_env, stdout=subprocess.PIPE)
except:
print("Failed to start application: {0}".format(sys.exc_info()[1]))

time.sleep(10)
while True:
line = p.stdout.readline()
if "SERVER STARTED" in line:
print(line)
break
else:
time.sleep(1)

try:
command = ["./testAPIs.sh"]
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"license": "Apache-2.0",
"devDependencies": {
"babel-eslint": "10.0.1",
"cross-env": "^5.2.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
Expand Down Expand Up @@ -84,9 +85,12 @@
"precommit": "lint-staged && ./verify-license.sh",
"e2e-test-check-tool": "/bin/bash -c 'if [[ -z $(which configtxgen) ]]; then echo \"### Need to install tools ###\n\"; exit -1; fi'",
"e2e-test-check-img": "/bin/bash -c 'if [[ -z $(docker images -q hyperledger/fabric-peer:latest) ]]; then echo \"### Need to pull fabric images ###\n\"; exit -1; fi'",
"e2e-test-setup-tool:ci": "/bin/bash -c 'mkdir fabric-samples; pushd fabric-samples; curl -sSL https://raw.githubusercontent.com/hyperledger/fabric-samples/release-1.4/scripts/bootstrap.sh | bash -s; popd'",
"e2e-test-setup-env": "cd app/platform/fabric/e2e-test; if [ ! -e e2e-test ]; then virtualenv e2e-test; fi && . ./e2e-test/bin/activate && pip install -r requirement.txt",
"e2e-test-setup-img": "./build_docker_image.sh",
"e2e-test-run": "cd app/platform/fabric/e2e-test; . ./e2e-test/bin/activate && behave explorer.feature",
"e2e-test": "run-s e2e-test-check-tool e2e-test-check-img e2e-test-setup-env e2e-test-setup-img e2e-test-run"
"e2e-test-run-sanitycheck": "cd app/platform/fabric/e2e-test; . ./e2e-test/bin/activate && behave --tags=@sanitycheck --stop --no-skipped explorer.feature",
"e2e-test": "run-s e2e-test-check-tool e2e-test-check-img e2e-test-setup-env e2e-test-setup-img e2e-test-run",
"e2e-test-sanitycheck:ci": "cross-env PATH=$PATH:$PWD/fabric-samples/bin run-s e2e-test-setup-tool:ci e2e-test-check-tool e2e-test-check-img e2e-test-setup-env e2e-test-setup-img e2e-test-run-sanitycheck"
}
}

0 comments on commit a21e534

Please sign in to comment.