def check_free_too_many(self):
     n = 10
     cluster = FiniteSubcluster([MockFiniteSubclusterNode() for _ in range(n)])
     nodes = cluster.alloc(Service.setup_cluster_spec(num_nodes=n))
     with pytest.raises(NodeNotPresentError):
         nodes.append(MockFiniteSubclusterNode())
         cluster.free(nodes)
示例#2
0
 def check_free_too_many(self):
     n = 10
     cluster = FiniteSubcluster([MockFiniteSubclusterNode() for _ in range(n)])
     nodes = cluster.alloc(Service.setup_cluster_spec(num_nodes=n))
     with pytest.raises(NodeNotPresentError):
         nodes.append(MockFiniteSubclusterNode())
         cluster.free(nodes)
示例#3
0
    def check_cluster_size(self):
        cluster = FiniteSubcluster([])
        assert len(cluster) == 0

        n = 10
        cluster = FiniteSubcluster([MockFiniteSubclusterNode() for _ in range(n)])
        assert len(cluster) == n
示例#4
0
 def check_free_too_many(self):
     n = 10
     cluster = FiniteSubcluster(
         [MockFiniteSubclusterNode() for _ in range(n)])
     nodes = cluster.alloc(Service.setup_node_spec(num_nodes=n))
     with pytest.raises(AssertionError):
         nodes.append(object())
         cluster.free(nodes)
示例#5
0
    def _preallocate_subcluster(self, test_context):
        """Preallocate the subcluster which will be used to run the test.

        Side effect: store association between the test_id and the preallocated subcluster.

        :param test_context
        :return None
        """
        allocated = self.cluster.alloc(test_context.expected_cluster_spec)
        if len(self.cluster.available()) == 0 and self.max_parallel > 1 and not self._test_cluster:
            self._log(logging.WARNING,
                      "Test %s is using entire cluster. It's possible this test has no associated cluster metadata."
                      % test_context.test_id)

        self._test_cluster[TestKey(test_context.test_id, self.test_counter)] = FiniteSubcluster(allocated)
示例#6
0
    def _preallocate_subcluster(self, test_context):
        """Preallocate the subcluster which will be used to run the test.

        Side effect: store association between the test_id and the preallocated subcluster.

        :param test_context
        :return None
        """
        test_cluster_compare = self.cluster.test_capacity_comparison(
            test_context)
        assert test_cluster_compare >= 0

        if test_cluster_compare == 0 and self.max_parallel > 1:
            self._log(
                logging.WARNING,
                "Test %s is using entire cluster. It's possible this test has no associated cluster metadata."
                % test_context.test_id)

        self._test_cluster[TestKey(test_context.test_id, self.test_counter)] = \
            FiniteSubcluster(self.cluster.alloc(Service.setup_node_spec(node_spec=test_context.expected_node_spec)))
 def check_alloc_too_many(self):
     n = 10
     cluster = FiniteSubcluster([MockFiniteSubclusterNode() for _ in range(n)])
     with pytest.raises(InsufficientResourcesError):
         cluster.alloc(Service.setup_cluster_spec(num_nodes=(n + 1)))
    def check_allocate_free(self):
        n = 10
        cluster = FiniteSubcluster([MockFiniteSubclusterNode() for _ in range(n)])
        assert len(cluster) == n
        assert cluster.num_available_nodes() == n

        nodes = cluster.alloc(Service.setup_cluster_spec(num_nodes=1))
        assert len(nodes) == 1
        assert len(cluster) == n
        assert cluster.num_available_nodes() == n - 1

        nodes2 = cluster.alloc(Service.setup_cluster_spec(num_nodes=2))
        assert len(nodes2) == 2
        assert len(cluster) == n
        assert cluster.num_available_nodes() == n - 3

        cluster.free(nodes)
        assert cluster.num_available_nodes() == n - 2

        cluster.free(nodes2)
        assert cluster.num_available_nodes() == n
示例#9
0
 def check_alloc_too_many(self):
     n = 10
     cluster = FiniteSubcluster(
         [MockFiniteSubclusterNode() for _ in range(n)])
     with pytest.raises(AssertionError):
         cluster.alloc(Service.setup_node_spec(num_nodes=(n + 1)))
示例#10
0
    def check_allocate_free(self):
        n = 10
        cluster = FiniteSubcluster(
            [MockFiniteSubclusterNode() for _ in range(n)])
        assert len(cluster) == n
        assert cluster.num_available_nodes() == n

        nodes = cluster.alloc(Service.setup_node_spec(num_nodes=1))
        assert len(nodes) == 1
        assert len(cluster) == n
        assert cluster.num_available_nodes() == n - 1

        nodes2 = cluster.alloc(Service.setup_node_spec(num_nodes=2))
        assert len(nodes2) == 2
        assert len(cluster) == n
        assert cluster.num_available_nodes() == n - 3

        cluster.free(nodes)
        assert cluster.num_available_nodes() == n - 2

        cluster.free(nodes2)
        assert cluster.num_available_nodes() == n
示例#11
0
 def check_pickleable(self):
     cluster = FiniteSubcluster(
         [MockFiniteSubclusterNode() for _ in range(10)])
     pickle.dumps(cluster)
示例#12
0
 def check_alloc_too_many(self):
     n = 10
     cluster = FiniteSubcluster(
         [MockFiniteSubclusterNode() for _ in range(n)])
     with pytest.raises(InsufficientResourcesError):
         cluster.alloc(Service.setup_cluster_spec(num_nodes=(n + 1)))