Skip to content

Commit

Permalink
Muted RollupActionIT because of #68609
Browse files Browse the repository at this point in the history
Relates to #68609

Backports #71058
  • Loading branch information
csoulios committed Mar 30, 2021
1 parent 2e6619e commit c38268c
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@

package org.elasticsearch.xpack.ilm.actions;

import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
import org.elasticsearch.xpack.core.ilm.RollupILMAction;
import org.elasticsearch.xpack.core.ilm.RollupStep;
import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
import org.elasticsearch.xpack.core.rollup.RollupActionDateHistogramGroupConfig;
import org.elasticsearch.xpack.core.rollup.RollupActionGroupConfig;
import org.elasticsearch.xpack.core.rollup.job.MetricConfig;
import org.junit.Before;

import java.io.IOException;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;

import static org.elasticsearch.xpack.TimeSeriesRestDriver.createIndexWithSettings;
import static org.elasticsearch.xpack.TimeSeriesRestDriver.createNewSingletonPolicy;
Expand All @@ -30,6 +34,7 @@
import static org.elasticsearch.xpack.TimeSeriesRestDriver.updatePolicy;
import static org.hamcrest.Matchers.equalTo;

@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/68609")
public class RollupActionIT extends ESRestTestCase {

private String index;
Expand All @@ -47,7 +52,6 @@ public void refreshIndex() {
public void testRollupIndex() throws Exception {
createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0));
String rollupIndex = RollupStep.getRollupIndexName(index);
index(client(), index, "_id", "timestamp", "2020-01-01T05:10:00Z", "volume", 11.0);
RollupActionConfig rollupConfig = new RollupActionConfig(
new RollupActionGroupConfig(new RollupActionDateHistogramGroupConfig.FixedInterval("timestamp", DateHistogramInterval.DAY)),
Expand All @@ -56,16 +60,16 @@ public void testRollupIndex() throws Exception {
createNewSingletonPolicy(client(), policy, "cold", new RollupILMAction(rollupConfig, null));
updatePolicy(client(), index, policy);

assertBusy(() -> assertNotNull(getRollupIndexName(index)));
String rollupIndex = getRollupIndexName(index);
assertBusy(() -> assertTrue(indexExists(rollupIndex)));
assertBusy(() -> assertFalse(getOnlyIndexSettings(client(), rollupIndex).containsKey(LifecycleSettings.LIFECYCLE_NAME)));
assertBusy(() -> assertTrue(indexExists(index)));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/69934")
public void testRollupIndexAndSetNewRollupPolicy() throws Exception {
createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0));
String rollupIndex = RollupStep.ROLLUP_INDEX_NAME_PREFIX + index;
index(client(), index, "_id", "timestamp", "2020-01-01T05:10:00Z", "volume", 11.0);
RollupActionConfig rollupConfig = new RollupActionConfig(
new RollupActionGroupConfig(new RollupActionDateHistogramGroupConfig.FixedInterval("timestamp", DateHistogramInterval.DAY)),
Expand All @@ -74,9 +78,26 @@ public void testRollupIndexAndSetNewRollupPolicy() throws Exception {
createNewSingletonPolicy(client(), policy, "cold", new RollupILMAction(rollupConfig, policy));
updatePolicy(client(), index, policy);

assertBusy(() -> assertNotNull(getRollupIndexName(index)));
String rollupIndex = getRollupIndexName(index);
assertBusy(() -> assertTrue(indexExists(rollupIndex)));
assertBusy(() -> assertThat(getOnlyIndexSettings(client(), rollupIndex).get(LifecycleSettings.LIFECYCLE_NAME), equalTo(policy)));
assertBusy(() -> assertTrue(indexExists(index)));
}

/**
* gets the generated rollup index name for a given index by looking at newly created indices that match the rollup index name pattern
*
* @param index the name of the source index used to generate the rollup index name
* @return the name of the rollup index for a given index, null if none exist
* @throws IOException if request fails
*/
private String getRollupIndexName(String index) throws IOException {
Response response = client().performRequest(new Request("GET", "/rollup-*-" + index));
Map<String, Object> asMap = responseAsMap(response);
if (asMap.size() == 1) {
return (String) asMap.keySet().toArray()[0];
}
return null;
}
}

0 comments on commit c38268c

Please sign in to comment.