Example #1
0
    def test_scheduler_reservation_associations(self):
        exp_inst_id1 = ExperimentInstanceId("exp1", "ud-pld",
                                            "PLD experiments")
        exp_inst_id1b = ExperimentInstanceId("exp2", "ud-pld",
                                             "PLD experiments")
        exp_inst_id2 = ExperimentInstanceId("exp1", "ud-fpga",
                                            "FPGA experiments")

        exp_id1 = exp_inst_id1.to_experiment_id()
        exp_id2 = exp_inst_id2.to_experiment_id()

        self.resources_manager.add_resource(Resource("pld_local", "instance"))
        self.resources_manager.add_resource(Resource("pld_remote", "instance"))
        self.resources_manager.add_resource(Resource("fpga_remote",
                                                     "instance"))

        self.resources_manager.add_experiment_instance_id(
            "laboratory1:WL_SERVER1@WL_MACHINE1", exp_inst_id1,
            Resource("pld_local", "instance"))
        self.resources_manager.add_experiment_instance_id(
            "laboratory1:WL_SERVER1@WL_MACHINE1", exp_inst_id1b,
            Resource("pld_remote", "instance"))
        self.resources_manager.add_experiment_instance_id(
            "laboratory1:WL_SERVER1@WL_MACHINE1", exp_inst_id2,
            Resource("fpga_remote", "instance"))

        reservation1 = 'reservation1'
        reservation2 = 'reservation2'

        self.resources_manager.associate_scheduler_to_reservation(
            reservation1, exp_id1, 'pld_local')
        self.resources_manager.associate_scheduler_to_reservation(
            reservation1, exp_id1, 'pld_remote')
        self.resources_manager.associate_scheduler_to_reservation(
            reservation2, exp_id2, 'fpga_remote')

        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(
            reservation1, exp_id1)
        self.assertEquals(set(('pld_local', 'pld_remote')),
                          set(resource_type_names))
        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(
            reservation2, exp_id2)
        self.assertEquals(['fpga_remote'], list(resource_type_names))

        self.resources_manager.dissociate_scheduler_from_reservation(
            reservation1, exp_id1, 'pld_remote')
        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(
            reservation1, exp_id1)
        self.assertEquals(['pld_local'], list(resource_type_names))

        self.resources_manager.clean_associations_for_reservation(
            reservation1, exp_id1)

        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(
            reservation1, exp_id1)
        self.assertEquals(0, len(resource_type_names))
Example #2
0
    def test_remove_resource_instance_id(self):
        exp_id = ExperimentInstanceId("exp1", "ud-pld", "PLD Experiments")
        self.resources_manager.add_experiment_instance_id(
            "laboratory1:WL_SERVER1@WL_MACHINE1", exp_id,
            Resource("type", "instance"))

        experiment_instances = self.resources_manager.list_experiment_instances_by_type(
            exp_id.to_experiment_id())
        self.assertEquals(1, len(experiment_instances))

        self.resources_manager.remove_resource_instance_id(exp_id)

        experiment_instances = self.resources_manager.list_experiment_instances_by_type(
            exp_id.to_experiment_id())
        self.assertEquals(0, len(experiment_instances))
    def test_scheduler_reservation_associations(self):
        exp_inst_id1  = ExperimentInstanceId("exp1","ud-pld",  "PLD experiments")
        exp_inst_id1b = ExperimentInstanceId("exp2","ud-pld",  "PLD experiments")
        exp_inst_id2  = ExperimentInstanceId("exp1","ud-fpga", "FPGA experiments")

        exp_id1 = exp_inst_id1.to_experiment_id()
        exp_id2 = exp_inst_id2.to_experiment_id()

        session = self.session_maker()
        try:
            self.resources_manager.add_resource(session, Resource("pld_local", "instance"))
            self.resources_manager.add_resource(session, Resource("pld_remote", "instance"))
            self.resources_manager.add_resource(session, Resource("fpga_remote", "instance"))
            session.commit()
        finally:
            session.close()

        self.resources_manager.add_experiment_instance_id("laboratory1:WL_SERVER1@WL_MACHINE1", exp_inst_id1, Resource("pld_local",  "instance"))
        self.resources_manager.add_experiment_instance_id("laboratory1:WL_SERVER1@WL_MACHINE1", exp_inst_id1b, Resource("pld_remote", "instance"))
        self.resources_manager.add_experiment_instance_id("laboratory1:WL_SERVER1@WL_MACHINE1", exp_inst_id2, Resource("fpga_remote", "instance"))

        reservation1 = 'reservation1'
        reservation2 = 'reservation2'

        self.resources_manager.associate_scheduler_to_reservation(reservation1, exp_id1, 'pld_local')
        self.resources_manager.associate_scheduler_to_reservation(reservation1, exp_id1, 'pld_remote')
        self.resources_manager.associate_scheduler_to_reservation(reservation2, exp_id2, 'fpga_remote')

        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(reservation1, exp_id1)
        self.assertEquals(set(('pld_local','pld_remote')), set(resource_type_names))
        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(reservation2, exp_id2)
        self.assertEquals(['fpga_remote'], list(resource_type_names))

        self.resources_manager.dissociate_scheduler_from_reservation(reservation1, exp_id1, 'pld_remote')
        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(reservation1, exp_id1)
        self.assertEquals(['pld_local'], list(resource_type_names))

        self.resources_manager.clean_associations_for_reservation(reservation1, exp_id1)

        resource_type_names = self.resources_manager.retrieve_schedulers_per_reservation(reservation1, exp_id1)
        self.assertEquals(0, len(resource_type_names))
Example #4
0
    def test_remove_resource_instance(self):
        exp_id = ExperimentInstanceId("exp1", "ud-pld", "PLD Experiments")
        resource_instance = Resource("type", "instance")
        self.resources_manager.add_experiment_instance_id(
            "laboratory1:WL_SERVER1@WL_MACHINE1", exp_id, resource_instance)

        # Checking that the resources are there
        experiment_instances = self.resources_manager.list_experiment_instances_by_type(
            exp_id.to_experiment_id())
        self.assertEquals(1, len(experiment_instances))
        resource_instances = self.resources_manager.list_resource_instances()
        self.assertEquals(1, len(resource_instances))

        # Removing resource instance
        self.resources_manager.remove_resource_instance(resource_instance)

        # Checking that the resources are not there, neither the experiment instances
        resource_instances = self.resources_manager.list_resource_instances()
        self.assertEquals(0, len(resource_instances))
        experiment_instances = self.resources_manager.list_experiment_instances_by_type(
            exp_id.to_experiment_id())
        self.assertEquals(0, len(experiment_instances))
    def test_remove_resource_instance(self):
        exp_id = ExperimentInstanceId("exp1","ud-pld","PLD Experiments")
        resource_instance = Resource("type", "instance")
        self.resources_manager.add_experiment_instance_id("laboratory1:WL_SERVER1@WL_MACHINE1", exp_id, resource_instance)

        # Checking that the resources are there
        experiment_instances = self.resources_manager.list_experiment_instances_by_type(exp_id.to_experiment_id())
        self.assertEquals(1, len(experiment_instances))
        resource_instances = self.resources_manager.list_resource_instances()
        self.assertEquals(1, len(resource_instances))

        # Removing resource instance
        self.resources_manager.remove_resource_instance(resource_instance)

        # Checking that the resources are not there, neither the experiment instances
        resource_instances = self.resources_manager.list_resource_instances()
        self.assertEquals(0, len(resource_instances))
        experiment_instances = self.resources_manager.list_experiment_instances_by_type(exp_id.to_experiment_id())
        self.assertEquals(0, len(experiment_instances))
    def test_remove_resource_instance_id(self):
        exp_id = ExperimentInstanceId("exp1","ud-pld","PLD Experiments")
        self.resources_manager.add_experiment_instance_id("laboratory1:WL_SERVER1@WL_MACHINE1", exp_id, Resource("type", "instance"))

        experiment_instances = self.resources_manager.list_experiment_instances_by_type(exp_id.to_experiment_id())
        self.assertEquals(1, len(experiment_instances))

        self.resources_manager.remove_resource_instance_id(exp_id)

        experiment_instances = self.resources_manager.list_experiment_instances_by_type(exp_id.to_experiment_id())
        self.assertEquals(0, len(experiment_instances))