Exemplo n.º 1
0
    def test_launching_experiment_live_when_record_is_in_main(self):
        launching_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_get_main_records([launching_experiment.slug])
        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP)

        launching_experiment = NimbusExperiment.objects.get(
            id=launching_experiment.id)
        self.assertEqual(launching_experiment.status,
                         NimbusExperiment.Status.LIVE)
        self.assertIsNone(launching_experiment.status_next)
        self.assertEqual(launching_experiment.publish_status,
                         NimbusExperiment.PublishStatus.IDLE)
        self.assertEqual(launching_experiment.published_dto,
                         {"id": launching_experiment.slug})

        self.assertTrue(
            launching_experiment.changes.filter(
                changed_by__email=settings.KINTO_DEFAULT_CHANGELOG_USER,
                old_status=NimbusExperiment.Status.DRAFT,
                old_publish_status=NimbusExperiment.PublishStatus.WAITING,
                new_status=NimbusExperiment.Status.LIVE,
                new_publish_status=NimbusExperiment.PublishStatus.IDLE,
            ).exists())
Exemplo n.º 2
0
    def test_ending_experiment_completed_when_record_is_not_in_main(self):
        experiment1 = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )
        experiment2 = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.ENDING_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_get_main_records([experiment1.slug])
        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP)

        self.assertTrue(
            experiment2.changes.filter(
                changed_by__email=settings.KINTO_DEFAULT_CHANGELOG_USER,
                old_status=NimbusExperiment.Status.LIVE,
                old_publish_status=NimbusExperiment.PublishStatus.WAITING,
                new_status=NimbusExperiment.Status.COMPLETE,
                new_publish_status=NimbusExperiment.PublishStatus.IDLE,
                message=NimbusChangeLog.Messages.COMPLETED,
            ).exists())
Exemplo n.º 3
0
    def test_check_with_no_approved_publish_status_pushes_nothing(self):
        for lifecycle in [
            NimbusExperimentFactory.Lifecycles.CREATED,
            NimbusExperimentFactory.Lifecycles.LAUNCH_REVIEW_REQUESTED,
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_WAITING,
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_APPROVE,
            NimbusExperimentFactory.Lifecycles.PAUSING_REVIEW_REQUESTED,
            NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_WAITING,
            NimbusExperimentFactory.Lifecycles.ENDING_REVIEW_REQUESTED,
            NimbusExperimentFactory.Lifecycles.ENDING_APPROVE_WAITING,
        ]:
            NimbusExperimentFactory.create_with_lifecycle(
                lifecycle,
                application=NimbusExperiment.Application.DESKTOP,
            )

        self.setup_kinto_get_main_records([])
        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP
        )
        self.mock_kinto_client.patch_collection.assert_not_called()
        self.mock_push_task.assert_not_called()
        self.mock_update_task.assert_not_called()
        self.mock_end_task.assert_not_called()
Exemplo n.º 4
0
    def test_check_waiting_experiment_with_signed_collection_becomes_rejection(
            self):
        waiting_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_get_main_records([])
        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP)

        waiting_experiment = NimbusExperiment.objects.get(
            id=waiting_experiment.id)
        self.assertEqual(waiting_experiment.status,
                         NimbusExperiment.Status.DRAFT)
        self.assertIsNone(waiting_experiment.status_next)
        self.assertEqual(waiting_experiment.publish_status,
                         NimbusExperiment.PublishStatus.IDLE)
        self.assertTrue(
            waiting_experiment.changes.filter(
                changed_by__email=settings.KINTO_DEFAULT_CHANGELOG_USER,
                old_status=NimbusExperiment.Status.DRAFT,
                old_publish_status=NimbusExperiment.PublishStatus.WAITING,
                new_status=NimbusExperiment.Status.DRAFT,
                new_publish_status=NimbusExperiment.PublishStatus.IDLE,
                message=NimbusChangeLog.Messages.REJECTED_FROM_KINTO,
            ).exists())
Exemplo n.º 5
0
    def test_check_with_approved_update_sets_experiment_to_idle_saves_published_dto(self):
        updated_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
            published_dto=None,
        )

        self.setup_kinto_get_main_records([updated_experiment.slug])
        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP
        )

        updated_experiment = NimbusExperiment.objects.get(id=updated_experiment.id)
        self.assertEqual(updated_experiment.status, NimbusExperiment.Status.LIVE)
        self.assertIsNone(updated_experiment.status_next)
        self.assertEqual(
            updated_experiment.publish_status, NimbusExperiment.PublishStatus.IDLE
        )
        self.assertEqual(
            updated_experiment.published_dto, {"id": updated_experiment.slug}
        )
        self.assertTrue(
            updated_experiment.changes.filter(
                changed_by__email=settings.KINTO_DEFAULT_CHANGELOG_USER,
                old_status=NimbusExperiment.Status.LIVE,
                old_publish_status=NimbusExperiment.PublishStatus.WAITING,
                new_status=NimbusExperiment.Status.LIVE,
                new_publish_status=NimbusExperiment.PublishStatus.IDLE,
            ).exists()
        )
Exemplo n.º 6
0
 def test_check_with_empty_queue_pushes_nothing(self):
     self.setup_kinto_no_pending_review()
     tasks.nimbus_check_kinto_push_queue_by_collection(
         settings.KINTO_COLLECTION_NIMBUS_DESKTOP
     )
     self.mock_kinto_client.patch_collection.assert_not_called()
     self.mock_push_task.assert_not_called()
     self.mock_update_task.assert_not_called()
     self.mock_end_task.assert_not_called()
Exemplo n.º 7
0
    def test_check_with_approved_end_and_no_kinto_pending_ends_experiment(
            self):
        ending_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.ENDING_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_get_main_records([])
        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP)
        self.mock_end_task.assert_called_with(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, ending_experiment.id)
Exemplo n.º 8
0
    def test_check_with_pending_review_before_timeout_aborts_early(self, ):
        NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_get_main_records([])
        self.setup_kinto_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP)
        self.mock_kinto_client.patch_collection.assert_not_called()
        self.mock_push_task.assert_not_called()
        self.mock_update_task.assert_not_called()
        self.mock_end_task.assert_not_called()
Exemplo n.º 9
0
    def test_check_with_approved_update_and_no_kinto_pending_updates_experiment(
        self,
    ):
        launching_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_no_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP
        )
        self.mock_update_task.assert_called_with(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, launching_experiment.id
        )
Exemplo n.º 10
0
    def test_check_with_rejected_update_rolls_back_and_pushes(self):
        rejected_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.PAUSING_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
        )
        launching_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_rejected_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP
        )

        self.mock_push_task.assert_called_with(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, launching_experiment.id
        )
        self.mock_kinto_client.patch_collection.assert_called_with(
            id=settings.KINTO_COLLECTION_NIMBUS_DESKTOP,
            bucket=settings.KINTO_BUCKET_WORKSPACE,
            data={"status": KINTO_ROLLBACK_STATUS},
        )

        rejected_experiment = NimbusExperiment.objects.get(id=rejected_experiment.id)
        self.assertEqual(rejected_experiment.status, NimbusExperiment.Status.LIVE)
        self.assertEqual(
            rejected_experiment.publish_status, NimbusExperiment.PublishStatus.IDLE
        )
        self.assertIsNone(rejected_experiment.status_next)
        self.assertFalse(rejected_experiment.is_paused)

        self.assertTrue(
            rejected_experiment.changes.filter(
                changed_by__email=settings.KINTO_DEFAULT_CHANGELOG_USER,
                old_status=NimbusExperiment.Status.LIVE,
                old_publish_status=NimbusExperiment.PublishStatus.WAITING,
                new_status=NimbusExperiment.Status.LIVE,
                new_publish_status=NimbusExperiment.PublishStatus.IDLE,
            ).exists()
        )
Exemplo n.º 11
0
    def test_check_with_missing_rejection_and_queued_launch_rolls_back_and_pushes(
            self):
        launching_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_get_main_records([])
        self.setup_kinto_rejected_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP)

        self.mock_push_task.assert_called_with(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, launching_experiment.id)
        self.mock_kinto_client.patch_collection.assert_called_with(
            id=settings.KINTO_COLLECTION_NIMBUS_DESKTOP,
            data={"status": "to-rollback"},
            bucket="main-workspace",
        )
Exemplo n.º 12
0
    def test_check_with_timeout_end_review_and_queued_launch_rolls_back_and_pushes(
        self,
    ):
        pending_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.ENDING_APPROVE_WAITING,
            application=NimbusExperiment.Application.DESKTOP,
        )
        launching_experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        self.setup_kinto_pending_review()

        tasks.nimbus_check_kinto_push_queue_by_collection(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP
        )

        self.mock_push_task.assert_called_with(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, launching_experiment.id
        )
        self.mock_kinto_client.patch_collection.assert_called_with(
            id=settings.KINTO_COLLECTION_NIMBUS_DESKTOP,
            data={"status": "to-rollback"},
            bucket="main-workspace",
        )

        pending_experiment = NimbusExperiment.objects.get(id=pending_experiment.id)
        self.assertEqual(
            pending_experiment.publish_status, NimbusExperiment.PublishStatus.REVIEW
        )
        self.assertTrue(
            pending_experiment.changes.filter(
                old_status=NimbusExperiment.Status.LIVE,
                old_publish_status=NimbusExperiment.PublishStatus.WAITING,
                new_status=NimbusExperiment.Status.LIVE,
                new_publish_status=NimbusExperiment.PublishStatus.REVIEW,
            ).exists()
        )