fix(api): Add preceding / to get index sizes path (#9043)

Co-authored-by: Indy Prentice <indy@Indys-MacBook-Pro.local>
This commit is contained in:
Indy Prentice 2023-10-18 17:19:10 -03:00 committed by GitHub
parent aae1347efc
commit 7855fb60a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -169,7 +169,7 @@ public class ElasticSearchTimeseriesAspectService implements TimeseriesAspectSer
List<TimeseriesIndexSizeResult> res = new ArrayList<>();
try {
String indicesPattern = _indexConvention.getAllTimeseriesAspectIndicesPattern();
Response r = _searchClient.getLowLevelClient().performRequest(new Request("GET", indicesPattern + "/_stats"));
Response r = _searchClient.getLowLevelClient().performRequest(new Request("GET", "/" + indicesPattern + "/_stats"));
JsonNode body = new ObjectMapper().readTree(r.getEntity().getContent());
body.get("indices").fields().forEachRemaining(entry -> {
TimeseriesIndexSizeResult elemResult = new TimeseriesIndexSizeResult();

View File

@ -45,6 +45,7 @@ import com.linkedin.timeseries.GenericTable;
import com.linkedin.timeseries.GroupingBucket;
import com.linkedin.timeseries.GroupingBucketType;
import com.linkedin.timeseries.TimeWindowSize;
import com.linkedin.timeseries.TimeseriesIndexSizeResult;
import org.opensearch.client.RestHighLevelClient;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.BeforeClass;
@ -884,4 +885,19 @@ abstract public class TimeseriesAspectServiceTestBase extends AbstractTestNGSpri
_elasticSearchTimeseriesAspectService.countByFilter(ENTITY_NAME, ASPECT_NAME, urnAndTimeFilter);
assertEquals(count, 0L);
}
@Test(groups = {"getAggregatedStats"}, dependsOnGroups = {"upsert"})
public void testGetIndexSizes() {
List<TimeseriesIndexSizeResult> result = _elasticSearchTimeseriesAspectService.getIndexSizes();
/*
Example result:
{aspectName=testentityprofile, sizeMb=52.234, indexName=es_timeseries_aspect_service_test_testentity_testentityprofileaspect_v1, entityName=testentity}
{aspectName=testentityprofile, sizeMb=0.208, indexName=es_timeseries_aspect_service_test_testentitywithouttests_testentityprofileaspect_v1, entityName=testentitywithouttests}
*/
// There may be other indices in there from other tests, so just make sure that index for entity + aspect is in there
assertTrue(result.size() > 1);
assertTrue(
result.stream().anyMatch(idxSizeResult -> idxSizeResult.getIndexName().equals(
"es_timeseries_aspect_service_test_testentitywithouttests_testentityprofileaspect_v1")));
}
}