Renaming GeoIpDownloaderStatsAction (#107290)

Renaming GeoIpDownloaderStatsAction to GeoIpStatsAction
This commit is contained in:
Keith Massey 2024-04-10 09:21:24 -05:00 committed by GitHub
parent 19e9fc32f2
commit 48a88c575c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 65 additions and 80 deletions

View file

@ -4,8 +4,8 @@
<titleabbrev>GeoIP stats</titleabbrev> <titleabbrev>GeoIP stats</titleabbrev>
++++ ++++
Gets download statistics for GeoIP2 databases used with the Gets statistics about the <<geoip-processor,`geoip` processor>>, including
<<geoip-processor,`geoip` processor>>. download statistics for GeoIP2 databases used with it.
[source,console] [source,console]
---- ----
@ -60,7 +60,7 @@ Total number of database updates skipped.
`nodes`:: `nodes`::
(object) (object)
Downloaded GeoIP2 databases for each node. Statistics for each node.
+ +
.Properties of `nodes` .Properties of `nodes`
[%collapsible%open] [%collapsible%open]

View file

@ -30,7 +30,7 @@ import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.ingest.AbstractProcessor; import org.elasticsearch.ingest.AbstractProcessor;
import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.ingest.Processor; import org.elasticsearch.ingest.Processor;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction;
import org.elasticsearch.persistent.PersistentTaskParams; import org.elasticsearch.persistent.PersistentTaskParams;
import org.elasticsearch.persistent.PersistentTasksCustomMetadata; import org.elasticsearch.persistent.PersistentTasksCustomMetadata;
import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.IngestPlugin;
@ -121,13 +121,10 @@ public class GeoIpDownloaderIT extends AbstractGeoIpIT {
} }
}); });
assertBusy(() -> { assertBusy(() -> {
GeoIpDownloaderStatsAction.Response response = client().execute( GeoIpStatsAction.Response response = client().execute(GeoIpStatsAction.INSTANCE, new GeoIpStatsAction.Request()).actionGet();
GeoIpDownloaderStatsAction.INSTANCE, assertThat(response.getDownloaderStats().getDatabasesCount(), equalTo(0));
new GeoIpDownloaderStatsAction.Request()
).actionGet();
assertThat(response.getStats().getDatabasesCount(), equalTo(0));
assertThat(response.getNodes(), not(empty())); assertThat(response.getNodes(), not(empty()));
for (GeoIpDownloaderStatsAction.NodeResponse nodeResponse : response.getNodes()) { for (GeoIpStatsAction.NodeResponse nodeResponse : response.getNodes()) {
assertThat(nodeResponse.getConfigDatabases(), empty()); assertThat(nodeResponse.getConfigDatabases(), empty());
assertThat(nodeResponse.getDatabases(), empty()); assertThat(nodeResponse.getDatabases(), empty());
assertThat(nodeResponse.getFilesInTemp().stream().filter(s -> s.endsWith(".txt") == false).toList(), empty()); assertThat(nodeResponse.getFilesInTemp().stream().filter(s -> s.endsWith(".txt") == false).toList(), empty());
@ -703,12 +700,9 @@ public class GeoIpDownloaderIT extends AbstractGeoIpIT {
}); });
assertBusy(() -> { assertBusy(() -> {
GeoIpDownloaderStatsAction.Response response = client().execute( GeoIpStatsAction.Response response = client().execute(GeoIpStatsAction.INSTANCE, new GeoIpStatsAction.Request()).actionGet();
GeoIpDownloaderStatsAction.INSTANCE,
new GeoIpDownloaderStatsAction.Request()
).actionGet();
assertThat(response.getNodes(), not(empty())); assertThat(response.getNodes(), not(empty()));
for (GeoIpDownloaderStatsAction.NodeResponse nodeResponse : response.getNodes()) { for (GeoIpStatsAction.NodeResponse nodeResponse : response.getNodes()) {
assertThat( assertThat(
nodeResponse.getConfigDatabases(), nodeResponse.getConfigDatabases(),
containsInAnyOrder("GeoLite2-Country.mmdb", "GeoLite2-City.mmdb", "GeoLite2-ASN.mmdb") containsInAnyOrder("GeoLite2-Country.mmdb", "GeoLite2-City.mmdb", "GeoLite2-ASN.mmdb")
@ -751,12 +745,9 @@ public class GeoIpDownloaderIT extends AbstractGeoIpIT {
}); });
assertBusy(() -> { assertBusy(() -> {
GeoIpDownloaderStatsAction.Response response = client().execute( GeoIpStatsAction.Response response = client().execute(GeoIpStatsAction.INSTANCE, new GeoIpStatsAction.Request()).actionGet();
GeoIpDownloaderStatsAction.INSTANCE,
new GeoIpDownloaderStatsAction.Request()
).actionGet();
assertThat(response.getNodes(), not(empty())); assertThat(response.getNodes(), not(empty()));
for (GeoIpDownloaderStatsAction.NodeResponse nodeResponse : response.getNodes()) { for (GeoIpStatsAction.NodeResponse nodeResponse : response.getNodes()) {
assertThat(nodeResponse.getConfigDatabases(), empty()); assertThat(nodeResponse.getConfigDatabases(), empty());
} }
}); });

View file

@ -11,7 +11,7 @@ package org.elasticsearch.ingest.geoip;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.reindex.ReindexPlugin; import org.elasticsearch.reindex.ReindexPlugin;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
@ -65,8 +65,8 @@ public class GeoIpDownloaderStatsIT extends AbstractGeoIpIT {
* slowly to pass. * slowly to pass.
*/ */
assumeTrue("only test with fixture to have stable results", getEndpoint() != null); assumeTrue("only test with fixture to have stable results", getEndpoint() != null);
GeoIpDownloaderStatsAction.Request req = new GeoIpDownloaderStatsAction.Request(); GeoIpStatsAction.Request req = new GeoIpStatsAction.Request();
GeoIpDownloaderStatsAction.Response response = client().execute(GeoIpDownloaderStatsAction.INSTANCE, req).actionGet(); GeoIpStatsAction.Response response = client().execute(GeoIpStatsAction.INSTANCE, req).actionGet();
XContentTestUtils.JsonMapView jsonMapView = new XContentTestUtils.JsonMapView(convertToMap(response)); XContentTestUtils.JsonMapView jsonMapView = new XContentTestUtils.JsonMapView(convertToMap(response));
assertThat(jsonMapView.get("stats.successful_downloads"), equalTo(0)); assertThat(jsonMapView.get("stats.successful_downloads"), equalTo(0));
assertThat(jsonMapView.get("stats.failed_downloads"), equalTo(0)); assertThat(jsonMapView.get("stats.failed_downloads"), equalTo(0));
@ -78,7 +78,7 @@ public class GeoIpDownloaderStatsIT extends AbstractGeoIpIT {
updateClusterSettings(Settings.builder().put(GeoIpDownloaderTaskExecutor.ENABLED_SETTING.getKey(), true)); updateClusterSettings(Settings.builder().put(GeoIpDownloaderTaskExecutor.ENABLED_SETTING.getKey(), true));
assertBusy(() -> { assertBusy(() -> {
GeoIpDownloaderStatsAction.Response res = client().execute(GeoIpDownloaderStatsAction.INSTANCE, req).actionGet(); GeoIpStatsAction.Response res = client().execute(GeoIpStatsAction.INSTANCE, req).actionGet();
XContentTestUtils.JsonMapView view = new XContentTestUtils.JsonMapView(convertToMap(res)); XContentTestUtils.JsonMapView view = new XContentTestUtils.JsonMapView(convertToMap(res));
assertThat(view.get("stats.successful_downloads"), equalTo(4)); assertThat(view.get("stats.successful_downloads"), equalTo(4));
assertThat(view.get("stats.failed_downloads"), equalTo(0)); assertThat(view.get("stats.failed_downloads"), equalTo(0));

View file

@ -28,9 +28,9 @@ import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.ingest.IngestService; import org.elasticsearch.ingest.IngestService;
import org.elasticsearch.ingest.Processor; import org.elasticsearch.ingest.Processor;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStats; import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStats;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsTransportAction; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsTransportAction;
import org.elasticsearch.ingest.geoip.stats.RestGeoIpDownloaderStatsAction; import org.elasticsearch.ingest.geoip.stats.RestGeoIpStatsAction;
import org.elasticsearch.persistent.PersistentTaskParams; import org.elasticsearch.persistent.PersistentTaskParams;
import org.elasticsearch.persistent.PersistentTaskState; import org.elasticsearch.persistent.PersistentTaskState;
import org.elasticsearch.persistent.PersistentTasksExecutor; import org.elasticsearch.persistent.PersistentTasksExecutor;
@ -144,7 +144,7 @@ public class IngestGeoIpPlugin extends Plugin implements IngestPlugin, SystemInd
@Override @Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return List.of(new ActionHandler<>(GeoIpDownloaderStatsAction.INSTANCE, GeoIpDownloaderStatsTransportAction.class)); return List.of(new ActionHandler<>(GeoIpStatsAction.INSTANCE, GeoIpStatsTransportAction.class));
} }
@Override @Override
@ -159,7 +159,7 @@ public class IngestGeoIpPlugin extends Plugin implements IngestPlugin, SystemInd
Supplier<DiscoveryNodes> nodesInCluster, Supplier<DiscoveryNodes> nodesInCluster,
Predicate<NodeFeature> clusterSupportsFeature Predicate<NodeFeature> clusterSupportsFeature
) { ) {
return List.of(new RestGeoIpDownloaderStatsAction()); return List.of(new RestGeoIpStatsAction());
} }
@Override @Override

View file

@ -30,11 +30,11 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
public class GeoIpDownloaderStatsAction { public class GeoIpStatsAction {
public static final ActionType<Response> INSTANCE = new ActionType<>("cluster:monitor/ingest/geoip/stats"); public static final ActionType<Response> INSTANCE = new ActionType<>("cluster:monitor/ingest/geoip/stats");
private GeoIpDownloaderStatsAction() {/* no instances */} private GeoIpStatsAction() {/* no instances */}
public static class Request extends BaseNodesRequest<Request> implements ToXContentObject { public static class Request extends BaseNodesRequest<Request> implements ToXContentObject {
@ -89,8 +89,8 @@ public class GeoIpDownloaderStatsAction {
super(clusterName, nodes, failures); super(clusterName, nodes, failures);
} }
public GeoIpDownloaderStats getStats() { public GeoIpDownloaderStats getDownloaderStats() {
return getNodes().stream().map(n -> n.stats).filter(Objects::nonNull).findFirst().orElse(GeoIpDownloaderStats.EMPTY); return getNodes().stream().map(n -> n.downloaderStats).filter(Objects::nonNull).findFirst().orElse(GeoIpDownloaderStats.EMPTY);
} }
@Override @Override
@ -105,7 +105,7 @@ public class GeoIpDownloaderStatsAction {
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
GeoIpDownloaderStats stats = getStats(); GeoIpDownloaderStats stats = getDownloaderStats();
builder.startObject(); builder.startObject();
builder.field("stats", stats); builder.field("stats", stats);
builder.startObject("nodes"); builder.startObject("nodes");
@ -153,14 +153,14 @@ public class GeoIpDownloaderStatsAction {
public static class NodeResponse extends BaseNodeResponse { public static class NodeResponse extends BaseNodeResponse {
private final GeoIpDownloaderStats stats; private final GeoIpDownloaderStats downloaderStats;
private final Set<String> databases; private final Set<String> databases;
private final Set<String> filesInTemp; private final Set<String> filesInTemp;
private final Set<String> configDatabases; private final Set<String> configDatabases;
protected NodeResponse(StreamInput in) throws IOException { protected NodeResponse(StreamInput in) throws IOException {
super(in); super(in);
stats = in.readBoolean() ? new GeoIpDownloaderStats(in) : null; downloaderStats = in.readBoolean() ? new GeoIpDownloaderStats(in) : null;
databases = in.readCollectionAsImmutableSet(StreamInput::readString); databases = in.readCollectionAsImmutableSet(StreamInput::readString);
filesInTemp = in.readCollectionAsImmutableSet(StreamInput::readString); filesInTemp = in.readCollectionAsImmutableSet(StreamInput::readString);
configDatabases = in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0) configDatabases = in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)
@ -170,20 +170,20 @@ public class GeoIpDownloaderStatsAction {
protected NodeResponse( protected NodeResponse(
DiscoveryNode node, DiscoveryNode node,
GeoIpDownloaderStats stats, GeoIpDownloaderStats downloaderStats,
Set<String> databases, Set<String> databases,
Set<String> filesInTemp, Set<String> filesInTemp,
Set<String> configDatabases Set<String> configDatabases
) { ) {
super(node); super(node);
this.stats = stats; this.downloaderStats = downloaderStats;
this.databases = Set.copyOf(databases); this.databases = Set.copyOf(databases);
this.filesInTemp = Set.copyOf(filesInTemp); this.filesInTemp = Set.copyOf(filesInTemp);
this.configDatabases = Set.copyOf(configDatabases); this.configDatabases = Set.copyOf(configDatabases);
} }
public GeoIpDownloaderStats getStats() { public GeoIpDownloaderStats getDownloaderStats() {
return stats; return downloaderStats;
} }
public Set<String> getDatabases() { public Set<String> getDatabases() {
@ -201,9 +201,9 @@ public class GeoIpDownloaderStatsAction {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeBoolean(stats != null); out.writeBoolean(downloaderStats != null);
if (stats != null) { if (downloaderStats != null) {
stats.writeTo(out); downloaderStats.writeTo(out);
} }
out.writeStringCollection(databases); out.writeStringCollection(databases);
out.writeStringCollection(filesInTemp); out.writeStringCollection(filesInTemp);
@ -217,7 +217,7 @@ public class GeoIpDownloaderStatsAction {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
NodeResponse that = (NodeResponse) o; NodeResponse that = (NodeResponse) o;
return stats.equals(that.stats) return downloaderStats.equals(that.downloaderStats)
&& databases.equals(that.databases) && databases.equals(that.databases)
&& filesInTemp.equals(that.filesInTemp) && filesInTemp.equals(that.filesInTemp)
&& Objects.equals(configDatabases, that.configDatabases); && Objects.equals(configDatabases, that.configDatabases);
@ -225,7 +225,7 @@ public class GeoIpDownloaderStatsAction {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(stats, databases, filesInTemp, configDatabases); return Objects.hash(downloaderStats, databases, filesInTemp, configDatabases);
} }
} }
} }

View file

@ -18,10 +18,10 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.ingest.geoip.DatabaseNodeService; import org.elasticsearch.ingest.geoip.DatabaseNodeService;
import org.elasticsearch.ingest.geoip.GeoIpDownloader; import org.elasticsearch.ingest.geoip.GeoIpDownloader;
import org.elasticsearch.ingest.geoip.GeoIpDownloaderTaskExecutor; import org.elasticsearch.ingest.geoip.GeoIpDownloaderTaskExecutor;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction.NodeRequest; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction.NodeRequest;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction.NodeResponse; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction.NodeResponse;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction.Request; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction.Request;
import org.elasticsearch.ingest.geoip.stats.GeoIpDownloaderStatsAction.Response; import org.elasticsearch.ingest.geoip.stats.GeoIpStatsAction.Response;
import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportService;
@ -29,14 +29,14 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
public class GeoIpDownloaderStatsTransportAction extends TransportNodesAction<Request, Response, NodeRequest, NodeResponse> { public class GeoIpStatsTransportAction extends TransportNodesAction<Request, Response, NodeRequest, NodeResponse> {
private final TransportService transportService; private final TransportService transportService;
private final DatabaseNodeService registry; private final DatabaseNodeService registry;
private final GeoIpDownloaderTaskExecutor geoIpDownloaderTaskExecutor; private final GeoIpDownloaderTaskExecutor geoIpDownloaderTaskExecutor;
@Inject @Inject
public GeoIpDownloaderStatsTransportAction( public GeoIpStatsTransportAction(
TransportService transportService, TransportService transportService,
ClusterService clusterService, ClusterService clusterService,
ThreadPool threadPool, ThreadPool threadPool,
@ -45,7 +45,7 @@ public class GeoIpDownloaderStatsTransportAction extends TransportNodesAction<Re
GeoIpDownloaderTaskExecutor geoIpDownloaderTaskExecutor GeoIpDownloaderTaskExecutor geoIpDownloaderTaskExecutor
) { ) {
super( super(
GeoIpDownloaderStatsAction.INSTANCE.name(), GeoIpStatsAction.INSTANCE.name(),
clusterService, clusterService,
transportService, transportService,
actionFilters, actionFilters,
@ -75,10 +75,10 @@ public class GeoIpDownloaderStatsTransportAction extends TransportNodesAction<Re
@Override @Override
protected NodeResponse nodeOperation(NodeRequest request, Task task) { protected NodeResponse nodeOperation(NodeRequest request, Task task) {
GeoIpDownloader geoIpTask = geoIpDownloaderTaskExecutor.getCurrentTask(); GeoIpDownloader geoIpTask = geoIpDownloaderTaskExecutor.getCurrentTask();
GeoIpDownloaderStats stats = geoIpTask == null || geoIpTask.getStatus() == null ? null : geoIpTask.getStatus(); GeoIpDownloaderStats downloaderStats = geoIpTask == null || geoIpTask.getStatus() == null ? null : geoIpTask.getStatus();
return new NodeResponse( return new NodeResponse(
transportService.getLocalNode(), transportService.getLocalNode(),
stats, downloaderStats,
registry.getAvailableDatabases(), registry.getAvailableDatabases(),
registry.getFilesInTemp(), registry.getFilesInTemp(),
registry.getConfigDatabases() registry.getConfigDatabases()

View file

@ -20,7 +20,7 @@ import java.util.List;
import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.GET;
@ServerlessScope(Scope.INTERNAL) @ServerlessScope(Scope.INTERNAL)
public class RestGeoIpDownloaderStatsAction extends BaseRestHandler { public class RestGeoIpStatsAction extends BaseRestHandler {
@Override @Override
public String getName() { public String getName() {
@ -34,10 +34,6 @@ public class RestGeoIpDownloaderStatsAction extends BaseRestHandler {
@Override @Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) { protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
return channel -> client.execute( return channel -> client.execute(GeoIpStatsAction.INSTANCE, new GeoIpStatsAction.Request(), new RestToXContentListener<>(channel));
GeoIpDownloaderStatsAction.INSTANCE,
new GeoIpDownloaderStatsAction.Request(),
new RestToXContentListener<>(channel)
);
} }
} }

View file

@ -15,30 +15,29 @@ import org.elasticsearch.test.AbstractWireSerializingTestCase;
import java.util.Set; import java.util.Set;
public class GeoIpDownloaderStatsActionNodeResponseSerializingTests extends AbstractWireSerializingTestCase< public class GeoIpStatsActionNodeResponseSerializingTests extends AbstractWireSerializingTestCase<GeoIpStatsAction.NodeResponse> {
GeoIpDownloaderStatsAction.NodeResponse> {
@Override @Override
protected Writeable.Reader<GeoIpDownloaderStatsAction.NodeResponse> instanceReader() { protected Writeable.Reader<GeoIpStatsAction.NodeResponse> instanceReader() {
return GeoIpDownloaderStatsAction.NodeResponse::new; return GeoIpStatsAction.NodeResponse::new;
} }
@Override @Override
protected GeoIpDownloaderStatsAction.NodeResponse createTestInstance() { protected GeoIpStatsAction.NodeResponse createTestInstance() {
return createRandomInstance(); return createRandomInstance();
} }
@Override @Override
protected GeoIpDownloaderStatsAction.NodeResponse mutateInstance(GeoIpDownloaderStatsAction.NodeResponse instance) { protected GeoIpStatsAction.NodeResponse mutateInstance(GeoIpStatsAction.NodeResponse instance) {
return null;// TODO implement https://github.com/elastic/elasticsearch/issues/25929 return null;// TODO implement https://github.com/elastic/elasticsearch/issues/25929
} }
static GeoIpDownloaderStatsAction.NodeResponse createRandomInstance() { static GeoIpStatsAction.NodeResponse createRandomInstance() {
DiscoveryNode node = DiscoveryNodeUtils.create("id"); DiscoveryNode node = DiscoveryNodeUtils.create("id");
Set<String> databases = Set.copyOf(randomList(10, () -> randomAlphaOfLengthBetween(5, 10))); Set<String> databases = Set.copyOf(randomList(10, () -> randomAlphaOfLengthBetween(5, 10)));
Set<String> files = Set.copyOf(randomList(10, () -> randomAlphaOfLengthBetween(5, 10))); Set<String> files = Set.copyOf(randomList(10, () -> randomAlphaOfLengthBetween(5, 10)));
Set<String> configDatabases = Set.copyOf(randomList(10, () -> randomAlphaOfLengthBetween(5, 10))); Set<String> configDatabases = Set.copyOf(randomList(10, () -> randomAlphaOfLengthBetween(5, 10)));
return new GeoIpDownloaderStatsAction.NodeResponse( return new GeoIpStatsAction.NodeResponse(
node, node,
GeoIpDownloaderStatsSerializingTests.createRandomInstance(), GeoIpDownloaderStatsSerializingTests.createRandomInstance(),
databases, databases,

View file

@ -18,14 +18,14 @@ import java.util.Set;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
public class GeoIpDownloaderStatsActionNodeResponseTests extends ESTestCase { public class GeoIpStatsActionNodeResponseTests extends ESTestCase {
public void testInputsAreDefensivelyCopied() { public void testInputsAreDefensivelyCopied() {
DiscoveryNode node = DiscoveryNodeUtils.create("id"); DiscoveryNode node = DiscoveryNodeUtils.create("id");
Set<String> databases = new HashSet<>(randomList(10, () -> randomAlphaOfLengthBetween(5, 10))); Set<String> databases = new HashSet<>(randomList(10, () -> randomAlphaOfLengthBetween(5, 10)));
Set<String> files = new HashSet<>(randomList(10, () -> randomAlphaOfLengthBetween(5, 10))); Set<String> files = new HashSet<>(randomList(10, () -> randomAlphaOfLengthBetween(5, 10)));
Set<String> configDatabases = new HashSet<>(randomList(10, () -> randomAlphaOfLengthBetween(5, 10))); Set<String> configDatabases = new HashSet<>(randomList(10, () -> randomAlphaOfLengthBetween(5, 10)));
GeoIpDownloaderStatsAction.NodeResponse nodeResponse = new GeoIpDownloaderStatsAction.NodeResponse( GeoIpStatsAction.NodeResponse nodeResponse = new GeoIpStatsAction.NodeResponse(
node, node,
GeoIpDownloaderStatsSerializingTests.createRandomInstance(), GeoIpDownloaderStatsSerializingTests.createRandomInstance(),
databases, databases,

View file

@ -14,25 +14,24 @@ import org.elasticsearch.test.AbstractWireSerializingTestCase;
import java.util.List; import java.util.List;
public class GeoIpDownloaderStatsActionResponseSerializingTests extends AbstractWireSerializingTestCase< public class GeoIpStatsActionResponseSerializingTests extends AbstractWireSerializingTestCase<GeoIpStatsAction.Response> {
GeoIpDownloaderStatsAction.Response> {
@Override @Override
protected Writeable.Reader<GeoIpDownloaderStatsAction.Response> instanceReader() { protected Writeable.Reader<GeoIpStatsAction.Response> instanceReader() {
return GeoIpDownloaderStatsAction.Response::new; return GeoIpStatsAction.Response::new;
} }
@Override @Override
protected GeoIpDownloaderStatsAction.Response createTestInstance() { protected GeoIpStatsAction.Response createTestInstance() {
List<GeoIpDownloaderStatsAction.NodeResponse> nodeResponses = randomList( List<GeoIpStatsAction.NodeResponse> nodeResponses = randomList(
10, 10,
GeoIpDownloaderStatsActionNodeResponseSerializingTests::createRandomInstance GeoIpStatsActionNodeResponseSerializingTests::createRandomInstance
); );
return new GeoIpDownloaderStatsAction.Response(ClusterName.DEFAULT, nodeResponses, List.of()); return new GeoIpStatsAction.Response(ClusterName.DEFAULT, nodeResponses, List.of());
} }
@Override @Override
protected GeoIpDownloaderStatsAction.Response mutateInstance(GeoIpDownloaderStatsAction.Response instance) { protected GeoIpStatsAction.Response mutateInstance(GeoIpStatsAction.Response instance) {
return null;// TODO implement https://github.com/elastic/elasticsearch/issues/25929 return null;// TODO implement https://github.com/elastic/elasticsearch/issues/25929
} }
} }