protected override IEnumerable <SynchronizationEntry> MapFromWhiskWork(IEnumerable <WorkItem> workItems)
        {
            var bugs       = workItems.Where(wi => wi.Classes.Contains("cr") && (wi.Id.StartsWith("B") || wi.Id.StartsWith("S") || wi.Id.StartsWith("T")));
            var normalBugs = bugs.Where(wi => !wi.Classes.Contains("cr-review") && !wi.Classes.Contains("cr-test"));

            return(normalBugs.Select(wi => SynchronizationEntry.FromWorkItem(wi)));
        }
Beispiel #2
0
        public void Create(SynchronizationEntry entry)
        {
            var workItem = CreateWorkItem(entry);

            _repository.PostWorkItem(workItem.MoveTo(_beginStep, DateTime.Now));

            _repository.PostWorkItem(workItem);
        }
Beispiel #3
0
        protected static SynchronizationEntry Entry(string id, string status, int?ordinal)
        {
            var entry = new SynchronizationEntry(id, status, new Dictionary <string, string>())
            {
                Ordinal = ordinal
            };

            return(entry);
        }
Beispiel #4
0
        private static WorkItem CreateWorkItem(SynchronizationEntry entry)
        {
            var workItem = WorkItem.New(entry.Id, entry.Status);

            if (entry.Ordinal.HasValue)
            {
                workItem = workItem.UpdateOrdinal(entry.Ordinal.Value);
            }

            return(workItem.UpdateProperties(entry.Properties));
        }
        public void UpdateData(SynchronizationEntry entry)
        {
            var unid = entry.Properties["unid"];

            foreach (var keyValue in entry.Properties)
            {
                if (keyValue.Key == "unid")
                {
                    continue;
                }

                _dominoRepository.UpdateField(unid, keyValue.Key, keyValue.Value);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Setup the CommandManager for a new test pass for a browser on
        /// the given thread
        /// </summary>
        /// <param name="threadId">Server thread handling the tests for the browser</param>
        public static void CreateBrowserQueue(int threadId)
        {
            lock (_syncRoot)
            {
                SynchronizationEntry entry = GetEntry(threadId, false);
                if (entry != null)
                {
                    // Destroy the old queue (which will release anyone waiting
                    // on its synchronization object)
                    DestroyBrowserQueue(threadId);
                }

                entry = new SynchronizationEntry();
                _entries.Add(threadId, entry);
            }
        }
        public IEnumerable <SynchronizationEntry> GetAll()
        {
            DataTable table = _dominoRepository.OpenTable();

            var entries = new List <SynchronizationEntry>();

            foreach (DataRow row in table.Rows)
            {
                SynchronizationEntry entry = _mapper(row);
                if (entry != null)
                {
                    entries.Add(entry);
                }
            }

            return(entries);
        }
Beispiel #8
0
        /// <summary>
        /// Destroy a browser's command queue
        /// </summary>
        /// <param name="threadId">Server thread handling the tests for the browser</param>
        internal static void DestroyBrowserQueue(int threadId)
        {
            lock (_syncRoot)
            {
                SynchronizationEntry entry = GetEntry(threadId);
                lock (entry.SyncRoot)
                {
                    entry.Command = null;
                    entry.Result  = null;

                    // Release anyone waiting to synchronize on the entry
                    Monitor.PulseAll(entry.SyncRoot);

                    _entries.Remove(threadId);
                }
            }
        }
        /// <summary>
        /// Registration method through witch clients show interest in being notified when an object available for them in a queue identified by a given key.
        /// </summary>
        /// <param name="key">Key object</param>
        /// <param name="entry">A SynchronizationEntry object</param>
        public static void Register(string key, SynchronizationEntry entry)
        {
            if ((key == null) || (entry == null))
            {
                throw new ArgumentNullException("None of Regist method argumets can be null.");
            }

            if (entry.SynchronizationObject == null)
            {
                throw new ArgumentNullException("SynchronizationEntry<T>.SynchronizationObject cannot be null.");
            }
            Queue <SynchronizationEntry> queue = GetQueue(key);

            lock (queue)
            {
                queue.Enqueue(entry);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Post the result of the last executed command and wait for the next
        /// command or return no command if
        /// </summary>
        /// <param name="threadId">Server thread handling the tests for the browser</param>
        /// <param name="result">Result of the executing the last command</param>
        /// <returns>Next command to execute (or null if there are no more commands or we timed out while waiting)</returns>
        /// <remarks>
        /// This method works hand in hand with ExecuteCommand. They wait and
        /// signal each other.
        /// </remarks>
        public static BrowserCommand SetResultAndGetNextCommand(int threadId, BrowserInfo result)
        {
            SynchronizationEntry entry = null;

            lock (_syncRoot)
            {
                entry = GetEntry(threadId);
            }

            lock (entry.SyncRoot)
            {
                // Get the next command to execute
                BrowserCommand command = null;
                if (!entry.Started)
                {
                    // If this is the first request, a command has already been queued
                    entry.Started = true;
                    command       = entry.Command;
                }
                else
                {
                    // Update the command that was waiting for its result
                    entry.Result = result;
                    Monitor.Pulse(entry.SyncRoot);

                    // Wait for the next command (only if the last command didn't
                    // signal the end of the test run)
                    if (!entry.Finished && Monitor.Wait(entry.SyncRoot, NextCommandTimeout))
                    {
                        command = entry.Command;
                    }
                }

                entry.Command = null;
                return(command);
            }
        }
        /// <summary>
        /// Offer a object to a given queue
        /// </summary>
        /// <param name="key">Key that identifies the queue.</param>
        /// <param name="value">Value to enqueue</param>
        /// <returns>returs true if the object was accepted (there was a registered client for the queue) or false otherwise.</returns>
        public static bool Offer(string key, T value)
        {
            Queue <SynchronizationEntry> queue = GetQueue(key);
            SynchronizationEntry         entry = null;

            lock (queue)
            {
                if (queue.Count == 0)
                {
                    return(false);
                }
                else
                {
                    entry = Dequeue(queue, key);
                }
            }
            if (entry.StillInterested)
            {
                lock (entry.Values)
                {
                    entry.Values.Add(value);
                }
                lock (entry.SynchronizationObject)
                {
                    Monitor.Pulse(entry.SynchronizationObject);
                }

                if (entry.ReceiveMultiple)
                {
                    // add client again
                    Register(key, entry);
                }
                return(true);
            }
            // Retrieved client wasn't interested. Offer it to another client.
            return(Offer(key, value));
        }
Beispiel #12
0
        /// <summary>
        /// Execute a commmand on the client and wait for its result
        /// </summary>
        /// <param name="threadId">Server thread handling the tests for the browser</param>
        /// <param name="command">Command to execute</param>
        /// <param name="secondsTimeout">Maximum timeout </param>
        /// <returns>Result of executing the command on the client</returns>
        /// <remarks>
        /// This method works hand in hand with SetResultAndGetNextCommand.
        /// They wait and signal each other.
        /// </remarks>
        public static BrowserInfo ExecuteCommand(int threadId, BrowserCommand command, int secondsTimeout)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command", "BrowserCommand cannot be null!");
            }

            SynchronizationEntry entry = null;

            lock (_syncRoot)
            {
                entry = GetEntry(threadId);
            }

            lock (entry.SyncRoot)
            {
                // Set the command and notify anyone waiting for the next command
                // (also setting whether this command marks the end of a test run)
                entry.Command = command;
                if (string.CompareOrdinal(entry.Command.Handler.ClientFunctionName, BrowserCommand.FunctionNames.TestRunFinished) == 0)
                {
                    entry.Finished = true;
                }
                Monitor.Pulse(entry.SyncRoot);

                // Wait for the command's result
                if (!Monitor.Wait(entry.SyncRoot, secondsTimeout * 1000))
                {
                    // Use null if the command timed out
                    entry.Result = null;
                }

                BrowserInfo result = entry.Result;
                return(result);
            }
        }
 public void Delete(SynchronizationEntry entry)
 {
     throw new NotImplementedException();
 }
        public void UpdateStatus(SynchronizationEntry entry)
        {
            var unid = entry.Properties["unid"];

            _dominoRepository.UpdateField(unid, "Status", entry.Status);
        }
Beispiel #15
0
        public void UpdateData(SynchronizationEntry entry)
        {
            var workItem = CreateWorkItem(entry);

            _repository.PostWorkItem(workItem);
        }
Beispiel #16
0
        public void UpdateStatus(SynchronizationEntry entry)
        {
            var workItem = WorkItem.New(entry.Id, entry.Status);

            _repository.PostWorkItem(workItem);
        }
Beispiel #17
0
        public void Delete(SynchronizationEntry entry)
        {
            var workItem = WorkItem.New(entry.Id, entry.Status);

            _repository.DeleteWorkItem(workItem);
        }