Example #1
0
    def test_bugzilla_resolution_with_archive_false(self):
        experiment = ExperimentFactory.create_with_status(
            Experiment.STATUS_DRAFT,
            name="An Experiment",
            bugzilla_id="123",
            type=Experiment.TYPE_PREF,
            archived=False,
        )

        update_bug_resolution(experiment)

        self.mock_bugzilla_requests_put.assert_called_with(
            settings.BUGZILLA_UPDATE_URL.format(id=experiment.bugzilla_id),
            {"status": "REOPENED"},
        )
Example #2
0
def update_status(experiment):
    recipe_data = normandy.get_recipe(experiment.normandy_id)

    if needs_to_be_updated(recipe_data, experiment.status):
        logger.info("Updating experiment Status")
        # set email default if no email/creator is found in normandy
        enabler_email = settings.NORMANDY_DEFAULT_CHANGELOG_USER

        enabled_states = recipe_data.get("enabled_states", [])
        if len(enabled_states) > 0:
            creator = enabled_states[0].get("creator")
            if creator:
                enabler_email = creator.get("email")

        enabler, _ = get_user_model().objects.get_or_create(
            email=enabler_email)

        old_status = experiment.status
        new_status = STATUS_UPDATE_MAPPING[old_status]
        experiment.status = new_status
        with transaction.atomic():
            experiment.save()

            experiment.changes.create(
                changed_by=enabler,
                old_status=old_status,
                new_status=new_status,
            )
            metrics.incr("update_experiment_info.updated")
            logger.info("Finished updating Experiment: {}".format(experiment))

        if experiment.status == Experiment.STATUS_LIVE:
            add_start_date_comment(experiment)
            email.send_experiment_launch_email(experiment)
            logger.info(
                "Sent launch email for Experiment: {}".format(experiment))

        if experiment.status == Experiment.STATUS_COMPLETE:
            bugzilla.update_bug_resolution(experiment)

    if recipe_data:
        paused_val = is_paused(recipe_data)
        if paused_val != experiment.is_paused:
            with transaction.atomic():
                experiment.is_paused = paused_val
                experiment.save()
Example #3
0
def update_bug_resolution_task(user_id, experiment_id):
    metrics.incr("update_bug_resolution.started")
    experiment = Experiment.objects.get(id=experiment_id)

    if (
        experiment.status == experiment.STATUS_COMPLETE
        or experiment.bugzilla_id is None
    ):
        logger.info(
            "Skipping update either experiment complete or no bugzilla ticket"
        )
        return

    logger.info("Updating Bugzilla Resolution")

    try:
        bugzilla.update_bug_resolution(experiment)
        logger.info("Bugzilla resolution updated")
        Notification.objects.create(
            user_id=user_id,
            message=NOTIFICATION_MESSAGE_ARCHIVE_COMMENT.format(
                bug_url=experiment.bugzilla_url
            ),
        )
        metrics.incr("update_bug_resolution.completed")
        logger.info("Bugzilla resolution update sent")
    except bugzilla.BugzillaError as e:
        metrics.incr("update_bug_resolution.failed")
        logger.info("Failed to update resolution of bugzilla ticket")
        Notification.objects.create(
            user_id=user_id,
            message=NOTIFICATION_MESSAGE_ARCHIVE_ERROR_MESSAGE.format(
                bug_url=experiment.bugzilla_url
            ),
        )
        raise e