Example #1
0
    def test_wait_for_deployment_hard_fail(self, mock_sleep, boto_factory, doctor_factory):
        rev = "000000"
        mock_elb = MagicMock()
        boto_factory.client.return_value = mock_elb
        mock_doctor = MagicMock(spec=ServiceDoctor)
        mock_doctor.db = MagicMock()
        mock_doctor.db.get_service.return_value = {rev: 1}
        mock_doctor.is_healthy_revision.side_effect = [False, ValueError("Hard fail")]
        doctor_factory.return_value = mock_doctor
        dynamo_cache = {region: MagicMock() for region in REGIONS}

        wait_for_deployment(dynamo_cache, REGIONS, SERVICE, rev, 0.001)

        mock_doctor.db.make_only_revision.assert_not_called()
        mock_doctor.db.set_services.assert_called_with(ANY)
Example #2
0
    def test_wait_for_deployment(self, mock_sleep, boto_factory, doctor_factory):
        mock_elb = MagicMock()
        boto_factory.client.return_value = mock_elb
        mock_doctor = MagicMock(spec=ServiceDoctor)
        mock_doctor.db = MagicMock()
        mock_doctor.is_healthy_revision.side_effect = [False, False, True]
        doctor_factory.return_value = mock_doctor
        dynamo_cache = {region: MagicMock() for region in REGIONS}
        rev = "000000"

        wait_for_deployment(dynamo_cache, REGIONS, SERVICE, rev, 1)

        self.assertEqual(2, mock_sleep.call_count)
        mock_doctor.db.make_only_revision.assert_called_with(SERVICE, rev)
        mock_doctor.db.set_services.assert_not_called()
Example #3
0
    def test_wait_for_deployment_timeout(self, mock_sleep, boto_factory,
                                         doctor_factory):
        rev = '000000'
        mock_elb = MagicMock()
        boto_factory.client.return_value = mock_elb
        mock_doctor = MagicMock(spec=ServiceDoctor)
        mock_doctor.db = MagicMock()
        mock_doctor.db.get_service.return_value = {rev: 1}
        mock_doctor.is_healthy_revision.return_value = False
        doctor_factory.return_value = mock_doctor
        dynamo_cache = {region: MagicMock() for region in REGIONS}

        wait_for_deployment(dynamo_cache, REGIONS, SERVICE, rev, 0.001)

        mock_doctor.db.make_only_revision.assert_not_called()
        mock_doctor.db.set_services.assert_called_with(ANY)
Example #4
0
    def test_wait_for_deployment(self, mock_sleep, boto_factory,
                                 doctor_factory):
        mock_elb = MagicMock()
        boto_factory.client.return_value = mock_elb
        mock_doctor = MagicMock(spec=ServiceDoctor)
        mock_doctor.db = MagicMock()
        mock_doctor.is_healthy_revision.side_effect = [False, False, True]
        doctor_factory.return_value = mock_doctor
        dynamo_cache = {region: MagicMock() for region in REGIONS}
        rev = '000000'

        wait_for_deployment(dynamo_cache, REGIONS, SERVICE, rev, 1)

        self.assertEqual(2, mock_sleep.call_count)
        mock_doctor.db.make_only_revision.assert_called_with(SERVICE, rev)
        mock_doctor.db.set_services.assert_not_called()