コード例 #1
0
ファイル: running.py プロジェクト: scserlch/ScSFWorkload
    def check_trace_and_store(self, scheduler_db_obj, store_db_obj):
        """ Imports the result trace from an experiment and stores it in a 
        central database.
        Args:
         - scheduler_db_obj: DBManager object configured to connect to the
            schedulers's database.
        - store_db_obj: DBManager object configured to connect to the database
            where results traces should be stored.
        Returns True if the simulation produced a valid trace. False otherwise.
        """
        result_trace = ResultTrace()
        result_trace.import_from_db(scheduler_db_obj,
                                    ExperimentRunner._scheduler_acc_table)

        status = True
        end_time = self._definition.get_end_epoch()
        if len(result_trace._lists_start["time_end"]) == 0:
            print("Error: No simulated jobs")
            return False
        last_job_end_time = result_trace._lists_submit["time_submit"][-1]
        if last_job_end_time < (end_time - 600):
            print(("Simulation ended too soon: {0} vs. expected {1}.".format(
                last_job_end_time, end_time)))
            status = False
        result_trace.store_trace(store_db_obj, self._definition._trace_id)
        return status
コード例 #2
0
    def test_import_from_db(self):
        self._create_tables()
        self._db.doUpdate("""insert into  import_table 
          (`job_db_inx`, `account`, `cpus_req`, `cpus_alloc`,
           `job_name`, `id_job`, `id_qos`, `id_resv`, `id_user`, 
           `nodes_alloc`, `partition`, `priority`, `state`, `timelimit`,
           `time_submit`, `time_start`, `time_end`) VALUES (
           1, "account1", 48, 48,
           "jobName1", 1, 2, 3, 4, 
           2, "partition1", 99, 3, 100,
           3000, 3002, 3002  
           )""")

        self._db.doUpdate("""insert into  import_table 
          (`job_db_inx`, `account`, `cpus_req`, `cpus_alloc`,
           `job_name`, `id_job`, `id_qos`, `id_resv`, `id_user`, 
           `nodes_alloc`, `partition`, `priority`, `state`, `timelimit`,
           `time_submit`, `time_start`, `time_end`) VALUES (
           2, "account2", 96, 96,
           "jobName2", 2, 3, 4, 5, 
           4, "partition2", 199, 2, 200,
           3003, 3001, 3005  
           )""")

        rt = ResultTrace()
        rt.import_from_db(self._db, "import_table")
        compare_data = {
            "job_db_inx": [1, 2],
            "account": ["account1", "account2"],
            "cpus_req": [48, 96],
            "cpus_alloc": [48, 96],
            "job_name": ["jobName1", "jobName2"],
            "id_job": [1, 2],
            "id_qos": [2, 3],
            "id_resv": [3, 4],
            "id_user": [4, 5],
            "nodes_alloc": [2, 4],
            "partition": ["partition1", "partition2"],
            "priority": [99, 199],
            "state": [3, 2],
            "timelimit": [100, 200],
            "time_submit": [3000, 3003],
            "time_start": [3002, 3001],
            "time_end": [3002, 3005]
        }
        for key in list(compare_data.keys()):
            self.assertEqual(compare_data[key], rt._lists_submit[key])

        compare_data = {
            "job_db_inx": [2, 1],
            "account": ["account2", "account1"],
            "cpus_req": [96, 48],
            "cpus_alloc": [96, 48],
            "job_name": ["jobName2", "jobName1"],
            "id_job": [2, 1],
            "id_qos": [3, 2],
            "id_resv": [4, 3],
            "id_user": [5, 4],
            "nodes_alloc": [4, 2],
            "partition": ["partition2", "partition1"],
            "priority": [199, 99],
            "state": [2, 3],
            "timelimit": [200, 100],
            "time_submit": [3003, 3000],
            "time_start": [3001, 3002],
            "time_end": [3005, 3002]
        }
        for key in list(compare_data.keys()):
            self.assertEqual(compare_data[key], rt._lists_start[key])