Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XPack/HLRC request/response compatibility tests #34547

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7d3f9d6
HLRC XPack Protocol clean up: Licence, Misc
Oct 14, 2018
b7b8f8d
package typo (extra space)
Oct 15, 2018
1931084
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_1
Oct 16, 2018
c5e6c9d
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_1
Oct 16, 2018
32872b4
inline ParseField as it's used in one place
Oct 16, 2018
7e778d7
fill the gaps for LicensingIT
Oct 16, 2018
3a7f138
move protocol-test to another PR
Oct 16, 2018
dab4d55
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 17, 2018
10c9bb8
XPack/OSS request/response compatibility tests
Oct 17, 2018
2f0015b
AbstractHLRCStreamableXContentTestCase is added
Oct 17, 2018
9e236d4
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_1
Oct 17, 2018
7afecce
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 18, 2018
a12a507
moved ProtocolUtils from protocol to client
Oct 19, 2018
85eb8f5
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 19, 2018
ad85b75
HLRC XPack Protocol clean up: Migration; Graph; Watcher
Oct 19, 2018
a179e92
Merge remote-tracking branch 'remotes/vladimirdolzhenko/hlrc_xprotoco…
Oct 19, 2018
87e7a66
initial extension of XPack tests to support HLRC requests/responses
Oct 19, 2018
ed4274a
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_2
Oct 19, 2018
26f4260
Merge branch 'origin/master' into hlrc_xprotocol_cleanup_2
Oct 19, 2018
0d62e6a
revert missed StartWatchServiceRequest
Oct 20, 2018
ef67f6e
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 20, 2018
6afde11
added StartBasicResponse xpack-hlrc test
Oct 20, 2018
1b28d1f
license
Oct 20, 2018
61be8a3
XPackInfoResponse clean up
Oct 20, 2018
b4d33cf
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 21, 2018
89b5edb
Merge remote-tracking branch 'remotes/origin/hlrc_xprotocol_cleanup_2…
Oct 21, 2018
ad8581f
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 24, 2018
4767e1a
Merge remote-tracking branch 'remotes/origin/hlrc_xprotocol_cleanup_2…
Oct 24, 2018
b5372c4
code style enhancements
Oct 24, 2018
6c3b19c
drop FS case sensitive mess
Oct 25, 2018
775ef01
fix FS case sensitive mess
Oct 25, 2018
7a7ca56
enforce validation in ctor
Oct 26, 2018
02b3061
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 26, 2018
7a776f3
fix wrong import
Oct 29, 2018
4669e4a
fix wrong import
Oct 29, 2018
ce3bd66
fixed test due to enforce ctor checks in DeleteWatchRequest/PutWatchR…
Oct 29, 2018
8479f7e
Merge remote-tracking branch 'remotes/origin/hlrc_xprotocol_cleanup_2…
Oct 29, 2018
81941e3
Merge branch 'origin/master' into hlrc_xprotocol_response_tests
Oct 29, 2018
36ffbd8
drop empty file
Oct 29, 2018
c99b27b
make XPackInfoResponse ToXContentObject-able again
Oct 30, 2018
793bacc
indent!
Oct 30, 2018
71c88a5
Merge remote-tracking branch 'remotes/origin/master' into hlrc_xproto…
Oct 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -44,7 +44,7 @@ public class GraphClient {
public final GraphExploreResponse explore(GraphExploreRequest graphExploreRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
options, GraphExploreResponse::fromXContext, emptySet());
options, GraphExploreResponse::fromXContent, emptySet());
}

/**
Expand All @@ -57,7 +57,7 @@ public final void exploreAsync(GraphExploreRequest graphExploreRequest,
RequestOptions options,
ActionListener<GraphExploreResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
options, GraphExploreResponse::fromXContext, listener, emptySet());
options, GraphExploreResponse::fromXContent, listener, emptySet());
vladimirdolzhenko marked this conversation as resolved.
Show resolved Hide resolved
}

}
Expand Up @@ -47,7 +47,7 @@
*
* @see GraphExploreRequest
*/
public class GraphExploreResponse implements ToXContentObject {
public class GraphExploreResponse implements ToXContentObject {

private long tookInMillis;
private boolean timedOut = false;
Expand Down Expand Up @@ -94,14 +94,30 @@ public Collection<Connection> getConnections() {
return connections.values();
}

public Collection<ConnectionId> getConnectionIds() {
return connections.keySet();
}

public Connection getConnection(ConnectionId connectionId) {
return connections.get(connectionId);
}

public Collection<Vertex> getVertices() {
return vertices.values();
}


public Collection<VertexId> getVertexIds() {
vladimirdolzhenko marked this conversation as resolved.
Show resolved Hide resolved
return vertices.keySet();
}

public Vertex getVertex(VertexId id) {
return vertices.get(id);
}

public boolean isReturnDetailedInfo() {
return returnDetailedInfo;
}

private static final ParseField TOOK = new ParseField("took");
private static final ParseField TIMED_OUT = new ParseField("timed_out");
private static final ParseField VERTICES = new ParseField("vertices");
Expand Down Expand Up @@ -190,7 +206,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
PARSER.declareObjectArray(optionalConstructorArg(), (p, c) -> ShardSearchFailure.fromXContent(p), FAILURES);
}

public static GraphExploreResponse fromXContext(XContentParser parser) throws IOException {
public static GraphExploreResponse fromXContent(XContentParser parser) throws IOException {
return PARSER.apply(parser, null);
}

Expand Down
Expand Up @@ -220,6 +220,14 @@ public VertexId(String field, String term) {
this.term = term;
}

public String getField() {
return field;
}

public String getTerm() {
return term;
}

@Override
public boolean equals(Object o) {
if (this == o)
Expand Down
Expand Up @@ -84,14 +84,13 @@ public class StartBasicResponse {
}
}
return new Tuple<>(message, acknowledgeMessages);
},
new ParseField("acknowledge"));
}, new ParseField("acknowledge"));
}

private Map<String, String[]> acknowledgeMessages;
private String acknowledgeMessage;

enum Status {
public enum Status {
GENERATED_BASIC(true, null, RestStatus.OK),
ALREADY_USING_BASIC(false, "Operation failed: Current license is basic.", RestStatus.FORBIDDEN),
NEED_ACKNOWLEDGEMENT(false, "Operation failed: Needs acknowledgement.", RestStatus.OK);
Expand Down Expand Up @@ -141,6 +140,10 @@ public StartBasicResponse() {
this.acknowledgeMessage = acknowledgeMessage;
}

public Status getStatus() {
return status;
}

public boolean isAcknowledged() {
return status != StartBasicResponse.Status.NEED_ACKNOWLEDGEMENT;
}
Expand Down
Expand Up @@ -18,17 +18,12 @@
*/
package org.elasticsearch.client.migration;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;

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

/**
* Indicates the type of the upgrade required for the index
*/
public enum UpgradeActionRequired implements Writeable {
public enum UpgradeActionRequired {
NOT_APPLICABLE, // Indicates that the check is not applicable to this index type, the next check will be performed
UP_TO_DATE, // Indicates that the check finds this index to be up to date - no additional checks are required
REINDEX, // The index should be reindex
Expand All @@ -38,15 +33,6 @@ public static UpgradeActionRequired fromString(String value) {
return UpgradeActionRequired.valueOf(value.toUpperCase(Locale.ROOT));
}

public static UpgradeActionRequired readFromStream(StreamInput in) throws IOException {
return in.readEnum(UpgradeActionRequired.class);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeEnum(this);
}

@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
Expand Down
Expand Up @@ -21,9 +21,6 @@
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
import org.elasticsearch.common.xcontent.ToXContentObject;
Expand Down Expand Up @@ -252,7 +249,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}
}

public static class BuildInfo implements ToXContentObject, Writeable {
public static class BuildInfo implements ToXContentObject {
private final String hash;
private final String timestamp;

Expand All @@ -261,16 +258,6 @@ public BuildInfo(String hash, String timestamp) {
this.timestamp = timestamp;
}

public BuildInfo(StreamInput input) throws IOException {
this(input.readString(), input.readString());
}

@Override
public void writeTo(StreamOutput output) throws IOException {
output.writeString(hash);
output.writeString(timestamp);
}

public String getHash() {
return hash;
}
Expand Down Expand Up @@ -309,7 +296,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}
}

public static class FeatureSetsInfo implements ToXContentObject, Writeable {
public static class FeatureSetsInfo implements ToXContentObject {
private final Map<String, FeatureSet> featureSets;

public FeatureSetsInfo(Set<FeatureSet> featureSets) {
Expand All @@ -320,24 +307,6 @@ public FeatureSetsInfo(Set<FeatureSet> featureSets) {
this.featureSets = Collections.unmodifiableMap(map);
}

public FeatureSetsInfo(StreamInput in) throws IOException {
int size = in.readVInt();
Map<String, FeatureSet> featureSets = new HashMap<>(size);
for (int i = 0; i < size; i++) {
FeatureSet featureSet = new FeatureSet(in);
featureSets.put(featureSet.name, featureSet);
}
this.featureSets = Collections.unmodifiableMap(featureSets);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(featureSets.size());
for (FeatureSet featureSet : featureSets.values()) {
featureSet.writeTo(out);
}
}

public Map<String, FeatureSet> getFeatureSets() {
return featureSets;
}
Expand Down Expand Up @@ -365,7 +334,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder.endObject();
}

public static class FeatureSet implements ToXContentObject, Writeable {
public static class FeatureSet implements ToXContentObject {
private final String name;
@Nullable private final String description;
private final boolean available;
Expand All @@ -381,19 +350,6 @@ public FeatureSet(String name, @Nullable String description, boolean available,
this.nativeCodeInfo = nativeCodeInfo;
}

public FeatureSet(StreamInput in) throws IOException {
this(in.readString(), in.readOptionalString(), in.readBoolean(), in.readBoolean(), in.readMap());
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(name);
out.writeOptionalString(description);
out.writeBoolean(available);
out.writeBoolean(enabled);
out.writeMap(nativeCodeInfo);
}

public String name() {
return name;
}
Expand Down
Expand Up @@ -34,7 +34,7 @@ public class XPackUsageResponse {

private final Map<String, Map<String, Object>> usages;

private XPackUsageResponse(Map<String, Map<String, Object>> usages) throws IOException {
private XPackUsageResponse(Map<String, Map<String, Object>> usages) {
this.usages = usages;
}

Expand Down
Expand Up @@ -81,7 +81,7 @@ private static GraphExploreResponse createTestInstanceWithFailures() {

@Override
protected GraphExploreResponse doParseInstance(XContentParser parser) throws IOException {
return GraphExploreResponse.fromXContext(parser);
return GraphExploreResponse.fromXContent(parser);
}

@Override
Expand Down

This file was deleted.

Expand Up @@ -23,8 +23,6 @@

public class IndexUpgradeInfoRequestTests extends ESTestCase {

// TODO: add to cross XPack-HLRC serialization test

public void testNullIndices() {
expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest((String[])null));
expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest().indices((String[])null));
Expand Down