Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
Signed-off-by: Xue Zhou <[email protected]>
  • Loading branch information
xuezhou25 committed Oct 20, 2022
1 parent a210be7 commit c1daf24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.repositories.azure;

import org.opensearch.common.settings.SettingsException;
import reactor.core.scheduler.Schedulers;

import org.junit.AfterClass;
Expand All @@ -46,6 +47,7 @@
import org.opensearch.repositories.blobstore.BlobStoreTestUtil;
import org.opensearch.test.OpenSearchTestCase;

import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -161,21 +163,22 @@ public void testChunkSize() {
assertEquals(new ByteSizeValue(size, ByteSizeUnit.MB), azureRepository.chunkSize());

// zero bytes is not allowed
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
SettingsException e = expectThrows(
SettingsException.class,
() -> azureRepository(Settings.builder().put("chunk_size", "0").build())
);
assertEquals("failed to parse value [0] for setting [chunk_size], must be >= [1b]", e.getMessage());
assertThat(e.getCause(), instanceOf(IllegalArgumentException.class));
assertEquals("failed to parse value [0] for setting [chunk_size], must be >= [1b]", e.getCause().getMessage());

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cluster.remote.test_remote_cluster.proxy_address: $remote_ip

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

Expand All @@ -32,7 +32,7 @@
cluster.remote.test_remote_cluster.proxy_address: $remote_ip

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

Expand All @@ -54,7 +54,7 @@
cluster.remote.test_remote_cluster.seeds: $remote_ip

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

Expand All @@ -68,7 +68,7 @@
cluster.remote.test_remote_cluster.seeds: $remote_ip

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

Expand Down Expand Up @@ -182,7 +182,7 @@
cluster.remote.test_remote_cluster.proxy_address: $remote_ip

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

Expand Down

0 comments on commit c1daf24

Please sign in to comment.