|
7 | 7 | import lombok.extern.log4j.Log4j2;
|
8 | 8 | import org.junit.After;
|
9 | 9 | import org.junit.Before;
|
| 10 | +import org.opensearch.client.Request; |
| 11 | +import org.opensearch.client.Response; |
| 12 | +import org.opensearch.client.ResponseException; |
| 13 | +import org.opensearch.core.rest.RestStatus; |
10 | 14 | import org.opensearch.neuralsearch.BaseNeuralSearchIT;
|
| 15 | +import org.opensearch.neuralsearch.plugin.NeuralSearch; |
11 | 16 | import org.opensearch.neuralsearch.settings.NeuralSearchSettings;
|
12 | 17 | import org.opensearch.neuralsearch.stats.common.StatSnapshot;
|
13 | 18 | import org.opensearch.neuralsearch.stats.info.InfoStatName;
|
@@ -57,6 +62,14 @@ public void tearDown() throws Exception {
|
57 | 62 | updateClusterSettings(NeuralSearchSettings.NEURAL_STATS_ENABLED.getKey(), false);
|
58 | 63 | }
|
59 | 64 |
|
| 65 | + public void test_statsDisabledIsForbidden() throws Exception { |
| 66 | + updateClusterSettings("plugins.neural_search.stats_enabled", false); |
| 67 | + Request request = new Request("GET", NeuralSearch.NEURAL_BASE_URI + "/stats"); |
| 68 | + |
| 69 | + ResponseException response = expectThrows(ResponseException.class, () -> client().performRequest(request)); |
| 70 | + assertEquals(RestStatus.FORBIDDEN, RestStatus.fromCode(response.getResponse().getStatusLine().getStatusCode())); |
| 71 | + } |
| 72 | + |
60 | 73 | public void test_textEmbedding() throws Exception {
|
61 | 74 | // Setup processors
|
62 | 75 | String modelId = uploadTextEmbeddingModel();
|
@@ -138,7 +151,7 @@ public void test_includeMetadata() throws Exception {
|
138 | 151 | String valueWithMetadata = ((Map<String, String>) clusterVersionStatMetadata).get(StatSnapshot.VALUE_FIELD);
|
139 | 152 |
|
140 | 153 | // Stat type metadata should match
|
141 |
| - assertEquals(InfoStatType.SETTABLE_STRING.getTypeString(), statType); |
| 154 | + assertEquals(InfoStatType.INFO_STRING.getTypeString(), statType); |
142 | 155 |
|
143 | 156 | // Fetch Without metadata
|
144 | 157 | params.put(RestNeuralStatsAction.INCLUDE_METADATA_PARAM, "false");
|
|
0 commit comments