Skip to content

Commit 67f19e3

Browse files
committed
tests: add tests for cpu,memory,volume resize
1 parent 50a39b6 commit 67f19e3

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

tests/test_branches.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,63 @@ def test_branch_resize(client, org, project, branch_id):
165165
)
166166

167167

168+
def test_branch_resize_cpu(client, org, project, branch_id):
169+
r = client.post(
170+
f"organizations/{org}/projects/{project}/branches/{branch_id}/resize",
171+
json={"milli_vcpu": 1000},
172+
)
173+
assert r.status_code == 202
174+
wait_for_status(
175+
client,
176+
f"organizations/{org}/projects/{project}/branches/{branch_id}/",
177+
"ACTIVE_HEALTHY",
178+
BRANCH_TIMEOUT_SEC,
179+
)
180+
r = client.get(f"organizations/{org}/projects/{project}/branches/{branch_id}/")
181+
assert r.status_code == 200
182+
assert r.json()["max_resources"]["milli_vcpu"] == 1000
183+
184+
185+
def test_branch_resize_memory(client, org, project, branch_id):
186+
# 2 GiB expressed in bytes (must be a multiple of 256 MiB)
187+
two_gib = 2 * 1024 * 1024 * 1024
188+
r = client.post(
189+
f"organizations/{org}/projects/{project}/branches/{branch_id}/resize",
190+
json={"memory_bytes": two_gib},
191+
)
192+
assert r.status_code == 202
193+
wait_for_status(
194+
client,
195+
f"organizations/{org}/projects/{project}/branches/{branch_id}/",
196+
"ACTIVE_HEALTHY",
197+
BRANCH_TIMEOUT_SEC,
198+
)
199+
r = client.get(f"organizations/{org}/projects/{project}/branches/{branch_id}/")
200+
assert r.status_code == 200
201+
assert r.json()["max_resources"]["ram_bytes"] == two_gib
202+
203+
204+
def test_branch_resize_database_size(client, org, project, branch_id):
205+
# 6 GB expressed in bytes (must be a multiple of 1 GB)
206+
six_gb = 6 * 1_000_000_000
207+
# due to issues related to round up
208+
seven_gb = 7 * 1_000_000_000
209+
r = client.post(
210+
f"organizations/{org}/projects/{project}/branches/{branch_id}/resize",
211+
json={"database_size": six_gb},
212+
)
213+
assert r.status_code == 202
214+
wait_for_status(
215+
client,
216+
f"organizations/{org}/projects/{project}/branches/{branch_id}/",
217+
"ACTIVE_HEALTHY",
218+
BRANCH_TIMEOUT_SEC,
219+
)
220+
r = client.get(f"organizations/{org}/projects/{project}/branches/{branch_id}/")
221+
assert r.status_code == 200
222+
assert r.json()["max_resources"]["nvme_bytes"] == seven_gb
223+
224+
168225
def test_branch_password_reset(client, org, project, branch_id):
169226
r = client.post(
170227
f"organizations/{org}/projects/{project}/branches/{branch_id}/reset-password",

0 commit comments

Comments
 (0)