|
17 | 17 | import org.apache.http.conn.ssl.TrustAllStrategy;
|
18 | 18 | import org.apache.http.impl.client.BasicCredentialsProvider;
|
19 | 19 |
|
| 20 | +import org.opensearch.client.ResponseException; |
20 | 21 | import org.opensearch.client.RestClient;
|
21 | 22 | import org.opensearch.client.RestClientBuilder;
|
22 | 23 | import org.opensearch.cluster.metadata.IndexMetadata;
|
23 | 24 | import org.opensearch.common.settings.Settings;
|
24 | 25 | import org.opensearch.core.common.Strings;
|
| 26 | +import org.opensearch.index.codec.customcodecs.Lucene99QatCodec; |
25 | 27 | import org.opensearch.index.codec.customcodecs.QatZipperFactory;
|
26 | 28 | import org.opensearch.test.rest.OpenSearchRestTestCase;
|
27 | 29 |
|
@@ -64,6 +66,49 @@ public void testCreateIndexWithZstdCodec() throws IOException {
|
64 | 66 | }
|
65 | 67 | }
|
66 | 68 |
|
| 69 | + public void testCreateIndexWithQatCodecWithQatHardwareUnavailable() throws IOException { |
| 70 | + |
| 71 | + assumeThat("Qat library is not available", QatZipperFactory.isQatAvailable(), is(false)); |
| 72 | + final String index = "custom-codecs-test-index"; |
| 73 | + |
| 74 | + // creating index |
| 75 | + final ResponseException e = expectThrows( |
| 76 | + ResponseException.class, |
| 77 | + () -> createIndex( |
| 78 | + index, |
| 79 | + Settings.builder() |
| 80 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 81 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) |
| 82 | + .put("index.codec", randomFrom(QAT_DEFLATE_CODEC, QAT_LZ4_CODEC)) |
| 83 | + .put("index.codec.compression_level", randomIntBetween(1, 6)) |
| 84 | + .build() |
| 85 | + ) |
| 86 | + ); |
| 87 | + assertTrue(e.getResponse().toString().contains("400 Bad Request")); |
| 88 | + } |
| 89 | + |
| 90 | + public void testCreateIndexWithQatSPICodecWithQatHardwareUnavailable() throws IOException { |
| 91 | + |
| 92 | + assumeThat("Qat library is not available", QatZipperFactory.isQatAvailable(), is(false)); |
| 93 | + final String index = "custom-codecs-test-index"; |
| 94 | + |
| 95 | + // creating index |
| 96 | + final ResponseException e = expectThrows( |
| 97 | + ResponseException.class, |
| 98 | + () -> createIndex( |
| 99 | + index, |
| 100 | + Settings.builder() |
| 101 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 102 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) |
| 103 | + .put("index.codec", randomFrom(Lucene99QatCodec.Mode.QAT_LZ4.getCodec(), Lucene99QatCodec.Mode.QAT_DEFLATE.getCodec())) |
| 104 | + .put("index.codec.compression_level", randomIntBetween(1, 6)) |
| 105 | + .build() |
| 106 | + ) |
| 107 | + ); |
| 108 | + assertTrue(e.getResponse().toString().contains("400 Bad Request")); |
| 109 | + |
| 110 | + } |
| 111 | + |
67 | 112 | public void testCreateIndexWithQatCodec() throws IOException {
|
68 | 113 | assumeThat("Qat library is available", QatZipperFactory.isQatAvailable(), is(true));
|
69 | 114 |
|
|
0 commit comments