예제 #1
0
        public async void GetInstanceAsync_InvokesServer_ReturnsExpectedInstances()
        {
            var json    = @"{ 
'instance':
    {
    'instanceId':'DESKTOP-GNQ5SUT',
    'app':'FOOBAR',
    'appGroupName':null,
    'ipAddr':'192.168.0.147',
    'sid':'na',
    'port':{'@enabled':true,'$':80},
    'securePort':{'@enabled':false,'$':443},
    'homePageUrl':'http://*****:*****@class':'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo','name':'MyOwn'},
    'hostName':'DESKTOP-GNQ5SUT',
    'status':'UP',
    'overriddenstatus':'UNKNOWN',
    'leaseInfo':{'renewalIntervalInSecs':30,'durationInSecs':90,'registrationTimestamp':0,'lastRenewalTimestamp':0,'renewalTimestamp':0,'evictionTimestamp':0,'serviceUpTimestamp':0},
    'isCoordinatingDiscoveryServer':false,
    'metadata':{'@class':'java.util.Collections$EmptyMap','metadata':null},
    'lastUpdatedTimestamp':1458116137663,
    'lastDirtyTimestamp':1458116137663,
    'actionType':'ADDED',
    'asgName':null
    }
}";
            var startup = new TestConfigServerStartup(json, 200);
            var server  = TestServer.Create(startup.Configure);
            var uri     = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse <InstanceInfo> resp = await client.GetInstanceAsync("DESKTOP-GNQ5SUT");

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.Equal("GET", startup.LastRequest.Method);
            Assert.Equal("localhost:8888", startup.LastRequest.Host.Value);
            Assert.Equal("/instances/DESKTOP-GNQ5SUT", startup.LastRequest.Path.Value);
            Assert.NotNull(resp.Headers);
            Assert.NotNull(resp.Response);
            Assert.Equal("DESKTOP-GNQ5SUT", resp.Response.InstanceId);
            Assert.Equal("DESKTOP-GNQ5SUT:80", resp.Response.VipAddress);
            Assert.Equal("DESKTOP-GNQ5SUT", resp.Response.HostName);
            Assert.Equal("192.168.0.147", resp.Response.IpAddr);
            Assert.Equal(InstanceStatus.UP, resp.Response.Status);
        }
예제 #2
0
        public async void RegisterAsync_SendsValidPOSTData()
        {
            IHostingEnvironment envir = new HostingEnvironment();

            TestConfigServerStartup.Response     = "";
            TestConfigServerStartup.ReturnStatus = 204;
            var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName);
            var server  = new TestServer(builder);


            var uri = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);
            EurekaInstanceConfig config = new EurekaInstanceConfig()
            {
                AppName = "foobar"
            };

            InstanceInfo info = InstanceInfo.FromInstanceConfig(config);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse resp = await client.RegisterAsync(info);

            Assert.NotNull(TestConfigServerStartup.LastRequest);
            Assert.Equal("POST", TestConfigServerStartup.LastRequest.Method);
            Assert.Equal("localhost:8888", TestConfigServerStartup.LastRequest.Host.Value);
            Assert.Equal("/apps/FOOBAR", TestConfigServerStartup.LastRequest.Path.Value);

            // Check JSON payload
            JsonInstanceInfoRoot recvJson = JsonInstanceInfoRoot.Deserialize(TestConfigServerStartup.RequestBody);

            Assert.NotNull(recvJson);
            Assert.NotNull(recvJson.Instance);

            // Compare a few random values
            JsonInstanceInfo sentJsonObj = info.ToJsonInstance();

            Assert.Equal(sentJsonObj.Actiontype, recvJson.Instance.Actiontype);
            Assert.Equal(sentJsonObj.AppName, recvJson.Instance.AppName);
            Assert.Equal(sentJsonObj.HostName, recvJson.Instance.HostName);
        }
예제 #3
0
        protected internal async T.Task <bool> RenewAsync()
        {
            InstanceInfo inst = _appInfoManager.InstanceInfo;

            if (inst == null)
            {
                return(false);
            }

            RefreshInstanceInfo();

            if (inst.IsDirty)
            {
                await RegisterDirtyInstanceInfo(inst);
            }

            try
            {
                EurekaHttpResponse <InstanceInfo> resp = await HttpClient.SendHeartBeatAsync(inst.AppName, inst.InstanceId, inst, InstanceStatus.UNKNOWN);

                _logger?.LogDebug("Renew {Application}/{Instance} returned: {StatusCode}", inst.AppName, inst.InstanceId, resp.StatusCode);
                if (resp.StatusCode == HttpStatusCode.NotFound)
                {
                    return(await RegisterAsync());
                }

                var result = resp.StatusCode == HttpStatusCode.OK;
                if (result)
                {
                    LastGoodHeartbeatTimestamp = System.DateTime.UtcNow.Ticks;
                }

                return(result);
            }
            catch (Exception e)
            {
                _logger?.LogError(e, "Renew Failed");
            }

            _logger?.LogDebug("Renew failed");
            return(false);
        }
예제 #4
0
        internal protected async Task <Applications> FetchRegistryDeltaAsync()
        {
            long         startingCounter = _registryFetchCounter;
            Applications delta           = null;

            EurekaHttpResponse <Applications> resp = await HttpClient.GetDeltaAsync();

            _logger?.LogDebug("FetchRegistryDelta returned: {0}", resp.StatusCode);
            if (resp.StatusCode == HttpStatusCode.OK)
            {
                delta = resp.Response;
            }

            if (delta == null)
            {
                // Log
                return(await FetchFullRegistryAsync());
            }

            if (Interlocked.CompareExchange(ref _registryFetchCounter, ((startingCounter + 1) % long.MaxValue), startingCounter) == startingCounter)
            {
                _localRegionApps.UpdateFromDelta(delta);
                string hashCode = _localRegionApps.ComputeHashCode();
                if (!hashCode.Equals(delta.AppsHashCode))
                {
                    _logger?.LogWarning("FetchRegistryDelta discarding delta, hashcodes mismatch: {0}!={1}", hashCode, delta.AppsHashCode);
                    return(await FetchFullRegistryAsync());
                }
                else
                {
                    _localRegionApps.AppsHashCode       = delta.AppsHashCode;
                    LastGoodDeltaRegistryFetchTimestamp = DateTime.UtcNow.Ticks;
                    return(_localRegionApps);
                }
            }

            _logger?.LogDebug("FetchRegistryDelta failed");
            return(null);
        }
예제 #5
0
        public async void RegisterAsync_InvokesServer_ReturnsStatusCodeAndHeaders()
        {
            var startup = new TestConfigServerStartup("", 204);
            var server  = TestServer.Create(startup.Configure);
            var uri     = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);
            EurekaInstanceConfig config = new EurekaInstanceConfig();
            InstanceInfo         info   = InstanceInfo.FromInstanceConfig(config);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());

            EurekaHttpResponse resp = await client.RegisterAsync(info);

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.NoContent, resp.StatusCode);
            Assert.NotNull(resp.Headers);
        }
예제 #6
0
        public async void CancelAsync_InvokesServer_ReturnsStatusCodeAndHeaders()
        {
            var startup = new TestConfigServerStartup("", 200);
            var server  = TestServer.Create(startup.Configure);
            var uri     = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse resp = await client.CancelAsync("foo", "bar");

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.NotNull(resp.Headers);
            Assert.Equal("DELETE", startup.LastRequest.Method);
            Assert.Equal("localhost:8888", startup.LastRequest.Host.Value);
            Assert.Equal("/apps/foo/bar", startup.LastRequest.Path.Value);
        }
예제 #7
0
        protected internal async T.Task <Applications> FetchFullRegistryAsync()
        {
            long startingCounter = _registryFetchCounter;
            EurekaHttpResponse <Applications> resp = null;
            Applications fetched = null;

            if (string.IsNullOrEmpty(ClientConfig.RegistryRefreshSingleVipAddress))
            {
                resp = await HttpClient.GetApplicationsAsync();
            }
            else
            {
                resp = await HttpClient.GetVipAsync(ClientConfig.RegistryRefreshSingleVipAddress);
            }

            _logger?.LogDebug(
                "FetchFullRegistry returned: {StatusCode}, {Response}",
                resp.StatusCode,
                (resp.Response != null) ? resp.Response.ToString() : "null");
            if (resp.StatusCode == HttpStatusCode.OK)
            {
                fetched = resp.Response;
            }

            if (fetched != null && Interlocked.CompareExchange(ref _registryFetchCounter, (startingCounter + 1) % long.MaxValue, startingCounter) == startingCounter)
            {
                // Log
                LastGoodFullRegistryFetchTimestamp = DateTime.UtcNow.Ticks;
                return(fetched);
            }
            else
            {
                _logger?.LogWarning("FetchFullRegistry discarding fetch, race condition");
            }

            _logger?.LogDebug("FetchFullRegistry failed");
            return(null);
        }
예제 #8
0
        internal protected async Task <bool> UnregisterAsync()
        {
            InstanceInfo inst = ApplicationInfoManager.Instance.InstanceInfo;

            if (inst == null)
            {
                return(false);
            }
            try
            {
                EurekaHttpResponse resp = await HttpClient.CancelAsync(inst.AppName, inst.InstanceId);

                _logger?.LogDebug("Unregister {0}/{1} returned: {2}", inst.AppName, inst.InstanceId, resp.StatusCode);
                return(resp.StatusCode == HttpStatusCode.OK);
            }
            catch (Exception e)
            {
                _logger?.LogError("Unregister failed, Exception:", e);
            }

            _logger?.LogDebug("Unregister failed");
            return(false);
        }
예제 #9
0
        public async void SendHeartBeatAsync_InvokesServer_ReturnsStatusCodeAndHeaders()
        {
            IHostingEnvironment envir = new HostingEnvironment();

            TestConfigServerStartup.Response     = "";
            TestConfigServerStartup.ReturnStatus = 200;
            var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName);
            var server  = new TestServer(builder);

            var uri = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);
            EurekaInstanceConfig config = new EurekaInstanceConfig()
            {
                AppName    = "foo",
                InstanceId = "id1"
            };
            InstanceInfo info = InstanceInfo.FromInstanceConfig(config);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse <InstanceInfo> resp = await client.SendHeartBeatAsync("foo", "id1", info, InstanceStatus.UNKNOWN);

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.NotNull(resp.Headers);

            Assert.Equal("PUT", TestConfigServerStartup.LastRequest.Method);
            Assert.Equal("localhost:8888", TestConfigServerStartup.LastRequest.Host.Value);
            Assert.Equal("/apps/FOO/id1", TestConfigServerStartup.LastRequest.Path.Value);
            var time = DateTimeConversions.ToJavaMillis(new DateTime(info.LastDirtyTimestamp, DateTimeKind.Utc));

            Assert.Equal("?status=STARTING&lastDirtyTimestamp=" + time, TestConfigServerStartup.LastRequest.QueryString.Value);
        }
예제 #10
0
        protected internal async T.Task <bool> UnregisterAsync()
        {
            InstanceInfo inst = _appInfoManager.InstanceInfo;

            if (inst == null)
            {
                return(false);
            }

            try
            {
                EurekaHttpResponse resp = await HttpClient.CancelAsync(inst.AppName, inst.InstanceId).ConfigureAwait(false);

                _logger?.LogDebug("Unregister {Application}/{Instance} returned: {StatusCode}", inst.AppName, inst.InstanceId, resp.StatusCode);
                return(resp.StatusCode == HttpStatusCode.OK);
            }
            catch (Exception e)
            {
                _logger?.LogError(e, "Unregister Failed");
            }

            _logger?.LogDebug("Unregister failed");
            return(false);
        }
예제 #11
0
        public async void GetApplicationAsync_InvokesServer_ReturnsExpectedApplications()
        {
            var json = @"{
'application':
    {
    'name':'FOO',
    'instance':[
    {
        'instanceId':'localhost:foo',
        'hostName':'localhost',
        'app':'FOO',
        'ipAddr':'192.168.56.1',
        'status':'UP',
        'overriddenstatus':'UNKNOWN',
        'port':{'$':8080,'@enabled':'true'},
        'securePort':{'$':443,'@enabled':'false'},
        'countryId':1,
        'dataCenterInfo':{'@class':'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo','name':'MyOwn'},
        'leaseInfo':{'renewalIntervalInSecs':30,'durationInSecs':90,'registrationTimestamp':1458152330783,'lastRenewalTimestamp':1458243422342,'evictionTimestamp':0,'serviceUpTimestamp':1458152330783},
        'metadata':{'@class':'java.util.Collections$EmptyMap'},
        'homePageUrl':'http://localhost:8080/',
        'statusPageUrl':'http://localhost:8080/info',
        'healthCheckUrl':'http://localhost:8080/health',
        'vipAddress':'foo',
        'isCoordinatingDiscoveryServer':'false',
        'lastUpdatedTimestamp':'1458152330783',
        'lastDirtyTimestamp':'1458152330696',
        'actionType':'ADDED'
    }]
    }
}";
            IHostingEnvironment envir = new HostingEnvironment();

            TestConfigServerStartup.Response     = json;
            TestConfigServerStartup.ReturnStatus = 200;
            var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName);
            var server  = new TestServer(builder);

            var uri = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);


            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse <Application> resp = await client.GetApplicationAsync("foo");

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.Equal("GET", TestConfigServerStartup.LastRequest.Method);
            Assert.Equal("localhost:8888", TestConfigServerStartup.LastRequest.Host.Value);
            Assert.Equal("/apps/foo", TestConfigServerStartup.LastRequest.Path.Value);
            Assert.NotNull(resp.Headers);
            Assert.NotNull(resp.Response);
            Assert.Equal("FOO", resp.Response.Name);

            var instances = resp.Response.Instances;

            Assert.NotNull(instances);
            Assert.Equal(1, instances.Count);
            foreach (var instance in instances)
            {
                Assert.Equal("localhost:foo", instance.InstanceId);
                Assert.Equal("foo", instance.VipAddress);
                Assert.Equal("localhost", instance.HostName);
                Assert.Equal("192.168.56.1", instance.IpAddr);
                Assert.Equal(InstanceStatus.UP, instance.Status);
            }
        }
예제 #12
0
        public async void GetApplicationsAsync_InvokesServer_ReturnsExpectedApplications()
        {
            var json    = @"{ 
'applications': { 
    'versions__delta':'1',
    'apps__hashcode':'UP_1_',
    'application':[
        {
        'name':'FOO',
        'instance':[
            { 
            'instanceId':'localhost:foo',
            'hostName':'localhost',
            'app':'FOO',
            'ipAddr':'192.168.56.1',
            'status':'UP',
            'overriddenstatus':'UNKNOWN',
            'port':{'$':8080,'@enabled':'true'},
            'securePort':{'$':443,'@enabled':'false'},
            'countryId':1,
            'dataCenterInfo':{'@class':'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo','name':'MyOwn'},
            'leaseInfo':{'renewalIntervalInSecs':30,'durationInSecs':90,'registrationTimestamp':1457714988223,'lastRenewalTimestamp':1457716158319,'evictionTimestamp':0,'serviceUpTimestamp':1457714988223},
            'metadata':{'@class':'java.util.Collections$EmptyMap'},
            'homePageUrl':'http://localhost:8080/',
            'statusPageUrl':'http://localhost:8080/info',
            'healthCheckUrl':'http://localhost:8080/health',
            'vipAddress':'foo',
            'isCoordinatingDiscoveryServer':'false',
            'lastUpdatedTimestamp':'1457714988223',
            'lastDirtyTimestamp':'1457714988172',
            'actionType':'ADDED'
            }]
        }]
    }
}";
            var startup = new TestConfigServerStartup(json, 200);
            var server  = TestServer.Create(startup.Configure);
            var uri     = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);


            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse <Applications> resp = await client.GetApplicationsAsync();

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.Equal("GET", startup.LastRequest.Method);
            Assert.Equal("localhost:8888", startup.LastRequest.Host.Value);
            Assert.Equal("/apps/", startup.LastRequest.Path.Value);
            Assert.NotNull(resp.Headers);
            Assert.NotNull(resp.Response);
            Assert.NotNull(resp.Response.ApplicationMap);
            Assert.Equal(1, resp.Response.ApplicationMap.Count);
            var app = resp.Response.GetRegisteredApplication("foo");

            Assert.NotNull(app);
            Assert.Equal("FOO", app.Name);

            var instances = app.Instances;

            Assert.NotNull(instances);
            Assert.Equal(1, instances.Count);
            foreach (var instance in instances)
            {
                Assert.Equal("localhost:foo", instance.InstanceId);
                Assert.Equal("foo", instance.VipAddress);
                Assert.Equal("localhost", instance.HostName);
                Assert.Equal("192.168.56.1", instance.IpAddr);
                Assert.Equal(InstanceStatus.UP, instance.Status);
            }
        }
예제 #13
0
        public async void GetInstanceAsync_FirstServerFails_InvokesSecondServer_ReturnsExpectedInstances()
        {
            var json  = @"
                { 
                    ""instance"":{
                        ""instanceId"":""DESKTOP-GNQ5SUT"",
                        ""app"":""FOOBAR"",
                        ""appGroupName"":null,
                        ""ipAddr"":""192.168.0.147"",
                        ""sid"":""na"",
                        ""port"":{""@enabled"":true,""$"":80},
                        ""securePort"":{""@enabled"":false,""$"":443},
                        ""homePageUrl"":""http://*****:*****@class"":""com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo"",""name"":""MyOwn""},
                        ""hostName"":""DESKTOP-GNQ5SUT"",
                        ""status"":""UP"",
                        ""overriddenstatus"":""UNKNOWN"",
                        ""leaseInfo"":{""renewalIntervalInSecs"":30,""durationInSecs"":90,""registrationTimestamp"":0,""lastRenewalTimestamp"":0,""renewalTimestamp"":0,""evictionTimestamp"":0,""serviceUpTimestamp"":0},
                        ""isCoordinatingDiscoveryServer"":false,
                        ""metadata"":{""@class"":""java.util.Collections$EmptyMap"",""metadata"":null},
                        ""lastUpdatedTimestamp"":1458116137663,
                        ""lastDirtyTimestamp"":1458116137663,
                        ""actionType"":""ADDED"",
                        ""asgName"":null
                    }
                }";
            var envir = HostingHelpers.GetHostingEnvironment();

            TestConfigServerStartup.Response     = json;
            TestConfigServerStartup.ReturnStatus = 200;
            TestConfigServerStartup.Host         = "localhost:8888";
            var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName);
            var server  = new TestServer(builder);

            var uri = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = "https://bad.host:9999/," + uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse <InstanceInfo> resp = await client.GetInstanceAsync("DESKTOP-GNQ5SUT");

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.Equal("GET", TestConfigServerStartup.LastRequest.Method);
            Assert.Equal("localhost:8888", TestConfigServerStartup.LastRequest.Host.Value);
            Assert.Equal("/instances/DESKTOP-GNQ5SUT", TestConfigServerStartup.LastRequest.Path.Value);
            Assert.NotNull(resp.Headers);
            Assert.NotNull(resp.Response);
            Assert.Equal("DESKTOP-GNQ5SUT", resp.Response.InstanceId);
            Assert.Equal("DESKTOP-GNQ5SUT:80", resp.Response.VipAddress);
            Assert.Equal("DESKTOP-GNQ5SUT", resp.Response.HostName);
            Assert.Equal("192.168.0.147", resp.Response.IpAddr);
            Assert.Equal(InstanceStatus.UP, resp.Response.Status);

            Assert.Equal("http://localhost:8888/", client._serviceUrl);
        }
예제 #14
0
        public async void GetApplicationAsync__FirstServerFails_InvokesSecondServer_ReturnsExpectedApplications()
        {
            var json  = @"
                {
                    ""application"": {
                        ""name"":""FOO"",
                        ""instance"":[{
                            ""instanceId"":""localhost:foo"",
                            ""hostName"":""localhost"",
                            ""app"":""FOO"",
                            ""ipAddr"":""192.168.56.1"",
                            ""status"":""UP"",
                            ""overriddenstatus"":""UNKNOWN"",
                            ""port"":{""$"":8080,""@enabled"":""true""},
                            ""securePort"":{""$"":443,""@enabled"":""false""},
                            ""countryId"":1,
                            ""dataCenterInfo"":{""@class"":""com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo"",""name"":""MyOwn""},
                            ""leaseInfo"":{""renewalIntervalInSecs"":30,""durationInSecs"":90,""registrationTimestamp"":1458152330783,""lastRenewalTimestamp"":1458243422342,""evictionTimestamp"":0,""serviceUpTimestamp"":1458152330783},
                            ""metadata"":{""@class"":""java.util.Collections$EmptyMap""},
                            ""homePageUrl"":""http://localhost:8080/"",
                            ""statusPageUrl"":""http://localhost:8080/info"",
                            ""healthCheckUrl"":""http://localhost:8080/health"",
                            ""vipAddress"":""foo"",
                            ""isCoordinatingDiscoveryServer"":""false"",
                            ""lastUpdatedTimestamp"":""1458152330783"",
                            ""lastDirtyTimestamp"":""1458152330696"",
                            ""actionType"":""ADDED""
                        }]
                    }
                }";
            var envir = HostingHelpers.GetHostingEnvironment();

            TestConfigServerStartup.Response     = json;
            TestConfigServerStartup.ReturnStatus = 200;
            TestConfigServerStartup.Host         = "localhost:8888";
            var builder = new WebHostBuilder().UseStartup <TestConfigServerStartup>().UseEnvironment(envir.EnvironmentName);
            var server  = new TestServer(builder);

            var uri = "http://localhost:8888/";

            server.BaseAddress = new Uri(uri);

            var cconfig = new EurekaClientConfig()
            {
                EurekaServerServiceUrls = "https://bad.host:9999/," + uri
            };
            var client = new EurekaHttpClient(cconfig, server.CreateClient());
            EurekaHttpResponse <Application> resp = await client.GetApplicationAsync("foo");

            Assert.NotNull(resp);
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            Assert.Equal("GET", TestConfigServerStartup.LastRequest.Method);
            Assert.Equal("localhost:8888", TestConfigServerStartup.LastRequest.Host.Value);
            Assert.Equal("/apps/foo", TestConfigServerStartup.LastRequest.Path.Value);
            Assert.NotNull(resp.Headers);
            Assert.NotNull(resp.Response);
            Assert.Equal("FOO", resp.Response.Name);

            var instances = resp.Response.Instances;

            Assert.NotNull(instances);
            Assert.Equal(1, instances.Count);
            foreach (var instance in instances)
            {
                Assert.Equal("localhost:foo", instance.InstanceId);
                Assert.Equal("foo", instance.VipAddress);
                Assert.Equal("localhost", instance.HostName);
                Assert.Equal("192.168.56.1", instance.IpAddr);
                Assert.Equal(InstanceStatus.UP, instance.Status);
            }

            Assert.Equal("http://localhost:8888/", client._serviceUrl);
        }