Пример #1
0
        public void Start()
        {
            NTrace.Info("Starting");
            this.channel = ServerUtilities.GetTcpChannel();
            NTrace.Debug("Acquired Tcp Channel");

            try
            {
                this.agency = (TestAgency)Activator.GetObject(typeof(TestAgency), agencyUrl);
                NTrace.DebugFormat("Connected to TestAgency at {0}", agencyUrl);
            }
            catch (Exception ex)
            {
                NTrace.ErrorFormat("Unable to connect to test agency at {0}", agencyUrl);
                NTrace.Error(ex.Message);
            }

            try
            {
                this.agency.Register(this, ProcessId);
                NTrace.Debug("Registered with TestAgency");
            }
            catch (Exception ex)
            {
                NTrace.Error("Failed to register with TestAgency", ex);
            }
        }
Пример #2
0
		public void Start()
		{
			NTrace.Info("Starting");
			this.channel = ServerUtilities.GetTcpChannel();
			NTrace.Debug("Acquired Tcp Channel");

			try
			{
				this.agency = (TestAgency)Activator.GetObject( typeof( TestAgency ), agencyUrl );
				NTrace.DebugFormat("Connected to TestAgency at {0}", agencyUrl);
			}
			catch( Exception ex )
			{
				NTrace.ErrorFormat( "Unable to connect to test agency at {0}", agencyUrl );
				NTrace.Error( ex.Message );
			}

			try
			{
				this.agency.Register( this, ProcessId );
				NTrace.Debug( "Registered with TestAgency" );
			}
			catch( Exception ex )
			{
				NTrace.Error( "Failed to register with TestAgency", ex );
			}
		}
		/// <summary>
		/// Construct a RemoteTestAgent
		/// </summary>
		public RemoteTestAgent( Guid agentId, TestAgency agency )
            : base(agentId, agency) { }
Пример #4
0
		public static int Main(string[] args)
		{
            AgentId = new Guid(args[0]);
            AgencyUrl = args[1];

#if DEBUG
            if ( args.Length > 2 && args[2] == "--pause" )
                System.Windows.Forms.MessageBox.Show( "Attach debugger if desired, then press OK", "NUnit-Agent");
#endif

            // Create SettingsService early so we know the trace level right at the start
            SettingsService settingsService = new SettingsService(false);
            InternalTrace.Initialize("nunit-agent_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default));

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

			// Add Standard Services to ServiceManager
            log.Info("Adding Services");
            ServiceManager.Services.AddService(settingsService);
            ServiceManager.Services.AddService(new ProjectService());
			ServiceManager.Services.AddService( new DomainManager() );
			//ServiceManager.Services.AddService( new RecentFilesService() );
			//ServiceManager.Services.AddService( new TestLoader() );
			ServiceManager.Services.AddService( new AddinRegistry() );
			ServiceManager.Services.AddService( new AddinManager() );

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

            Channel = ServerUtilities.GetTcpChannel();

            log.Info("Connecting to TestAgency at {0}", AgencyUrl);
            try
            {
                Agency = Activator.GetObject(typeof(TestAgency), AgencyUrl) as TestAgency;
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect", ex);
            }

            if (Channel != null)
            {
                log.Info("Starting RemoteTestAgent");
                RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency);

                try
                {
                    if (agent.Start())
                    {
                        log.Debug("Waiting for stopSignal");
                        agent.WaitForStop();
                        log.Debug("Stop signal received");
                    }
                    else
                        log.Error("Failed to start RemoteTestAgent");
                }
                catch (Exception ex)
                {
                    log.Error("Exception in RemoteTestAgent", ex);
                }

                log.Info("Unregistering Channel");
                try
                {
                    ChannelServices.UnregisterChannel(Channel);
                }
                catch (Exception ex)
                {
                    log.Error("ChannelServices.UnregisterChannel threw an exception", ex);
                }
            }

            log.Info("Stopping all services");
            ServiceManager.Services.StopAllServices();
            log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id);
            InternalTrace.Close();

			return 0;
		}
Пример #5
0
		public TestAgent( TestAgency agency, int agentId, RemoteTestAgent remoteAgent )
		{
			this.agency = agency;
			this.agentId = agentId;
			this.remoteAgent = remoteAgent;
		}
Пример #6
0
 /// <summary>
 /// Construct a RemoteTestAgent
 /// </summary>
 public RemoteTestAgent(Guid agentId, TestAgency agency)
     : base(agentId, agency)
 {
 }
Пример #7
0
        public static int Main(string[] args)
        {
            AgentId = new Guid(args[0]);
            AgencyUrl = args[1];

            InternalTrace.Initialize("nunit-agent_%p.log");
            log.Info("Agent process {0} starting", Process.GetCurrentProcess().Id);
            log.Info("Running under version {0}, {1}",
                Environment.Version,
                RuntimeFramework.CurrentFramework.DisplayName);

            // Add Standard Services to ServiceManager
            log.Info("Adding Services");
            ServiceManager.Services.AddService(new SettingsService(false));
            ServiceManager.Services.AddService(new ProjectService());
            ServiceManager.Services.AddService( new DomainManager() );
            //ServiceManager.Services.AddService( new RecentFilesService() );
            //ServiceManager.Services.AddService( new TestLoader() );
            ServiceManager.Services.AddService( new AddinRegistry() );
            ServiceManager.Services.AddService( new AddinManager() );

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

            Channel = ServerUtilities.GetTcpChannel();

            log.Info("Connecting to TestAgency at {0}", AgencyUrl);
            try
            {
                Agency = Activator.GetObject(typeof(TestAgency), AgencyUrl) as TestAgency;
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect", ex);
            }

            if (Channel != null)
            {
                log.Info("Starting RemoteTestAgent");
                RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency);

                try
                {
                    if (agent.Start())
                    {
                        log.Debug("Waiting for stopSignal");
                        agent.WaitForStop();
                        log.Debug("Stop signal received");
                    }
                    else
                        log.Error("Failed to start RemoteTestAgent");
                }
                catch (Exception ex)
                {
                    log.Error("Exception in RemoteTestAgent", ex);
                }

                log.Info("Unregistering Channel");
                try
                {
                    ChannelServices.UnregisterChannel(Channel);
                }
                catch (Exception ex)
                {
                    log.Error("ChannelServices.UnregisterChannel threw an exception", ex);
                }
            }

            log.Info("Stopping all services");
            ServiceManager.Services.StopAllServices();
            log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id);
            InternalTrace.Close();

            return 0;
        }
Пример #8
0
 public TestAgent(TestAgency agency, int agentId, RemoteTestAgent remoteAgent)
 {
     this.agency      = agency;
     this.agentId     = agentId;
     this.remoteAgent = remoteAgent;
 }