Exemple #1
0
 def test_wait_for_servers_retries_until_timeout(self):
     """
     If the matcher does not match the nova servers state, retries until
     it times out.
     """
     d = nova.wait_for_servers(self.rcs, self.pool, Equals(self.wanted),
                               group=self.group, timeout=5, period=1,
                               clock=self.clock, _treq=self.treq)
     self.clock.pump((1, 1, 1, 1, 1))
     self.failureResultOf(d, TimedOutError)
Exemple #2
0
 def test_wait_for_servers_without_group(self):
     """
     If no group is provided, applies the matcher against all servers and
     not just those in a group.
     """
     d = nova.wait_for_servers(
         self.rcs, self.pool, MatchesListwise([Contains('metadata')]*2),
         timeout=5, period=1,
         clock=self.clock, _treq=self.treq)
     self.clock.pump((1,))
     self.assertEqual(self.servers, self.successResultOf(d))
Exemple #3
0
    def test_wait_for_servers_retries_until_matcher_matches(self):
        """
        If the matcher does not match the nova servers state, retries until
        it does.
        """
        d = nova.wait_for_servers(self.rcs, self.pool, Equals(self.wanted),
                                  group=self.group, timeout=5, period=1,
                                  clock=self.clock, _treq=self.treq)
        self.clock.pump((1, 1, 1))
        self.assertNoResult(d)

        self.servers.extend(self.wanted)
        self.clock.pump([1])
        self.assertEqual(self.wanted, self.successResultOf(d))
Exemple #4
0
    def create_servers(self, rcs, num, wait_for=None):
        """
        Create some number of servers using just Nova, and wait until they
        are active.  This uses the same default server arguments as
        `create_group`.

        :param TestResources rcs: An instance of
            :class:`otter.integration.lib.resources.TestResources`
        :param int num: The number of servers to create.
        :param wait_for: What state to wait for for those servers - by default,
            it waits just for them to be active

        :return: an iterable of server details JSON of the created servers.
        """
        image_id = yield fetch_ubuntu_image_id(rcs, self.pool)
        as_args = create_scaling_group_dict(
            image_ref=image_id,
            flavor_ref=flavor_ref)
        server_args = as_args['launchConfiguration']['args']
        server_args['server']['name'] = "autogenerated-non-as-test-server"

        if wait_for is None:
            wait_for = ContainsDict({'status': Equals("ACTIVE")})

        server_ids = yield gatherResults([
            create_server(rcs, self.pool, server_args) for _ in range(num)])

        self.test_case.addCleanup(delete_servers, server_ids, rcs, self.pool)

        servers = yield wait_for_servers(
            rcs,
            self.pool,
            # The list of active servers' ids has the created server ids
            AfterPreprocessing(
                lambda servers: [s for s in servers if s['id'] in server_ids],
                AllMatch(wait_for)
            )
        )

        returnValue(
            [server for server in servers if server['id'] in server_ids])
Exemple #5
0
    def create_servers(self, rcs, num, wait_for=None):
        """
        Create some number of servers using just Nova, and wait until they
        are active.  This uses the same default server arguments as
        `create_group`.

        :param TestResources rcs: An instance of
            :class:`otter.integration.lib.resources.TestResources`
        :param int num: The number of servers to create.
        :param wait_for: What state to wait for for those servers - by default,
            it waits just for them to be active

        :return: an iterable of server details JSON of the created servers.
        """
        image_id = yield fetch_ubuntu_image_id(rcs, self.pool)
        as_args = create_scaling_group_dict(
            image_ref=image_id,
            flavor_ref=flavor_ref)
        server_args = as_args['launchConfiguration']['args']
        server_args['server']['name'] = "autogenerated-non-as-test-server"

        if wait_for is None:
            wait_for = ContainsDict({'status': Equals("ACTIVE")})

        server_ids = yield gatherResults([
            create_server(rcs, self.pool, server_args) for _ in range(num)])

        self.test_case.addCleanup(delete_servers, server_ids, rcs, self.pool)

        servers = yield wait_for_servers(
            rcs,
            self.pool,
            # The list of active servers' ids has the created server ids
            AfterPreprocessing(
                lambda servers: [s for s in servers if s['id'] in server_ids],
                AllMatch(wait_for)
            )
        )

        returnValue(
            [server for server in servers if server['id'] in server_ids])