private void InitializeExecutionMessageHandlers() { var activatorWrapper = new ActivatorWrapper(); var reflectionWrapper = new ReflectionWrapper(); var assemblies = new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), assemblies, reflectionWrapper, activatorWrapper); _stepRegistry = assemblyLoader.GetStepRegistry(); var tableFormatter = new TableFormatter(assemblyLoader, activatorWrapper); var classInstanceManager = assemblyLoader.GetClassInstanceManager(); var executionOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper, classInstanceManager, new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager), new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager)); this.executionStartingProcessor = new ExecutionStartingProcessor(executionOrchestrator); this.executionEndingProcessor = new ExecutionEndingProcessor(executionOrchestrator); this.specExecutionStartingProcessor = new SpecExecutionStartingProcessor(executionOrchestrator); this.specExecutionEndingProcessor = new SpecExecutionEndingProcessor(executionOrchestrator); this.scenarioExecutionStartingProcessor = new ScenarioExecutionStartingProcessor(executionOrchestrator); this.scenarioExecutionEndingProcessor = new ScenarioExecutionEndingProcessor(executionOrchestrator); this.stepExecutionStartingProcessor = new StepExecutionStartingProcessor(executionOrchestrator); this.stepExecutionEndingProcessor = new StepExecutionEndingProcessor(executionOrchestrator); this.executeStepProcessor = new ExecuteStepProcessor(_stepRegistry, executionOrchestrator, tableFormatter); this.scenarioDataStoreInitProcessor = new ScenarioDataStoreInitProcessor(assemblyLoader); this.specDataStoreInitProcessor = new SpecDataStoreInitProcessor(assemblyLoader); this.suiteDataStoreInitProcessor = new SuiteDataStoreInitProcessor(assemblyLoader); }
public void StartServer() { var server = new Server(); var assemblies = new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies(); var reflectionWrapper = new ReflectionWrapper(); var activatorWrapper = new ActivatorWrapper(); var assemblyLoader = new AssemblyLoader(new AssemblyWrapper(), assemblies, reflectionWrapper, activatorWrapper, _staticLoader.GetStepRegistry()); var handler = new RunnerServiceHandler(activatorWrapper, reflectionWrapper, assemblyLoader, _staticLoader, server); server.Services.Add(Runner.BindService(handler)); var port = server.Ports.Add(new ServerPort("127.0.0.1", 0, ServerCredentials.Insecure)); server.Start(); Console.WriteLine("Listening on port:" + port); server.ShutdownTask.Wait(); Environment.Exit(Environment.ExitCode); }
public virtual void ConfigureServices(IServiceCollection services) { var assemblyPath = new AssemblyLocater(new DirectoryWrapper()).GetTestAssembly(); Logger.Debug($"Loading assembly from : {assemblyPath}"); services.AddGrpc(); services.AddLogging(logConfig => { logConfig.SetMinimumLevel(LogLevel.Error); var logLevel = Utils.TryReadEnvValue("GAUGE_LOG_LEVEL"); if (logLevel != null && logLevel.ToUpper() == "DEBUG") { logConfig.SetMinimumLevel(LogLevel.Debug); } }); services.AddSingleton <IReflectionWrapper, ReflectionWrapper>(); services.AddSingleton <IActivatorWrapper, ActivatorWrapper>(); services.AddSingleton <ExecutorPool>(new ExecutorPool(GetNoOfStreams(), IsMultithreading())); services.AddSingleton <IGaugeLoadContext>((sp) => { var isDaemon = string.Compare(Environment.GetEnvironmentVariable("IS_DAEMON"), "true", true) == 0; return(isDaemon ? new LockFreeGaugeLoadContext(assemblyPath) : new GaugeLoadContext(assemblyPath)); }); services.AddSingleton <AssemblyPath>(s => assemblyPath); services.AddSingleton <IAssemblyLoader, AssemblyLoader>(); services.AddSingleton <IDirectoryWrapper, DirectoryWrapper>(); services.AddSingleton <IStaticLoader, StaticLoader>(); services.AddSingleton <IAttributesLoader, AttributesLoader>(); services.AddSingleton <IStepRegistry>(s => s.GetRequiredService <IStaticLoader>().GetStepRegistry()); if (Configuration.GetValue <string>("ReflectionScanAssemblies") == "True") { Logger.Debug("Using ExecutableRunnerServiceHandler"); services.AddSingleton <Gauge.Messages.Runner.RunnerBase, ExecutableRunnerServiceHandler>(); } else { Logger.Debug("Using AuthoringRunnerServiceHandler"); services.AddSingleton <Gauge.Messages.Runner.RunnerBase, AuthoringRunnerServiceHandler>(); } }