Skip to content

Commit 7c2db2f

Browse files
Refactoring testing functions
1 parent f0023df commit 7c2db2f

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/InferenceIndicesIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ public List<InferenceServiceExtension.Factory> getInferenceServiceFactories() {
9292

9393
@Override
9494
public Settings getIndexSettings() {
95-
return InferenceIndex.settingsForTesting(
96-
Settings.builder().put("index.routing.allocation.require.index_router", "config").build()
97-
);
95+
return InferenceIndex.builder()
96+
.put(Settings.builder().put("index.routing.allocation.require.index_router", "config").build())
97+
.build();
9898
}
9999

100100
@Override
101101
public Settings getSecretsIndexSettings() {
102-
return InferenceSecretsIndex.settingsForTesting(
103-
Settings.builder().put("index.routing.allocation.require.index_router", "secrets").build()
104-
);
102+
return InferenceSecretsIndex.builder()
103+
.put(Settings.builder().put("index.routing.allocation.require.index_router", "secrets").build())
104+
.build();
105105
}
106106
};
107107
plugins.add(inferencePlugin);

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,11 @@ public static Settings settings() {
3333
return builder().build();
3434
}
3535

36-
private static Settings.Builder builder() {
36+
// Public to allow tests to create the index with custom settings
37+
public static Settings.Builder builder() {
3738
return Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1");
3839
}
3940

40-
/**
41-
* This allows tests to set additional settings for the inference index.
42-
* @param extraSettings additional settings to apply to the inference index.
43-
*/
44-
public static Settings settingsForTesting(Settings extraSettings) {
45-
return builder().put(extraSettings).build();
46-
}
47-
4841
/**
4942
* Reject any unknown fields being added by setting dynamic mappings to
5043
* {@code strict} for the top level object. A document that contains unknown

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceSecretsIndex.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,11 @@ public static Settings settings() {
3232
return builder().build();
3333
}
3434

35-
private static Settings.Builder builder() {
35+
// Public to allow tests to create the index with custom settings
36+
public static Settings.Builder builder() {
3637
return Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1");
3738
}
3839

39-
/**
40-
* This allows tests to set additional settings for the inference index.
41-
* @param extraSettings additional settings to apply to the inference index.
42-
*/
43-
public static Settings settingsForTesting(Settings extraSettings) {
44-
return builder().put(extraSettings).build();
45-
}
46-
4740
/**
4841
* Reject any unknown fields being added by setting dynamic mappings to
4942
* {@code strict} for the top level object. A document that contains unknown

0 commit comments

Comments
 (0)