예제 #1
0
    def test_can_start_on_cluster_2_2b(self):
        """
        status:
            ----bbbb----
            ****--------

        job:
            ****-------- 1, 0, 1
            --****------ 1, 0.5, 1
            ----****---- 1, 1, 1
            ------****-- 1, 1.5, 1
            --------**** 1, 2, 1
        """

        nodes_status = {
            "node1": {
                "reservations": [{
                    "queue": "besteffort",
                    "walltime": 1,
                    "scheduled_at": 1,
                    "started_at": 1
                }]
            },
            "node2": {
                "reservations": [{
                    "walltime": 1,
                    "scheduled_at": 0,
                    "started_at": 0
                }]
            },
        }

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 2, 0, 1)
        self.assertFalse(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 2, 0.5, 1)
        self.assertFalse(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 2, 1, 1)
        self.assertTrue(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 2, 1.5, 1)
        self.assertTrue(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 2, 2, 1)
        self.assertTrue(ok)
예제 #2
0
    def test_can_start_on_cluster_1_1(self):
        """
        status:
            ----****----

        job:
            ****-------- 1, 0, 1
            --****------ 1, 0.5, 1
            ----****---- 1, 1, 1
            ------****-- 1, 1.5, 1
            --------**** 1, 2, 1
        """

        nodes_status = {
            "node1": {
                "reservations": [{
                    "walltime": 1,
                    "scheduled_at": 1,
                    "started_at": 1
                }]
            }
        }

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 1, 0, 1)
        self.assertTrue(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 1, 0.5, 1)
        self.assertFalse(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 1, 1, 1)
        self.assertFalse(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 1, 1.5, 1)
        self.assertFalse(ok)

        ok = g5k_api_utils.can_start_on_cluster(nodes_status, 1, 2, 1)
        self.assertTrue(ok)