Esempio n. 1
0
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="extensionConfig"></param>
        /// <param name="server">The server that this extension is for.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            var counters = this.PerformanceCounters ?? new DefaultPerformanceCounters();

            counters.EnsureCategoryExists(
                CategoryName,
                "Performance counters for CruiseControl.NET",
                new CounterCreationData(NumberCompletedCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                new CounterCreationData(NumberFailedCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                new CounterCreationData(AverageTimeCounter, string.Empty, PerformanceCounterType.AverageTimer32),
                new CounterCreationData(NumberTotalCounter, string.Empty, PerformanceCounterType.AverageBase));

            // Retrieve the counters
            Log.Debug("Initialising performance monitoring - integration requests");
            var stopwatches = new Dictionary <string, Stopwatch>();

            server.IntegrationStarted += (o, e) =>
            {
                Log.Debug(
                    string.Format(CultureInfo.CurrentCulture, "Starting stopwatch for '{0}'", e.ProjectName));

                // Start a stopwatch for the project
                if (stopwatches.ContainsKey(e.ProjectName))
                {
                    stopwatches[e.ProjectName].Reset();
                }
                else
                {
                    var stopwatch = new Stopwatch();
                    stopwatches.Add(e.ProjectName, stopwatch);
                    stopwatch.Start();
                }
            };

            server.IntegrationCompleted += (o, e) =>
            {
                Log.Debug(
                    string.Format(CultureInfo.CurrentCulture, "Performance logging for '{0}'", e.ProjectName));

                // Stop the stopwatch and record the elapsed time
                if (stopwatches.ContainsKey(e.ProjectName))
                {
                    var stopwatch = stopwatches[e.ProjectName];
                    stopwatch.Stop();
                    stopwatches.Remove(e.ProjectName);
                    counters.IncrementCounter(CategoryName, NumberTotalCounter);
                    counters.IncrementCounter(CategoryName, AverageTimeCounter, stopwatch.ElapsedMilliseconds);
                }

                // Record the result
                if (e.Status == IntegrationStatus.Success)
                {
                    counters.IncrementCounter(CategoryName, NumberCompletedCounter);
                }
                else
                {
                    counters.IncrementCounter(CategoryName, NumberFailedCounter);
                }
            };
        }
Esempio n. 2
0
        public void Initialise(ICruiseServer server,
                               ExtensionConfiguration extensionConfig)
        {
            var projectsElement = extensionConfig.Items
                                  .SingleOrDefault(n => n.Name == "allowedProjects");

            if (projectsElement != null)
            {
                this.maxCount = int.Parse(
                    projectsElement.InnerText) - 1;
            }

            this.server = server;
            this.server.ProjectStarting += (o, e) =>
            {
                if (this.count >= this.maxCount)
                {
                    e.Cancel = true;
                }
                else
                {
                    this.count++;
                }
            };
            this.server.ProjectStopped += (o, e) =>
            {
                this.count--;
            };
            Console.WriteLine("Initialise");
        }
        /// <summary>
        /// Generates a local <see cref="ICruiseServer"/> instance.
        /// </summary>
        /// <param name="configFile">The configuration file to use.</param>
        /// <returns>
        /// The new <see cref="ICruiseServer"/> instance.
        /// </returns>
        private ICruiseServer CreateLocal(string configFile)
        {
            var stateManager  = new XmlProjectStateManager();
            var configuration = ConfigurationManager.GetSection("cruiseServer") as ServerConfiguration;
            List <ExtensionConfiguration> extensionList = null;

            if (configuration != null)
            {
                extensionList = configuration.Extensions;
            }

            PathUtils.ConfigFileLocation = Path.IsPathRooted(configFile)
                                               ? configFile
                                               : Path.Combine(Environment.CurrentDirectory, configFile);
            var server = new CruiseServer(
                NewConfigurationService(configFile),
                new ProjectIntegratorListFactory(),
                new NetReflectorProjectSerializer(),
                stateManager,
                new SystemIoFileSystem(),
                new ExecutionEnvironment(),
                extensionList);

            server.InitialiseServices();
            this.ServerInstance = server;
            return(server);
        }
Esempio n. 4
0
        private void LaunchServer()
        {
            using (ConsoleEventHandler handler = new ConsoleEventHandler())
            {
                handler.OnConsoleEvent += new EventHandler(HandleControlEvent);

                using (server = serverFactory.Create(args.UseRemoting, args.ConfigFile))
                {
                    if (args.Project == null)
                    {
                        server.Start();
                        server.WaitForExit();
                    }
                    else
                    {
                        // Force the build
                        ValidateResponse(
                            server.ForceBuild(
                                new ProjectRequest(SecurityOverride.SessionIdentifier, args.Project)));

                        // Tell the server to stop as soon as the build has finished and then wait for it
                        ValidateResponse(
                            server.Stop(
                                new ProjectRequest(SecurityOverride.SessionIdentifier, args.Project)));
                        server.WaitForExit(
                            new ProjectRequest(SecurityOverride.SessionIdentifier, args.Project));
                    }
                }
            }
        }
 /// <summary>
 /// Generates a <see cref="ICruiseServer"/> instance.
 /// </summary>
 /// <param name="remote">A flag indicating whether it should be a local or remote instance.</param>
 /// <param name="configFile">The configuration file to</param>
 /// <returns>
 /// The new <see cref="ICruiseServer"/> instance.
 /// </returns>
 public ICruiseServer Create(bool remote, string configFile)
 {
     this.ServerInstance = (remote)
         ? this.CreateRemote(configFile)
         : this.CreateLocal(configFile);
     return(this.ServerInstance);
 }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteCruiseServer" /> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="remotingConfigurationFile">The remoting configuration file.</param>
        /// <param name="disableRemoting">The disable remoting.</param>
        /// <remarks></remarks>
        public RemoteCruiseServer(ICruiseServer server, string remotingConfigurationFile, bool disableRemoting)
        {
            // Store the server instance and wire up the events so they are passed on
            this.server = server;
            this.server.AbortBuildProcessed  += (o, e) => { this.FireAbortBuildProcessed(e.ProjectName, e.Data); };
            this.server.AbortBuildReceived   += (o, e) => { this.FireAbortBuildReceived(e.ProjectName, e.Data); };
            this.server.ForceBuildProcessed  += (o, e) => { this.FireForceBuildProcessed(e.ProjectName, e.Data); };
            this.server.ForceBuildReceived   += (o, e) => { this.FireForceBuildReceived(e.ProjectName, e.Data); };
            this.server.IntegrationCompleted += (o, e) => { this.FireIntegrationCompleted(e.Request, e.ProjectName, e.Status); };
            this.server.IntegrationStarted   += (o, e) => { this.FireIntegrationStarted(e.Request, e.ProjectName); };
            this.server.ProjectStarted       += (o, e) => { this.FireProjectStarted(e.ProjectName); };
            this.server.ProjectStarting      += (o, e) => { this.FireProjectStarting(e.ProjectName); };
            this.server.ProjectStopped       += (o, e) => { this.FireProjectStopped(e.ProjectName); };
            this.server.ProjectStopping      += (o, e) => { this.FireProjectStopping(e.ProjectName); };
            this.server.SendMessageProcessed += (o, e) => { this.FireSendMessageProcessed(e.ProjectName, e.Data); };
            this.server.SendMessageReceived  += (o, e) => { this.FireSendMessageReceived(e.ProjectName, e.Data); };

            this.disableRemoting = disableRemoting;
            if (!disableRemoting)
            {
                RemotingConfiguration.Configure(remotingConfigurationFile, false);
                RegisterManagerForRemoting();
                RegisterServerClientForRemoting();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteCruiseServer" /> class.	
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="remotingConfigurationFile">The remoting configuration file.</param>
        /// <param name="disableRemoting">The disable remoting.</param>
        /// <remarks></remarks>
        public RemoteCruiseServer(ICruiseServer server, string remotingConfigurationFile, bool disableRemoting)
        {
            // Store the server instance and wire up the events so they are passed on
            this.server = server;
            this.server.AbortBuildProcessed += (o, e) => { this.FireAbortBuildProcessed(e.ProjectName, e.Data); };
            this.server.AbortBuildReceived += (o, e) => { this.FireAbortBuildReceived(e.ProjectName, e.Data); };
            this.server.ForceBuildProcessed += (o, e) => { this.FireForceBuildProcessed(e.ProjectName, e.Data); };
            this.server.ForceBuildReceived += (o, e) => { this.FireForceBuildReceived(e.ProjectName, e.Data); };
            this.server.IntegrationCompleted += (o, e) => { this.FireIntegrationCompleted(e.Request, e.ProjectName, e.Status); };
            this.server.IntegrationStarted += (o, e) => { this.FireIntegrationStarted(e.Request, e.ProjectName); };
            this.server.ProjectStarted += (o, e) => { this.FireProjectStarted(e.ProjectName); };
            this.server.ProjectStarting += (o, e) => { this.FireProjectStarting(e.ProjectName); };
            this.server.ProjectStopped += (o, e) => { this.FireProjectStopped(e.ProjectName); };
            this.server.ProjectStopping += (o, e) => { this.FireProjectStopping(e.ProjectName); };
            this.server.SendMessageProcessed += (o, e) => { this.FireSendMessageProcessed(e.ProjectName, e.Data); };
            this.server.SendMessageReceived += (o, e) => { this.FireSendMessageReceived(e.ProjectName, e.Data); };

            this.disableRemoting = disableRemoting;
            if (!disableRemoting)
            {
                RemotingConfiguration.Configure(remotingConfigurationFile, false);
                RegisterManagerForRemoting();
                RegisterServerClientForRemoting();
            }
        }
 /// <summary>
 /// Generates a <see cref="ICruiseServer"/> instance.
 /// </summary>
 /// <param name="remote">A flag indicating whether it should be a local or remote instance.</param>
 /// <param name="configFile">The configuration file to</param>
 /// <returns>
 /// The new <see cref="ICruiseServer"/> instance.
 /// </returns>
 public ICruiseServer Create(bool remote, string configFile)
 {
     this.ServerInstance = (remote)
         ? this.CreateRemote(configFile)
         : this.CreateLocal(configFile);
     return this.ServerInstance;
 }
Esempio n. 9
0
        public void Initialise(ICruiseServer server, 
            ExtensionConfiguration extensionConfig)
        {
            var projectsElement = extensionConfig.Items
                .SingleOrDefault(n => n.Name == "allowedProjects");
            if (projectsElement != null)
            {
                this.maxCount = int.Parse(
                    projectsElement.InnerText) - 1;
            }

            this.server = server;
            this.server.ProjectStarting += (o, e) =>
            {
                if (this.count >= this.maxCount)
                {
                    e.Cancel = true;
                }
                else
                {
                    this.count++;
                }
            };
            this.server.ProjectStopped += (o, e) =>
            {
                this.count--;
            };
            Console.WriteLine("Initialise");
        }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="extensionConfig"></param>
        /// <param name="server">The server that this extension is for.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            var counters = this.PerformanceCounters ?? new DefaultPerformanceCounters();
            counters.EnsureCategoryExists(
                CategoryName,
                "Performance counters for CruiseControl.NET",
                new CounterCreationData(NumberCompletedCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                new CounterCreationData(NumberFailedCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                new CounterCreationData(AverageTimeCounter, string.Empty, PerformanceCounterType.AverageTimer32),
                new CounterCreationData(NumberTotalCounter, string.Empty, PerformanceCounterType.AverageBase));

            // Retrieve the counters
            Log.Debug("Initialising performance monitoring - integration requests");
            var stopwatches = new Dictionary<string, Stopwatch>();

            server.IntegrationStarted += (o, e) =>
            {
                Log.Debug(
                    string.Format(CultureInfo.CurrentCulture,"Starting stopwatch for '{0}'", e.ProjectName));

                // Start a stopwatch for the project
                if (stopwatches.ContainsKey(e.ProjectName))
                {
                    stopwatches[e.ProjectName].Reset();
                }
                else
                {
                    var stopwatch = new Stopwatch();
                    stopwatches.Add(e.ProjectName, stopwatch);
                    stopwatch.Start();
                }
            };

            server.IntegrationCompleted += (o, e) =>
            {
                Log.Debug(
                    string.Format(CultureInfo.CurrentCulture,"Performance logging for '{0}'", e.ProjectName));

                // Stop the stopwatch and record the elapsed time
                if (stopwatches.ContainsKey(e.ProjectName))
                {
                    var stopwatch = stopwatches[e.ProjectName];
                    stopwatch.Stop();
                    stopwatches.Remove(e.ProjectName);
                    counters.IncrementCounter(CategoryName, NumberTotalCounter);
                    counters.IncrementCounter(CategoryName, AverageTimeCounter, stopwatch.ElapsedMilliseconds);
                }

                // Record the result
                if (e.Status == IntegrationStatus.Success)
                {
                    counters.IncrementCounter(CategoryName, NumberCompletedCounter);
                }
                else
                {
                    counters.IncrementCounter(CategoryName, NumberFailedCounter);
                }
            };
        }
        /// <summary>
        /// Initialises a new instance of this implementation.
        /// </summary>
        /// <param name="server">The associated server.</param>
        public CruiseControlImplementation(ICruiseServer server)
        {
            // Validate the input parameters
            if (server == null) throw new ArgumentNullException("server");

            // Store the parameters that we need for later
            cruiseServer = server;
        }
Esempio n. 12
0
        public void CreateRemoteCruiseServer()
        {
            mockArgs.ExpectAndReturn("IsRemote", true);

            ICruiseServer server = container.CreateServer();

            Assert.AreEqual(typeof(RemoteCruiseServer), server.GetType());
        }
Esempio n. 13
0
 public ICruiseServer CreateServer(bool isRemote)
 {
     server = new CruiseServer(configuration);
     if (isRemote)
     {
         server = new RemoteCruiseServer(server);
     }
     return server;
 }
 public ICruiseServer CreateServer(bool isRemote)
 {
     server = new CruiseServer(configuration);
     if (isRemote)
     {
         server = new RemoteCruiseServer(server);
     }
     return(server);
 }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="extensionConfig"></param>
        /// <param name="server">The server that this extension is for.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            foreach (XmlElement itemEl in extensionConfig.Items)
            {
                if (itemEl.Name == "limit") numberOfRequestsAllowed = Convert.ToInt32(itemEl.InnerText);
            }

            server.IntegrationStarted += new EventHandler<IntegrationStartedEventArgs>(server_IntegrationStarted);
            server.IntegrationCompleted += new EventHandler<IntegrationCompletedEventArgs>(server_IntegrationCompleted);
        }
Esempio n. 16
0
        /// <summary>
        /// Initialises a new instance of this implementation.
        /// </summary>
        /// <param name="server">The associated server.</param>
        public CruiseControlImplementation(ICruiseServer server)
        {
            // Validate the input parameters
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // Store the parameters that we need for later
            cruiseServer = server;
        }
        /// <summary>
        /// Initialises the service host to use.
        /// </summary>
        /// <param name="server">The CruiseServer that is initialising this extension.</param>
        /// <param name="extensionConfig">The configuration for the extension.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            // Validate the input parameters
            if (server == null) throw new ArgumentNullException("server");

            // Store the parameters that we need for later
            cruiseServer = server;

            // Create a new service host
            wcfServiceHost = new ServiceHost(new CruiseControlImplementation(cruiseServer));
        }
        public void ProcessMessageCorrectlyHandlesAnUnknownMessage()
        {
            // Initialises the mocks
            ICruiseServer server = mocks.DynamicMock<ICruiseServer>();
            mocks.ReplayAll();

            // Run the actual test
            var manager = new ThoughtWorks.CruiseControl.Core.CruiseServerClient(server);
            string responseText = manager.ProcessMessage("ForceBuild", "<garbage><data/></garbage>");
            Response response = ConvertXmlToResponse(responseText);
            Assert.AreEqual(ResponseResult.Failure, response.Result, "Result is unexpected");
        }
        /// <summary>
        /// Initialise a new <see cref="CruiseServerClient"/>.
        /// </summary>
        /// <param name="cruiseServer"></param>
        public CruiseServerClient(ICruiseServer cruiseServer)
        {
            this.cruiseServer = cruiseServer;

            // Retrieve any associated channel security
            var server = cruiseServer as CruiseServer;
            if ((server != null) &&
                (server.SecurityManager != null))
            {
                channelSecurity = server.SecurityManager.Channel;
            }
        }
        /// <summary>
        /// Initialise a new <see cref="CruiseServerClient"/>.
        /// </summary>
        /// <param name="cruiseServer"></param>
        public CruiseServerClient(ICruiseServer cruiseServer)
        {
            this.cruiseServer = cruiseServer;

            // Retrieve any associated channel security
            var server = cruiseServer as CruiseServer;

            if ((server != null) &&
                (server.SecurityManager != null))
            {
                channelSecurity = server.SecurityManager.Channel;
            }
        }
        /// <summary>
        /// Initialises the service host to use.
        /// </summary>
        /// <param name="server">The CruiseServer that is initialising this extension.</param>
        /// <param name="extensionConfig">The configuration for the extension.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            // Validate the input parameters
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // Store the parameters that we need for later
            cruiseServer = server;

            // Create a new service host
            wcfServiceHost = new ServiceHost(new CruiseControlImplementation(cruiseServer));
        }
        public void ProcessMessageCorrectlyHandlesAnUnknownAction()
        {
            // Setup the messages
            ProjectRequest request = new ProjectRequest("123-45", "A test project");

            // Initialises the mocks
            ICruiseServer server = mocks.DynamicMock<ICruiseServer>();
            mocks.ReplayAll();

            // Run the actual test
            var manager = new ThoughtWorks.CruiseControl.Core.CruiseServerClient(server);
            string responseText = manager.ProcessMessage("UnknownAction", request.ToString());
            Response response = ConvertXmlToResponse(responseText);
            Assert.AreEqual(ResponseResult.Failure, response.Result, "Result is unexpected");
        }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="extensionConfig"></param>
        /// <param name="server">The server that this extension is for.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            foreach (var itemEl in extensionConfig.Items ?? new XmlElement[0])
            {
                if (itemEl.Name == "limit")
                {
                    this.NumberOfRequestsAllowed = Convert.ToInt32(
                        itemEl.InnerText, 
                        CultureInfo.CurrentCulture);
                }
            }

            server.IntegrationStarted += server_IntegrationStarted;
            server.IntegrationCompleted += server_IntegrationCompleted;
        }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="extensionConfig"></param>
        /// <param name="server">The server that this extension is for.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            foreach (var itemEl in extensionConfig.Items ?? new XmlElement[0])
            {
                if (itemEl.Name == "limit")
                {
                    this.NumberOfRequestsAllowed = Convert.ToInt32(
                        itemEl.InnerText,
                        CultureInfo.CurrentCulture);
                }
            }

            server.IntegrationStarted   += server_IntegrationStarted;
            server.IntegrationCompleted += server_IntegrationCompleted;
        }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="server">The server that this extension is for.</param>
        /// <param name="extensionConfig"></param>
        public virtual void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            else
            {
                server.IntegrationStarted += (o, e) =>
                {
                    // Check all the drives that they have sufficient space
                    var  fileSystem = server.RetrieveService(typeof(IFileSystem)) as IFileSystem ?? new SystemIoFileSystem();
                    bool hasSpace   = true;
                    foreach (var drive in driveSpaces.Keys)
                    {
                        var freeSpace = fileSystem.GetFreeDiskSpace(drive);
                        hasSpace &= (freeSpace >= driveSpaces[drive]);
                    }
                    e.Result = hasSpace ? IntegrationStartedEventArgs.EventResult.Continue
                        : IntegrationStartedEventArgs.EventResult.Cancel;
                    if (!hasSpace)
                    {
                        Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Integration for '{0}' cancelled due to a lack of space.", e.ProjectName));
                    }
                };
            }

            foreach (var element in extensionConfig.Items ?? new XmlElement[0])
            {
                if (element.Name == "drive")
                {
                    if (element.SelectNodes("*").Count > 0)
                    {
                        throw new ArgumentException("Drive definitions cannot contain child elements");
                    }
                    AddDriveSpace(element.GetAttribute("name"), element.GetAttribute("unit"), element.InnerText);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Unknown configuration option: " + element.Name);
                }
            }

            if (driveSpaces.Count == 0)
            {
                throw new ArgumentOutOfRangeException("At least one drive must be defined to monitor");
            }
        }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="server">The server that this extension is for.</param>
        /// <param name="extensionConfig"></param>
        public virtual void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            else
            {
                server.IntegrationStarted += (o, e) =>
                {
                    // Check all the drives that they have sufficient space
                    var fileSystem = server.RetrieveService(typeof(IFileSystem)) as IFileSystem ?? new SystemIoFileSystem();
                    bool hasSpace = true;
                    foreach (var drive in driveSpaces.Keys)
                    {
                        var freeSpace = fileSystem.GetFreeDiskSpace(drive);
                        hasSpace &= (freeSpace >= driveSpaces[drive]);
                    }
                    e.Result = hasSpace ? IntegrationStartedEventArgs.EventResult.Continue 
                        : IntegrationStartedEventArgs.EventResult.Cancel;
                    if (!hasSpace)
                    {
                        Log.Warning(string.Format(System.Globalization.CultureInfo.CurrentCulture,"Integration for '{0}' cancelled due to a lack of space.", e.ProjectName));
                    }
                };
            }

            foreach (var element in extensionConfig.Items ?? new XmlElement[0])
            {
                if (element.Name == "drive")
                {
                    if (element.SelectNodes("*").Count > 0) throw new ArgumentException("Drive definitions cannot contain child elements");
                    AddDriveSpace(element.GetAttribute("name"), element.GetAttribute("unit"), element.InnerText);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Unknown configuration option: " + element.Name);
                }
            }

            if (driveSpaces.Count == 0)
            {
                throw new ArgumentOutOfRangeException("At least one drive must be defined to monitor");
            }
        }
        public void ProcessMessageCorrectlyHandlesAValidMessage()
        {
            // Setup the messages
            ProjectRequest request = new ProjectRequest("123-45", "A test project");
            Response response = new Response(request);
            response.Result = ResponseResult.Success;

            // Initialises the mocks
            ICruiseServer server = mocks.DynamicMock<ICruiseServer>();
            Expect.Call(server.ForceBuild(request)).Return(response);
            mocks.ReplayAll();

            // Run the actual test
            var manager = new ThoughtWorks.CruiseControl.Core.CruiseServerClient(server);
            string responseText = manager.ProcessMessage("ForceBuild", request.ToString());
            Assert.AreEqual(response.ToString(), responseText);
            mocks.VerifyAll();
        }
Esempio n. 28
0
        private void LaunchServer()
        {
            using (ConsoleEventHandler handler = new ConsoleEventHandler())
            {
                handler.OnConsoleEvent += new EventHandler(HandleControlEvent);

                using (server = _serverFactory.Create(_parser.UseRemoting, _parser.ConfigFile))
                {
                    if (_parser.Project == null)
                    {
                        server.Start();
                        server.WaitForExit();
                    }
                    else
                    {
                        server.ForceBuild(_parser.Project, null);
                        server.WaitForExit(_parser.Project);
                    }
                }
            }
        }
Esempio n. 29
0
        private void LaunchServer()
        {
            using (ConsoleEventHandler handler = new ConsoleEventHandler())
            {
                handler.OnConsoleEvent += new EventHandler(HandleControlEvent);

                using (server = _serverFactory.Create(_parser.UseRemoting, _parser.ConfigFile))
                {
                    if (_parser.Project == null)
                    {
                        server.Start();
                        server.WaitForExit();
                    }
                    else
                    {
                        server.ForceBuild(_parser.Project, null);
                        server.WaitForExit(_parser.Project);
                    }
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CruiseServerHarness"/> class.
        /// </summary>
        /// <param name="projects">The projects.</param>
        public CruiseServerHarness(XmlDocument configuration, params string[] projects)
        {
            // Initialise the default values
            this.TimeoutLength = new TimeSpan(0, 5, 0);

            // Initialise the configuration file (this needs to be in the physical directory since CC.NET reads from the directory)
            var workingFolder = Environment.CurrentDirectory;

            this.configFile = Path.Combine(workingFolder, "ScenarioTests.xml");
            configuration.Save(configFile);

            // Initialise the projects (state files, build folders, etc.)
            this.projects     = new List <string>(projects);
            this.stateFiles   = projects.Select(p => Path.Combine(workingFolder, p + ".state")).ToArray();
            this.buildFolders = projects.Select(p => Path.Combine(workingFolder, Path.Combine("ScenarioTests", p))).ToArray();

            // Initialise the server instance
            this.factory = new CruiseServerFactory();
            this.server  = this.factory.Create(true, this.configFile);

            // Initialise the events
            this.completionEvents = new ManualResetEvent[projects.Length];
            for (var loop = 0; loop < this.completionEvents.Length; loop++)
            {
                this.completionEvents[loop] = new ManualResetEvent(false);
            }

            // Handle integration completed
            this.server.IntegrationCompleted += (o, e) =>
            {
                if (this.IntegrationCompleted != null)
                {
                    this.IntegrationCompleted(o, e);
                }

                // Do this last - this ensures that any processing in the event handler has completed (otherwise strange errors can occur due to timing issues)
                this.FindCompletionEvent(e.ProjectName).Set();
            };
        }
Esempio n. 31
0
        public RemoteCruiseServer(ICruiseServer server, string configFile)
        {
            _self   = this;
            _server = server;
            RegisterForRemoting(configFile);

            XmlDocument document = new XmlDocument();

            document.Load(configFile); XPathNavigator Navigator = document.CreateNavigator();
            string RestUri = Navigator.SelectSingleNode("/cruisecontrol/@restUri").ToString();

            if (string.IsNullOrEmpty(RestUri))
            {
                throw new InvalidProgramException(@"Please set the attribute ""restUri"" on the root node ""cruisecontrol"" in the ccnet project file.");
            }

            Uri uri = new Uri(RestUri);

            Host = new WebServiceHost(typeof(CIFactoryServer), uri);

            Host.AddServiceEndpoint(typeof(ICIFactoryServer), new WebHttpBinding(), uri);
            Host.Open();
        }
Esempio n. 32
0
 public ConsoleContainer(string configFile, bool isRemote)
 {
     configuration = CreateConfiguration(configFile);
     server = CreateServer(isRemote);
 }
 public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
 {
     HasInitialised = true;
 }
        /// <summary>
        /// Generates a local <see cref="ICruiseServer"/> instance.
        /// </summary>
        /// <param name="configFile">The configuration file to use.</param>
        /// <returns>
        /// The new <see cref="ICruiseServer"/> instance.
        /// </returns>
        private ICruiseServer CreateLocal(string configFile)
        {
            var stateManager = new XmlProjectStateManager();
            var configuration = ConfigurationManager.GetSection("cruiseServer") as ServerConfiguration;
            List<ExtensionConfiguration> extensionList = null;
            if (configuration != null)
            {
                extensionList = configuration.Extensions;
            }

            PathUtils.ConfigFileLocation = Path.IsPathRooted(configFile)
                                               ? configFile
                                               : Path.Combine(Environment.CurrentDirectory, configFile);
            var server = new CruiseServer(
                NewConfigurationService(configFile),
                new ProjectIntegratorListFactory(),
                new NetReflectorProjectSerializer(),
                stateManager,
                new SystemIoFileSystem(),
                new ExecutionEnvironment(),
                extensionList);
            server.InitialiseServices();
            this.ServerInstance = server;
            return server;
        }
Esempio n. 35
0
        private void LaunchServer()
        {
            using (ConsoleEventHandler handler = new ConsoleEventHandler())
            {
                handler.OnConsoleEvent += new EventHandler(HandleControlEvent);

                using (server = serverFactory.Create(args.UseRemoting, args.ConfigFile))
                {
                    if (args.Project == null)
                    {
                        server.Start();
                        server.WaitForExit();
                    }
                    else
                    {
                        // Force the build
                        ValidateResponse(
                            server.ForceBuild(
                                new ProjectRequest(null, args.Project)));

                        // Tell the server to stop as soon as the build has finished and then wait for it
                        ValidateResponse(
                            server.Stop(
                                new ProjectRequest(null, args.Project)));
                        server.WaitForExit(
                            new ProjectRequest(null, args.Project));
                    }
                }
            }
        }
        /// <summary>
        /// Initialises the extension.
        /// </summary>
        /// <param name="extensionConfig"></param>
        /// <param name="server">The server that this extension is for.</param>
        public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
        {
            if (!PerformanceCounterCategory.Exists("CruiseControl.NET"))
            {
                Log.Info("Initialising new performance counters for integration requests");
                var collection = new CounterCreationDataCollection();

                // Number of integrations completed counter
                var numberOfCompletedIntegrations = new CounterCreationData();
                numberOfCompletedIntegrations.CounterType = PerformanceCounterType.NumberOfItems32;
                numberOfCompletedIntegrations.CounterName = "Number of Completed Integrations";
                collection.Add(numberOfCompletedIntegrations);

                // Number of integrations failed counter
                var numberOfFailedIntegrations = new CounterCreationData();
                numberOfFailedIntegrations.CounterType = PerformanceCounterType.NumberOfItems32;
                numberOfFailedIntegrations.CounterName = "Number of Failed Integrations";
                collection.Add(numberOfFailedIntegrations);

                // Integration time counter
                var integrationElapsedTime = new CounterCreationData();
                integrationElapsedTime.CounterType = PerformanceCounterType.AverageTimer32;
                integrationElapsedTime.CounterName = "Integration Time";
                collection.Add(integrationElapsedTime);

                // Integration count counter
                var averageIntegrations = new CounterCreationData();
                averageIntegrations.CounterType = PerformanceCounterType.AverageBase;
                averageIntegrations.CounterName = "Average number of integrations";
                collection.Add(averageIntegrations);

                // Create the category
                PerformanceCounterCategory.Create("CruiseControl.NET",
                    "Performance counters for CruiseControl.NET",
                    collection);
            }

            // Retrieve the counters
            Log.Debug("Initialising performance monitoring - integration requests");
            var numberOfCompletedIntegrationsCounter = new PerformanceCounter("CruiseControl.NET", "Number of Completed Integrations", false);
            var numberOfFailedIntegrationsCounter = new PerformanceCounter("CruiseControl.NET", "Number of Failed Integrations", false);
            var integrationElapsedTimeCounter = new PerformanceCounter("CruiseControl.NET", "Integration Time", false);
            var averageIntegrationsCounter = new PerformanceCounter("CruiseControl.NET", "Average number of integrations", false);
            var stopwatches = new Dictionary<string, Stopwatch>();

            server.IntegrationStarted += (o, e) =>
            {
                Log.Debug(string.Format("Starting stopwatch for '{0}'", e.ProjectName));

                // Start a stopwatch for the project
                if (stopwatches.ContainsKey(e.ProjectName))
                {
                    stopwatches[e.ProjectName].Reset();
                }
                else
                {
                    var stopwatch = new Stopwatch();
                    stopwatches.Add(e.ProjectName, stopwatch);
                    stopwatch.Start();
                }
            };
            server.IntegrationCompleted += (o, e) =>
            {
                Log.Debug(string.Format("Performance logging for '{0}'", e.ProjectName));

                // Stop the stopwatch and record the elapsed time
                if (stopwatches.ContainsKey(e.ProjectName))
                {
                    var stopwatch = stopwatches[e.ProjectName];
                    stopwatch.Stop();
                    stopwatches.Remove(e.ProjectName);
                    averageIntegrationsCounter.Increment();
                    integrationElapsedTimeCounter.IncrementBy(stopwatch.ElapsedTicks);
                }

                // Record the result
                if (e.Status == IntegrationStatus.Success)
                {
                    numberOfCompletedIntegrationsCounter.Increment();
                }
                else
                {
                    numberOfFailedIntegrationsCounter.Increment();
                }
            };
        }
Esempio n. 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteCruiseServer" /> class.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="remotingConfigurationFile">The remoting configuration file.</param>
 /// <remarks></remarks>
 public RemoteCruiseServer(ICruiseServer server, string remotingConfigurationFile)
     : this(server, remotingConfigurationFile, false)
 {
 }
Esempio n. 38
0
 public CruiseManager(ICruiseServer cruiseServer)
 {
     this.cruiseServer = cruiseServer;
 }
Esempio n. 39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 public BuildController(ICruiseServer cruiseServer)
     : base(cruiseServer)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 public ServerController(ICruiseServer cruiseServer)
     : base(cruiseServer)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 public ProjectController(ICruiseServer cruiseServer)
     : base(cruiseServer)
 {
 }
 public void Initialise(ICruiseServer server, ExtensionConfiguration extensionConfig)
 {
     HasInitialised = true;
 }
Esempio n. 43
0
 private void CreateAndStartCruiseServer()
 {
     server = new CruiseServerFactory().Create(UseRemoting(), ConfigFilename);
     server.Start();
 }
Esempio n. 44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 public ProjectController(ICruiseServer cruiseServer)
     : base(cruiseServer)
 {
 }
 public ConsoleContainer(string configFile, bool isRemote)
 {
     configuration = CreateConfiguration(configFile);
     server        = CreateServer(isRemote);
 }
Esempio n. 46
0
 public RemoteCruiseServer(ICruiseServer server, string remotingConfigurationFile)
 {
     _server = server;
     RemotingConfiguration.Configure(remotingConfigurationFile);
     RegisterForRemoting();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 protected ApiControllerBase(ICruiseServer cruiseServer)
 {
     this.cruiseServer = cruiseServer;
 }
Esempio n. 48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 public ServerController(ICruiseServer cruiseServer)
     : base(cruiseServer)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 protected ApiControllerBase(ICruiseServer cruiseServer)
 {
     this.cruiseServer = cruiseServer;
 }
Esempio n. 50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectController" /> class.
 /// </summary>
 /// <param name="cruiseServer">The cruise server.</param>
 public BuildController(ICruiseServer cruiseServer)
     : base(cruiseServer)
 {
 }
Esempio n. 51
0
 private void CreateAndStartCruiseServer()
 {
     server = new CruiseServerFactory().Create(UseRemoting(), ConfigFilename);
     server.Start();
 }
Esempio n. 52
0
 public void Initialise(ICruiseServer server,
                        ExtensionConfiguration extensionConfig)
 {
     this.server = server;
     this.server.SendMessageReceived += SendMessageReceived;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteCruiseServer" /> class.	
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="remotingConfigurationFile">The remoting configuration file.</param>
 /// <remarks></remarks>
 public RemoteCruiseServer(ICruiseServer server, string remotingConfigurationFile)
     : this(server, remotingConfigurationFile, false)
 {
 }
Esempio n. 54
0
 public CruiseManager(ICruiseServer cruiseServer)
 {
     this.cruiseServer = cruiseServer;
 }
Esempio n. 55
0
 public RemoteCruiseServer(ICruiseServer server, string remotingConfigurationFile)
 {
     _server = server;
     RemotingConfiguration.Configure(remotingConfigurationFile);
     RegisterForRemoting();
 }