public void ShouldDeserialize()
        {
            const string nodeId        = "pQHNt5rXTTWNvUgOrdynKg";
            var          fixedResponse = new
            {
                _nodes = new
                {
                    total      = 1,
                    successful = 1,
                    failed     = 0,
                    failures   = new[]
                    {
                        new
                        {
                            type      = "illegal_argument_exception",
                            reason    = "failed to execute script",
                            caused_by = new
                            {
                                type      = "script_exception",
                                reason    = "failed to run inline script [use(java.lang.Exception) {throw new Exception(\"Customized Exception\")}] using lang [groovy]",
                                caused_by = new
                                {
                                    type      = "privileged_action_exception",
                                    reason    = (string)null,
                                    caused_by = new
                                    {
                                        type   = "exception",
                                        reason = "Custom Exception"
                                    }
                                }
                            }
                        }
                    }
                },
                cluster_name = "my_cluster",
                nodes        = new Dictionary <string, object>
                {
                    {
                        nodeId, new
                        {
                            timestamp    = 1492553961812,
                            since        = 1492553906606,
                            rest_actions = new Dictionary <string, object>
                            {
                                { "org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction", 1 },
                                { "org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction", 1 },
                                { "org.elasticsearch.rest.action.document.RestGetAction", 1 },
                                { "org.elasticsearch.rest.action.search.RestSearchAction", 19 },
                                { "org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction", 36 }
                            }
                        }
                    }
                }
            };

            var client = FixedResponseClient.Create(fixedResponse);

            //warmup
            var response = client.Nodes.Usage();

            response.ShouldBeValid();

            response.ClusterName.Should().Be("my_cluster");

            response.NodeStatistics.Should().NotBeNull();
            response.NodeStatistics.Total.Should().Be(1);
            response.NodeStatistics.Successful.Should().Be(1);
            response.NodeStatistics.Failed.Should().Be(0);
            response.NodeStatistics.Failures.Should().HaveCount(1);
            var failure = response.NodeStatistics.Failures.First();

            failure.Type.Should().NotBeNull();
            failure.Reason.Should().NotBeNull();
            failure.CausedBy.Should().NotBeNull();

            response.Nodes.Should().NotBeNull();
            response.Nodes.Should().HaveCount(1);

            response.Nodes.Should().ContainKey(nodeId);

            var node = response.Nodes[nodeId];

            node.Timestamp.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 19, 21, 812, TimeSpan.Zero));
            node.Since.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 18, 26, 606, TimeSpan.Zero));
            node.RestActions.Should().NotBeNull();
            node.RestActions.Should().HaveCount(5);
            node.RestActions.Should().ContainKey("org.elasticsearch.rest.action.search.RestSearchAction");
            node.RestActions["org.elasticsearch.rest.action.search.RestSearchAction"].Should().Be(19);
        }
Esempio n. 2
0
        public void ShouldDeserialize()
        {
            const string indexName = ".monitoring-es-6-2017.07.21";

            var fixedResponse = new
            {
                cluster_settings = new[]
                {
                    new
                    {
                        level   = "info",
                        message = "Network settings changes",
                        url     =
                            "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal",
                        details =
                            "templates using <literal>template</literal> field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana"
                    }
                },
                node_settings  = new object[0],
                index_settings = new Dictionary <string, object>
                {
                    {
                        indexName, new object[]
                        {
                            new
                            {
                                level   = "info",
                                message = "Coercion of boolean fields",
                                url     =
                                    "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
                                details = "<anchor id=\"type: doc\" xreflabel=\"field: spins]\"/>"
                            }
                        }
                    }
                }
            };

            var client = FixedResponseClient.Create(fixedResponse);

            //warmup
            var response = client.Migration.DeprecationInfo();

            response.ShouldBeValid();

            response.ClusterSettings.Should().NotBeNull();
            response.ClusterSettings.Should().HaveCount(1);
            response.ClusterSettings.First().Level.Should().Be(DeprecationWarningLevel.Information);
            response.ClusterSettings.First().Message.Should().Be("Network settings changes");
            response.ClusterSettings.First()
            .Url.Should()
            .Be(
                "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal");
            response.ClusterSettings.First()
            .Details.Should()
            .Be(
                "templates using <literal>template</literal> field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana");

            response.NodeSettings.Should().NotBeNull();
            response.NodeSettings.Should().BeEmpty();

            response.IndexSettings.Should().NotBeNull();
            response.IndexSettings.Should().HaveCount(1);
            response.IndexSettings.Should().ContainKey(indexName);
            response.IndexSettings[indexName].Count.Should().Be(1);

            var deprecationInfo = response.IndexSettings[indexName].First();

            deprecationInfo.Details.Should().Be("<anchor id=\"type: doc\" xreflabel=\"field: spins]\"/>");
            deprecationInfo.Url.Should()
            .Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields");
            deprecationInfo.Message.Should().Be("Coercion of boolean fields");
            deprecationInfo.Level.Should().Be(DeprecationWarningLevel.Information);
        }
Esempio n. 3
0
        protected ServerErrorTestsBase()
        {
            var settings = FixedResponseClient.CreateConnectionSettings(ResponseJson, 500);

            HighLevelClient = new ElasticsearchClient(settings);
        }