class GPUResourceManagerTestCase(unittest.TestCase):
    n_parallel = 1
    auppath = os.path.join("tests", "data", ".aup")
    connector = get_default_connector(auppath)
    val = 0
    ori_db = os.path.join(auppath, "sqlite3.db")
    bk_db = os.path.join(auppath, "bk.db")
    job = Job("test_Job.py", BasicConfig(), "./tests/EE")

    def setUp(self):
        copyfile(self.ori_db, self.bk_db)
        self.connector = get_default_connector(self.auppath)
        self.rm = GPUResourceManager(self.connector,
                                     self.n_parallel,
                                     auppath=self.auppath)

    def tearDown(self):
        copyfile(self.bk_db, self.ori_db)
        os.remove(self.bk_db)

    def test_run(self):
        def callback(*args):
            self.val = -1

        self.rm.run(self.job, self.rm.get_available("test", "gpu"), {},
                    callback)
        sleep(3)  # wait till subprocess finished - handled by rm.finish()

        self.assertEqual(self.val, -1)
 def setUp(self):
     copyfile(self.ori_db, self.bk_db)
     self.connector = get_default_connector(self.auppath)
     self.rm = GPUResourceManager(self.connector,
                                  self.n_parallel,
                                  auppath=self.auppath)
 def setUp(self):
     copyfile(self.ori_db, self.bk_db)
     self.connector = get_default_connector(self.auppath)
     self.rm = PassiveResourceManager(self.connector)