public async Task CloseStopsSilo() { var endpoints = new EndpointsCollection { CreateEndpoint(ServiceFabricConstants.SiloEndpointName, 9082), CreateEndpoint(ServiceFabricConstants.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); var listener = new OrleansCommunicationListener( builder => { builder.ConfigureServices( services => { // Use our mock silo host. services.Replace(ServiceDescriptor.Singleton <ISiloHost>(sp => Substitute.ForPartsOf <MockSiloHost>(sp))); }); builder.ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory()); builder.Configure <EndpointOptions>(options => options.ConfigureFromServiceContext(this.serviceContext)); builder.UseLocalhostClustering(); }); await listener.OpenAsync(CancellationToken.None); var siloHost = listener.Host; siloHost.ClearReceivedCalls(); await listener.CloseAsync(CancellationToken.None); await siloHost.ReceivedWithAnyArgs(1).StopAsync(Arg.Is <CancellationToken>(c => !c.IsCancellationRequested)); await siloHost.DidNotReceiveWithAnyArgs().StartAsync(Arg.Any <CancellationToken>()); }
public async Task CloseStopsSilo() { var endpoints = new EndpointsCollection { CreateEndpoint(ServiceFabricConstants.SiloEndpointName, 9082), CreateEndpoint(ServiceFabricConstants.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); clusterConfig.Defaults.ConfigureServiceFabricSiloEndpoints(this.serviceContext); var listener = new OrleansCommunicationListener( builder => { builder.ConfigureServices( services => { // Use our mock silo host. services.Replace(ServiceDescriptor.Singleton <ISiloHost>(sp => Substitute.ForPartsOf <MockSiloHost>(sp))); }); // Our cluster configuration is what feeds the endpoint info, so add it. builder.UseConfiguration(this.clusterConfig); }); await listener.OpenAsync(CancellationToken.None); var siloHost = listener.Host; siloHost.ClearReceivedCalls(); await listener.CloseAsync(CancellationToken.None); await siloHost.ReceivedWithAnyArgs(1).StopAsync(Arg.Is <CancellationToken>(c => !c.IsCancellationRequested)); await siloHost.DidNotReceiveWithAnyArgs().StartAsync(Arg.Any <CancellationToken>()); }
public async Task SimpleUsageScenarioTest() { var endpoints = new EndpointsCollection { CreateEndpoint(ServiceFabricConstants.SiloEndpointName, 9082), CreateEndpoint(ServiceFabricConstants.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); var listener = new OrleansCommunicationListener( builder => { builder.ConfigureServices( services => { // Use our mock silo host. services.Replace(ServiceDescriptor.Singleton <ISiloHost>(sp => Substitute.ForPartsOf <MockSiloHost>(sp))); }); builder.ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory()); builder.UseLocalhostClustering(); builder.Configure <EndpointOptions>(options => { options.SiloPort = 9082; options.GatewayPort = 8888; }); }); var result = await listener.OpenAsync(CancellationToken.None); var siloHost = listener.Host; var publishedEndpoints = JsonConvert.DeserializeObject <FabricSiloInfo>(result); var siloAddress = publishedEndpoints.SiloAddress; siloAddress.Generation.Should().NotBe(0); siloAddress.Endpoint.Port.ShouldBeEquivalentTo(9082); var gatewayAddress = publishedEndpoints.GatewayAddress; gatewayAddress.Generation.Should().Be(0); gatewayAddress.Endpoint.Port.ShouldBeEquivalentTo(8888); await siloHost.ReceivedWithAnyArgs(1).StartAsync(Arg.Is <CancellationToken>(c => !c.IsCancellationRequested)); await siloHost.DidNotReceive().StopAsync(Arg.Any <CancellationToken>()); siloHost.ClearReceivedCalls(); await listener.CloseAsync(CancellationToken.None); await siloHost.ReceivedWithAnyArgs(1).StopAsync(Arg.Is <CancellationToken>(c => !c.IsCancellationRequested)); await siloHost.DidNotReceiveWithAnyArgs().StartAsync(Arg.Any <CancellationToken>()); }
public async Task SimpleUsageScenarioTest() { var endpoints = new EndpointsCollection { CreateEndpoint(ServiceFabricConstants.SiloEndpointName, 9082), CreateEndpoint(ServiceFabricConstants.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); clusterConfig.Defaults.ConfigureServiceFabricSiloEndpoints(this.serviceContext); var listener = new OrleansCommunicationListener( builder => { builder.ConfigureServices( services => { // Use our mock silo host. services.Replace(ServiceDescriptor.Singleton <ISiloHost>(sp => Substitute.ForPartsOf <MockSiloHost>(sp))); }); // Our cluster configuration is what feeds the endpoint info, so add it. builder.UseConfiguration(this.clusterConfig); }); var result = await listener.OpenAsync(CancellationToken.None); var siloHost = listener.Host; var publishedEndpoints = JsonConvert.DeserializeObject <FabricSiloInfo>(result); var siloAddress = publishedEndpoints.SiloAddress; siloAddress.Generation.ShouldBeEquivalentTo(864); siloAddress.Endpoint.Port.ShouldBeEquivalentTo(9082); var gatewayAddress = publishedEndpoints.GatewayAddress; gatewayAddress.Generation.ShouldBeEquivalentTo(864); gatewayAddress.Endpoint.Port.ShouldBeEquivalentTo(8888); await siloHost.ReceivedWithAnyArgs(1).StartAsync(Arg.Is <CancellationToken>(c => !c.IsCancellationRequested)); await siloHost.DidNotReceive().StopAsync(Arg.Any <CancellationToken>()); siloHost.ClearReceivedCalls(); await listener.CloseAsync(CancellationToken.None); await siloHost.ReceivedWithAnyArgs(1).StopAsync(Arg.Is <CancellationToken>(c => !c.IsCancellationRequested)); await siloHost.DidNotReceiveWithAnyArgs().StartAsync(Arg.Any <CancellationToken>()); }
public void MissingEndpointsCauseException() { var endpoints = new EndpointsCollection(); activationContext.GetEndpoints().Returns(_ => endpoints); // Check for the silo endpoint. var exception = Assert.Throws <KeyNotFoundException>(() => new OrleansCommunicationListener(serviceContext, clusterConfig)); Assert.Contains(OrleansCommunicationListener.SiloEndpointName, exception.Message); // Check for the proxy endpoint. endpoints.Add(CreateEndpoint(OrleansCommunicationListener.SiloEndpointName, 9082)); exception = Assert.Throws <KeyNotFoundException>(() => new OrleansCommunicationListener(serviceContext, clusterConfig)); Assert.Contains(OrleansCommunicationListener.GatewayEndpointName, exception.Message); }
public void MissingEndpointsCauseException() { var endpoints = new EndpointsCollection(); activationContext.GetEndpoints().Returns(_ => endpoints); // Check for the silo endpoint. var exception = Assert.Throws <KeyNotFoundException>(() => this.clusterConfig.Defaults.ConfigureServiceFabricSiloEndpoints(this.serviceContext)); var siloEndpointName = ServiceFabricConstants.SiloEndpointName; Assert.Contains(siloEndpointName, exception.Message); // Check for the proxy endpoint. endpoints.Add(CreateEndpoint(siloEndpointName, 9082)); exception = Assert.Throws <KeyNotFoundException>(() => clusterConfig.Defaults.ConfigureServiceFabricSiloEndpoints(serviceContext)); Assert.Contains(ServiceFabricConstants.GatewayEndpointName, exception.Message); }
public async Task SimpleUsageScenarioTest() { var endpoints = new EndpointsCollection { CreateEndpoint(OrleansCommunicationListener.SiloEndpointName, 9082), CreateEndpoint(OrleansCommunicationListener.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); var siloHost = Substitute.For <ISiloHost>(); var listener = new OrleansCommunicationListener(this.serviceContext, clusterConfig) { SiloHost = siloHost }; siloHost.NodeConfig.Returns(_ => clusterConfig.GetOrCreateNodeConfigurationForSilo(listener.SiloName)); var result = await listener.OpenAsync(CancellationToken.None); var publishedEndpoints = JsonConvert.DeserializeObject <FabricSiloInfo>(result); var siloAddress = publishedEndpoints.SiloAddress; siloAddress.Generation.ShouldBeEquivalentTo(864); siloAddress.Endpoint.Port.ShouldBeEquivalentTo(9082); var gatewayAddress = publishedEndpoints.GatewayAddress; gatewayAddress.Generation.ShouldBeEquivalentTo(864); gatewayAddress.Endpoint.Port.ShouldBeEquivalentTo(8888); siloHost.ReceivedWithAnyArgs(1).Start(null, null); siloHost.DidNotReceive().Stop(); siloHost.ClearReceivedCalls(); await listener.CloseAsync(CancellationToken.None); siloHost.Received(1).Stop(); siloHost.DidNotReceiveWithAnyArgs().Start(null, null); }
public void AbortStopAndDisposesSilo() { var endpoints = new EndpointsCollection { CreateEndpoint(OrleansCommunicationListener.SiloEndpointName, 9082), CreateEndpoint(OrleansCommunicationListener.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); var siloHost = Substitute.For <ISiloHost>(); var listener = new OrleansCommunicationListener( serviceContext, new ClusterConfiguration()) { SiloHost = siloHost }; listener.Abort(); siloHost.ReceivedWithAnyArgs(1).Stop(); siloHost.ReceivedWithAnyArgs(1).Dispose(); siloHost.DidNotReceiveWithAnyArgs().Start(null, null); }
public async Task CloseStopsSilo() { var endpoints = new EndpointsCollection { CreateEndpoint(OrleansCommunicationListener.SiloEndpointName, 9082), CreateEndpoint(OrleansCommunicationListener.GatewayEndpointName, 8888) }; activationContext.GetEndpoints().Returns(_ => endpoints); var siloHost = Substitute.For <ISiloHost>(); var listener = new OrleansCommunicationListener( serviceContext, new ClusterConfiguration()) { SiloHost = siloHost }; await listener.CloseAsync(CancellationToken.None); siloHost.ReceivedWithAnyArgs(1).Stop(); siloHost.DidNotReceiveWithAnyArgs().Dispose(); siloHost.DidNotReceiveWithAnyArgs().Start(null, null); }