gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: spawn test environment via util


From: gnunet
Subject: [libeufin] branch master updated: spawn test environment via util
Date: Mon, 08 Jun 2020 13:52:57 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 3dbf7c8  spawn test environment via util
3dbf7c8 is described below

commit 3dbf7c87943e8ff7c1194d65ac60c1665d2d1a90
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Mon Jun 8 17:22:49 2020 +0530

    spawn test environment via util
---
 {contrib => integration-tests}/start-testenv.py    | 94 +---------------------
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt  |  4 +-
 nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt |  1 +
 nexus/src/test/kotlin/DBTest.kt                    |  2 +-
 .../tech/libeufin/sandbox/EbicsProtocolBackend.kt  |  2 +-
 5 files changed, 9 insertions(+), 94 deletions(-)

diff --git a/contrib/start-testenv.py b/integration-tests/start-testenv.py
similarity index 65%
rename from contrib/start-testenv.py
rename to integration-tests/start-testenv.py
index 66e4947..cc78840 100755
--- a/contrib/start-testenv.py
+++ b/integration-tests/start-testenv.py
@@ -7,31 +7,7 @@ import os
 import socket
 import hashlib
 import base64
-
-# Steps implemented in this test.
-#
-# 0 Prepare sandbox.
-#  -> (a) Make a EBICS host, (b) make a EBICS subscriber
-#     for the test runner, and (c) assign a IBAN to such
-#     subscriber.
-#
-# 1 Prepare nexus.
-#  -> (a) Make a Nexus user, (b) make a EBICS subscriber
-#     associated to that user
-#
-# 2 Prepare the Ebics bank connection for the nexus user.
-#  -> (a) Upload keys from Nexus to the Bank (INI & HIA),
-#     (b) Download key from the Bank (HPB) to the Nexus,
-#     and (c) Fetch the bank account owned by that subscriber
-#     at the bank.
-
-# 3 Request history from the Nexus to the Bank (C53).
-# 4 Verify that history is empty.
-# 5 Issue a payment from Nexus
-#  -> (a) Prepare & (b) trigger CCT.
-# 6 Request history after submitting the payment,
-#   from Nexus to Bank.
-# 7 Verify that previous payment shows up.
+from util import startNexus, startSandbox
 
 # Nexus user details
 USERNAME = "person"
@@ -63,82 +39,24 @@ 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
 
 
-# -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
+startNexus("nexus-testenv.sqlite3")
+startSandbox()
 
 # 0.a
 assertResponse(
@@ -286,8 +204,4 @@ if len(resp.json().get("transactions")) != 1:
     fail("Unexpected number of transactions; should be 1")
 
 
-try:
-    input("press enter to stop LibEuFin test environment ...")
-finally:
-    nexus.terminate()
-    sandbox.terminate()
+input("press enter to stop LibEuFin test environment ...")
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 3cbcdfc..18c1bfa 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -265,7 +265,6 @@ fun schedulePeriodicWork() {
         while (true) {
             logger.debug("Outer background job")
             try {
-                delay(Duration.ofSeconds(1))
                 downloadTalerFacadesTransactions()
                 // ingestTalerTransactions()
                 submitPreparedPaymentsViaEbics()
@@ -275,6 +274,7 @@ fun schedulePeriodicWork() {
                 e.printStackTrace(pw)
                 logger.info("==== Background job exception ====\n${sw}======")
             }
+            delay(Duration.ofSeconds(1))
         }
     }
 }
@@ -430,7 +430,7 @@ fun serverMain(dbName: String) {
             return@intercept
         }
 
-        //schedulePeriodicWork()
+        schedulePeriodicWork()
         routing {
             /**
              * Shows information about the requesting user.
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 0023145..5b7990a 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -411,6 +411,7 @@ suspend fun submitPreparedPaymentsViaEbics() {
     }
     val httpClient = HttpClient()
     workQueue.forEach {
+        println("submitting prepared payment via EBICS");
         doEbicsUploadTransaction(
             httpClient,
             it.subscriberDetails,
diff --git a/nexus/src/test/kotlin/DBTest.kt b/nexus/src/test/kotlin/DBTest.kt
index 8b86382..4f1078c 100644
--- a/nexus/src/test/kotlin/DBTest.kt
+++ b/nexus/src/test/kotlin/DBTest.kt
@@ -52,7 +52,7 @@ class DBTest {
                     type = "any"
                     creator = user
                 }
-                val talerConfig = TalerFacadeStateEntity.new {
+                TalerFacadeStateEntity.new {
                     bankAccount = "b"
                     bankConnection = "b"
                     reserveTransferLevel = "any"
diff --git 
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 9f4c542..c600815 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -870,7 +870,7 @@ private fun 
handleEbicsUploadTransactionInitialization(requestContext: RequestCo
         this.orderID = orderID
         this.numSegments = numSegments.toInt()
         this.transactionKeyEnc = ExposedBlob(transactionKeyEnc)
-    }.flush()
+    }
     logger.debug("after SQL flush")
     val sigObj = 
XMLUtil.convertStringToJaxb<UserSignatureData>(plainSigData.toString(Charsets.UTF_8))
     logger.debug("got UserSignatureData: 
${plainSigData.toString(Charsets.UTF_8)}")

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]