Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2082,8 +2082,12 @@ void testCreateAndUpdateTableWithPolicyTags() throws IOException {
.setParent(String.format("projects/%s/locations/%s", PROJECT_ID, "us"))
.setTaxonomy(
Taxonomy.newBuilder()
// DisplayName must be unique across org
.setDisplayName(String.format("testing taxonomy %s", Instant.now().getNano()))
// DisplayName must be unique across org. Use UUID rather than time to ensure
// no collisions
// from parallel test invocations
.setDisplayName(
String.format(
"testing taxonomy %s", UUID.randomUUID().toString().substring(0, 8)))
Comment on lines +2088 to +2090
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using a UUID is a great improvement for uniqueness over Instant.now().getNano(), truncating it to 8 characters reduces its entropy and still leaves a small chance of collision, which could lead to test flakiness in the future. To ensure uniqueness across the organization as the comment suggests, it would be more robust to use the full UUID. If there is a length limit for DisplayName, it would be helpful to document that with a comment.

Additionally, for simple string concatenation, using the + operator is often more readable and can be more efficient than String.format.

                      .setDisplayName("testing taxonomy " + UUID.randomUUID().toString())

.setDescription("taxonomy created for integration tests")
.addActivatedPolicyTypes(PolicyType.FINE_GRAINED_ACCESS_CONTROL)
.build())
Expand Down
Loading