summaryrefslogtreecommitdiff
path: root/integration-tests/test-ebics.py
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-06-08 17:57:09 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-06-08 17:57:09 +0530
commit142df4189b48f00ebf0b227ff646dc62a86efe40 (patch)
treeaf54c26c759bba581f320c5f02600e3f17faea65 /integration-tests/test-ebics.py
parent3dbf7c87943e8ff7c1194d65ac60c1665d2d1a90 (diff)
downloadlibeufin-142df4189b48f00ebf0b227ff646dc62a86efe40.tar.gz
libeufin-142df4189b48f00ebf0b227ff646dc62a86efe40.tar.bz2
libeufin-142df4189b48f00ebf0b227ff646dc62a86efe40.zip
use integration test helpers everywhere
Diffstat (limited to 'integration-tests/test-ebics.py')
-rwxr-xr-xintegration-tests/test-ebics.py69
1 files changed, 4 insertions, 65 deletions
diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py
index 5c37a58e..04d1c810 100755
--- a/integration-tests/test-ebics.py
+++ b/integration-tests/test-ebics.py
@@ -8,6 +8,8 @@ import socket
import hashlib
import base64
+from util import startNexus, startSandbox
+
# Steps implemented in this test.
#
# 0 Prepare sandbox.
@@ -63,82 +65,21 @@ NEXUS_DB="test-nexus.sqlite3"
def fail(msg):
print(msg)
- nexus.terminate()
- sandbox.terminate()
exit(1)
-
-def checkPorts(ports):
- for i in ports:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- s.bind(("0.0.0.0", i))
- s.close()
- except:
- print("Port {} is not available".format(i))
- exit(77)
-
-
def assertResponse(response):
if response.status_code != 200:
print("Test failed on URL: {}".format(response.url))
# stdout/stderr from both services is A LOT of text.
# Confusing to dump all that to console.
print("Check nexus.log and sandbox.log, probably under /tmp")
- nexus.terminate()
- sandbox.terminate()
exit(1)
# Allows for finer grained checks.
return response
+startSandbox()
+startNexus(NEXUS_DB)
-# -1 Clean databases and start services.
-os.chdir("..")
-assert 0 == call(["rm", "-f", "sandbox/libeufin-sandbox.sqlite3"])
-assert 0 == call(["rm", "-f", "nexus/{}".format(NEXUS_DB)])
-DEVNULL = open(os.devnull, "w")
-
-assert 0 == call(
- ["./gradlew", "nexus:run", "--console=plain", "--args=superuser admin --password x --db-name={}".format(NEXUS_DB)]
-)
-
-# Start nexus
-checkPorts([5001])
-nexus = Popen(
- ["./gradlew", "nexus:run", "--console=plain", "--args=serve --db-name={}".format(NEXUS_DB)],
- stdout=PIPE,
- stderr=PIPE,
-)
-for i in range(10):
- try:
- get("http://localhost:5001/")
- except:
- if i == 9:
- nexus.terminate()
- stdout, stderr = nexus.communicate()
- print("Nexus timed out")
- print("{}\n{}".format(stdout.decode(), stderr.decode()))
- exit(77)
- sleep(2)
- continue
- break
-# Start sandbox
-checkPorts([5000])
-sandbox = Popen(["./gradlew", "sandbox:run"], stdout=PIPE, stderr=PIPE)
-for i in range(10):
- try:
- get("http://localhost:5000/")
- except:
- if i == 9:
- nexus.terminate()
- sandbox.terminate()
- stdout, stderr = nexus.communicate()
- print("Sandbox timed out")
- print("{}\n{}".format(stdout.decode(), stderr.decode()))
- exit(77)
- sleep(2)
- continue
- break
# 0.a
assertResponse(
@@ -302,6 +243,4 @@ resp = assertResponse(
if len(resp.json().get("transactions")) != 1:
fail("Unexpected number of transactions; should be 1")
-nexus.terminate()
-sandbox.terminate()
print("Test passed!")