Example #1
0
def test_amgr_read_config():

    amgr = Amgr(hostname=host, port=port)

    assert amgr._reattempts == 3

    assert amgr._rmq_cleanup
    assert amgr._autoterminate

    assert not amgr._write_workflow
    assert not amgr._resubmit_failed

    assert amgr._rts              == 'radical.pilot'
    assert amgr._num_pending_qs   == 1
    assert amgr._num_completed_qs == 1
    assert amgr._rts_config       == {"sandbox_cleanup": False,
                                      "db_cleanup"     : False}

    d = {"hostname"       : "radical.two",
         "port"           : 25672,
         "username"       : user,
         "password"       : passwd,
         "reattempts"     : 5,
         "resubmit_failed": True,
         "autoterminate"  : False,
         "write_workflow" : True,
         "rts"            : "mock",
         "rts_config"     : {"sandbox_cleanup": True,
                             "db_cleanup"     : True},
         "pending_qs"     : 2,
         "completed_qs"   : 3,
         "rmq_cleanup"    : False}

    ru.write_json(d, './config.json')
    amgr._read_config(config_path='./',
                      hostname=None,
                      port=None,
                      username=None,
                      password=None,
                      reattempts=None,
                      resubmit_failed=None,
                      autoterminate=None,
                      write_workflow=None,
                      rts=None,
                      rmq_cleanup=None,
                      rts_config=None)

    assert amgr._hostname         == d['hostname']
    assert amgr._port             == d['port']
    assert amgr._reattempts       == d['reattempts']
    assert amgr._resubmit_failed  == d['resubmit_failed']
    assert amgr._autoterminate    == d['autoterminate']
    assert amgr._write_workflow   == d['write_workflow']
    assert amgr._rts              == d['rts']
    assert amgr._rts_config       == d['rts_config']
    assert amgr._num_pending_qs   == d['pending_qs']
    assert amgr._num_completed_qs == d['completed_qs']
    assert amgr._rmq_cleanup      == d['rmq_cleanup']

    os.remove('./config.json')
def test_amgr_read_config():

    amgr = Amgr()

    assert amgr._mq_hostname == 'localhost'
    assert amgr._port == 5672
    assert amgr._reattempts == 3
    assert amgr._resubmit_failed == False
    assert amgr._autoterminate == True
    assert amgr._write_workflow == False
    assert amgr._rts == 'radical.pilot'
    assert amgr._num_pending_qs == 1
    assert amgr._num_completed_qs == 1
    assert amgr._rmq_cleanup == True
    assert amgr._rts_config == { "sandbox_cleanup": False, "db_cleanup": False}

    d = {"hostname": "radical.two",
         "port": 25672,
         "reattempts": 5,
         "resubmit_failed": True,
         "autoterminate": False,
         "write_workflow": True,
         "rts": "mock",
         "rts_config": { "sandbox_cleanup": True, "db_cleanup": True},
         "pending_qs": 2,
         "completed_qs": 3,
         "rmq_cleanup": False}

    ru.write_json(d, './config.json')
    amgr._read_config(config_path='./',
                      hostname=None,
                      port=None,
                      reattempts=None,
                      resubmit_failed=None,
                      autoterminate=None,
                      write_workflow=None,
                      rts=None,
                      rmq_cleanup=None,
                      rts_config=None)

    assert amgr._mq_hostname == d['hostname']
    assert amgr._port == d['port']
    assert amgr._reattempts == d['reattempts']
    assert amgr._resubmit_failed == d['resubmit_failed']
    assert amgr._autoterminate == d['autoterminate']
    assert amgr._write_workflow == d['write_workflow']
    assert amgr._rts == d['rts']
    assert amgr._rts_config == d['rts_config']
    assert amgr._num_pending_qs == d['pending_qs']
    assert amgr._num_completed_qs == d['completed_qs']
    assert amgr._rmq_cleanup == d['rmq_cleanup']

    os.remove('./config.json')
Example #3
0
    def test_amgr_read_config(self, mocked_init, mocked_PlainCredentials,
                              mocked_ConnectionParameters, d):

        amgr = Amgr(hostname='host',
                    port='port',
                    username='******',
                    password='******')

        d["rts"] = "mock"
        d["rts_config"] = {"sandbox_cleanup": True, "db_cleanup": True}

        ru.write_json(d, './config.json')
        amgr._read_config(config_path='./',
                          hostname=None,
                          port=None,
                          username=None,
                          password=None,
                          reattempts=None,
                          resubmit_failed=None,
                          autoterminate=None,
                          write_workflow=None,
                          rts=None,
                          rmq_cleanup=None,
                          rts_config=None)

        self.assertEqual(amgr._hostname, d['hostname'])
        self.assertEqual(amgr._port, d['port'])
        self.assertEqual(amgr._reattempts, d['reattempts'])
        self.assertEqual(amgr._resubmit_failed, d['resubmit_failed'])
        self.assertEqual(amgr._autoterminate, d['autoterminate'])
        self.assertEqual(amgr._write_workflow, d['write_workflow'])
        self.assertEqual(amgr._rts, d['rts'])
        self.assertEqual(amgr._rts_config, d['rts_config'])
        self.assertEqual(amgr._num_pending_qs, d['pending_qs'])
        self.assertEqual(amgr._num_completed_qs, d['completed_qs'])
        self.assertEqual(amgr._rmq_cleanup, d['rmq_cleanup'])

        d['rts'] = 'another'
        ru.write_json(d, './config.json')
        print(d)
        with self.assertRaises(ValueError):
            amgr._read_config(config_path='./',
                              hostname=None,
                              port=None,
                              username=None,
                              password=None,
                              reattempts=None,
                              resubmit_failed=None,
                              autoterminate=None,
                              write_workflow=None,
                              rts=None,
                              rmq_cleanup=None,
                              rts_config=None)
Example #4
0
    def test_amgr_read_config2(self, mocked_init, mocked_PlainCredentials,
                               mocked_ConnectionParameters, d2):

        amgr = Amgr(hostname='host',
                    port='port',
                    username='******',
                    password='******')

        amgr._read_config(config_path='./',
                          hostname=d2['hostname'],
                          port=d2['port'],
                          username=d2['username'],
                          password=d2['password'],
                          reattempts=d2['reattempts'],
                          resubmit_failed=d2['resubmit_failed'],
                          autoterminate=d2['autoterminate'],
                          write_workflow=d2['write_workflow'],
                          rmq_cleanup=d2['rmq_cleanup'],
                          rts="mock",
                          rts_config={
                              "sandbox_cleanup": True,
                              "db_cleanup": True
                          })

        self.assertEqual(amgr._hostname, d2['hostname'])
        self.assertEqual(amgr._port, d2['port'])
        self.assertEqual(amgr._reattempts, d2['reattempts'])
        self.assertEqual(amgr._resubmit_failed, d2['resubmit_failed'])
        self.assertEqual(amgr._autoterminate, d2['autoterminate'])
        self.assertEqual(amgr._write_workflow, d2['write_workflow'])
        self.assertEqual(amgr._rts, "mock")
        self.assertEqual(amgr._rts_config, {
            "sandbox_cleanup": True,
            "db_cleanup": True
        })
        self.assertEqual(amgr._rmq_cleanup, d2['rmq_cleanup'])