Skip to content

Commit e08fb88

Browse files
committed
Add targetIndexSettings validation with test
Signed-off-by: Aleksandr Tuliakov <[email protected]>
1 parent 6eed372 commit e08fb88

File tree

2 files changed

+16
-0
lines changed
  • src
    • main/kotlin/org/opensearch/indexmanagement/rollup/model
    • test/kotlin/org/opensearch/indexmanagement/rollup/model

2 files changed

+16
-0
lines changed

src/main/kotlin/org/opensearch/indexmanagement/rollup/model/Rollup.kt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.opensearch.indexmanagement.rollup.model
77

8+
import org.opensearch.common.settings.IndexScopedSettings
89
import org.opensearch.common.settings.Settings
910
import org.opensearch.commons.authuser.User
1011
import org.opensearch.core.common.io.stream.StreamInput
@@ -89,6 +90,9 @@ data class Rollup(
8990
}
9091
}
9192
require(sourceIndex != targetIndex) { "Your source and target index cannot be the same" }
93+
if (targetIndexSettings != null) {
94+
IndexScopedSettings(null, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS).validate(targetIndexSettings, true)
95+
}
9296
require(dimensions.filter { it.type == Dimension.Type.DATE_HISTOGRAM }.size == 1) {
9397
"Must specify precisely one date histogram dimension" // this covers empty dimensions case too
9498
}

src/test/kotlin/org/opensearch/indexmanagement/rollup/model/RollupTests.kt

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package org.opensearch.indexmanagement.rollup.model
77

8+
import org.opensearch.common.settings.Settings
9+
import org.opensearch.common.settings.SettingsException
810
import org.opensearch.indexmanagement.randomInstant
911
import org.opensearch.indexmanagement.randomSchedule
1012
import org.opensearch.indexmanagement.rollup.randomDateHistogram
@@ -52,6 +54,16 @@ class RollupTests : OpenSearchTestCase() {
5254
}
5355
}
5456

57+
fun `test rollup requires correct target index settings`() {
58+
assertFailsWith(SettingsException::class, "Unknown property was `index.codec1`") {
59+
randomRollup().copy(targetIndexSettings = Settings.builder().put("index.codec1", "zlib").build())
60+
}
61+
62+
val sb = Settings.builder()
63+
sb.put("index.codec", "zlib")
64+
randomRollup().copy(targetIndexSettings = sb.build())
65+
}
66+
5567
fun `test rollup requires page size to be between 1 and 10k`() {
5668
assertFailsWith(IllegalArgumentException::class, "Page size was negative") {
5769
randomRollup().copy(pageSize = -1)

0 commit comments

Comments
 (0)