Marvel: stabilize LocalExporterTests
closes elastic/elasticsearch#779 Original commit: elastic/x-pack-elasticsearch@8b5e80e246
This commit is contained in:
parent
72c015f82e
commit
6862cf6996
|
@ -35,8 +35,8 @@ import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||||
import org.elasticsearch.test.InternalTestCluster;
|
import org.elasticsearch.test.InternalTestCluster;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -60,16 +60,23 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
return Settings.builder()
|
return Settings.builder()
|
||||||
.put(super.nodeSettings(nodeOrdinal))
|
.put(super.nodeSettings(nodeOrdinal))
|
||||||
|
.put(MarvelSettings.INTERVAL, "-1")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanup() throws Exception {
|
||||||
|
updateMarvelInterval(-1, TimeUnit.SECONDS);
|
||||||
|
wipeMarvelIndices();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleExport() throws Exception {
|
public void testSimpleExport() throws Exception {
|
||||||
internalCluster().startNode(Settings.builder()
|
internalCluster().startNode(Settings.builder()
|
||||||
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
||||||
.put("marvel.agent.exporters._local.enabled", true)
|
.put("marvel.agent.exporters._local.enabled", true)
|
||||||
.build());
|
.build());
|
||||||
ensureGreen();
|
securedEnsureGreen();
|
||||||
|
|
||||||
Exporter exporter = getLocalExporter("_local");
|
Exporter exporter = getLocalExporter("_local");
|
||||||
|
|
||||||
|
@ -100,12 +107,17 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
public void testTemplateCreation() throws Exception {
|
public void testTemplateCreation() throws Exception {
|
||||||
internalCluster().startNode(Settings.builder()
|
internalCluster().startNode(Settings.builder()
|
||||||
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
||||||
|
.put("marvel.agent.exporters._local.template.settings.index.number_of_replicas", 0)
|
||||||
.build());
|
.build());
|
||||||
ensureGreen();
|
securedEnsureGreen();
|
||||||
|
|
||||||
LocalExporter exporter = getLocalExporter("_local");
|
LocalExporter exporter = getLocalExporter("_local");
|
||||||
assertTrue(exporter.installedTemplateVersionMandatesAnUpdate(Version.CURRENT, null));
|
assertTrue(exporter.installedTemplateVersionMandatesAnUpdate(Version.CURRENT, null));
|
||||||
|
|
||||||
|
// start collecting
|
||||||
|
updateMarvelInterval(3L, TimeUnit.SECONDS);
|
||||||
|
waitForMarvelIndices();
|
||||||
|
|
||||||
// lets wait until the marvel template will be installed
|
// lets wait until the marvel template will be installed
|
||||||
awaitMarvelTemplateInstalled();
|
awaitMarvelTemplateInstalled();
|
||||||
|
|
||||||
|
@ -118,16 +130,25 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
public void testTemplateUpdate() throws Exception {
|
public void testTemplateUpdate() throws Exception {
|
||||||
internalCluster().startNode(Settings.builder()
|
internalCluster().startNode(Settings.builder()
|
||||||
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
||||||
|
.put("marvel.agent.exporters._local.template.settings.index.number_of_replicas", 0)
|
||||||
.build());
|
.build());
|
||||||
ensureGreen();
|
securedEnsureGreen();
|
||||||
|
|
||||||
LocalExporter exporter = getLocalExporter("_local");
|
LocalExporter exporter = getLocalExporter("_local");
|
||||||
Version fakeVersion = MIN_SUPPORTED_TEMPLATE_VERSION;
|
Version fakeVersion = MIN_SUPPORTED_TEMPLATE_VERSION;
|
||||||
assertThat(exporter.installedTemplateVersionMandatesAnUpdate(Version.CURRENT, fakeVersion), is(true));
|
assertThat(exporter.installedTemplateVersionMandatesAnUpdate(Version.CURRENT, fakeVersion), is(true));
|
||||||
|
|
||||||
|
// start collecting
|
||||||
|
updateMarvelInterval(3L, TimeUnit.SECONDS);
|
||||||
|
waitForMarvelIndices();
|
||||||
|
|
||||||
// first, lets wait for the marvel template to be installed
|
// first, lets wait for the marvel template to be installed
|
||||||
awaitMarvelTemplateInstalled();
|
awaitMarvelTemplateInstalled();
|
||||||
|
|
||||||
|
// stop collecting before cluster restart
|
||||||
|
updateMarvelInterval(-1, TimeUnit.SECONDS);
|
||||||
|
wipeMarvelIndices();
|
||||||
|
|
||||||
// now lets update the template with an old one and then restart the cluster
|
// now lets update the template with an old one and then restart the cluster
|
||||||
exporter.putTemplate(Settings.builder().put(MarvelTemplateUtils.MARVEL_VERSION_FIELD, fakeVersion.toString()).build());
|
exporter.putTemplate(Settings.builder().put(MarvelTemplateUtils.MARVEL_VERSION_FIELD, fakeVersion.toString()).build());
|
||||||
logger.debug("full cluster restart");
|
logger.debug("full cluster restart");
|
||||||
|
@ -142,6 +163,10 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
fail("waited too long (at least 30 seconds) for the cluster to restart");
|
fail("waited too long (at least 30 seconds) for the cluster to restart");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start collecting again
|
||||||
|
updateMarvelInterval(3L, TimeUnit.SECONDS);
|
||||||
|
waitForMarvelIndices();
|
||||||
|
|
||||||
// now that the cluster is restarting, lets wait for the new template version to be installed
|
// now that the cluster is restarting, lets wait for the new template version to be installed
|
||||||
awaitMarvelTemplateInstalled(Version.CURRENT);
|
awaitMarvelTemplateInstalled(Version.CURRENT);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +209,7 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
verify(exporter, times(1)).installedTemplateVersionIsSufficient(Version.CURRENT, unsupportedVersion);
|
verify(exporter, times(1)).installedTemplateVersionIsSufficient(Version.CURRENT, unsupportedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @TestLogging("marvel.agent:trace")
|
@Test
|
||||||
public void testIndexTimestampFormat() throws Exception {
|
public void testIndexTimestampFormat() throws Exception {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
String timeFormat = randomFrom("YY", "YYYY", "YYYY.MM", "YYYY-MM", "MM.YYYY", "MM");
|
String timeFormat = randomFrom("YY", "YYYY", "YYYY.MM", "YYYY-MM", "MM.YYYY", "MM");
|
||||||
|
@ -193,7 +218,7 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
.put("marvel.agent.exporters._local.type", LocalExporter.TYPE)
|
||||||
.put("marvel.agent.exporters._local." + LocalExporter.INDEX_NAME_TIME_FORMAT_SETTING, timeFormat)
|
.put("marvel.agent.exporters._local." + LocalExporter.INDEX_NAME_TIME_FORMAT_SETTING, timeFormat)
|
||||||
.build());
|
.build());
|
||||||
ensureGreen();
|
securedEnsureGreen();
|
||||||
|
|
||||||
LocalExporter exporter = getLocalExporter("_local");
|
LocalExporter exporter = getLocalExporter("_local");
|
||||||
|
|
||||||
|
@ -239,8 +264,6 @@ public class LocalExporterTests extends MarvelIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Version getCurrentlyInstalledTemplateVersion() {
|
private Version getCurrentlyInstalledTemplateVersion() {
|
||||||
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(MarvelTemplateUtils.INDEX_TEMPLATE_NAME).get();
|
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(MarvelTemplateUtils.INDEX_TEMPLATE_NAME).get();
|
||||||
assertThat(response, notNullValue());
|
assertThat(response, notNullValue());
|
||||||
|
|
Loading…
Reference in New Issue