Make pgaas tests propagate test failures 39/98439/1
authorMiroslav Los <miroslav.los@pantheon.tech>
Fri, 15 Nov 2019 08:30:47 +0000 (09:30 +0100)
committerMiroslav Los <miroslav.los@pantheon.tech>
Fri, 15 Nov 2019 08:30:47 +0000 (09:30 +0100)
Reraise the exceptions so that test harness reports them properly.
Fix parameters passed in test_update_database.
Ensure strings are encoded before hashing (enforced in python3).

Signed-off-by: Miroslav Los <miroslav.los@pantheon.tech>
Issue-ID: CCSDK-1929
Change-Id: Iee098fd53bc0fbd1c69d737002d1f63f9548f7f4

pgaas/pgaas/pgaas_plugin.py
pgaas/tests/test_plugin.py

index 73f7db6..b1625c5 100644 (file)
@@ -325,7 +325,7 @@ def getpass(data, ident, hostport, dbname):
   generate the password for a given user on a specific server
   """
   m = hashlib.sha256()
-  m.update(ident)
+  m.update(ident.encode())
 
   # mix in the seed (the last line) for that database, if one exists
   hostport = hostport.lower()
@@ -336,7 +336,7 @@ def getpass(data, ident, hostport, dbname):
     with open(hostPortDbname, "r") as fp:
       for line in fp:
         lastLine = line
-    m.update(lastLine)
+    m.update(lastLine.encode())
   except IOError:
     pass
 
index 0071499..10a9e10 100644 (file)
@@ -178,6 +178,7 @@ def test_add_pgaas_cluster(monkeypatch):
   except Exception as e:
     print("Error: {0}".format(e))
     print("Stack: {0}".format(traceback.format_exc()))
+    raise
   finally:
     current_ctx.clear()
 
@@ -192,6 +193,7 @@ def test_add_database(monkeypatch):
   except Exception as e:
     print("Error: {0}".format(e))
     print("Stack: {0}".format(traceback.format_exc()))
+    raise
   finally:
     current_ctx.clear()
 
@@ -207,6 +209,7 @@ def test_bad_add_database(monkeypatch):
   except Exception as e:
     print("Error: {0}".format(e))
     print("Stack: {0}".format(traceback.format_exc()))
+    raise
   finally:
     current_ctx.clear()
 
@@ -249,10 +252,11 @@ def test_update_database(monkeypatch):
     # pylint: disable=protected-access
     mynode.properties = mynode._properties
     myctx.nodes = [mynode]
-    pgaas.pgaas_plugin.update_database(ctx=myctx, args={})
+    pgaas.pgaas_plugin.update_database(refctx=myctx)
   except Exception as e:
     print("Error: {0}".format(e))
     print("Stack: {0}".format(traceback.format_exc()))
+    raise
   finally:
     current_ctx.clear()
 
@@ -267,6 +271,7 @@ def test_delete_database(monkeypatch):
   except Exception as e:
     print("Error: {0}".format(e))
     print("Stack: {0}".format(traceback.format_exc()))
+    raise
   finally:
     current_ctx.clear()
 
@@ -281,5 +286,6 @@ def test_rm_pgaas_cluster(monkeypatch):
   except Exception as e:
     print("Error: {0}".format(e))
     print("Stack: {0}".format(traceback.format_exc()))
+    raise
   finally:
     current_ctx.clear()