Skip to content

Commit

Permalink
test: Making firewall test tolerant of GCE Enforcer. (#162)
Browse files Browse the repository at this point in the history
* docs(samples): Making firewall test tolerant of GCE Enforcer.

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* docs(samples): Marking the default values test as flaky.

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people authored Dec 1, 2021
1 parent 62f23e8 commit 4699cca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest==6.2.5
flaky==3.7.0
google-cloud-storage==1.43.0
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import typing
import uuid

from flaky import flaky
import google.auth
import google.cloud.storage as storage
import pytest
Expand All @@ -38,6 +39,7 @@ def temp_bucket():
bucket.delete(force=True)


@flaky(max_runs=3)
def test_set_usage_export_bucket_default(
capsys: typing.Any, temp_bucket: storage.Bucket
) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import time
import uuid

import google.api_core.exceptions
import google.auth
from google.cloud import compute_v1
import pytest
Expand Down Expand Up @@ -52,8 +53,15 @@ def firewall_rule():

yield firewall_client.get(project=PROJECT, firewall=firewall_rule.name)

op = firewall_client.delete(project=PROJECT, firewall=firewall_rule.name)
op_client.wait(project=PROJECT, operation=op.name)
try:
op = firewall_client.delete(project=PROJECT, firewall=firewall_rule.name)
op_client.wait(project=PROJECT, operation=op.name)
except google.api_core.exceptions.BadRequest as err:
if err.code == 400 and "is not ready" in err.message:
# This means GCE enforcer has already deleted that rule.
pass
else:
raise err


def test_create_delete():
Expand Down

0 comments on commit 4699cca

Please sign in to comment.