Skip to content

Commit fe5fdb1

Browse files
bug fix - flaky bot issue #8431 (#8482)
changes 1. Fix `test_list_namespace`: Update the check to do validation based on namespace object's name attribute. This change is required to due a bug in class's __eq__ method & flaky bot issue. 2. Update `namespace` method, to ensure that proper clean-up of created object. As of now, in case of failure, we found un wanted object created but did not clean-up
1 parent 33d89a7 commit fe5fdb1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

servicedirectory/quickstart_test.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ def namespace(client):
3838
namespace = servicedirectory_v1.Namespace(
3939
name=client.namespace_path(PROJECT_ID, LOCATION_ID, NAMESPACE_ID))
4040

41-
client.create_namespace(
42-
parent=f'projects/{PROJECT_ID}/locations/{LOCATION_ID}',
43-
namespace=namespace,
44-
namespace_id=NAMESPACE_ID,
45-
)
41+
try:
42+
client.create_namespace(
43+
parent=f'projects/{PROJECT_ID}/locations/{LOCATION_ID}',
44+
namespace=namespace,
45+
namespace_id=NAMESPACE_ID,
46+
)
4647

47-
yield namespace
48-
49-
client.delete_namespace(name=namespace.name)
48+
yield namespace
49+
finally:
50+
client.delete_namespace(name=namespace.name)
5051

5152

5253
def test_list_namespace(namespace):
53-
assert namespace in quickstart.list_namespaces(PROJECT_ID,
54-
LOCATION_ID).namespaces
54+
google_cloud_namespaces = quickstart.list_namespaces(PROJECT_ID, LOCATION_ID).namespaces
55+
assert namespace.name in [_namespace.name for _namespace in google_cloud_namespaces]

0 commit comments

Comments
 (0)