Exemplo n.º 1
0
class CheckLocalhostCluster(object):
    def setup_method(self, method):
        self.cluster = LocalhostCluster()

    def check_size(self):
        len(self.cluster) >= 2 ** 31 - 1

    def check_request_free(self):
        available = self.cluster.num_available_nodes()
        initial_size = len(self.cluster)

        # Should be able to allocate arbitrarily many nodes
        slots = self.cluster.request(100)
        assert(len(slots) == 100)
        for slot in slots:
            assert(slot.account.hostname == 'localhost')
            assert(slot.account.user is None)
            assert(slot.account.ssh_args is None)

        assert(self.cluster.num_available_nodes() == (available - 100))
        assert len(self.cluster) == initial_size  # This shouldn't change

        self.cluster.free(slots)

        assert(self.cluster.num_available_nodes() == available)
Exemplo n.º 2
0
class CheckAllocateFree(object):
    def setup_method(self, _):
        self.cluster = LocalhostCluster()
        self.session_context = session_context()
        self.context = test_context(self.session_context, cluster=self.cluster)

    def check_allocate_free(self):
        """Check that allocating and freeing nodes works.

        This regression test catches the error with Service.free() introduced in v0.3.3 and fixed in v0.3.4
        """

        # Node allocation takes place during service instantiation
        initial_cluster_size = len(self.cluster)
        self.service = DummyService(self.context, 10)
        assert self.cluster.num_available_nodes() == initial_cluster_size - 10

        self.service.free()
        assert self.cluster.num_available_nodes() == initial_cluster_size

    def check_order(self):
        """Check expected behavior with service._order method"""
        self.dummy0 = DummyService(self.context, 4)
        self.diffDummy0 = DifferentDummyService(self.context, 100)
        self.dummy1 = DummyService(self.context, 1)
        self.diffDummy1 = DifferentDummyService(self.context, 2)
        self.diffDummy2 = DifferentDummyService(self.context, 5)

        assert self.dummy0._order == 0
        assert self.dummy1._order == 1
        assert self.diffDummy0._order == 0
        assert self.diffDummy1._order == 1
        assert self.diffDummy2._order == 2
Exemplo n.º 3
0
class CheckAllocateFree(object):

    def setup_method(self, method):
        self.cluster = LocalhostCluster()
        self.session_context = session_context(cluster=self.cluster)
        self.context = test_context(self.session_context)

    def check_allocate_free(self):
        """Check that allocating and freeing nodes works.

        This regression test catches the error with Service.free() introduced in v0.3.3 and fixed in v0.3.4
        """

        # Node allocation takes place during service instantiation
        initial_cluster_size = len(self.cluster)
        self.service = DummyService(self.context, 10)
        assert self.cluster.num_available_nodes() == initial_cluster_size - 10

        self.service.free()
        assert self.cluster.num_available_nodes() == initial_cluster_size

    def check_order(self):
        """Check expected behavior with service._order method"""
        self.dummy0 = DummyService(self.context, 4)
        self.diffDummy0 = DifferentDummyService(self.context, 100)
        self.dummy1 = DummyService(self.context, 1)
        self.diffDummy1 = DifferentDummyService(self.context, 2)
        self.diffDummy2 = DifferentDummyService(self.context, 5)

        assert self.dummy0._order == 0
        assert self.dummy1._order == 1
        assert self.diffDummy0._order == 0
        assert self.diffDummy1._order == 1
        assert self.diffDummy2._order == 2
Exemplo n.º 4
0
class CheckLocalhostCluster(object):
    def setup_method(self, _):
        self.cluster = LocalhostCluster(is_type_based=False)

    def check_size(self):
        len(self.cluster) >= 2**31 - 1

    def check_pickleable(self):
        cluster = LocalhostCluster(is_type_based=False)
        pickle.dumps(cluster)

    def check_request_free(self):
        available = self.cluster.num_available_nodes()
        initial_size = len(self.cluster)

        # Should be able to allocate arbitrarily many nodes
        nodes = self.cluster.alloc(Service.setup_cluster_spec(num_nodes=100))
        assert (len(nodes) == 100)
        for i, node in enumerate(nodes):
            assert node.account.hostname == 'localhost%d' % i
            assert node.account.ssh_hostname == 'localhost'
            assert node.account.ssh_config.hostname == 'localhost'
            assert node.account.ssh_config.port == 22
            assert node.account.user is None

        assert (self.cluster.num_available_nodes() == (available - 100))
        assert len(self.cluster) == initial_size  # This shouldn't change

        self.cluster.free(nodes)

        assert (self.cluster.num_available_nodes() == available)
Exemplo n.º 5
0
class CheckLocalhostCluster(object):
    def setup_method(self, method):
        self.cluster = LocalhostCluster()

    def check_size(self):
        len(self.cluster) >= 2**31 - 1

    def check_request_free(self):
        available = self.cluster.num_available_nodes()
        initial_size = len(self.cluster)

        # Should be able to allocate arbitrarily many nodes
        slots = self.cluster.request(100)
        assert (len(slots) == 100)
        for slot in slots:
            assert (slot.account.hostname == 'localhost')
            assert (slot.account.user is None)
            assert (slot.account.ssh_args is None)

        assert (self.cluster.num_available_nodes() == (available - 100))
        assert len(self.cluster) == initial_size  # This shouldn't change

        self.cluster.free(slots)

        assert (self.cluster.num_available_nodes() == available)
Exemplo n.º 6
0
class CheckAllocateFree(object):
    def setup_method(self, method):
        self.cluster = LocalhostCluster()
        self.session_context = session_context(cluster=self.cluster)
        self.context = test_context(self.session_context)

    def check_allocate_free(self):
        """Check that allocating and freeing nodes works.

        This regression test catches the error with Service.free() introduced in v0.3.3 and fixed in v0.3.4
        """

        # Node allocation takes place during service instantiation
        initial_cluster_size = len(self.cluster)
        self.service = DummyService(self.context, 10)
        assert self.cluster.num_available_nodes() == initial_cluster_size - 10

        self.service.free()
        assert self.cluster.num_available_nodes() == initial_cluster_size
Exemplo n.º 7
0
class CheckLocalhostCluster(object):
    def setup_method(self, method):
        self.cluster = LocalhostCluster()

    def check_request_free(self):
        available = self.cluster.num_available_nodes()

        # Should be able to allocate arbitrarily many nodes
        slots = self.cluster.request(100)
        assert (len(slots) == 100)
        for slot in slots:
            assert (slot.account.hostname == 'localhost')
            assert (slot.account.user == None)
            assert (slot.account.ssh_args == None)

        assert (self.cluster.num_available_nodes() == (available - 100))

        self.cluster.free(slots)

        assert (self.cluster.num_available_nodes() == available)
Exemplo n.º 8
0
class CheckAllocateFree(object):

    def setup_method(self, method):
        self.cluster = LocalhostCluster()
        self.session_context = session_context(cluster=self.cluster)
        self.context = test_context(self.session_context)

    def check_allocate_free(self):
        """Check that allocating and freeing nodes works.

        This regression test catches the error with Service.free() introduced in v0.3.3 and fixed in v0.3.4
        """

        # Node allocation takes place during service instantiation
        initial_cluster_size = len(self.cluster)
        self.service = DummyService(self.context, 10)
        assert self.cluster.num_available_nodes() == initial_cluster_size - 10

        self.service.free()
        assert self.cluster.num_available_nodes() == initial_cluster_size
Exemplo n.º 9
0
class CheckLocalhostCluster(object):
    def setup_method(self, method):
        self.cluster = LocalhostCluster()

    def check_request_free(self):
        available = self.cluster.num_available_nodes()

        # Should be able to allocate arbitrarily many nodes
        slots = self.cluster.request(100)
        assert(len(slots) == 100)
        for slot in slots:
            assert(slot.account.hostname == 'localhost')
            assert(slot.account.user == None)
            assert(slot.account.ssh_args == None)

        assert(self.cluster.num_available_nodes() == (available - 100))

        self.cluster.free(slots)

        assert(self.cluster.num_available_nodes() == available)