Search in sources :

Example 6 with Build

use of org.elasticsearch.Build in project elasticsearch by elastic.

the class MainActionTests method testMainResponseSerialization.

public void testMainResponseSerialization() throws IOException {
    final String nodeName = "node1";
    final ClusterName clusterName = new ClusterName("cluster1");
    final String clusterUUID = randomAsciiOfLengthBetween(10, 20);
    final boolean available = randomBoolean();
    final Version version = Version.CURRENT;
    final Build build = Build.CURRENT;
    final MainResponse mainResponse = new MainResponse(nodeName, version, clusterName, clusterUUID, build, available);
    BytesStreamOutput streamOutput = new BytesStreamOutput();
    mainResponse.writeTo(streamOutput);
    final MainResponse serialized = new MainResponse();
    serialized.readFrom(streamOutput.bytes().streamInput());
    assertThat(serialized.getNodeName(), equalTo(nodeName));
    assertThat(serialized.getClusterName(), equalTo(clusterName));
    assertThat(serialized.getBuild(), equalTo(build));
    assertThat(serialized.isAvailable(), equalTo(available));
    assertThat(serialized.getVersion(), equalTo(version));
}
Also used : Version(org.elasticsearch.Version) Build(org.elasticsearch.Build) ClusterName(org.elasticsearch.cluster.ClusterName) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput)

Example 7 with Build

use of org.elasticsearch.Build in project elasticsearch by elastic.

the class MainResponseTests method mutate.

private static MainResponse mutate(MainResponse o) {
    String clusterUuid = o.getClusterUuid();
    boolean available = o.isAvailable();
    Build build = o.getBuild();
    Version version = o.getVersion();
    String nodeName = o.getNodeName();
    ClusterName clusterName = o.getClusterName();
    switch(randomIntBetween(0, 5)) {
        case 0:
            clusterUuid = clusterUuid + randomAsciiOfLength(5);
            break;
        case 1:
            nodeName = nodeName + randomAsciiOfLength(5);
            break;
        case 2:
            available = !available;
            break;
        case 3:
            // toggle the snapshot flag of the original Build parameter
            build = new Build(build.shortHash(), build.date(), !build.isSnapshot());
            break;
        case 4:
            version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random()));
            break;
        case 5:
            clusterName = new ClusterName(clusterName + randomAsciiOfLength(5));
            break;
    }
    return new MainResponse(nodeName, version, clusterName, clusterUuid, build, available);
}
Also used : Version(org.elasticsearch.Version) Build(org.elasticsearch.Build) ClusterName(org.elasticsearch.cluster.ClusterName)

Aggregations

Build (org.elasticsearch.Build)7 Version (org.elasticsearch.Version)6 ClusterName (org.elasticsearch.cluster.ClusterName)6 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)3 HashMap (java.util.HashMap)2 MainResponse (org.elasticsearch.action.main.MainResponse)2 BytesRestResponse (org.elasticsearch.rest.BytesRestResponse)2 RestRequest (org.elasticsearch.rest.RestRequest)2 RestStatus (org.elasticsearch.rest.RestStatus)2 FakeRestRequest (org.elasticsearch.test.rest.FakeRestRequest)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)1 PluginsAndModules (org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 BytesReference (org.elasticsearch.common.bytes.BytesReference)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 Settings (org.elasticsearch.common.settings.Settings)1 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)1 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)1