From 8d31f2a8ccb43943e814dbc8c84ec641ea236331 Mon Sep 17 00:00:00 2001 From: Patrick Firnkes Date: Tue, 9 Aug 2016 10:00:23 +0200 Subject: [PATCH 1/2] wip: use ConTest --- contest/run_tests.py | 22 ++++++++++++++++++++++ contest/taskDef.yaml | 26 ++++++++++++++++++++++++++ setup.cfg | 5 +++++ 3 files changed, 53 insertions(+) create mode 100644 contest/run_tests.py create mode 100644 contest/taskDef.yaml create mode 100644 setup.cfg diff --git a/contest/run_tests.py b/contest/run_tests.py new file mode 100644 index 0000000..a893b4e --- /dev/null +++ b/contest/run_tests.py @@ -0,0 +1,22 @@ +import socket +import time +import pytest +import sys + +def main(): + + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + while True: + result = sock.connect_ex(('127.0.0.1', 30015)) + if result == 0: + break + else: + print("hana not available yet, retrying...") + time.sleep(1) + + pytest.main(sys.argv[1:]) + + +if __name__ == "__main__": + main() diff --git a/contest/taskDef.yaml b/contest/taskDef.yaml new file mode 100644 index 0000000..456d520 --- /dev/null +++ b/contest/taskDef.yaml @@ -0,0 +1,26 @@ +version: 0.1 +name: pyhdb-test +containers: + - name: pytest-runner + image: docker.wdf.sap.corp:51037/contest/pytest-runner:2.7 + command: ['bash', '-c', 'python /src/${REPO_NAME}/contest/run_tests.py /src/${REPO_NAME}/tests/'] + resources: + requests: + cpu: 1000m + memory: 500m + withHelpers: + - kind: exportDir + mountPath: /exports + - kind: syncEventSources + mountPath: /src + - kind: injectEventData + + - name: hana + image: docker.wdf.sap.corp:51037/contest/ppms_hana_112_04_standalone:1.0 + resources: + requests: + cpu: 2000m + memory: 12Gi + + command: ['bash', '/tools/build', '/tools/wait.sh'] +mainContainer: pytest-runner diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..203b504 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[pytest] +hana_host = localhost +hana_port = 30015 +hana_user = System +hana_password = Password01 \ No newline at end of file From 8175c7f2f23daa19ca4f973e34d07d21da5e6fcb Mon Sep 17 00:00:00 2001 From: Patrick Firnkes Date: Thu, 11 Aug 2016 10:23:51 +0200 Subject: [PATCH 2/2] Update run_tests.py --- contest/run_tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contest/run_tests.py b/contest/run_tests.py index a893b4e..fd93f20 100644 --- a/contest/run_tests.py +++ b/contest/run_tests.py @@ -13,10 +13,11 @@ def main(): break else: print("hana not available yet, retrying...") - time.sleep(1) - - pytest.main(sys.argv[1:]) + time.sleep(10) + rc = pytest.main(sys.argv[1:]) + if rc != 0: + sys.exit("pytest run has failed") if __name__ == "__main__": main()