public static void RegisterDiscoveryClient(this ContainerBuilder container, IConfigurationRoot config, ILoggerFactory logFactory) { EurekaServiceInfo info = config.GetSingletonServiceInfo <EurekaServiceInfo>(); DiscoveryOptions configOptions = new DiscoveryOptions(config) { ClientType = DiscoveryClientType.EUREKA }; DiscoveryClientFactory factory = new DiscoveryClientFactory(info, configOptions); container.Register <IDiscoveryClient>(c => (IDiscoveryClient)factory.CreateClient(null, logFactory)).SingleInstance(); }
private static void UpdateWithDefaults(EurekaServiceInfo si, EurekaInstanceOptions instOptions) { instOptions.HostName = si.ApplicationInfo.ApplicationUris[0]; instOptions.IpAddress = si.ApplicationInfo.InternalIP; var map = instOptions.MetadataMap; map[CF_APP_GUID] = si.ApplicationInfo.ApplicationId; map[CF_INSTANCE_INDEX] = si.ApplicationInfo.InstanceIndex.ToString(); map[INSTANCE_ID] = si.ApplicationInfo.InstanceId; map[ZONE] = UNKNOWN_ZONE; }
public static void AddDiscoveryService(this ContainerBuilder services) { EurekaServiceInfo info = ServerConfig.Configuration.GetSingletonServiceInfo <EurekaServiceInfo>(); DiscoveryOptions configOptions = new DiscoveryOptions(ServerConfig.Configuration) { ClientType = DiscoveryClientType.EUREKA }; DiscoveryClientFactory factory = new DiscoveryClientFactory(info, configOptions); var discoveryClient = (IDiscoveryClient)factory.CreateClient(); services.Register(c => discoveryClient).SingleInstance().AutoActivate(); services.Register(c => new EndpointClientHandler(discoveryClient)).AsImplementedInterfaces().SingleInstance(); }
private static void ConfigureEurekaServices(IServiceCollection services, IConfiguration config, IServiceInfo info) { EurekaServiceInfo einfo = info as EurekaServiceInfo; var clientSection = config.GetSection(EurekaClientOptions.EUREKA_CLIENT_CONFIGURATION_PREFIX); services.Configure<EurekaClientOptions>(clientSection); services.PostConfigure<EurekaClientOptions>((options) => { EurekaPostConfigurer.UpdateConfiguration(config, einfo, options); }); var instSection = config.GetSection(EurekaInstanceOptions.EUREKA_INSTANCE_CONFIGURATION_PREFIX); services.Configure<EurekaInstanceOptions>(instSection); services.PostConfigure<EurekaInstanceOptions>((options) => { EurekaPostConfigurer.UpdateConfiguration(config, einfo, options); }); }
internal void UpdateConfiguration(EurekaServiceInfo si, DiscoveryOptions config) { config.ClientType = DiscoveryClientType.EUREKA; var clientOptions = config.ClientOptions as EurekaClientOptions; if (clientOptions == null) { return; } var uri = si.Uri; if (!uri.EndsWith(EUREKA_URI_SUFFIX)) { uri = uri + EUREKA_URI_SUFFIX; } clientOptions.EurekaServerServiceUrls = uri; clientOptions.AccessTokenUri = si.TokenUri; clientOptions.ClientId = si.ClientId; clientOptions.ClientSecret = si.ClientSecret; var instOptions = config.RegistrationOptions as EurekaInstanceOptions; if (instOptions == null) { return; } instOptions.HostName = si.ApplicationInfo.ApplicationUris[0]; string instance_id = si.ApplicationInfo.InstanceId; if (string.IsNullOrEmpty(instance_id)) { instance_id = Environment.GetEnvironmentVariable("CF_INSTANCE_GUID"); } if (!string.IsNullOrEmpty(instance_id)) { instOptions.InstanceId = instOptions.HostName + ":" + instance_id; instOptions.MetadataMap.Add("instanceId", instance_id); } instOptions.NonSecurePort = DEFAULT_NONSECUREPORT; }
public static void UpdateConfiguration(IConfiguration config, EurekaServiceInfo si, EurekaClientOptions clientOptions) { if (clientOptions == null || si == null) { return; } var uri = si.Uri; if (!uri.EndsWith(EUREKA_URI_SUFFIX)) { uri = uri + EUREKA_URI_SUFFIX; } clientOptions.EurekaServerServiceUrls = uri; clientOptions.AccessTokenUri = si.TokenUri; clientOptions.ClientId = si.ClientId; clientOptions.ClientSecret = si.ClientSecret; }
public void Constructor_CreatesExpected() { string uri = "http://*****:*****@hostname:1111/"; string clientId = "clientId"; string clientSecret = "clientSecret"; string accessTokeUri = "https://p-spring-cloud-services.uaa.my-cf.com/oauth/token"; EurekaServiceInfo r1 = new EurekaServiceInfo("myId", uri, clientId, clientSecret, accessTokeUri); Assert.Equal("myId", r1.Id); Assert.Equal("http", r1.Scheme); Assert.Equal("hostname", r1.Host); Assert.Equal(1111, r1.Port); Assert.Equal("password", r1.Password); Assert.Equal("username", r1.UserName); Assert.Equal("clientId", r1.ClientId); Assert.Equal("clientSecret", r1.ClientSecret); Assert.Equal("https://p-spring-cloud-services.uaa.my-cf.com/oauth/token", r1.TokenUri); Assert.Equal("http://*****:*****@hostname:1111/", r1.Uri); }
private static IDiscoveryClient CreateDiscoveryClient(IServiceInfo info, IConfiguration config, IDiscoveryLifecycle lifecycle) { var clientConfigsection = config.GetSection(EUREKA_PREFIX); int childCount = clientConfigsection.GetChildren().Count(); if (childCount > 0) { EurekaServiceInfo einfo = info as EurekaServiceInfo; var clientSection = config.GetSection(EurekaClientOptions.EUREKA_CLIENT_CONFIGURATION_PREFIX); EurekaClientOptions clientOptions = new EurekaClientOptions(); ConfigurationBinder.Bind(clientSection, clientOptions); if (einfo != null) { PivotalEurekaConfigurer.UpdateConfiguration(config, einfo, clientOptions); } var instSection = config.GetSection(EurekaInstanceOptions.EUREKA_INSTANCE_CONFIGURATION_PREFIX); EurekaInstanceOptions instOptions = new EurekaInstanceOptions(); ConfigurationBinder.Bind(instSection, instOptions); if (einfo != null) { PivotalEurekaConfigurer.UpdateConfiguration(config, einfo, instOptions); } var manager = new EurekaApplicationInfoManager(new OptionsMonitorWrapper <EurekaInstanceOptions>(instOptions), LoggingConfig.LoggerFactory); return(new PivotalEurekaDiscoveryClient( new OptionsMonitorWrapper <EurekaClientOptions>(clientOptions), new OptionsMonitorWrapper <EurekaInstanceOptions>(instOptions), manager, null, LoggingConfig.LoggerFactory)); } else { throw new ArgumentException("Unable to create Eureka client"); } }
private IDiscoveryClient CreateDiscoveryClient() { IConfigurationSection clientConfigSection = appContext.Configuration.GetSection(EurekaClientOptions.EUREKA_CLIENT_CONFIGURATION_PREFIX); if (clientConfigSection == null) { throw new ConfigurationErrorsException("Unable to load the Eureka client configuration section"); } IConfigurationSection instanceConfigSection = appContext.Configuration.GetSection(EurekaInstanceOptions.EUREKA_INSTANCE_CONFIGURATION_PREFIX); if (instanceConfigSection == null) { throw new ConfigurationErrorsException("Unable to load the Eureka instance configuration section"); } EurekaClientOptions clientOptions = new EurekaClientOptions(); clientConfigSection.Bind(clientOptions); EurekaInstanceOptions instanceOptions = new EurekaInstanceOptions(); instanceConfigSection.Bind(instanceOptions); EurekaServiceInfo svcInfo = GetSingletonDiscoveryServiceInfo() as EurekaServiceInfo; if (svcInfo != null) { EurekaPostConfigurer.UpdateConfiguration(appContext.Configuration, svcInfo, clientOptions); EurekaPostConfigurer.UpdateConfiguration(appContext.Configuration, svcInfo, instanceOptions); } EurekaApplicationInfoManager appInfoManager = new EurekaApplicationInfoManager (new OptionsMonitorWrapper <EurekaInstanceOptions>(instanceOptions), appContext.LoggerFactory); return(new EurekaDiscoveryClient(new OptionsMonitorWrapper <EurekaClientOptions>(clientOptions), new OptionsMonitorWrapper <EurekaInstanceOptions>(instanceOptions), appInfoManager, null, appContext.LoggerFactory)); }
public static void UpdateConfiguration(IConfiguration config, EurekaServiceInfo si, EurekaInstanceOptions instOptions, IApplicationInstanceInfo appInfo) { if (instOptions == null) { return; } UpdateConfiguration(config, instOptions, appInfo); if (si == null) { return; } if (EurekaInstanceOptions.Default_Appname.Equals(instOptions.AppName)) { instOptions.AppName = si.ApplicationInfo.ApplicationName; } if (string.IsNullOrEmpty(instOptions.RegistrationMethod) || ROUTE_REGISTRATIONMETHOD.Equals(instOptions.RegistrationMethod, StringComparison.OrdinalIgnoreCase)) { UpdateWithDefaultsForRoute(si, instOptions); return; } if (DIRECT_REGISTRATIONMETHOD.Equals(instOptions.RegistrationMethod, StringComparison.OrdinalIgnoreCase)) { UpdateWithDefaultsForDirect(si, instOptions); return; } if (HOST_REGISTRATIONMETHOD.Equals(instOptions.RegistrationMethod, StringComparison.OrdinalIgnoreCase)) { UpdateWithDefaultsForHost(si, instOptions, instOptions.HostName); } }
private static void UpdateWithDefaultsForHost(EurekaServiceInfo si, EurekaInstanceOptions instOptions, string hostName) { UpdateWithDefaults(si, instOptions); instOptions.HostName = hostName; instOptions.InstanceId = hostName + ":" + si.ApplicationInfo.InstanceId; }
public void UpdateConfiguration_WithVCAPEnvVariables_AppName_Overrides_VCAPBinding() { var vcap_application = @" { ""limits"": { ""fds"": 16384, ""mem"": 512, ""disk"": 1024 }, ""application_name"": ""foo"", ""application_uris"": [ ""foo.apps.testcloud.com"" ], ""name"": ""foo"", ""space_name"": ""test"", ""space_id"": ""98c627e7-f559-46a4-9032-88cab63f8249"", ""uris"": [ ""foo.apps.testcloud.com"" ], ""users"": null, ""version"": ""4a439db9-4a82-47a3-aeea-8240465cff8e"", ""application_version"": ""4a439db9-4a82-47a3-aeea-8240465cff8e"", ""application_id"": ""ac923014-93a5-4aee-b934-a043b241868b"", ""instance_id"": ""instance_id"" }"; var vcap_services = @" { ""p-config-server"": [{ ""credentials"": { ""uri"": ""https://config-de211817-2e99-4c57-89e8-31fa7ca6a276.apps.testcloud.com"", ""client_id"": ""p-config-server-8f49dd26-e6cd-47a6-b2a0-7655cea20333"", ""client_secret"": ""vBDjqIf7XthT"", ""access_token_uri"": ""https://p-spring-cloud-services.uaa.system.testcloud.com/oauth/token"" }, ""syslog_drain_url"": null, ""label"": ""p-config-server"", ""provider"": null, ""plan"": ""standard"", ""name"": ""myConfigServer"", ""tags"": [ ""configuration"", ""spring-cloud"" ] }], ""p-service-registry"": [{ ""credentials"": { ""uri"": ""https://eureka-6a1b81f5-79e2-4d14-a86b-ddf584635a60.apps.testcloud.com"", ""client_id"": ""p-service-registry-06e28efd-24be-4ce3-9784-854ed8d2acbe"", ""client_secret"": ""dCsdoiuklicS"", ""access_token_uri"": ""https://p-spring-cloud-services.uaa.system.testcloud.com/oauth/token"" }, ""syslog_drain_url"": null, ""label"": ""p-service-registry"", ""provider"": null, ""plan"": ""standard"", ""name"": ""myDiscoveryService"", ""tags"": [ ""eureka"", ""discovery"", ""registry"", ""spring-cloud"" ] }] }"; var appsettings = @" { ""eureka"": { ""client"": { ""eurekaServer"": { ""proxyHost"": ""proxyHost"", ""proxyPort"": 100, ""proxyUserName"": ""proxyUserName"", ""proxyPassword"": ""proxyPassword"", ""shouldGZipContent"": true, ""connectTimeoutSeconds"": 100 }, ""allowRedirects"": true, ""shouldDisableDelta"": true, ""shouldFilterOnlyUpInstances"": true, ""shouldFetchRegistry"": true, ""registryRefreshSingleVipAddress"":""registryRefreshSingleVipAddress"", ""shouldOnDemandUpdateStatusChange"": true, ""shouldRegisterWithEureka"": true, ""registryFetchIntervalSeconds"": 100, ""instanceInfoReplicationIntervalSeconds"": 100, ""serviceUrl"": ""http://localhost:8761/eureka/"" }, ""instance"": { ""registrationMethod"": ""hostname"", ""instanceId"": ""instanceId"", ""appName"": ""appName"", ""appGroup"": ""appGroup"", ""instanceEnabledOnInit"": true, ""hostname"": ""myhostname"", ""port"": 100, ""securePort"": 100, ""nonSecurePortEnabled"": true, ""securePortEnabled"": true, ""leaseExpirationDurationInSeconds"":100, ""leaseRenewalIntervalInSeconds"": 100, ""secureVipAddress"": ""secureVipAddress"", ""vipAddress"": ""vipAddress"", ""asgName"": ""asgName"", ""metadataMap"": { ""foo"": ""bar"", ""bar"": ""foo"" }, ""statusPageUrlPath"": ""statusPageUrlPath"", ""statusPageUrl"": ""statusPageUrl"", ""homePageUrlPath"":""homePageUrlPath"", ""homePageUrl"": ""homePageUrl"", ""healthCheckUrlPath"": ""healthCheckUrlPath"", ""healthCheckUrl"":""healthCheckUrl"", ""secureHealthCheckUrl"":""secureHealthCheckUrl"" } } }"; Environment.SetEnvironmentVariable("VCAP_APPLICATION", vcap_application); Environment.SetEnvironmentVariable("VCAP_SERVICES", vcap_services); Environment.SetEnvironmentVariable("CF_INSTANCE_INDEX", "1"); Environment.SetEnvironmentVariable("CF_INSTANCE_GUID", "ac923014-93a5-4aee-b934-a043b241868b"); var path = TestHelpers.CreateTempFile(appsettings); string directory = Path.GetDirectoryName(path); string fileName = Path.GetFileName(path); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.SetBasePath(directory); configurationBuilder.AddJsonFile(fileName); configurationBuilder.AddCloudFoundry(); var config = configurationBuilder.Build(); var sis = config.GetServiceInfos <EurekaServiceInfo>(); Assert.Single(sis); EurekaServiceInfo si = sis[0]; var clientOpts = new EurekaClientOptions(); var clientSection = config.GetSection(EurekaClientOptions.EUREKA_CLIENT_CONFIGURATION_PREFIX); clientSection.Bind(clientOpts); EurekaPostConfigurer.UpdateConfiguration(config, si, clientOpts); var co = clientOpts; Assert.NotNull(co); Assert.Equal("proxyHost", co.ProxyHost); Assert.Equal(100, co.ProxyPort); Assert.Equal("proxyPassword", co.ProxyPassword); Assert.Equal("proxyUserName", co.ProxyUserName); Assert.True(co.AllowRedirects); Assert.Equal(100, co.InstanceInfoReplicationIntervalSeconds); Assert.Equal(100, co.EurekaServerConnectTimeoutSeconds); Assert.Equal("https://eureka-6a1b81f5-79e2-4d14-a86b-ddf584635a60.apps.testcloud.com/eureka/", co.EurekaServerServiceUrls); Assert.Equal(100, co.RegistryFetchIntervalSeconds); Assert.Equal("registryRefreshSingleVipAddress", co.RegistryRefreshSingleVipAddress); Assert.True(co.ShouldDisableDelta); Assert.True(co.ShouldFetchRegistry); Assert.True(co.ShouldFilterOnlyUpInstances); Assert.True(co.ShouldGZipContent); Assert.True(co.ShouldOnDemandUpdateStatusChange); Assert.True(co.ShouldRegisterWithEureka); Assert.Equal("https://p-spring-cloud-services.uaa.system.testcloud.com/oauth/token", co.AccessTokenUri); Assert.Equal("p-service-registry-06e28efd-24be-4ce3-9784-854ed8d2acbe", co.ClientId); Assert.Equal("dCsdoiuklicS", co.ClientSecret); var instOpts = new EurekaInstanceOptions(); var instSection = config.GetSection(EurekaInstanceOptions.EUREKA_INSTANCE_CONFIGURATION_PREFIX); instSection.Bind(instOpts); EurekaPostConfigurer.UpdateConfiguration(config, si, instOpts); var ro = instOpts; Assert.Equal("hostname", ro.RegistrationMethod); Assert.Equal("myhostname:instance_id", ro.InstanceId); Assert.Equal("appName", ro.AppName); Assert.Equal("appGroup", ro.AppGroupName); Assert.True(ro.IsInstanceEnabledOnInit); Assert.Equal(100, ro.NonSecurePort); Assert.Equal("myhostname", ro.HostName); Assert.Equal(100, ro.SecurePort); Assert.True(ro.IsNonSecurePortEnabled); Assert.True(ro.SecurePortEnabled); Assert.Equal(100, ro.LeaseExpirationDurationInSeconds); Assert.Equal(100, ro.LeaseRenewalIntervalInSeconds); Assert.Equal("secureVipAddress", ro.SecureVirtualHostName); Assert.Equal("vipAddress", ro.VirtualHostName); Assert.Equal("asgName", ro.ASGName); Assert.Equal("statusPageUrlPath", ro.StatusPageUrlPath); Assert.Equal("statusPageUrl", ro.StatusPageUrl); Assert.Equal("homePageUrlPath", ro.HomePageUrlPath); Assert.Equal("homePageUrl", ro.HomePageUrl); Assert.Equal("healthCheckUrlPath", ro.HealthCheckUrlPath); Assert.Equal("healthCheckUrl", ro.HealthCheckUrl); Assert.Equal("secureHealthCheckUrl", ro.SecureHealthCheckUrl); var map = ro.MetadataMap; Assert.NotNull(map); Assert.Equal(6, map.Count); Assert.Equal("bar", map["foo"]); Assert.Equal("foo", map["bar"]); Assert.Equal("instance_id", map[EurekaPostConfigurer.INSTANCE_ID]); Assert.Equal("ac923014-93a5-4aee-b934-a043b241868b", map[EurekaPostConfigurer.CF_APP_GUID]); Assert.Equal("1", map[EurekaPostConfigurer.CF_INSTANCE_INDEX]); Assert.Equal(EurekaPostConfigurer.UNKNOWN_ZONE, map[EurekaPostConfigurer.ZONE]); }
public void UpdateConfiguration_WithVCAPEnvVariables_Route_ConfiguresEurekaDiscovery_Correctly() { var vcap_application = @" { 'limits': { 'fds': 16384, 'mem': 512, 'disk': 1024 }, 'application_name': 'foo', 'application_uris': [ 'foo.apps.testcloud.com' ], 'name': 'foo', 'space_name': 'test', 'space_id': '98c627e7-f559-46a4-9032-88cab63f8249', 'uris': [ 'foo.apps.testcloud.com' ], 'users': null, 'version': '4a439db9-4a82-47a3-aeea-8240465cff8e', 'application_version': '4a439db9-4a82-47a3-aeea-8240465cff8e', 'application_id': 'ac923014-93a5-4aee-b934-a043b241868b', 'instance_id': 'instance_id' }"; var vcap_services = @" { 'p-config-server': [ { 'credentials': { 'uri': 'https://config-de211817-2e99-4c57-89e8-31fa7ca6a276.apps.testcloud.com', 'client_id': 'p-config-server-8f49dd26-e6cd-47a6-b2a0-7655cea20333', 'client_secret': 'vBDjqIf7XthT', 'access_token_uri': 'https://p-spring-cloud-services.uaa.system.testcloud.com/oauth/token' }, 'syslog_drain_url': null, 'label': 'p-config-server', 'provider': null, 'plan': 'standard', 'name': 'myConfigServer', 'tags': [ 'configuration', 'spring-cloud' ] } ], 'p-service-registry': [ { 'credentials': { 'uri': 'https://eureka-6a1b81f5-79e2-4d14-a86b-ddf584635a60.apps.testcloud.com', 'client_id': 'p-service-registry-06e28efd-24be-4ce3-9784-854ed8d2acbe', 'client_secret': 'dCsdoiuklicS', 'access_token_uri': 'https://p-spring-cloud-services.uaa.system.testcloud.com/oauth/token' }, 'syslog_drain_url': null, 'label': 'p-service-registry', 'provider': null, 'plan': 'standard', 'name': 'myDiscoveryService', 'tags': [ 'eureka', 'discovery', 'registry', 'spring-cloud' ] } ] }"; var appsettings = @" { 'eureka': { 'client': { 'eurekaServer': { 'proxyHost': 'proxyHost', 'proxyPort': 100, 'proxyUserName': '******', 'proxyPassword': '******', 'shouldGZipContent': true, 'connectTimeoutSeconds': 100 }, 'allowRedirects': true, 'shouldDisableDelta': true, 'shouldFilterOnlyUpInstances': true, 'shouldFetchRegistry': true, 'registryRefreshSingleVipAddress':'registryRefreshSingleVipAddress', 'shouldOnDemandUpdateStatusChange': true, 'shouldRegisterWithEureka': true, 'registryFetchIntervalSeconds': 100, 'instanceInfoReplicationIntervalSeconds': 100, 'serviceUrl': 'http://localhost:8761/eureka/' }, 'instance': { 'registrationMethod': 'route', 'instanceId': 'instanceId', 'appGroup': 'appGroup', 'instanceEnabledOnInit': true, 'hostname': 'myhostname', 'port': 100, 'securePort': 100, 'nonSecurePortEnabled': true, 'securePortEnabled': true, 'leaseExpirationDurationInSeconds':100, 'leaseRenewalIntervalInSeconds': 100, 'secureVipAddress': 'secureVipAddress', 'vipAddress': 'vipAddress', 'asgName': 'asgName', 'metadataMap': { 'foo': 'bar', 'bar': 'foo' }, 'statusPageUrlPath': 'statusPageUrlPath', 'statusPageUrl': 'statusPageUrl', 'homePageUrlPath':'homePageUrlPath', 'homePageUrl': 'homePageUrl', 'healthCheckUrlPath': 'healthCheckUrlPath', 'healthCheckUrl':'healthCheckUrl', 'secureHealthCheckUrl':'secureHealthCheckUrl' } } }"; Environment.SetEnvironmentVariable("VCAP_APPLICATION", vcap_application); Environment.SetEnvironmentVariable("VCAP_SERVICES", vcap_services); Environment.SetEnvironmentVariable("CF_INSTANCE_INDEX", "1"); Environment.SetEnvironmentVariable("CF_INSTANCE_GUID", "ac923014-93a5-4aee-b934-a043b241868b"); var path = TestHelpers.CreateTempFile(appsettings); string directory = Path.GetDirectoryName(path); string fileName = Path.GetFileName(path); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.SetBasePath(directory); configurationBuilder.AddJsonFile(fileName); configurationBuilder.AddCloudFoundry(); var config = configurationBuilder.Build(); var sis = config.GetServiceInfos <EurekaServiceInfo>(); Assert.Single(sis); EurekaServiceInfo si = sis[0]; var clientOpts = new EurekaClientOptions(); var clientSection = config.GetSection(EurekaClientOptions.EUREKA_CLIENT_CONFIGURATION_PREFIX); clientSection.Bind(clientOpts); EurekaPostConfigurer.UpdateConfiguration(config, si, clientOpts); var co = clientOpts; Assert.NotNull(co); Assert.Equal("proxyHost", co.ProxyHost); Assert.Equal(100, co.ProxyPort); Assert.Equal("proxyPassword", co.ProxyPassword); Assert.Equal("proxyUserName", co.ProxyUserName); Assert.True(co.AllowRedirects); Assert.Equal(100, co.InstanceInfoReplicationIntervalSeconds); Assert.Equal(100, co.EurekaServerConnectTimeoutSeconds); Assert.Equal("https://eureka-6a1b81f5-79e2-4d14-a86b-ddf584635a60.apps.testcloud.com/eureka/", co.EurekaServerServiceUrls); Assert.Equal(100, co.RegistryFetchIntervalSeconds); Assert.Equal("registryRefreshSingleVipAddress", co.RegistryRefreshSingleVipAddress); Assert.True(co.ShouldDisableDelta); Assert.True(co.ShouldFetchRegistry); Assert.True(co.ShouldFilterOnlyUpInstances); Assert.True(co.ShouldGZipContent); Assert.True(co.ShouldOnDemandUpdateStatusChange); Assert.True(co.ShouldRegisterWithEureka); Assert.Equal("https://p-spring-cloud-services.uaa.system.testcloud.com/oauth/token", co.AccessTokenUri); Assert.Equal("p-service-registry-06e28efd-24be-4ce3-9784-854ed8d2acbe", co.ClientId); Assert.Equal("dCsdoiuklicS", co.ClientSecret); var instOpts = new EurekaInstanceOptions(); var instSection = config.GetSection(EurekaInstanceOptions.EUREKA_INSTANCE_CONFIGURATION_PREFIX); instSection.Bind(instOpts); EurekaPostConfigurer.UpdateConfiguration(config, si, instOpts); var ro = instOpts; Assert.Equal("route", ro.RegistrationMethod); Assert.Equal("foo.apps.testcloud.com:instance_id", ro.InstanceId); Assert.Equal("foo", ro.AppName); Assert.Equal("appGroup", ro.AppGroupName); Assert.True(ro.IsInstanceEnabledOnInit); Assert.Equal(80, ro.NonSecurePort); Assert.Equal("foo.apps.testcloud.com", ro.HostName); Assert.Equal(443, ro.SecurePort); Assert.True(ro.IsNonSecurePortEnabled); Assert.True(ro.SecurePortEnabled); Assert.Equal(100, ro.LeaseExpirationDurationInSeconds); Assert.Equal(100, ro.LeaseRenewalIntervalInSeconds); Assert.Equal("secureVipAddress", ro.SecureVirtualHostName); Assert.Equal("vipAddress", ro.VirtualHostName); Assert.Equal("asgName", ro.ASGName); Assert.Equal("statusPageUrlPath", ro.StatusPageUrlPath); Assert.Equal("statusPageUrl", ro.StatusPageUrl); Assert.Equal("homePageUrlPath", ro.HomePageUrlPath); Assert.Equal("homePageUrl", ro.HomePageUrl); Assert.Equal("healthCheckUrlPath", ro.HealthCheckUrlPath); Assert.Equal("healthCheckUrl", ro.HealthCheckUrl); Assert.Equal("secureHealthCheckUrl", ro.SecureHealthCheckUrl); var map = ro.MetadataMap; Assert.NotNull(map); Assert.Equal(6, map.Count); Assert.Equal("bar", map["foo"]); Assert.Equal("foo", map["bar"]); Assert.Equal("instance_id", map[EurekaPostConfigurer.INSTANCE_ID]); Assert.Equal("ac923014-93a5-4aee-b934-a043b241868b", map[EurekaPostConfigurer.CF_APP_GUID]); Assert.Equal("1", map[EurekaPostConfigurer.CF_INSTANCE_INDEX]); Assert.Equal(EurekaPostConfigurer.UNKNOWN_ZONE, map[EurekaPostConfigurer.ZONE]); }
public static void UpdateConfiguration(IConfiguration config, EurekaServiceInfo si, EurekaInstanceOptions instOptions) { Steeltoe.Discovery.Eureka.EurekaPostConfigurer.UpdateConfiguration(config, si, instOptions); }
public static void UpdateConfiguration(IConfiguration config, EurekaServiceInfo si, EurekaClientOptions clientOptions) { Steeltoe.Discovery.Eureka.EurekaPostConfigurer.UpdateConfiguration(config, si, clientOptions); }