|
1 | 1 | using System.Collections.Generic; |
2 | 2 | using System.Linq; |
| 3 | +using Elastic.Xunit.XunitPlumbing; |
3 | 4 | using Elasticsearch.Net; |
4 | 5 | using FluentAssertions; |
5 | 6 | using Nest; |
@@ -102,4 +103,44 @@ protected void Assert(RoutingNodesState routingNodes, string master) |
102 | 103 | node.State.Should().NotBeNullOrWhiteSpace(); |
103 | 104 | } |
104 | 105 | } |
| 106 | + |
| 107 | + [SkipVersion("<6.5.0", "Validated against 6.5.0")] |
| 108 | + public class ClusterStateStoredScriptApiTests |
| 109 | + : ApiIntegrationTestBase<WritableCluster, IClusterStateResponse, IClusterStateRequest, ClusterStateDescriptor, ClusterStateRequest> |
| 110 | + { |
| 111 | + public ClusterStateStoredScriptApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } |
| 112 | + |
| 113 | + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) |
| 114 | + { |
| 115 | + client.PutScript("my-script-id", s => s.Painless("return 0")); |
| 116 | + client.PutScript("my-other-script-id", s => s.Painless("return 1")); |
| 117 | + } |
| 118 | + |
| 119 | + protected override bool ExpectIsValid => true; |
| 120 | + protected override int ExpectStatusCode => 200; |
| 121 | + protected override HttpMethod HttpMethod => HttpMethod.GET; |
| 122 | + protected override string UrlPath => "/_cluster/state/metadata"; |
| 123 | + |
| 124 | + protected override LazyResponses ClientUsage() => Calls( |
| 125 | + (client, f) => client.ClusterState(s => s.Metric(ClusterStateMetric.Metadata)), |
| 126 | + (client, f) => client.ClusterStateAsync(s => s.Metric(ClusterStateMetric.Metadata)), |
| 127 | + (client, r) => client.ClusterState(new ClusterStateRequest(ClusterStateMetric.Metadata)), |
| 128 | + (client, r) => client.ClusterStateAsync(new ClusterStateRequest(ClusterStateMetric.Metadata)) |
| 129 | + ); |
| 130 | + |
| 131 | + protected override void ExpectResponse(IClusterStateResponse response) |
| 132 | + { |
| 133 | + response.Metadata.Should().NotBeNull(); |
| 134 | + response.Metadata.StoredScripts.Should().NotBeNull(); |
| 135 | + response.Metadata.StoredScripts.Count.Should().Be(2); |
| 136 | + |
| 137 | + response.Metadata.StoredScripts["my-script-id"].Language.Should().Be("painless"); |
| 138 | + response.Metadata.StoredScripts["my-script-id"].Source.Should().Be("return 0"); |
| 139 | + response.Metadata.StoredScripts["my-script-id"].Options.Should().BeEmpty(); |
| 140 | + |
| 141 | + response.Metadata.StoredScripts["my-other-script-id"].Language.Should().Be("painless"); |
| 142 | + response.Metadata.StoredScripts["my-other-script-id"].Source.Should().Be("return 1"); |
| 143 | + response.Metadata.StoredScripts["my-other-script-id"].Options.Should().BeEmpty(); |
| 144 | + } |
| 145 | + } |
105 | 146 | } |
0 commit comments