public void ServiceConfigGenerationTest() { // BaseInstaller.RunPreCheck(this.Container, this.Sys.Settings.Config); var configurator = this.ActorOfAsTestActorRef <NginxConfiguratorActor>("configurator"); this.ActorOfAsTestActorRef <NameSpaceActor>(this.Sys.DI().Props <NameSpaceActor>(), "Web"); var address = Cluster.Get(this.Sys).SelfAddress; configurator.Tell( new ClusterEvent.MemberUp( ClusterExtensions.MemberCreate(new UniqueAddress(address, 1), 1, MemberStatus.Up, ImmutableHashSet.Create("Web")))); this.ExpectTestMsg <WebDescriptionRequest>(); Assert.Equal(1, configurator.UnderlyingActor.KnownActiveNodes.Count); configurator.Tell( new WebDescriptionResponse { Services = new List <ServiceDescription> { new ServiceDescription { ListeningPort = 8080, PublicHostName = "web1", Route = "/TestWebService" }, new ServiceDescription { ListeningPort = 8080, PublicHostName = "web1", Route = "/test/TestWebService2" }, new ServiceDescription { ListeningPort = 8080, PublicHostName = "web2", Route = "/Api" } } .AsReadOnly() }); Assert.Equal(1, configurator.UnderlyingActor.NodePublishUrls.Count); Assert.Equal( "0.0.0.0:8080", configurator.UnderlyingActor.Configuration["web1"]["/TestWebService"].ActiveNodes[0].NodeUrl); Assert.Equal( "0.0.0.0:8080", configurator.UnderlyingActor.Configuration["web1"]["/test/TestWebService2"].ActiveNodes[0].NodeUrl); Assert.Equal( "0.0.0.0:8080", configurator.UnderlyingActor.Configuration["web2"]["/Api"].ActiveNodes[0].NodeUrl); var config = File.ReadAllText("./nginx.conf"); this.Sys.Log.Info(config); }
public void SimpleNodeLifeCycleTest() { var schemaProvider = this.Container.Resolve <SchemaProvider>(); Assert.Null(schemaProvider.CurrentSchema); var browser = this.ActorOf(this.Sys.DI().Props <ApiBrowserActor>()); this.ExpectNoMsg(); Assert.Null(schemaProvider.CurrentSchema); var nodeAddress = new UniqueAddress(new Address("akka.tcp", "KlusterKite", "testNode1", 1), 1); var remoteActorRef = new FakeActorRef( ActorPath.Parse($"{nodeAddress.Address}/user/KlusterKite/API/Publisher"), this.TestActor); browser.Tell( new ClusterEvent.MemberUp( ClusterExtensions.MemberCreate(nodeAddress, 1, MemberStatus.Up, ImmutableHashSet <string> .Empty))); // node role check this.ExpectNoMsg(); browser.Tell( new ClusterEvent.MemberUp( ClusterExtensions.MemberCreate( nodeAddress, 1, MemberStatus.Up, ImmutableHashSet.Create("KlusterKite.API.Endpoint")))); var discoverRequest = this.ExpectMsg <RemoteTestMessage <ApiDiscoverRequest> >(); Assert.Equal("/user/KlusterKite/API/Publisher", discoverRequest.ReceiverPath); Assert.Equal(nodeAddress.Address, discoverRequest.RecipientAddress); this.ExpectNoMsg(); Assert.Null(schemaProvider.CurrentSchema); this.TestScheduler.Advance(TimeSpan.FromSeconds(30)); discoverRequest = this.ExpectMsg <RemoteTestMessage <ApiDiscoverRequest> >(); Assert.Equal("/user/KlusterKite/API/Publisher", discoverRequest.ReceiverPath); Assert.Equal(nodeAddress.Address, discoverRequest.RecipientAddress); this.ExpectNoMsg(); Assert.Null(schemaProvider.CurrentSchema); var internalApiProvider = new API.Tests.Mock.TestProvider(); var discoverResponse = new ApiDiscoverResponse { Description = internalApiProvider.ApiDescription, Handler = this.TestActor }; browser.Tell(new List <ApiDiscoverResponse> { discoverResponse }, remoteActorRef); this.ExpectNoMsg(); // The new api node now launched Assert.NotNull(schemaProvider.CurrentSchema); this.TestScheduler.Advance(TimeSpan.FromSeconds(30)); this.ExpectNoMsg(); browser.Tell( new ClusterEvent.MemberRemoved( ClusterExtensions.MemberCreate( nodeAddress, 1, MemberStatus.Removed, ImmutableHashSet.Create("KlusterKite.API.Endpoint")), MemberStatus.Up)); this.ExpectNoMsg(); Assert.Null(schemaProvider.CurrentSchema); }