Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var services = new ServiceContext();

            RouteNetworkBuilder.Run("../../../../Demo.BuildTestNetwork/Data/", services.CommandBus);

            ConduitBuilder.Run(services.ServiceProvider.GetService <IConduitNetworkQueryService>(), services.CommandBus);
        }
Exemplo n.º 2
0
        public DemoNetwork(IHostingEnvironment env, IDocumentStore documentStore, IMediator commandBus, IConduitClosureRepository conduitClosureRepository, IRouteNetworkState routeNetwork, IConduitNetworkQueryService conduitNetwork, IFiberNetworkQueryService fiberNetworkQueryService)
        {
            Description = "API for invoking the demo/test data builder";

            Field <StringGraphType>(
                "rebuild",
                description: "Deletes the database and rebuild the demo data from the GeoJson files created using QGIS",
                resolve: context =>
            {
                try
                {
                    // First delete everything in the database
                    documentStore.Advanced.Clean.CompletelyRemoveAll();

                    // Clean everything in projected in-memory read models
                    routeNetwork.Clean();
                    conduitNetwork.Clean();
                    conduitClosureRepository.Clean();
                    fiberNetworkQueryService.Clean();

                    var iisExpressFolder = AppDomain.CurrentDomain.BaseDirectory;

                    var pathToData = env.ContentRootPath;

                    if (iisExpressFolder.Contains("Debug\\netcoreapp"))
                    {
                        pathToData = iisExpressFolder;
                    }

                    pathToData += Path.DirectorySeparatorChar.ToString() + "Data" + Path.DirectorySeparatorChar.ToString();

                    // Rebuild demo data
                    RouteNetworkBuilder.Run(pathToData, commandBus);
                    ConduitBuilder.Run(conduitNetwork, commandBus);
                    EquipmentBuilder.Run(routeNetwork, conduitNetwork, commandBus);

                    // Reload everything again
                    routeNetwork.Clean();
                    conduitNetwork.Clean();
                    conduitClosureRepository.Clean();
                    fiberNetworkQueryService.Clean();

                    return("Read models cleaned and test data was rebuilt.");
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message, ex));
                    return("Failed");
                }
            }
                );
        }
Exemplo n.º 3
0
        public void Run()
        {
            var loggerFactory = LoggerFactory.Create(builder =>
                                                     builder.AddConsole().SetMinimumLevel(LogLevel.Debug)
                                                     );

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.ControlledBy(new Serilog.Core.LoggingLevelSwitch(Serilog.Events.LogEventLevel.Verbose))
                         .WriteTo.Console()
                         .CreateLogger();

            try {
                var routeNetworkDatastore = new RouteNetworkDatastore(PostgresConnectionString);

                var startMarker = Guid.NewGuid();
                var endMarker   = Guid.NewGuid();

                var routeNetworkBuilder = new RouteNetworkBuilder();
                routeNetworkBuilder.Run(Nodefilename, SegmentFilename, routeNetworkDatastore, startMarker, endMarker);

                var graph = routeNetworkBuilder.RouteGraph;

                using var eventFetcher = new WaitForAndFetchEvents <RouteNetworkEvent>(loggerFactory, KafkaServer, RouteNetworkTopicName);

                long timeoutMs = 1000 * 60 * 1; // Wait 1 minute, before giving up recieving route network events from topic

                bool timedOut = eventFetcher.WaitForEvents(
                    start => start.WorkTaskMrid.Equals(startMarker),
                    stop => stop.WorkTaskMrid.Equals(endMarker),
                    timeoutMs
                    ).Result;


                var events = eventFetcher.Events.ToList();

                // Check if event fetcher timed out
                if (timedOut)
                {
                    LogErrorAndThrowException($"Seeding of test network failed. Timeout ({timeoutMs} ms) exceded waiting for events to arrive on route network topic.");
                }

                // Check if GDB integrator has put the right amount of events in the route network event topic
                if (events.Count != (graph.Nodes.Count + graph.Edges.Count))
                {
                    LogErrorAndThrowException($"Seeding of test network failed. {(graph.Nodes.Count + graph.Edges.Count)} number of nodes and routes were inserted into Postgres. Expected the same amount of events inserted into the route network topic by GDB integrator, but got {events.Count} events from topic!");
                }


                bool someTestFailed = false;

                // Check that all properties we add to postgres is added to events etc.
                if (!new CheckEventProperties().Run(graph, events))
                {
                    someTestFailed = true;
                }


                // Check if event fetcher timed out
                if (someTestFailed)
                {
                    LogErrorAndThrowException($"Seeding of test network failed. Please search the log for errors resulting from integration tests.");
                }
            }
            catch (Exception ex)
            {
                Log.Error("Seeding of test network failed. Unhandled exception: " + ex.Message, ex);
                throw ex;
            }
        }
Exemplo n.º 4
0
        public void Run()
        {
            RouteNetworkBuilder.Run(_migrationBuilder);

            ConduitBuilder.Run(_migrationBuilder);
        }