Skip to content

Commit 090a200

Browse files
dizcologydandhlee
authored andcommitted
remove capacity commitment from tests and conftest.py
1 parent fbda09d commit 090a200

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

bigquery-reservation/snippets/conftest.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@
2121
import pytest
2222

2323

24-
@pytest.fixture(scope="session", autouse=True)
25-
def cleanup_commitments(
26-
reservation_client: reservation_service.ReservationServiceClient, location_path: str
27-
) -> None:
28-
for commitment in reservation_client.list_capacity_commitments(
29-
parent=location_path
30-
):
31-
if commitment.state == reservation_types.CapacityCommitment.State.FAILED or (
32-
commitment.commitment_start_time is not None
33-
and commitment.commitment_start_time
34-
< datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=1)
35-
):
36-
reservation_client.delete_capacity_commitment(name=commitment.name)
37-
38-
3924
@pytest.fixture(scope="session")
4025
def project_id() -> str:
4126
return os.environ["GOOGLE_CLOUD_PROJECT"]
@@ -58,22 +43,3 @@ def location_path(project_id: str, location: str) -> str:
5843
return reservation_service.ReservationServiceClient.common_location_path(
5944
project_id, location
6045
)
61-
62-
63-
@pytest.fixture(scope="session", autouse=True)
64-
def capacity_commitment(
65-
location_path: str, reservation_client: reservation_service.ReservationServiceClient
66-
) -> reservation_types.CapacityCommitment:
67-
commitment = reservation_types.CapacityCommitment()
68-
commitment.slot_count = 100
69-
commitment.plan = reservation_types.CapacityCommitment.CommitmentPlan.FLEX
70-
commitment = reservation_client.create_capacity_commitment(
71-
parent=location_path, capacity_commitment=commitment
72-
)
73-
yield commitment
74-
# Commitments can only be removed after 1 minute.
75-
now = datetime.datetime.now(datetime.timezone.utc)
76-
delta = commitment.commitment_end_time - now
77-
sleep_seconds = max(0, delta.total_seconds()) + 5
78-
time.sleep(sleep_seconds)
79-
reservation_client.delete_capacity_commitment(name=commitment.name)

bigquery-reservation/snippets/quickstart.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,9 @@ def main(
2424
# Constructs the client for interacting with the service.
2525
client = bigquery_reservation_v1.ReservationServiceClient(transport=transport)
2626

27-
report_capacity_commitments(client, project_id, location)
2827
report_reservations(client, project_id, location)
2928

3029

31-
def report_capacity_commitments(
32-
client: bigquery_reservation_v1.ReservationServiceClient,
33-
project_id: str,
34-
location: str,
35-
) -> None:
36-
"""Prints details and summary information about capacity commitments for
37-
a given admin project and location.
38-
"""
39-
print(f"Capacity commitments in project {project_id} in location {location}")
40-
req = bigquery_reservation_v1.ListCapacityCommitmentsRequest(
41-
parent=client.common_location_path(project_id, location)
42-
)
43-
total_commitments = 0
44-
for commitment in client.list_capacity_commitments(request=req):
45-
print(f"\tCommitment {commitment.name} in state {commitment.state}")
46-
total_commitments = total_commitments + 1
47-
print(f"\n{total_commitments} commitments processed.")
48-
49-
5030
def report_reservations(
5131
client: bigquery_reservation_v1.ReservationServiceClient,
5232
project_id: str,

0 commit comments

Comments
 (0)