Skip to content

Commit c1daf24

Browse files
committed
Fix test failure
Signed-off-by: Xue Zhou <[email protected]>
1 parent a210be7 commit c1daf24

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

plugins/repository-azure/src/test/java/org/opensearch/repositories/azure/AzureRepositorySettingsTests.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
package org.opensearch.repositories.azure;
3434

35+
import org.opensearch.common.settings.SettingsException;
3536
import reactor.core.scheduler.Schedulers;
3637

3738
import org.junit.AfterClass;
@@ -46,6 +47,7 @@
4647
import org.opensearch.repositories.blobstore.BlobStoreTestUtil;
4748
import org.opensearch.test.OpenSearchTestCase;
4849

50+
import static org.hamcrest.Matchers.instanceOf;
4951
import static org.hamcrest.Matchers.is;
5052
import static org.hamcrest.Matchers.nullValue;
5153
import static org.mockito.Mockito.mock;
@@ -161,21 +163,22 @@ public void testChunkSize() {
161163
assertEquals(new ByteSizeValue(size, ByteSizeUnit.MB), azureRepository.chunkSize());
162164

163165
// zero bytes is not allowed
164-
IllegalArgumentException e = expectThrows(
165-
IllegalArgumentException.class,
166+
SettingsException e = expectThrows(
167+
SettingsException.class,
166168
() -> azureRepository(Settings.builder().put("chunk_size", "0").build())
167169
);
168-
assertEquals("failed to parse value [0] for setting [chunk_size], must be >= [1b]", e.getMessage());
170+
assertThat(e.getCause(), instanceOf(IllegalArgumentException.class));
171+
assertEquals("failed to parse value [0] for setting [chunk_size], must be >= [1b]", e.getCause().getMessage());
169172

170173
// negative bytes not allowed
171-
e = expectThrows(IllegalArgumentException.class, () -> azureRepository(Settings.builder().put("chunk_size", "-1").build()));
172-
assertEquals("failed to parse value [-1] for setting [chunk_size], must be >= [1b]", e.getMessage());
174+
e = expectThrows(SettingsException.class, () -> azureRepository(Settings.builder().put("chunk_size", "-1").build()));
175+
assertEquals("failed to parse value [-1] for setting [chunk_size], must be >= [1b]", e.getCause().getMessage());
173176

174177
// greater than max chunk size not allowed
175-
e = expectThrows(IllegalArgumentException.class, () -> azureRepository(Settings.builder().put("chunk_size", "6tb").build()));
178+
e = expectThrows(SettingsException.class, () -> azureRepository(Settings.builder().put("chunk_size", "6tb").build()));
176179
assertEquals(
177180
"failed to parse value [6tb] for setting [chunk_size], must be <= [" + AzureStorageService.MAX_CHUNK_SIZE.getStringRep() + "]",
178-
e.getMessage()
181+
e.getCause().getMessage()
179182
);
180183
}
181184

qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/15_connection_mode_configuration.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
cluster.remote.test_remote_cluster.proxy_address: $remote_ip
1818

1919
- match: { status: 400 }
20-
- match: { error.root_cause.0.type: "illegal_argument_exception" }
20+
- match: { error.root_cause.0.type: "settings_exception" }
2121
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.node_connections\" cannot be
2222
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=PROXY]" }
2323

@@ -32,7 +32,7 @@
3232
cluster.remote.test_remote_cluster.proxy_address: $remote_ip
3333

3434
- match: { status: 400 }
35-
- match: { error.root_cause.0.type: "illegal_argument_exception" }
35+
- match: { error.root_cause.0.type: "settings_exception" }
3636
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.seeds\" cannot be
3737
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=PROXY]" }
3838

@@ -54,7 +54,7 @@
5454
cluster.remote.test_remote_cluster.seeds: $remote_ip
5555

5656
- match: { status: 400 }
57-
- match: { error.root_cause.0.type: "illegal_argument_exception" }
57+
- match: { error.root_cause.0.type: "settings_exception" }
5858
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.proxy_socket_connections\" cannot be
5959
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=PROXY, configured=SNIFF]" }
6060

@@ -68,7 +68,7 @@
6868
cluster.remote.test_remote_cluster.seeds: $remote_ip
6969

7070
- match: { status: 400 }
71-
- match: { error.root_cause.0.type: "illegal_argument_exception" }
71+
- match: { error.root_cause.0.type: "settings_exception" }
7272
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.proxy_address\" cannot be
7373
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=PROXY, configured=SNIFF]" }
7474

@@ -182,7 +182,7 @@
182182
cluster.remote.test_remote_cluster.proxy_address: $remote_ip
183183

184184
- match: { status: 400 }
185-
- match: { error.root_cause.0.type: "illegal_argument_exception" }
185+
- match: { error.root_cause.0.type: "settings_exception" }
186186
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.seeds\" cannot be
187187
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=PROXY]" }
188188

0 commit comments

Comments
 (0)