|
15 | 15 | GIFTED_SECS_QUOTA = GIFTED_MINS_QUOTA * 60 |
16 | 16 | EXTRA_MINS_QUOTA = 5 |
17 | 17 | EXTRA_SECS_QUOTA = EXTRA_MINS_QUOTA * 60 |
| 18 | +EXTRA_MINS_ADDED_QUOTA = 7 |
| 19 | +EXTRA_SECS_ADDED_QUOTA = EXTRA_MINS_ADDED_QUOTA * 60 |
18 | 20 |
|
19 | 21 | config_id = None |
20 | 22 |
|
@@ -107,6 +109,43 @@ def test_set_execution_mins_extra_quotas(org_with_quotas, admin_auth_headers): |
107 | 109 | assert update["update"] |
108 | 110 |
|
109 | 111 |
|
| 112 | +def test_add_execution_mins_extra_quotas( |
| 113 | + org_with_quotas, admin_auth_headers, preshared_secret_auth_headers |
| 114 | +): |
| 115 | + r = requests.post( |
| 116 | + f"{API_PREFIX}/orgs/{org_with_quotas}/quotas/add", |
| 117 | + headers=preshared_secret_auth_headers, |
| 118 | + json={ |
| 119 | + "extraExecMinutes": EXTRA_MINS_ADDED_QUOTA, |
| 120 | + "context": "test context 123", |
| 121 | + }, |
| 122 | + ) |
| 123 | + data = r.json() |
| 124 | + assert data.get("updated") == True |
| 125 | + |
| 126 | + # Ensure org data looks as we expect |
| 127 | + r = requests.get( |
| 128 | + f"{API_PREFIX}/orgs/{org_with_quotas}", |
| 129 | + headers=admin_auth_headers, |
| 130 | + ) |
| 131 | + data = r.json() |
| 132 | + assert ( |
| 133 | + data["extraExecSecondsAvailable"] == EXTRA_SECS_QUOTA + EXTRA_SECS_ADDED_QUOTA |
| 134 | + ) |
| 135 | + assert data["giftedExecSecondsAvailable"] == GIFTED_SECS_QUOTA |
| 136 | + assert data["extraExecSeconds"] == {} |
| 137 | + assert data["giftedExecSeconds"] == {} |
| 138 | + assert ( |
| 139 | + get_total_exec_seconds(data["crawlExecSeconds"]) |
| 140 | + >= EXEC_SECS_QUOTA + EXTRA_SECS_ADDED_QUOTA |
| 141 | + ) |
| 142 | + assert len(data["quotaUpdates"]) |
| 143 | + for update in data["quotaUpdates"]: |
| 144 | + assert update["modified"] |
| 145 | + assert update["update"] |
| 146 | + assert data["quotaUpdates"][-1]["context"] == "test context 123" |
| 147 | + |
| 148 | + |
110 | 149 | @pytest.mark.timeout(1200) |
111 | 150 | def test_crawl_stopped_when_quota_reached_with_extra( |
112 | 151 | org_with_quotas, admin_auth_headers |
|
0 commit comments