Fix LocalIndicesCleanerTests

Original commit: elastic/x-pack-elasticsearch@3e08c84e80
This commit is contained in:
Tanguy Leroux 2016-03-14 16:25:00 +01:00
parent 3d1f1814a4
commit 7d377a5b7f
2 changed files with 9 additions and 8 deletions

View File

@ -156,12 +156,14 @@ public abstract class MonitoringIndexNameResolver<T extends MonitoringDoc> {
public static final Setting<String> INDEX_NAME_TIME_FORMAT_SETTING = new Setting<>("index.name.time_format","YYYY.MM.dd", public static final Setting<String> INDEX_NAME_TIME_FORMAT_SETTING = new Setting<>("index.name.time_format","YYYY.MM.dd",
Function.identity(), Setting.Property.NodeScope); Function.identity(), Setting.Property.NodeScope);
private final MonitoredSystem id; private final MonitoredSystem system;
private final DateTimeFormatter formatter; private final DateTimeFormatter formatter;
private final String index;
public Timestamped(MonitoredSystem id, int version, Settings settings) { public Timestamped(MonitoredSystem system, int version, Settings settings) {
super(version); super(version);
this.id = id; this.system = system;
this.index = String.join(DELIMITER, PREFIX, system.getSystem(), String.valueOf(getVersion()));
String format = INDEX_NAME_TIME_FORMAT_SETTING.get(settings); String format = INDEX_NAME_TIME_FORMAT_SETTING.get(settings);
try { try {
this.formatter = DateTimeFormat.forPattern(format).withZoneUTC(); this.formatter = DateTimeFormat.forPattern(format).withZoneUTC();
@ -172,12 +174,12 @@ public abstract class MonitoringIndexNameResolver<T extends MonitoringDoc> {
@Override @Override
public String index(T document) { public String index(T document) {
return String.join(DELIMITER, PREFIX, id.getSystem(), String.valueOf(getVersion()), formatter.print(document.getTimestamp())); return String.join(DELIMITER, index, formatter.print(document.getTimestamp()));
} }
@Override @Override
public String indexPattern() { public String indexPattern() {
return String.join(DELIMITER, PREFIX, "*", String.valueOf(getVersion()), "*"); return String.join(DELIMITER, index, "*");
} }
@Override @Override
@ -187,7 +189,7 @@ public abstract class MonitoringIndexNameResolver<T extends MonitoringDoc> {
} }
String getId() { String getId() {
return id.getSystem(); return system.getSystem();
} }
} }
} }

View File

@ -233,8 +233,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MarvelIntegTestCase
MonitoringDoc monitoringDoc = randomMonitoringDoc(); MonitoringDoc monitoringDoc = randomMonitoringDoc();
monitoringDoc.setTimestamp(creationDate.getMillis()); monitoringDoc.setTimestamp(creationDate.getMillis());
MonitoringIndexNameResolver.Timestamped resolver = new MockTimestampedIndexNameResolver(randomFrom(MonitoredSystem.values()), MonitoringIndexNameResolver.Timestamped resolver = new MockTimestampedIndexNameResolver(MonitoredSystem.ES, version);
version);
createIndex(resolver.index(monitoringDoc), creationDate); createIndex(resolver.index(monitoringDoc), creationDate);
} }