コード例 #1
0
        public IEnumerable <HrefProperties> GetActuatorLinks()
        {
            logger.LogInformation("Retrieving actuators");

            var actuatorLinks = Enumerable.Empty <HrefProperties>();

            var actuatorEndpoints = actuatorEndpoint.Invoke("/actuator");

            if (actuatorEndpoints is not null)
            {
                logger.LogInformation($"Found {actuatorEndpoints._links.Count} actuators");

                actuatorLinks = actuatorEndpoints._links.Select(link =>
                                                                new HrefProperties
                {
                    Display = link.Key != "self" ? link.Key : "all actuators",
                    Address = link.Value.Href
                });
            }
            else
            {
                logger.LogError("No actuators were found");
            }

            return(actuatorLinks);
        }
コード例 #2
0
        public void Invoke_HonorsEndpointEnabled_ReturnsExpectedLinks()
        {
            var infoOpts = new InfoEndpointOptions {
                Enabled = false
            };
            var cloudOpts   = new HypermediaEndpointOptions();
            var mgmtOptions = new ActuatorManagementOptions();

            mgmtOptions.EndpointOptions.AddRange(new List <IEndpointOptions>()
            {
                infoOpts, cloudOpts
            });

            var ep = new ActuatorEndpoint(cloudOpts, new List <IManagementOptions> {
                mgmtOptions
            });

            var info = ep.Invoke("http://localhost:5000/foobar");

            Assert.NotNull(info);
            Assert.NotNull(info._links);
            Assert.True(info._links.ContainsKey("self"));
            Assert.Equal("http://localhost:5000/foobar", info._links["self"].href);
            Assert.False(info._links.ContainsKey("info"));
            Assert.Single(info._links);
        }
コード例 #3
0
        public void Invoke_OnlyActuatorHypermediaEndpoint_ReturnsExpectedLinks()
        {
            var cloudOpts   = new HypermediaEndpointOptions();
            var mgmtOptions = new ActuatorManagementOptions();

            mgmtOptions.EndpointOptions.Add(cloudOpts);
            var ep = new ActuatorEndpoint(cloudOpts, mgmtOptions);

            var info = ep.Invoke("http://localhost:5000/foobar");

            Assert.NotNull(info);
            Assert.NotNull(info._links);
            Assert.True(info._links.ContainsKey("self"));
            Assert.Equal("http://localhost:5000/foobar", info._links["self"].Href);
            Assert.Single(info._links);
        }
コード例 #4
0
        public void Invoke_CloudFoundryDisable_ReturnsExpectedLinks()
        {
            var infoOpts = new InfoEndpointOptions {
                Enabled = true
            };
            var cloudOpts = new HypermediaEndpointOptions {
                Enabled = false
            };
            var mgmtOptions = new ActuatorManagementOptions();

            mgmtOptions.EndpointOptions.AddRange(new List <IEndpointOptions>()
            {
                infoOpts, cloudOpts
            });

            var ep   = new ActuatorEndpoint(cloudOpts, mgmtOptions);
            var info = ep.Invoke("http://localhost:5000/foobar");

            Assert.NotNull(info);
            Assert.NotNull(info._links);
            Assert.Empty(info._links);
        }
コード例 #5
0
        public void Invoke_ReturnsExpectedLinks()
        {
            var mgmtOptions = new ActuatorManagementOptions();
            var infoOpts    = new InfoEndpointOptions();
            var cloudOpts   = new HypermediaEndpointOptions();

            mgmtOptions.EndpointOptions.AddRange(new List <IEndpointOptions>()
            {
                infoOpts, cloudOpts
            });

            var ep = new ActuatorEndpoint(cloudOpts, mgmtOptions);

            var info = ep.Invoke("http://localhost:5000/foobar");

            Assert.NotNull(info);
            Assert.NotNull(info._links);
            Assert.True(info._links.ContainsKey("self"));
            Assert.Equal("http://localhost:5000/foobar", info._links["self"].Href);
            Assert.True(info._links.ContainsKey("info"));
            Assert.Equal("http://localhost:5000/foobar/info", info._links["info"].Href);
            Assert.Equal(2, info._links.Count);
        }