Skip to content

Commit

Permalink
fix(api): Add preceding / to get index sizes path (#9043)
Browse files Browse the repository at this point in the history
Co-authored-by: Indy Prentice <[email protected]>
  • Loading branch information
iprentic and Indy Prentice authored Oct 18, 2023
1 parent aae1347 commit 7855fb6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public List<TimeseriesIndexSizeResult> getIndexSizes() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
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;
Expand Down Expand Up @@ -884,4 +885,19 @@ public void testCountByFilterAfterDelete() throws InterruptedException {
_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")));
}
}

0 comments on commit 7855fb6

Please sign in to comment.