|
18 | 18 | import org.apache.http.entity.StringEntity; |
19 | 19 | import org.apache.http.protocol.HttpContext; |
20 | 20 | import org.apache.lucene.util.SetOnce; |
| 21 | +import org.elasticsearch.common.blobstore.OperationPurpose; |
21 | 22 | import org.elasticsearch.common.bytes.BytesReference; |
22 | 23 | import org.elasticsearch.common.settings.MockSecureSettings; |
23 | 24 | import org.elasticsearch.common.settings.Setting; |
24 | 25 | import org.elasticsearch.common.settings.Settings; |
25 | 26 | import org.elasticsearch.core.TimeValue; |
| 27 | +import org.elasticsearch.repositories.blobstore.BlobStoreTestUtil; |
26 | 28 | import org.elasticsearch.test.ESTestCase; |
27 | 29 | import org.elasticsearch.xcontent.XContentBuilder; |
28 | 30 | import org.hamcrest.Matchers; |
@@ -155,26 +157,35 @@ public void testClientsAreNotSharedAcrossRepositories() throws Exception { |
155 | 157 | try (GoogleCloudStoragePlugin plugin = new GoogleCloudStoragePlugin(settings)) { |
156 | 158 | final GoogleCloudStorageService storageService = plugin.storageService; |
157 | 159 |
|
| 160 | + final OperationPurpose operationPurpose = randomPurpose(); |
| 161 | + final OperationPurpose differentOperationPurpose = randomValueOtherThan(operationPurpose, BlobStoreTestUtil::randomPurpose); |
158 | 162 | final Storage repo1Client = storageService.client( |
159 | 163 | "gcs1", |
160 | 164 | "repo1", |
161 | | - randomPurpose(), |
| 165 | + operationPurpose, |
| 166 | + new GoogleCloudStorageOperationsStats("bucket") |
| 167 | + ); |
| 168 | + final Storage repo1ClientOtherPurpose = storageService.client( |
| 169 | + "gcs1", |
| 170 | + "repo1", |
| 171 | + differentOperationPurpose, |
162 | 172 | new GoogleCloudStorageOperationsStats("bucket") |
163 | 173 | ); |
164 | 174 | final Storage repo2Client = storageService.client( |
165 | 175 | "gcs1", |
166 | 176 | "repo2", |
167 | | - randomPurpose(), |
| 177 | + operationPurpose, |
168 | 178 | new GoogleCloudStorageOperationsStats("bucket") |
169 | 179 | ); |
170 | 180 | final Storage repo1ClientSecondInstance = storageService.client( |
171 | 181 | "gcs1", |
172 | 182 | "repo1", |
173 | | - randomPurpose(), |
| 183 | + operationPurpose, |
174 | 184 | new GoogleCloudStorageOperationsStats("bucket") |
175 | 185 | ); |
176 | 186 |
|
177 | 187 | assertNotSame(repo1Client, repo2Client); |
| 188 | + assertNotSame(repo1Client, repo1ClientOtherPurpose); |
178 | 189 | assertSame(repo1Client, repo1ClientSecondInstance); |
179 | 190 | } |
180 | 191 | } |
|
0 commit comments