Test: do not wipe templates from clusters in audit tests
This commit adds both the security index template and the audit index template to the excluded templates for the RemoteIndexAuditTrailStartingTests and IndexAuditTrailTests. By allowing the templates to remain in place, we make it easier for subsequent tests in the suite to have their audit trails started. Relates elastic/x-pack-elasticsearch#435 Original commit: elastic/x-pack-elasticsearch@6e54de19f9
This commit is contained in:
parent
858178602e
commit
79a9576596
|
@ -28,6 +28,7 @@ import org.elasticsearch.common.settings.MockSecureSettings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
@ -43,6 +44,7 @@ import org.elasticsearch.transport.TransportRequest;
|
|||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.security.SecurityLifecycleService;
|
||||
import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail.Message;
|
||||
import org.elasticsearch.xpack.security.authc.AuthenticationToken;
|
||||
import org.elasticsearch.xpack.security.transport.filter.IPFilter;
|
||||
|
@ -243,13 +245,13 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
if (remoteCluster != null) {
|
||||
remoteCluster.wipe(Collections.<String>emptySet());
|
||||
remoteCluster.wipe(excludeTemplates());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> excludeTemplates() {
|
||||
return Collections.singleton(IndexAuditTrail.INDEX_TEMPLATE_NAME);
|
||||
return Sets.newHashSet(SecurityLifecycleService.SECURITY_TEMPLATE_NAME, IndexAuditTrail.INDEX_TEMPLATE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
|||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
|
@ -17,6 +18,7 @@ import org.elasticsearch.test.SecurityIntegTestCase;
|
|||
import org.elasticsearch.test.SecuritySettingsSource;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.security.SecurityLifecycleService;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrail;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrailService;
|
||||
import org.junit.After;
|
||||
|
@ -69,7 +71,7 @@ public class RemoteIndexAuditTrailStartingTests extends SecurityIntegTestCase {
|
|||
|
||||
@Override
|
||||
protected Set<String> excludeTemplates() {
|
||||
return Collections.singleton(IndexAuditTrail.INDEX_TEMPLATE_NAME);
|
||||
return Sets.newHashSet(SecurityLifecycleService.SECURITY_TEMPLATE_NAME, IndexAuditTrail.INDEX_TEMPLATE_NAME);
|
||||
}
|
||||
|
||||
@Before
|
||||
|
@ -123,11 +125,11 @@ public class RemoteIndexAuditTrailStartingTests extends SecurityIntegTestCase {
|
|||
.forEach((auditTrail) -> ((IndexAuditTrail) auditTrail).stop()));
|
||||
// first stop both audit trails otherwise we keep on indexing
|
||||
if (remoteCluster != null) {
|
||||
toStop.add(() -> StreamSupport.stream(remoteCluster.getInstances(AuditTrailService.class).spliterator(), false)
|
||||
toStop.add(() -> StreamSupport.stream(remoteCluster.getInstances(AuditTrailService.class).spliterator(), false)
|
||||
.map(s -> s.getAuditTrails()).flatMap(List::stream)
|
||||
.filter(t -> t.name().equals(IndexAuditTrail.NAME))
|
||||
.forEach((auditTrail) -> ((IndexAuditTrail) auditTrail).stop()));
|
||||
toStop.add(() -> remoteCluster.wipe(Collections.<String>emptySet()));
|
||||
toStop.add(() -> remoteCluster.wipe(excludeTemplates()));
|
||||
toStop.add(remoteCluster::afterTest);
|
||||
toStop.add(remoteCluster);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue