Skip to content

Commit 8933d60

Browse files
authored
test: make registry fixture names more "name~spacy" to appear better in otel traces (googleapis#2879)
1 parent c6a9fe3 commit 8933d60

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITUniverseDomainTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.assertNull;
21+
import static org.junit.Assume.assumeNotNull;
2122

2223
import com.google.auth.oauth2.GoogleCredentials;
2324
import com.google.auth.oauth2.ServiceAccountCredentials;
@@ -43,6 +44,10 @@ public class ITUniverseDomainTest {
4344

4445
@BeforeClass
4546
public static void setUp() throws Exception {
47+
assumeNotNull(TEST_UNIVERSE_DOMAIN);
48+
assumeNotNull(TEST_PROJECT_ID);
49+
assumeNotNull(TEST_UNIVERSE_LOCATION);
50+
assumeNotNull(CREDENTIAL_PATH);
4651
GoogleCredentials creds =
4752
ServiceAccountCredentials.fromStream(Files.newInputStream(Paths.get(CREDENTIAL_PATH)))
4853
.toBuilder()

google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/BackendResources.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
8787
ProtectedBucketNames protectedBucketNames = new ProtectedBucketNames();
8888
TestRunScopedInstance<StorageInstance> storageJson =
8989
TestRunScopedInstance.of(
90-
"STORAGE_JSON_" + backend.name(),
90+
"fixture/STORAGE/[JSON][" + backend.name() + "]",
9191
() -> {
9292
HttpStorageOptions.Builder optionsBuilder;
9393
switch (backend) {
@@ -108,7 +108,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
108108
});
109109
TestRunScopedInstance<StorageInstance> storageGrpc =
110110
TestRunScopedInstance.of(
111-
"STORAGE_GRPC_" + backend.name(),
111+
"fixture/STORAGE/[GRPC][" + backend.name() + "]",
112112
() -> {
113113
GrpcStorageOptions.Builder optionsBuilder;
114114
switch (backend) {
@@ -137,7 +137,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
137137
});
138138
TestRunScopedInstance<StorageControlInstance> ctrl =
139139
TestRunScopedInstance.of(
140-
"STORAGE_CONTROL_" + backend.name(),
140+
"fixture/STORAGE_CONTROL/[" + backend.name() + "]",
141141
() -> {
142142
StorageControlSettings.Builder builder;
143143
switch (backend) {
@@ -176,7 +176,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
176176
});
177177
TestRunScopedInstance<BucketInfoShim> bucket =
178178
TestRunScopedInstance.of(
179-
"BUCKET_" + backend.name(),
179+
"fixture/BUCKET/[" + backend.name() + "]",
180180
() -> {
181181
String bucketName = String.format("java-storage-grpc-%s", UUID.randomUUID());
182182
protectedBucketNames.add(bucketName);
@@ -185,7 +185,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
185185
});
186186
TestRunScopedInstance<BucketInfoShim> bucketRp =
187187
TestRunScopedInstance.of(
188-
"BUCKET_REQUESTER_PAYS_" + backend.name(),
188+
"fixture/BUCKET/[" + backend.name() + "]/REQUESTER_PAYS",
189189
() -> {
190190
String bucketName = String.format("java-storage-grpc-rp-%s", UUID.randomUUID());
191191
protectedBucketNames.add(bucketName);
@@ -196,7 +196,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
196196
});
197197
TestRunScopedInstance<BucketInfoShim> bucketVersioned =
198198
TestRunScopedInstance.of(
199-
"BUCKET_VERSIONED_" + backend.name(),
199+
"fixture/BUCKET/[" + backend.name() + "]/VERSIONED",
200200
() -> {
201201
String bucketName = String.format("java-storage-grpc-v-%s", UUID.randomUUID());
202202
protectedBucketNames.add(bucketName);
@@ -207,7 +207,7 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
207207
});
208208
TestRunScopedInstance<BucketInfoShim> bucketHns =
209209
TestRunScopedInstance.of(
210-
"BUCKET_HNS_" + backend.name(),
210+
"fixture/BUCKET/[" + backend.name() + "]/HNS",
211211
() -> {
212212
String bucketName = String.format("java-storage-grpc-hns-%s", UUID.randomUUID());
213213
protectedBucketNames.add(bucketName);
@@ -225,22 +225,23 @@ static BackendResources of(Backend backend, TestRunScopedInstance<OtelSdkShim> o
225225
});
226226
TestRunScopedInstance<ObjectsFixture> objectsFixture =
227227
TestRunScopedInstance.of(
228-
"OBJECTS_FIXTURE_" + backend.name(),
228+
"fixture/OBJECTS/[" + backend.name() + "]",
229229
() -> new ObjectsFixture(storageJson.get().getStorage(), bucket.get().getBucketInfo()));
230230
TestRunScopedInstance<ObjectsFixture> objectsFixtureRp =
231231
TestRunScopedInstance.of(
232-
"OBJECTS_FIXTURE_REQUESTER_PAYS_" + backend.name(),
232+
"fixture/OBJECTS/[" + backend.name() + "]/REQUESTER_PAYS",
233233
() ->
234234
new ObjectsFixture(storageJson.get().getStorage(), bucketRp.get().getBucketInfo()));
235235
TestRunScopedInstance<ObjectsFixture> objectsFixtureHns =
236236
TestRunScopedInstance.of(
237-
"OBJECTS_FIXTURE_HNS_" + backend.name(),
237+
"fixture/OBJECTS/[" + backend.name() + "]/HNS",
238238
() ->
239239
new ObjectsFixture(
240240
storageJson.get().getStorage(), bucketHns.get().getBucketInfo()));
241241
TestRunScopedInstance<KmsFixture> kmsFixture =
242242
TestRunScopedInstance.of(
243-
"KMS_FIXTURE_" + backend.name(), () -> KmsFixture.of(storageJson.get().getStorage()));
243+
"fixture/KMS/[" + backend.name() + "]",
244+
() -> KmsFixture.of(storageJson.get().getStorage()));
244245

245246
return new BackendResources(
246247
backend,

google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/Registry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ public final class Registry extends RunListener {
7373
new ThreadFactoryBuilder().setDaemon(true).setNameFormat("test-run-%d").build()));
7474

7575
private final TestRunScopedInstance<TestBench> testBench =
76-
TestRunScopedInstance.of("TEST_BENCH", () -> TestBench.newBuilder().build());
76+
TestRunScopedInstance.of("fixture/TEST_BENCH", () -> TestBench.newBuilder().build());
7777

7878
private final TestRunScopedInstance<Generator> generator =
79-
TestRunScopedInstance.of("GENERATOR", Generator::new);
79+
TestRunScopedInstance.of("fixture/GENERATOR", Generator::new);
8080

8181
final TestRunScopedInstance<OtelSdkShim> otelSdk =
8282
TestRunScopedInstance.of(
83-
"OTEL_SDK",
83+
"fixture/OTEL_SDK",
8484
() -> {
8585
String projectId = StorageOptions.getDefaultInstance().getProjectId();
8686
return new OtelSdkShim(projectId);

google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/TestRunScopedInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public T get() {
5353
if (instance == null) {
5454
// if we don't short-circuit for OTEL_SDK we will cause a stack overflow, because we would
5555
// be trying to get our instance to record that we're starting our instance.
56-
if (name.equals("OTEL_SDK")) {
56+
if (name.equals("fixture/OTEL_SDK")) {
5757
T tmp = ctor.get();
5858
tmp.start();
5959
instance = tmp;

0 commit comments

Comments
 (0)