Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed data science bugzilla stuff with jira #2316

Merged
merged 14 commits into from
Mar 9, 2020
1 change: 1 addition & 0 deletions .env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DB_PASS=postgres
DB_USER=postgres
DEBUG=True
DELIVERY_CONSOLE_HOST=
DS_ISSUE_HOST=https://jira.mozilla.com/browse/
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
EMAIL_HOST=
EMAIL_HOST_PASSWORD=
Expand Down
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DB_PASS=postgres
DB_USER=postgres
DEBUG=True
DELIVERY_CONSOLE_HOST=
DS_ISSUE_HOST=https://jira.mozilla.com/browse/
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
EMAIL_HOST=
EMAIL_HOST_PASSWORD=
Expand Down
11 changes: 5 additions & 6 deletions app/experimenter/bugzilla/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,14 @@ def format_summary(experiment):


def create_experiment_bug(experiment):
assigned_to, see_also, blocks = None, None, None
assigned_to, blocks = None, None

if user_exists(experiment.owner.email):
assigned_to = experiment.owner.email

see_also = set_bugzilla_id_value(experiment.data_science_bugzilla_url)
blocks = set_bugzilla_id_value(experiment.feature_bugzilla_url)

extra_fields = {"assigned_to": assigned_to, "see_also": see_also, "blocks": blocks}
extra_fields = {"assigned_to": assigned_to, "blocks": blocks}

bug_data = format_creation_bug_body(experiment, extra_fields)
response_data = make_bugzilla_call(
Expand All @@ -195,9 +194,9 @@ def get_bugzilla_id(bug_url):


def set_bugzilla_id_value(bug_url):
data_science_bug_id = get_bugzilla_id(bug_url)
if data_science_bug_id and bug_exists(data_science_bug_id):
return [data_science_bug_id]
bug_id = get_bugzilla_id(bug_url)
if bug_id and bug_exists(bug_id):
return [bug_id]


def add_experiment_comment(bugzilla_id, comment):
Expand Down
42 changes: 1 addition & 41 deletions app/experimenter/bugzilla/tests/test_bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def test_creating_pref_bugzilla_ticket_returns_ticket_id(self):
"type": "task",
"priority": "P3",
"assigned_to": experiment.owner.email,
"see_also": [12345],
"blocks": [12345],
"url": experiment.experiment_url,
},
Expand All @@ -75,7 +74,6 @@ def test_create_bugzilla_ticket_creation_with_bad_assigned_to_val(self):
self.mock_bugzilla_requests_get.side_effect = [
self.buildMockFailureResponse(),
self.buildMockSuccessBugResponse(),
self.buildMockSuccessBugResponse(),
]

response_data = create_experiment_bug(experiment)
Expand All @@ -94,7 +92,6 @@ def test_create_bugzilla_ticket_creation_with_bad_assigned_to_val(self):
"type": "task",
"priority": "P3",
"assigned_to": None,
"see_also": [12345],
"blocks": [12345],
"url": experiment.experiment_url,
}
Expand All @@ -103,51 +100,15 @@ def test_create_bugzilla_ticket_creation_with_bad_assigned_to_val(self):
settings.BUGZILLA_CREATE_URL, expected_call_data
)

def test_create_bugzilla_ticket_creation_with_see_also_bad_val(self):
experiment = ExperimentFactory.create_with_status(
Experiment.STATUS_DRAFT, name="An Experiment"
)

self.mock_bugzilla_requests_get.side_effect = [
self.buildMockSuccessUserResponse(),
self.buildMockFailureResponse(),
self.buildMockSuccessBugResponse(),
]

response_data = create_experiment_bug(experiment)

self.assertEqual(response_data, self.bugzilla_id)

expected_call_data = {
"product": "Shield",
"component": "Shield Study",
"version": "unspecified",
"summary": "[Experiment]: {experiment}".format(experiment=experiment),
"description": experiment.BUGZILLA_OVERVIEW_TEMPLATE.format(
experiment=experiment
),
"assigned_to": experiment.owner.email,
"cc": settings.BUGZILLA_CC_LIST,
"type": "task",
"priority": "P3",
"url": experiment.experiment_url,
"see_also": None,
"blocks": [12345],
}

self.mock_bugzilla_requests_post.assert_called_with(
settings.BUGZILLA_CREATE_URL, expected_call_data
)

def test_create_bugzilla_ticket_creation_with_blocks_bad_val(self):
experiment = ExperimentFactory.create_with_status(
Experiment.STATUS_DRAFT, name="An Experiment"
)

self.mock_bugzilla_requests_get.side_effect = [
self.buildMockSuccessUserResponse(),
self.buildMockSuccessBugResponse(),
self.buildMockFailureResponse(),
self.buildMockSuccessResponse(),
]

response_data = create_experiment_bug(experiment)
Expand All @@ -167,7 +128,6 @@ def test_create_bugzilla_ticket_creation_with_blocks_bad_val(self):
"type": "task",
"priority": "P3",
"url": experiment.experiment_url,
"see_also": [12345],
"blocks": None,
}

Expand Down
2 changes: 1 addition & 1 deletion app/experimenter/experiments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ExperimentAdmin(admin.ModelAdmin):
"normandy_slug",
"normandy_id",
"other_normandy_ids",
"data_science_bugzilla_url",
"data_science_issue_url",
"feature_bugzilla_url",
"related_work",
"is_paused",
Expand Down
14 changes: 6 additions & 8 deletions app/experimenter/experiments/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,24 +350,21 @@ class ExperimentConstants(object):
</p>
"""

DATA_SCIENCE_BUGZILLA_HELP_TEXT = """
DATA_SCIENCE_ISSUE_HELP_TEXT = """
<p>
Provide a link to the Bugzilla ticket that was filed with the Data
Provide a link to the ticket that was filed with the Data
Science team that tracks this delivery. If you have not already
filed a ticket with Data Science, you can do that <a
target="_blank" rel="noreferrer noopener"
href="{url}">here</a>.
</p>
<p>
<strong>Example:</strong>
{bugzilla_host}show_bug.cgi?id=12345
{ds_issue_host}DO-352
</p>
""".format(
url=(
"https://mana.mozilla.org/wiki/display/PM/Mozilla+Data+Science"
"#MozillaDataScience-dsflagshipprograms2019"
),
bugzilla_host=settings.BUGZILLA_HOST,
url=("https://mana.mozilla.org/wiki/display/PM/Data+Science+Jira+documentation"),
ds_issue_host=settings.DS_ISSUE_HOST,
)

FEATURE_BUGZILLA_HELP_TEXT = """
Expand Down Expand Up @@ -935,6 +932,7 @@ class ExperimentConstants(object):

Experimenter is the source of truth for details and delivery. Changes to Bugzilla are not reflected in Experimenter and will not change delivery configuration.

Data Science Issue: {experiment.data_science_issue_url}
More information: {experiment.experiment_url}
""" # noqa

Expand Down
2 changes: 1 addition & 1 deletion app/experimenter/experiments/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def filter_search(self, queryset, name, value):
"engineering_owner",
"bugzilla_id",
"normandy_slug",
"data_science_bugzilla_url",
"data_science_issue_url",
"feature_bugzilla_url",
)

Expand Down
32 changes: 24 additions & 8 deletions app/experimenter/experiments/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import decimal
import json
import re

from django import forms
from django.conf import settings
Expand Down Expand Up @@ -35,6 +36,24 @@ def clean(self, value):
return cleaned_value


class DSIssueURLField(forms.URLField):

def clean(self, value):
cleaned_value = super().clean(value)

if cleaned_value:
err_str = "Please Provide a Valid URL ex: {ds_url}DS-123 or {ds_url}DO-123"

ds = re.match(
re.escape(settings.DS_ISSUE_HOST) + r"(DS|DO)-(\w+.*)", cleaned_value
)

if ds is None:

raise forms.ValidationError(err_str.format(ds_url=settings.DS_ISSUE_HOST))
return cleaned_value


class BugzillaURLField(forms.URLField):

def clean(self, value):
Expand Down Expand Up @@ -112,10 +131,10 @@ class ExperimentOverviewForm(ChangeLogMixin, forms.ModelForm):
help_text=Experiment.PUBLIC_DESCRIPTION_HELP_TEXT,
widget=forms.Textarea(attrs={"rows": 3}),
)
data_science_bugzilla_url = BugzillaURLField(
data_science_issue_url = DSIssueURLField(
required=False,
label="Data Science Bugzilla URL",
help_text=Experiment.DATA_SCIENCE_BUGZILLA_HELP_TEXT,
label="Data Science Issue URL",
help_text=Experiment.DATA_SCIENCE_ISSUE_HELP_TEXT,
)
engineering_owner = forms.CharField(
required=False,
Expand Down Expand Up @@ -160,7 +179,7 @@ class Meta:
"short_description",
"public_name",
"public_description",
"data_science_bugzilla_url",
"data_science_issue_url",
"analysis_owner",
"engineering_owner",
"feature_bugzilla_url",
Expand Down Expand Up @@ -200,7 +219,7 @@ def clean(self):
if cleaned_data["type"] != ExperimentConstants.TYPE_ROLLOUT:
required_msg = "This field is required."
required_fields = (
"data_science_bugzilla_url",
"data_science_issue_url",
"public_name",
"public_description",
)
Expand Down Expand Up @@ -971,7 +990,6 @@ def save(self, *args, **kwargs):
):

tasks.create_experiment_bug_task.delay(self.request.user.id, experiment.id)
tasks.update_exp_id_to_ds_bug_task.delay(self.request.user.id, experiment.id)

if (
self.old_status == Experiment.STATUS_REVIEW
Expand All @@ -984,8 +1002,6 @@ def save(self, *args, **kwargs):

tasks.update_experiment_bug_task.delay(self.request.user.id, experiment.id)

tasks.update_ds_bug_task.delay(experiment.id)

return experiment


Expand Down
16 changes: 16 additions & 0 deletions app/experimenter/experiments/migrations/0082_auto_20200225_1924.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.0.3 on 2020-02-25 19:24

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [("experiments", "0081_remove_experiment_risk_internal_only")]

operations = [
migrations.RenameField(
model_name="experiment",
old_name="data_science_bugzilla_url",
new_name="data_science_issue_url",
)
]
4 changes: 2 additions & 2 deletions app/experimenter/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Experiment(ExperimentConstants, models.Model):
normandy_id = models.PositiveIntegerField(blank=True, null=True)
other_normandy_ids = ArrayField(models.IntegerField(), blank=True, null=True)

data_science_bugzilla_url = models.URLField(blank=True, null=True)
data_science_issue_url = models.URLField(blank=True, null=True)
feature_bugzilla_url = models.URLField(blank=True, null=True)

# Risk fields
Expand Down Expand Up @@ -367,7 +367,7 @@ def has_external_urls(self):
return (
self.bugzilla_url
or self.monitoring_dashboard_url
or self.data_science_bugzilla_url
or self.data_science_issue_url
or self.feature_bugzilla_url
)

Expand Down
2 changes: 1 addition & 1 deletion app/experimenter/experiments/serializers/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Meta:
"bugzilla_id",
"normandy_slug",
"normandy_id",
"data_science_bugzilla_url",
"data_science_issue_url",
"feature_bugzilla_url",
"risk_partner_related",
"risk_brand",
Expand Down
Loading