Skip to content

Commit d48cf3f

Browse files
authored
Fix GoogleCloudStorageServiceTests (#123092)
1 parent 29eb923 commit d48cf3f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

modules/repository-gcs/src/test/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageServiceTests.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
import org.apache.http.entity.StringEntity;
1919
import org.apache.http.protocol.HttpContext;
2020
import org.apache.lucene.util.SetOnce;
21+
import org.elasticsearch.common.blobstore.OperationPurpose;
2122
import org.elasticsearch.common.bytes.BytesReference;
2223
import org.elasticsearch.common.settings.MockSecureSettings;
2324
import org.elasticsearch.common.settings.Setting;
2425
import org.elasticsearch.common.settings.Settings;
2526
import org.elasticsearch.core.TimeValue;
27+
import org.elasticsearch.repositories.blobstore.BlobStoreTestUtil;
2628
import org.elasticsearch.test.ESTestCase;
2729
import org.elasticsearch.xcontent.XContentBuilder;
2830
import org.hamcrest.Matchers;
@@ -155,26 +157,35 @@ public void testClientsAreNotSharedAcrossRepositories() throws Exception {
155157
try (GoogleCloudStoragePlugin plugin = new GoogleCloudStoragePlugin(settings)) {
156158
final GoogleCloudStorageService storageService = plugin.storageService;
157159

160+
final OperationPurpose operationPurpose = randomPurpose();
161+
final OperationPurpose differentOperationPurpose = randomValueOtherThan(operationPurpose, BlobStoreTestUtil::randomPurpose);
158162
final Storage repo1Client = storageService.client(
159163
"gcs1",
160164
"repo1",
161-
randomPurpose(),
165+
operationPurpose,
166+
new GoogleCloudStorageOperationsStats("bucket")
167+
);
168+
final Storage repo1ClientOtherPurpose = storageService.client(
169+
"gcs1",
170+
"repo1",
171+
differentOperationPurpose,
162172
new GoogleCloudStorageOperationsStats("bucket")
163173
);
164174
final Storage repo2Client = storageService.client(
165175
"gcs1",
166176
"repo2",
167-
randomPurpose(),
177+
operationPurpose,
168178
new GoogleCloudStorageOperationsStats("bucket")
169179
);
170180
final Storage repo1ClientSecondInstance = storageService.client(
171181
"gcs1",
172182
"repo1",
173-
randomPurpose(),
183+
operationPurpose,
174184
new GoogleCloudStorageOperationsStats("bucket")
175185
);
176186

177187
assertNotSame(repo1Client, repo2Client);
188+
assertNotSame(repo1Client, repo1ClientOtherPurpose);
178189
assertSame(repo1Client, repo1ClientSecondInstance);
179190
}
180191
}

0 commit comments

Comments
 (0)