From 362d4ab2e4b14e9f45dabe76bbc19deced9188e8 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Tue, 4 Aug 2020 14:07:28 +0200
Subject: [PATCH] TMSS-287: instantiate the RATestEnvironment as well, so we
 can actually schedule stuff

---
 SAS/TMSS/test/test_utils.py | 53 ++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/SAS/TMSS/test/test_utils.py b/SAS/TMSS/test/test_utils.py
index 841d508f08e..09464d4701a 100644
--- a/SAS/TMSS/test/test_utils.py
+++ b/SAS/TMSS/test/test_utils.py
@@ -35,6 +35,8 @@ from lofar.sas.tmss.tmss.exceptions import TMSSException
 from lofar.messaging.config import DEFAULT_BROKER, DEFAULT_BUSNAME
 from lofar.common.testing.dbcredentials import TemporaryCredentials
 from lofar.sas.tmss.client.tmss_http_rest_client import TMSSsession
+from lofar.sas.resourceassignment.resourceassigner.test.ra_test_environment import RATestEnvironment
+
 
 def assertDataWithUrls(self, data, expected):
     """
@@ -346,32 +348,33 @@ def main_test_environment():
     parser.add_option_group(group)
     (options, args) = parser.parse_args()
 
-#    logging.basicConfig(format = '%(asctime)s %(levelname)s %(message)s', level = logging.INFO)
+    logging.basicConfig(format = '%(asctime)s %(levelname)s %(message)s', level = logging.INFO)
 
-    with TMSSTestEnvironment(host=options.host, preferred_django_port=options.port, exchange=options.exchange, broker=options.broker) as instance:
-        # print some nice info for the user to use the test servers...
-        # use print instead of log for clean lines.
-        for h in logging.root.handlers:
-            h.flush()
-        print()
-        print()
-        print("*****************************************************")
-        print("Test-TMSS database, LDAP and Django up and running...")
-        print("*****************************************************")
-        print("DB Credentials ID: %s" % (instance.database.dbcreds_id, ))
-        print("LDAP Credentials ID: %s" % (instance.django_server.ldap_dbcreds_id, ))
-        print("TMSS Client Credentials ID: %s" % (instance.client_credentials.dbcreds_id, ))
-        print("Django URL: %s" % (instance.django_server.url))
-        print()
-        print("Example cmdlines to run tmss or tmss_manage_django:")
-        print("TMSS_DBCREDENTIALS=%s TMSS_LDAPCREDENTIALS=%s tmss" % (instance.database.dbcreds_id, instance.django_server.ldap_dbcreds_id))
-        print("TMSS_DBCREDENTIALS=%s TMSS_LDAPCREDENTIALS=%s tmss_manage_django" % (instance.database.dbcreds_id, instance.django_server.ldap_dbcreds_id))
-        print()
-        print("Example cmdline to run tmss client call:")
-        print("TMSS_CLIENT_DBCREDENTIALS=%s tmss_set_subtask_state <id> <state>" % (instance.client_credentials.dbcreds_id, ))
-        print()
-        print("Press Ctrl-C to exit (and remove the test database and django server automatically)")
-        waitForInterrupt()
+    with RATestEnvironment(exchange=options.exchange, broker=options.broker):
+        with TMSSTestEnvironment(host=options.host, preferred_django_port=options.port, exchange=options.exchange, broker=options.broker) as instance:
+            # print some nice info for the user to use the test servers...
+            # use print instead of log for clean lines.
+            for h in logging.root.handlers:
+                h.flush()
+            print()
+            print()
+            print("*****************************************************")
+            print("Test-TMSS database, LDAP and Django up and running...")
+            print("*****************************************************")
+            print("DB Credentials ID: %s" % (instance.database.dbcreds_id, ))
+            print("LDAP Credentials ID: %s" % (instance.django_server.ldap_dbcreds_id, ))
+            print("TMSS Client Credentials ID: %s" % (instance.client_credentials.dbcreds_id, ))
+            print("Django URL: %s" % (instance.django_server.url))
+            print()
+            print("Example cmdlines to run tmss or tmss_manage_django:")
+            print("TMSS_DBCREDENTIALS=%s TMSS_LDAPCREDENTIALS=%s tmss" % (instance.database.dbcreds_id, instance.django_server.ldap_dbcreds_id))
+            print("TMSS_DBCREDENTIALS=%s TMSS_LDAPCREDENTIALS=%s tmss_manage_django" % (instance.database.dbcreds_id, instance.django_server.ldap_dbcreds_id))
+            print()
+            print("Example cmdline to run tmss client call:")
+            print("TMSS_CLIENT_DBCREDENTIALS=%s tmss_set_subtask_state <id> <state>" % (instance.client_credentials.dbcreds_id, ))
+            print()
+            print("Press Ctrl-C to exit (and remove the test database and django server automatically)")
+            waitForInterrupt()
 
 
 if __name__ == '__main__':
-- 
GitLab