|
13 | 13 | import org.opensearch.cluster.metadata.IndexMetadata;
|
14 | 14 | import org.opensearch.common.settings.Settings;
|
15 | 15 | import org.opensearch.index.codec.customcodecs.CustomCodecPlugin;
|
| 16 | +import org.opensearch.index.codec.customcodecs.QatZipperFactory; |
16 | 17 | import org.opensearch.plugins.Plugin;
|
17 | 18 | import org.opensearch.test.OpenSearchIntegTestCase;
|
18 | 19 |
|
19 | 20 | import java.util.Collection;
|
20 | 21 | import java.util.Collections;
|
21 | 22 | import java.util.concurrent.ExecutionException;
|
22 | 23 |
|
| 24 | +import static org.opensearch.index.codec.customcodecs.CustomCodecService.QAT_DEFLATE_CODEC; |
| 25 | +import static org.opensearch.index.codec.customcodecs.CustomCodecService.QAT_LZ4_CODEC; |
23 | 26 | import static org.opensearch.index.codec.customcodecs.CustomCodecService.ZSTD_CODEC;
|
24 | 27 | import static org.opensearch.index.codec.customcodecs.CustomCodecService.ZSTD_NO_DICT_CODEC;
|
25 | 28 | import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
|
| 29 | +import static org.hamcrest.Matchers.is; |
| 30 | +import static org.junit.Assume.assumeThat; |
26 | 31 |
|
27 | 32 | @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST)
|
28 | 33 | public class CodecCompressionLevelIT extends OpenSearchIntegTestCase {
|
@@ -80,6 +85,26 @@ public void testZStandardCodecsCreateIndexWithCompressionLevel() {
|
80 | 85 | ensureGreen(index);
|
81 | 86 | }
|
82 | 87 |
|
| 88 | + public void testQatCodecsCreateIndexWithCompressionLevel() { |
| 89 | + assumeThat("Qat library is available", QatZipperFactory.isQatAvailable(), is(true)); |
| 90 | + |
| 91 | + internalCluster().ensureAtLeastNumDataNodes(1); |
| 92 | + final String index = "test-index"; |
| 93 | + |
| 94 | + // creating index |
| 95 | + createIndex( |
| 96 | + index, |
| 97 | + Settings.builder() |
| 98 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 99 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) |
| 100 | + .put("index.codec", randomFrom(QAT_DEFLATE_CODEC, QAT_LZ4_CODEC)) |
| 101 | + .put("index.codec.compression_level", randomIntBetween(1, 6)) |
| 102 | + .build() |
| 103 | + ); |
| 104 | + |
| 105 | + ensureGreen(index); |
| 106 | + } |
| 107 | + |
83 | 108 | public void testZStandardToLuceneCodecsWithCompressionLevel() throws ExecutionException, InterruptedException {
|
84 | 109 |
|
85 | 110 | internalCluster().ensureAtLeastNumDataNodes(1);
|
@@ -132,6 +157,59 @@ public void testZStandardToLuceneCodecsWithCompressionLevel() throws ExecutionEx
|
132 | 157 | ensureGreen(index);
|
133 | 158 | }
|
134 | 159 |
|
| 160 | + public void testQatToLuceneCodecsWithCompressionLevel() throws ExecutionException, InterruptedException { |
| 161 | + assumeThat("Qat library is available", QatZipperFactory.isQatAvailable(), is(true)); |
| 162 | + |
| 163 | + internalCluster().ensureAtLeastNumDataNodes(1); |
| 164 | + final String index = "test-index"; |
| 165 | + |
| 166 | + // creating index |
| 167 | + createIndex( |
| 168 | + index, |
| 169 | + Settings.builder() |
| 170 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 171 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) |
| 172 | + .put("index.codec", randomFrom(QAT_DEFLATE_CODEC, QAT_LZ4_CODEC)) |
| 173 | + .put("index.codec.compression_level", randomIntBetween(1, 6)) |
| 174 | + .build() |
| 175 | + ); |
| 176 | + ensureGreen(index); |
| 177 | + |
| 178 | + assertAcked(client().admin().indices().prepareClose(index).setWaitForActiveShards(1)); |
| 179 | + |
| 180 | + Throwable executionException = expectThrows( |
| 181 | + ExecutionException.class, |
| 182 | + () -> client().admin() |
| 183 | + .indices() |
| 184 | + .updateSettings( |
| 185 | + new UpdateSettingsRequest(index).settings( |
| 186 | + Settings.builder().put("index.codec", randomFrom(CodecService.DEFAULT_CODEC, CodecService.BEST_COMPRESSION_CODEC)) |
| 187 | + ) |
| 188 | + ) |
| 189 | + .get() |
| 190 | + ); |
| 191 | + |
| 192 | + Throwable rootCause = Throwables.getRootCause(executionException); |
| 193 | + assertEquals(IllegalArgumentException.class, rootCause.getClass()); |
| 194 | + assertTrue(rootCause.getMessage().startsWith("Compression level cannot be set")); |
| 195 | + |
| 196 | + assertAcked( |
| 197 | + client().admin() |
| 198 | + .indices() |
| 199 | + .updateSettings( |
| 200 | + new UpdateSettingsRequest(index).settings( |
| 201 | + Settings.builder() |
| 202 | + .put("index.codec", randomFrom(CodecService.DEFAULT_CODEC, CodecService.BEST_COMPRESSION_CODEC)) |
| 203 | + .put("index.codec.compression_level", (String) null) |
| 204 | + ) |
| 205 | + ) |
| 206 | + .get() |
| 207 | + ); |
| 208 | + |
| 209 | + assertAcked(client().admin().indices().prepareOpen(index).setWaitForActiveShards(1)); |
| 210 | + ensureGreen(index); |
| 211 | + } |
| 212 | + |
135 | 213 | public void testLuceneToZStandardCodecsWithCompressionLevel() throws ExecutionException, InterruptedException {
|
136 | 214 |
|
137 | 215 | internalCluster().ensureAtLeastNumDataNodes(1);
|
@@ -185,4 +263,57 @@ public void testLuceneToZStandardCodecsWithCompressionLevel() throws ExecutionEx
|
185 | 263 | ensureGreen(index);
|
186 | 264 | }
|
187 | 265 |
|
| 266 | + public void testLuceneToQatCodecsWithCompressionLevel() throws ExecutionException, InterruptedException { |
| 267 | + assumeThat("Qat library is available", QatZipperFactory.isQatAvailable(), is(true)); |
| 268 | + |
| 269 | + internalCluster().ensureAtLeastNumDataNodes(1); |
| 270 | + final String index = "test-index"; |
| 271 | + |
| 272 | + // creating index |
| 273 | + createIndex( |
| 274 | + index, |
| 275 | + Settings.builder() |
| 276 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 277 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) |
| 278 | + .put("index.codec", randomFrom(CodecService.DEFAULT_CODEC, CodecService.BEST_COMPRESSION_CODEC)) |
| 279 | + .build() |
| 280 | + ); |
| 281 | + ensureGreen(index); |
| 282 | + |
| 283 | + assertAcked(client().admin().indices().prepareClose(index).setWaitForActiveShards(1)); |
| 284 | + |
| 285 | + Throwable executionException = expectThrows( |
| 286 | + ExecutionException.class, |
| 287 | + () -> client().admin() |
| 288 | + .indices() |
| 289 | + .updateSettings( |
| 290 | + new UpdateSettingsRequest(index).settings( |
| 291 | + Settings.builder() |
| 292 | + .put("index.codec", randomFrom(CodecService.DEFAULT_CODEC, CodecService.BEST_COMPRESSION_CODEC)) |
| 293 | + .put("index.codec.compression_level", randomIntBetween(1, 6)) |
| 294 | + ) |
| 295 | + ) |
| 296 | + .get() |
| 297 | + ); |
| 298 | + |
| 299 | + Throwable rootCause = Throwables.getRootCause(executionException); |
| 300 | + assertEquals(IllegalArgumentException.class, rootCause.getClass()); |
| 301 | + assertTrue(rootCause.getMessage().startsWith("Compression level cannot be set")); |
| 302 | + |
| 303 | + assertAcked( |
| 304 | + client().admin() |
| 305 | + .indices() |
| 306 | + .updateSettings( |
| 307 | + new UpdateSettingsRequest(index).settings( |
| 308 | + Settings.builder() |
| 309 | + .put("index.codec", randomFrom(QAT_DEFLATE_CODEC, QAT_LZ4_CODEC)) |
| 310 | + .put("index.codec.compression_level", randomIntBetween(1, 6)) |
| 311 | + ) |
| 312 | + ) |
| 313 | + .get() |
| 314 | + ); |
| 315 | + |
| 316 | + assertAcked(client().admin().indices().prepareOpen(index).setWaitForActiveShards(1)); |
| 317 | + ensureGreen(index); |
| 318 | + } |
188 | 319 | }
|
0 commit comments