Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var options = new AgentOptions(args);
            var pid     = Process.GetCurrentProcess().Id;
            var logName = $"testcentric-agent_{pid}.log";

            InternalTrace.Initialize(Path.Combine(options.WorkDirectory, logName), options.TraceLevel);
            log = InternalTrace.GetLogger(typeof(TestCentricAgent));

            if (options.DebugAgent || options.DebugTests)
            {
                TryLaunchDebugger();
            }

            LocateAgencyProcess(options.AgencyPid);

            log.Info("Agent process {0} starting", pid);

#if NET5_0
            log.Info($"Running .NET 5.0 agent under {RuntimeInformation.FrameworkDescription}");
#elif NETCOREAPP3_1
            log.Info($"Running .NET Core 3.1 agent under {RuntimeInformation.FrameworkDescription}");
#elif NETCOREAPP2_1
            log.Info($"Running .NET Core 2.1 agent under {RuntimeInformation.FrameworkDescription}");
#elif NET40
            log.Info("Running .NET Framework 4.0 agent");
#elif NET20
            log.Info("Running .NET Framework 2.0 agent");
#endif

            log.Info("Starting RemoteTestAgent");
            Agent           = new RemoteTestAgent(options.AgentId);
            Agent.Transport =
#if NETFRAMEWORK
                new TestCentric.Engine.Communication.Transports.Remoting.TestAgentRemotingTransport(Agent, options.AgencyUrl);
#else
                new TestCentric.Engine.Communication.Transports.Tcp.TestAgentTcpTransport(Agent, options.AgencyUrl);
#endif
            try
            {
                if (Agent.Start())
                {
                    WaitForStop();
                }
                else
                {
                    log.Error("Failed to start RemoteTestAgent");
                    Environment.Exit(AgentExitCodes.FAILED_TO_START_REMOTE_AGENT);
                }
            }
            catch (Exception ex)
            {
                log.Error("Exception in RemoteTestAgent. {0}", ExceptionHelper.BuildMessageAndStackTrace(ex));
                Environment.Exit(AgentExitCodes.UNEXPECTED_EXCEPTION);
            }
            log.Info("Agent process {0} exiting cleanly", pid);

            Environment.Exit(AgentExitCodes.OK);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            var options = new AgentOptions(args);
            var pid     = Process.GetCurrentProcess().Id;
            var logName = $"testcentric-agent_{pid}.log";

            InternalTrace.Initialize(Path.Combine(options.WorkDirectory, logName), options.TraceLevel);
            log = InternalTrace.GetLogger(typeof(TestCentricAgent));

            if (options.DebugAgent || options.DebugTests)
            {
                TryLaunchDebugger();
            }

            LocateAgencyProcess(options.AgencyPid);

            log.Info($".NET 2.0 Agent process {pid} starting");
            log.Info($"  AgentId:   {options.AgentId}");
            log.Info($"  AgencyUrl: {options.AgencyUrl}");

            log.Info("Starting RemoteTestAgent");
            Agent           = new RemoteTestAgent(options.AgentId);
            Agent.Transport = new TestAgentRemotingTransport(Agent, options.AgencyUrl);

            try
            {
                if (Agent.Start())
                {
                    WaitForStop();
                }
                else
                {
                    log.Error("Failed to start RemoteTestAgent");
                    Environment.Exit(AgentExitCodes.FAILED_TO_START_REMOTE_AGENT);
                }
            }
            catch (Exception ex)
            {
                log.Error("Exception in RemoteTestAgent. {0}", ExceptionHelper.BuildMessageAndStackTrace(ex));
                Environment.Exit(AgentExitCodes.UNEXPECTED_EXCEPTION);
            }
            log.Info("Agent process {0} exiting cleanly", pid);

            Environment.Exit(AgentExitCodes.OK);
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            AgentId   = new Guid(args[0]);
            AgencyUrl = args[1];

            var traceLevel     = InternalTraceLevel.Off;
            var pid            = Process.GetCurrentProcess().Id;
            var debugArgPassed = false;
            var workDirectory  = string.Empty;
            var agencyPid      = string.Empty;

            for (int i = 2; i < args.Length; i++)
            {
                string arg = args[i];

                // NOTE: we can test these strings exactly since
                // they originate from the engine itself.
                if (arg == "--debug-agent")
                {
                    debugArgPassed = true;
                }
                else if (arg.StartsWith("--trace:"))
                {
                    traceLevel = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), arg.Substring(8));
                }
                else if (arg.StartsWith("--pid="))
                {
                    agencyPid = arg.Substring(6);
                }
                else if (arg.StartsWith("--work="))
                {
                    workDirectory = arg.Substring(7);
                }
            }

            var logName = $"testcentric-agent_{pid}.log";

            InternalTrace.Initialize(Path.Combine(workDirectory, logName), traceLevel);
            log = InternalTrace.GetLogger(typeof(TestCentricAgent));

            if (debugArgPassed)
            {
                TryLaunchDebugger();
            }

            LocateAgencyProcess(agencyPid);

            log.Info("Agent process {0} starting", pid);
            log.Info("Running under version {0}, {1}",
                     Environment.Version,
                     RuntimeFramework.CurrentFramework.DisplayName);

            // Create CoreEngine
            var engine = new CoreEngine
            {
                WorkDirectory      = workDirectory,
                InternalTraceLevel = traceLevel
            };

            // Custom Service Initialization
            engine.Services.Add(new ExtensionService());
#if !NETCOREAPP
            engine.Services.Add(new DomainManager());
#endif
            engine.Services.Add(new InProcessTestRunnerFactory());
            engine.Services.Add(new DriverService());

            // Initialize Services
            log.Info("Initializing Services");
            engine.InitializeServices();

            log.Info("Starting RemoteTestAgent");
            Agent           = new RemoteTestAgent(AgentId, engine.Services);
            Agent.Transport =
#if NETFRAMEWORK
                new TestCentric.Engine.Communication.Transports.Remoting.TestAgentRemotingTransport(Agent, AgencyUrl);
#else
                new TestCentric.Engine.Communication.Transports.Tcp.TestAgentTcpTransport(Agent, AgencyUrl);
#endif
            try
            {
                if (Agent.Start())
                {
                    WaitForStop();
                }
                else
                {
                    log.Error("Failed to start RemoteTestAgent");
                    Environment.Exit(AgentExitCodes.FAILED_TO_START_REMOTE_AGENT);
                }
            }
            catch (Exception ex)
            {
                log.Error("Exception in RemoteTestAgent. {0}", ExceptionHelper.BuildMessageAndStackTrace(ex));
                Environment.Exit(AgentExitCodes.UNEXPECTED_EXCEPTION);
            }
            log.Info("Agent process {0} exiting cleanly", pid);

            Environment.Exit(AgentExitCodes.OK);
        }