def test_delete_clb_does_not_retry_on_get_failure(self):
        """
        Deleting a CLB will retry if the state wonky until it times out.
        """
        clock = Clock()
        self.clb_id = 12345
        _treq = self.get_fake_treq_for_delete(
            Response(400, strbody="Something is wrong"))

        clb = CloudLoadBalancer(pool=self.pool, treq=_treq)
        clb.clb_id = self.clb_id

        d = clb.delete(self.rcs, clock=clock)
        self.failureResultOf(d, UpstreamError)
Esempio n. 2
0
    def test_delete_clb_does_not_retry_on_get_failure(self):
        """
        Deleting a CLB will retry if the state wonky until it times out.
        """
        clock = Clock()
        self.clb_id = 12345
        _treq = self.get_fake_treq_for_delete(
            Response(400, strbody="Something is wrong"))

        clb = CloudLoadBalancer(pool=self.pool, treq=_treq)
        clb.clb_id = self.clb_id

        d = clb.delete(self.rcs, clock=clock)
        self.failureResultOf(d, UpstreamError)
    def test_delete_clb_retries_until_success(self):
        """
        Deleting a CLB will retry until the CLB is deleted (or in error or
        suspended mode, in which case it will give up).
        """
        self.clb_id = 12345

        success_treqs = [
            # All of these particular immutable states count as success.
            self.get_fake_treq_for_delete(
                Response(200, strbody=json.dumps(
                    {"loadBalancer": {"status": state}})),
                del_response=Response(400))
            for state in ("PENDING_DELETE", "DELETED", "ERROR", "SUSPENDED")
        ] + [
            # 404 from get-ting the server, meaning it's already gone.
            self.get_fake_treq_for_delete(
                Response(404, strbody=(
                    '{"message": "No such load balancer", "code": 404}')),
                del_response=Response(400))
        ]

        for success_treq in success_treqs:
            clock = Clock()
            _treq = self.get_fake_treq_for_delete(
                Response(
                    200,
                    strbody='{"loadBalancer": {"status": "PENDING_UPDATE"}}'),
                del_response=Response(400))

            clb = CloudLoadBalancer(pool=self.pool, treq=_treq)
            clb.clb_id = self.clb_id

            d = clb.delete(self.rcs, clock=clock)

            self.assertNoResult(d)
            clock.pump([3])
            self.assertNoResult(d)

            clb.treq = success_treq
            clock.pump([3])
            self.assertEqual(self.successResultOf(d), None)
Esempio n. 4
0
    def test_delete_clb_retries_until_success(self):
        """
        Deleting a CLB will retry until the CLB is deleted (or in error or
        suspended mode, in which case it will give up).
        """
        self.clb_id = 12345

        success_treqs = [
            # All of these particular immutable states count as success.
            self.get_fake_treq_for_delete(Response(
                200, strbody=json.dumps({"loadBalancer": {
                    "status": state
                }})),
                                          del_response=Response(400))
            for state in ("PENDING_DELETE", "DELETED", "ERROR", "SUSPENDED")
        ] + [
            # 404 from get-ting the server, meaning it's already gone.
            self.get_fake_treq_for_delete(Response(
                404,
                strbody=('{"message": "No such load balancer", "code": 404}')),
                                          del_response=Response(400))
        ]

        for success_treq in success_treqs:
            clock = Clock()
            _treq = self.get_fake_treq_for_delete(Response(
                200, strbody='{"loadBalancer": {"status": "PENDING_UPDATE"}}'),
                                                  del_response=Response(400))

            clb = CloudLoadBalancer(pool=self.pool, treq=_treq)
            clb.clb_id = self.clb_id

            d = clb.delete(self.rcs, clock=clock)

            self.assertNoResult(d)
            clock.pump([3])
            self.assertNoResult(d)

            clb.treq = success_treq
            clock.pump([3])
            self.assertEqual(self.successResultOf(d), None)
Esempio n. 5
0
    def test_delete_clb_retries_until_timeout(self):
        """
        Deleting a CLB will retry if the state wonky until it times out.
        """
        clock = Clock()
        self.clb_id = 12345
        _treq = self.get_fake_treq_for_delete(Response(
            200, strbody='{"loadBalancer": {"status": "PENDING_UPDATE"}}'),
                                              del_response=Response(400))

        clb = CloudLoadBalancer(pool=self.pool, treq=_treq)
        clb.clb_id = self.clb_id
        d = clb.delete(self.rcs, clock=clock)
        self.assertNoResult(d)

        timeout = 60
        for _ in range((timeout - 1) / 3):
            clock.pump([3])
            self.assertNoResult(d)

        clock.pump([3])
        self.failureResultOf(d, TimedOutError)
    def test_delete_clb_retries_until_timeout(self):
        """
        Deleting a CLB will retry if the state wonky until it times out.
        """
        clock = Clock()
        self.clb_id = 12345
        _treq = self.get_fake_treq_for_delete(
            Response(
                200,
                strbody='{"loadBalancer": {"status": "PENDING_UPDATE"}}'),
            del_response=Response(400))

        clb = CloudLoadBalancer(pool=self.pool, treq=_treq)
        clb.clb_id = self.clb_id
        d = clb.delete(self.rcs, clock=clock)
        self.assertNoResult(d)

        timeout = 60
        for _ in range((timeout - 1) / 3):
            clock.pump([3])
            self.assertNoResult(d)

        clock.pump([3])
        self.failureResultOf(d, TimedOutError)