Exemple #1
0
    def on_post(self, req: falcon.Request, resp):
        if not self.cctrl.list_workers():
            raise falcon.HTTPServiceUnavailable(
                'no available hosts to execute the experiment')

        doc = req.media

        exp = doc['experiment'] if 'experiment' in doc else dict()
        if 'id' not in exp:
            exp['id'] = generate_experiment_id()

        exp = Experiment(**exp)
        exp.created = time.time()
        exp.status = 'QUEUED'
        self.exp_service.save(exp)

        logger.debug('deserialized experiment %s', exp)

        workloads = [
            WorkloadConfiguration(**workload)
            for workload in doc['configuration']['workloads']
        ]
        duration = to_seconds(doc['configuration']['duration'])
        interval = to_seconds(doc['configuration']['interval'])
        config = ExperimentConfiguration(duration, interval, workloads)
        logger.debug('deserialized experiment config %s', config)
        logger.debug('queuing experiment with id %s', exp.id)
        self.ectrl.queue(config, exp)

        resp.media = exp.id
Exemple #2
0
    def run_experiment(self, exp: Experiment, cfg: ExperimentConfiguration):
        exp.status = 'IN_PROGRESS'
        exp.start = time.time()
        self.exp_service.save(exp)

        with managed_recorder(self.create_recorder, exp.id):
            logger.info("starting experiment %s", exp.id)
            runner.run_experiment(RedisClusterController(self.rds), cfg)
Exemple #3
0
    def test_update_experiment_and_get(self):
        exp = Experiment('expid8', 'test_experiment', 'unittest', 10, None, 1,
                         'running')
        self.db.save_experiment(exp)

        self.assertEqual(self.db.get_experiment('expid8').status, 'running')
        self.assertEqual(self.db.get_experiment('expid8').end, None)

        exp.status = 'finished'
        exp.end = 100

        self.db.update_experiment(exp)

        self.assertEqual(self.db.get_experiment('expid8').status, 'finished')
        self.assertEqual(self.db.get_experiment('expid8').end, 100)
Exemple #4
0
 def finalize_experiment(self, exp: Experiment, status):
     exp.status = status
     exp.end = time.time()
     self.update_experiment(exp)
     self.touch_traces(exp)