Exemplo n.º 1
0
    def test_populate(self, mocked_init, mocked_Logger, mocked_Profiler,
                      res_descr):

        rmgr = Rmgr({'resource':'localhost'}, 'test_rmgr', 'rp', 'test_config')
        rmgr._validated = False
        rmgr._resource_desc = res_descr
        rmgr._logger = mocked_Logger
        rmgr._prof = mocked_Profiler
        rmgr._uid = 'rmgr.0000'

        with self.assertRaises(EnTKError):
            rmgr._populate()

        rmgr._validated = True
        rmgr._resource_desc = res_descr
        rmgr._logger = mocked_Logger
        rmgr._prof = mocked_Profiler
        rmgr._uid = 'rmgr.0000'

        rmgr._populate()
        self.assertEqual(rmgr._resource, res_descr['resource'])
        self.assertEqual(rmgr._walltime, res_descr['walltime'])
        self.assertEqual(rmgr._cpus, res_descr['cpus'])
        self.assertEqual(rmgr._gpus, res_descr['gpus'])
        self.assertEqual(rmgr._project, res_descr['project'])
        self.assertEqual(rmgr._access_schema, res_descr['access_schema'])
        self.assertEqual(rmgr._queue, res_descr['queue'])
Exemplo n.º 2
0
def test_rmgr_base_populate(t, i):

    if isinstance(t, str):

        res_dict = {
            'resource': t,
            'walltime': i,
            'cpus': i,
            'gpus': i,
            'project': t,
            'access_schema': t,
            'queue': t
        }

        sid = 'test.0012'
        rm = BaseRmgr(res_dict, sid=sid, rts=None, rts_config={})

        with pytest.raises(ree.EnTKError):
            rm._populate()

        rm._validate_resource_desc()
        rm._populate()

    res_dict = {
        'resource': 'local.localhost',
        'walltime': 40,
        'cpus': 100,
        'gpus': 25,
        'project': 'new',
        'queue': 'high',
        'access_schema': 'gsissh'
    }

    rmgr_id = ru.generate_id('test.%(item_counter)04d', ru.ID_CUSTOM)
    rmgr = BaseRmgr(res_dict, sid=rmgr_id, rts=None, rts_config={})

    rmgr._validate_resource_desc()
    rmgr._populate()

    assert rmgr._sid == rmgr_id
    assert rmgr._resource == 'local.localhost'
    assert rmgr._walltime == 40
    assert rmgr._cpus == 100
    assert rmgr._gpus == 25
    assert rmgr._project == 'new'
    assert rmgr._access_schema == 'gsissh'
    assert rmgr._queue == 'high'
    assert rmgr._validated is True
def test_rmgr_base_populate(t, i):

    if isinstance(t, str):
        res_dict = {
            'resource': t,
            'walltime': i,
            'cpus': i,
            'gpus': i,
            'project': t,
            'access_schema': t,
            'queue': t
        }
        rm = BaseRmgr(res_dict, sid=sid, rts=None, rts_config={})

        with pytest.raises(EnTKError):
            rm._populate()

        rm._validate_resource_desc()
        rm._populate()


    res_dict = {
        'resource': 'local.localhost',
                    'walltime': 40,
                    'cpus': 100,
                    'gpus': 25,
                    'project': 'new',
                    'queue': 'high',
                    'access_schema': 'gsissh'
    }

    rmgr_id = ru.generate_id('test.%(item_counter)04d', ru.ID_CUSTOM)
    rmgr = BaseRmgr(res_dict, sid=rmgr_id, rts=None, rts_config={})
    rmgr._validate_resource_desc()
    rmgr._populate()

    assert rmgr._sid == rmgr_id
    assert rmgr._resource == 'local.localhost'
    assert rmgr._walltime == 40
    assert rmgr._cpus == 100
    assert rmgr._gpus == 25
    assert rmgr._project == 'new'
    assert rmgr._access_schema == 'gsissh'
    assert rmgr._queue == 'high'
    assert rmgr._validated == True