Skip to content

Commit 141281b

Browse files
authored
Merge pull request #285 from CenterForOpenScience/feature/prod_throttle
Throttle production tests
2 parents 69d0c9c + a595ab6 commit 141281b

File tree

9 files changed

+33
-3
lines changed

9 files changed

+33
-3
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# TIMEOUT=10
1313
# LONG_TIMEOUT=30
1414
# VERY_LONG_TIMEOUT=60
15-
15+
# PROD_THROTTLE=5
1616

1717
##### Driver config #####
1818

settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
TIMEOUT = env.int('TIMEOUT', 10)
5050
LONG_TIMEOUT = env.int('LONG_TIMEOUT', 30)
5151
VERY_LONG_TIMEOUT = env.int('VERY_LONG_TIMEOUT', 60)
52+
PROD_THROTTLE = env.int('PROD_THROTTLE', 5)
5253

5354
DOMAIN = env('DOMAIN', 'stage1')
5455

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import time
23

34
import pytest
45
from faker import Faker
@@ -194,3 +195,9 @@ def must_be_logged_in_as_registration_user(driver):
194195
user=settings.REGISTRATIONS_USER,
195196
password=settings.REGISTRATIONS_USER_PASSWORD,
196197
)
198+
199+
200+
@pytest.fixture(scope='function')
201+
def throttle_on_prod(driver):
202+
if settings.PRODUCTION:
203+
time.sleep(settings.PROD_THROTTLE)

tests/test_institutions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@markers.smoke_test
1313
@markers.core_functionality
14+
@pytest.mark.usefixtures('throttle_on_prod')
1415
class TestInstitutionsPage:
1516
@pytest.fixture()
1617
def landing_page(self, driver):

tests/test_login.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def login_page(driver):
3737

3838
@markers.smoke_test
3939
@markers.core_functionality
40+
@pytest.mark.usefixtures('throttle_on_prod')
4041
class TestLoginPage:
4142
def test_institutional_login(self, driver, login_page):
4243
"""Check that you arrive on the institutional login page and the institution dropdown is populated.
@@ -207,6 +208,7 @@ def test_cancel_tos_link(self, driver):
207208

208209

209210
@markers.core_functionality
211+
@pytest.mark.usefixtures('throttle_on_prod')
210212
class TestGenericPages:
211213
"""Generic pages have no service in the login/logout url. Typically users should not be able to access
212214
these pages through the standard authentication workflow. The tests in this class manually manipulate the
@@ -236,6 +238,7 @@ def test_generic_logged_out_page(self, driver):
236238

237239

238240
@markers.core_functionality
241+
@pytest.mark.usefixtures('throttle_on_prod')
239242
class TestLoginErrors:
240243
"""Test the inline error messages on the CAS login page when user enters invalid login data"""
241244

@@ -268,6 +271,7 @@ def test_invalid_password(self, driver, login_page):
268271

269272

270273
@markers.core_functionality
274+
@pytest.mark.usefixtures('throttle_on_prod')
271275
class TestCustomExceptionPages:
272276
"""CAS has several customized exception pages which share the same style and appearance as the CAS login pages.
273277
Not all of them can be easily tested. Those that can will require the manipulation of urls to reach the pages.
@@ -344,6 +348,7 @@ def try_login_page(driver, page_class):
344348

345349
@markers.smoke_test
346350
@markers.core_functionality
351+
@pytest.mark.usefixtures('throttle_on_prod')
347352
class TestInstitutionLoginPage:
348353
@pytest.fixture
349354
def institution_login_page(self, driver):

tests/test_navbar.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_logout_link(self, driver, page):
124124

125125
@markers.smoke_test
126126
@markers.core_functionality
127+
@pytest.mark.usefixtures('throttle_on_prod')
127128
class TestOSFHomeNavbarLoggedOut(NavbarTestLoggedOutMixin):
128129
@pytest.fixture()
129130
def page(self, driver):
@@ -145,6 +146,7 @@ def test_support_link(self, page, driver):
145146

146147
@markers.smoke_test
147148
@markers.core_functionality
149+
@pytest.mark.usefixtures('throttle_on_prod')
148150
class TestOSFHomeNavbarLoggedIn(NavbarTestLoggedInMixin):
149151
@pytest.fixture()
150152
def page(self, driver, log_in_if_not_already):
@@ -159,6 +161,7 @@ def test_my_projects_link(self, page, driver):
159161

160162
@markers.smoke_test
161163
@markers.core_functionality
164+
@pytest.mark.usefixtures('throttle_on_prod')
162165
class TestPreprintsNavbarLoggedOut(NavbarTestLoggedOutMixin):
163166
@pytest.fixture()
164167
def page(self, driver):
@@ -183,6 +186,7 @@ def test_sign_up_button(self, page, driver):
183186
@markers.smoke_test
184187
@markers.core_functionality
185188
@pytest.mark.usefixtures('log_in_if_not_already')
189+
@pytest.mark.usefixtures('throttle_on_prod')
186190
class TestPreprintsNavbarLoggedIn(NavbarTestLoggedInMixin):
187191
@pytest.fixture()
188192
def page(self, driver):
@@ -209,6 +213,7 @@ def test_my_reviewing_link(self, page, driver):
209213

210214
@markers.smoke_test
211215
@markers.core_functionality
216+
@pytest.mark.usefixtures('throttle_on_prod')
212217
class TestRegistriesNavbarLoggedOut(NavbarTestLoggedOutMixin):
213218
@pytest.fixture()
214219
def page(self, driver):
@@ -235,6 +240,7 @@ def test_sign_in_button(self, page, driver):
235240
@markers.smoke_test
236241
@markers.core_functionality
237242
@pytest.mark.usefixtures('log_in_if_not_already')
243+
@pytest.mark.usefixtures('throttle_on_prod')
238244
class TestRegistriesNavbarLoggedIn(NavbarTestLoggedInMixin):
239245
@pytest.fixture()
240246
def page(self, driver):
@@ -253,6 +259,7 @@ def test_my_registrations_link(self, page, driver):
253259

254260
@markers.smoke_test
255261
@markers.core_functionality
262+
@pytest.mark.usefixtures('throttle_on_prod')
256263
class TestMeetingsNavbarLoggedOut(NavbarTestLoggedOutMixin):
257264
@pytest.fixture()
258265
def page(self, driver):
@@ -272,6 +279,7 @@ def test_support_link(self, page, driver):
272279
@markers.smoke_test
273280
@markers.core_functionality
274281
@pytest.mark.usefixtures('log_in_if_not_already')
282+
@pytest.mark.usefixtures('throttle_on_prod')
275283
class TestMeetingsNavbarLoggedIn(NavbarTestLoggedInMixin):
276284
@pytest.fixture()
277285
def page(self, driver):
@@ -286,6 +294,7 @@ def test_my_projects_link(self, page, driver):
286294

287295
@markers.smoke_test
288296
@markers.core_functionality
297+
@pytest.mark.usefixtures('throttle_on_prod')
289298
class TestInstitutionsNavbarLoggedOut(NavbarTestLoggedOutMixin):
290299
@pytest.fixture()
291300
def page(self, driver):
@@ -305,6 +314,7 @@ def test_support_link(self, page, driver):
305314
@markers.smoke_test
306315
@markers.core_functionality
307316
@pytest.mark.usefixtures('log_in_if_not_already')
317+
@pytest.mark.usefixtures('throttle_on_prod')
308318
class TestInstitutionsNavbarLoggedIn(NavbarTestLoggedInMixin):
309319
@pytest.fixture()
310320
def page(self, driver):
@@ -331,6 +341,7 @@ def assert_donate_page(driver, donate_page):
331341

332342
@markers.smoke_test
333343
@markers.core_functionality
344+
@pytest.mark.usefixtures('throttle_on_prod')
334345
class TestCollectionsNavbarLoggedOut:
335346
@pytest.fixture
336347
def provider(self, driver):
@@ -359,6 +370,7 @@ def test_donate_link(self, session, driver, collections_discover_page):
359370
@markers.smoke_test
360371
@markers.core_functionality
361372
@pytest.mark.usefixtures('log_in_if_not_already')
373+
@pytest.mark.usefixtures('throttle_on_prod')
362374
class TestCollectionsNavbarLoggedIn:
363375
@pytest.fixture
364376
def provider(self, driver):
@@ -395,6 +407,7 @@ def test_donate_link(self, session, driver, page):
395407
@markers.smoke_test
396408
@markers.core_functionality
397409
@pytest.mark.usefixtures('log_in_if_not_already')
410+
@pytest.mark.usefixtures('throttle_on_prod')
398411
class TestProjectsNavbarLoggedIn:
399412
@pytest.fixture()
400413
def project_page(self, driver, default_project_page):

tests/test_preprints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ def test_submit_page_loads(self, driver, provider):
13131313

13141314

13151315
@markers.smoke_test
1316+
@pytest.mark.usefixtures('throttle_on_prod')
13161317
@pytest.mark.skipif(
13171318
not settings.PRODUCTION,
13181319
reason='Most of the Branded Preprint Provider pages in test environments have no preprints',

tests/test_registries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def test_detail_page(self, driver):
131131

132132

133133
@markers.smoke_test
134+
@pytest.mark.usefixtures('throttle_on_prod')
134135
@markers.core_functionality
135136
class TestBrandedRegistriesPages:
136137
def providers():

tests/test_search.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ def search_page(driver):
1515
return search_page
1616

1717

18+
@markers.smoke_test
19+
@markers.core_functionality
20+
@pytest.mark.usefixtures('throttle_on_prod')
1821
class TestSearchPage:
19-
@markers.smoke_test
20-
@markers.core_functionality
2122
def test_search_results_exist_all_tab(self, driver, search_page):
2223
search_page.search_input.send_keys('test')
2324
search_page.search_input.send_keys(Keys.ENTER)

0 commit comments

Comments
 (0)