Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion experimenter/experimenter/kinto/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def __init__(self, collection, review=True):
)
self.review = review
self.collection_data = None
self.read_bucket = (
settings.KINTO_BUCKET_WORKSPACE if not review else settings.KINTO_BUCKET_MAIN
)

def _fetch_collection_data(self):
self.collection_data = (
Expand Down Expand Up @@ -94,6 +97,6 @@ def get_main_records(self):
return {
r["id"]: r
for r in self.kinto_http_client.get_records(
bucket=settings.KINTO_BUCKET_MAIN, collection=self.collection
bucket=self.read_bucket, collection=self.collection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh @b4handjr I think should make changes for local environment only so that we don't break the prod and stage, you can add a check and change the bucket accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I technically didn't break any tests... 🤐

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but test doesn't include our stage and prod, I am just worried about that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh @yashikakhurana I don't think this changes which environment it goes to, it's just whether it's in the main or main-workspace collections in the local test kinto 🙏

)
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
{% endif %}
{% if experiment.can_preview_to_draft %}
<button type="button"
id="back-to-draft-button"
class="btn btn-secondary"
hx-post="{% url 'nimbus-ui-preview-to-draft' slug=experiment.slug %}"
hx-select="#content"
Expand Down
9 changes: 5 additions & 4 deletions experimenter/tests/integration/nimbus/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ def _verify_url(request, base_url):

@pytest.fixture
def kinto_client(default_data):
kinto_url = os.getenv("INTEGRATION_TEST_KINTO_URL", "http://kinto:8888/v1")
return KintoClient(
APPLICATION_KINTO_COLLECTION[default_data.application], server_url=kinto_url
)
def _kinto_client(collection=APPLICATION_KINTO_COLLECTION[default_data.application]):
kinto_url = os.getenv("INTEGRATION_TEST_KINTO_URL", "http://kinto:8888/v1")
return KintoClient(collection=collection, server_url=kinto_url)

return _kinto_client


@pytest.fixture
Expand Down
6 changes: 6 additions & 0 deletions experimenter/tests/integration/nimbus/kinto/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
KINTO_COLLECTION_DESKTOP = "nimbus-desktop-experiments"
KINTO_COLLECTION_MOBILE = "nimbus-mobile-experiments"
KINTO_COLLECTION_WEB = "nimbus-web-experiments"
KINTO_COLLECTION_PREVIEW = "nimbus-preview"
KINTO_BUCKET_WORKSPACE = "main-workspace"
KINTO_REVIEW_STATUS = "to-review"
KINTO_REJECTED_STATUS = "work-in-progress"
Expand Down Expand Up @@ -64,3 +65,8 @@ def reject(self):
return
time.sleep(2)
raise Exception("Unable to reject kinto review")

def get_record_data(self):
return self.kinto_http_client.get_records(
collection=self.collection, bucket=KINTO_BUCKET_WORKSPACE
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SummaryPage(ExperimenterBase):

_page_wait_locator = (By.CSS_SELECTOR, "#PageSummary")
_promote_rollout_locator = (By.CSS_SELECTOR, 'button[data-testid="promote-rollout"]')
_back_to_draft_locator = (By.CSS_SELECTOR, "#back-to-draft-button")
_header_slug = (By.CSS_SELECTOR, "#experiment-slug")
_approve_request_button_locator = (By.CSS_SELECTOR, "#review-controls .btn-success")
_reject_request_button_locator = (By.CSS_SELECTOR, "#reject-button")
Expand Down Expand Up @@ -200,6 +201,11 @@ def launch_to_preview(self):
self.wait_for_and_find_element(*self._launch_to_preview_locator).click()
return self

def back_to_draft(self):
self.wait_for_and_find_element(*self._back_to_draft_locator).click()
self.wait_for_and_find_element(*self._launch_to_preview_locator)
return self

@property
def request_review(self):
return self.RequestReview(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_check_telemetry_enrollment_unenrollment(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
Expand All @@ -97,7 +97,7 @@ def test_check_telemetry_enrollment_unenrollment(
# unenroll
summary = SummaryPage(selenium, experiment_url).open()
summary.end_and_approve()
kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_complete_status()

Expand Down Expand Up @@ -146,7 +146,7 @@ def test_check_telemetry_pref_flip(
)
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()
kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()

Expand All @@ -165,7 +165,7 @@ def test_check_telemetry_pref_flip(
# unenroll
summary = SummaryPage(selenium, experiment_url).open()
summary.end_and_approve()
kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_complete_status()

Expand Down Expand Up @@ -218,7 +218,7 @@ def test_check_telemetry_sticky_targeting(
)
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()
kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()

Expand Down Expand Up @@ -248,7 +248,7 @@ def test_check_telemetry_sticky_targeting(
# unenroll
summary = SummaryPage(selenium, experiment_url).open()
summary.end_and_approve()
kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_complete_status()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_first_run_release_date_visible_for_mobile(

summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
Expand All @@ -150,7 +150,7 @@ def test_first_run_release_date_not_visible_for_non_mobile(
audience.wait_until_first_run_not_found()
summary = audience.navigate_to_summary()
summary.launch_and_approve()
kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
summary.wait_for_timeline_visible()
Expand Down
74 changes: 57 additions & 17 deletions experimenter/tests/integration/nimbus/test_remote_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

import pytest

from nimbus.pages.experimenter.home import HomePage
Expand All @@ -20,7 +22,7 @@ def test_create_new_experiment_approve_remote_settings(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

SummaryPage(selenium, experiment_url).open().wait_for_live_status()

Expand All @@ -44,7 +46,7 @@ def test_create_new_rollout_approve_remote_settings(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

SummaryPage(selenium, experiment_url).open().wait_for_live_status()

Expand All @@ -65,7 +67,7 @@ def test_create_new_experiment_reject_remote_settings(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.reject()
kinto_client().reject()

SummaryPage(selenium, experiment_url).open().wait_for_rejected_alert()

Expand All @@ -86,7 +88,7 @@ def test_create_new_rollout_reject_remote_settings(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.reject()
kinto_client().reject()

SummaryPage(selenium, experiment_url).open().wait_for_rejected_alert()

Expand All @@ -105,13 +107,13 @@ def test_end_experiment_and_approve_end_set_takeaways(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
summary.end_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_complete_status()
Expand Down Expand Up @@ -139,13 +141,13 @@ def test_end_rollout_and_approve_end_set_takeaways(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
summary.end_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_complete_status()
Expand All @@ -171,13 +173,13 @@ def test_end_experiment_and_reject_end(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
summary.end_and_approve()

kinto_client.reject()
kinto_client().reject()

SummaryPage(selenium, experiment_url).open().wait_for_rejected_alert()

Expand All @@ -198,13 +200,13 @@ def test_end_rollout_and_reject_end(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()

summary = SummaryPage(selenium, experiment_url).open()
summary.wait_for_live_status()
summary.end_and_approve()

kinto_client.reject()
kinto_client().reject()

SummaryPage(selenium, experiment_url).open().wait_for_rejected_alert()

Expand All @@ -225,7 +227,7 @@ def test_rollout_live_update_approve(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()

summary.wait_for_live_status()
Expand All @@ -236,7 +238,7 @@ def test_rollout_live_update_approve(

summary.wait_for_update_request_visible()
summary.request_update_and_approve()
kinto_client.approve()
kinto_client().approve()


@pytest.mark.remote_settings_all
Expand All @@ -255,7 +257,7 @@ def test_rollout_live_update_approve_and_reject(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()

summary.wait_for_live_status()
Expand All @@ -267,7 +269,7 @@ def test_rollout_live_update_approve_and_reject(
summary.wait_for_update_request_visible()

summary.request_update_and_approve()
kinto_client.reject()
kinto_client().reject()

summary.wait_for_rejection_notice_visible()

Expand All @@ -288,7 +290,7 @@ def test_rollout_live_update_reject_on_experimenter(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()

kinto_client.approve()
kinto_client().approve()
summary = SummaryPage(selenium, experiment_url).open()

summary.wait_for_live_status()
Expand Down Expand Up @@ -320,3 +322,41 @@ def test_create_new_experiment_timeout_remote_settings(
summary = SummaryPage(selenium, experiment_url).open()
summary.launch_and_approve()
summary.wait_for_timeout_alert()


@pytest.mark.remote_settings_launch
def test_create_new_experiment_publish_to_preview_and_unpublish(
selenium,
experiment_url,
kinto_client,
base_url,
application,
default_data_api,
experiment_slug,
):
timeout = time.time() + 120
records_before = len(kinto_client(collection="nimbus-preview").get_record_data())

helpers.create_experiment(experiment_slug, application, default_data_api)

summary = SummaryPage(selenium, experiment_url).open()
summary.launch_to_preview()

while time.time() < timeout:
preview_data = kinto_client(collection="nimbus-preview").get_record_data()
if any(record.get("slug") == experiment_slug for record in preview_data):
break
time.sleep(15)
else:
pytest.fail("Experiment not published to preview in time")

summary = SummaryPage(selenium, experiment_url).open()
summary.back_to_draft()

while time.time() < timeout:
records_after = kinto_client(collection="nimbus-preview").get_record_data()
if len(records_after) == records_before:
break
time.sleep(15)
else:
pytest.fail("Experiment not unpublished from preview in time")