public AgentRecord(Guid id, Process p, TestAgent a, AgentStatus s)
 {
     this.Id      = id;
     this.Process = p;
     this.Agent   = a;
     this.Status  = s;
 }
        private TestAgent CreateRemoteAgent(RuntimeFramework framework, int waitTime)
        {
            Guid agentId = LaunchAgentProcess(framework);

            log.Debug("Waiting for agent {0} to register", agentId.ToString("B"));

            int  pollTime = 200;
            bool infinite = waitTime == Timeout.Infinite;

            while (infinite || waitTime > 0)
            {
                Thread.Sleep(pollTime);
                if (!infinite)
                {
                    waitTime -= pollTime;
                }
                TestAgent agent = agentData[agentId].Agent;
                if (agent != null)
                {
                    log.Debug("Returning new agent {0}", agentId.ToString("B"));
                    return(agent);
                }
            }

            return(null);
        }
        public void Register(TestAgent agent)
        {
            AgentRecord r = agentData[agent.Id];

            if (r == null)
            {
                throw new ArgumentException(
                          string.Format("Agent {0} is not in the agency database", agent.Id),
                          "agentId");
            }
            r.Agent = agent;
        }
        public void DestroyAgent(TestAgent agent)
        {
            AgentRecord r = agentData[agent.Id];

            if (r != null)
            {
                if (!r.Process.HasExited)
                {
                    r.Agent.Stop();
                }
                agentData[r.Process.Id] = null;
            }
        }
        public override void Dispose()
        {
            // Do this first, because the next step will
            // make the downstream runner inaccessible.
            base.Dispose();

            if (this.agent != null)
            {
                log.Info("Stopping remote agent");
                agent.Stop();
                this.agent = null;
            }
        }
        public override bool Load(TestPackage package)
        {
            if (this.agent == null)
            {
                this.agent = Services.TestAgency.GetAgent(AgentType.ProcessAgent, 5000);
            }

            if (this.TestRunner == null)
            {
                this.TestRunner = agent.CreateRunner(this.runnerID);
            }

            return(base.Load(package));
        }
        public void ReleaseAgent(TestAgent agent)
        {
            AgentRecord r = agentData[agent.Id];

            if (r == null)
            {
                NTrace.Error(string.Format("Unable to release agent {0} - not in database", agent.Id));
            }
            else
            {
                r.Status = AgentStatus.Ready;
                NTrace.Debug("Releasing agent " + agent.Id.ToString());
            }
        }
        public void Dispose()
        {
            if (TestRunner != null)
            {
                this.TestRunner.Unload();
            }

            if (this.agent != null)
            {
                Services.TestAgency.ReleaseAgent(this.agent);
            }

            this.TestRunner = null;
            this.agent      = null;
        }
Exemple #9
0
        public override bool Load(TestPackage package)
        {
            log.Info("Loading " + package.Name);
            Unload();

            RuntimeFramework runtimeFramework = package.Settings["RuntimeFramework"] as RuntimeFramework;

            if (runtimeFramework == null)
            {
                runtimeFramework = RuntimeFramework.CurrentFramework;
            }

            bool enableDebug = package.GetSetting("EnableDebug", false);

            bool loaded = false;

            try
            {
                if (this.agent == null)
                {
                    this.agent = Services.TestAgency.GetAgent(
                        runtimeFramework,
                        20000,
                        enableDebug);
                }

                if (this.agent == null)
                {
                    return(false);
                }

                if (this.TestRunner == null)
                {
                    this.TestRunner = agent.CreateRunner(this.runnerID);
                }

                loaded = base.Load(package);
                return(loaded);
            }
            finally
            {
                // Clean up if the load failed
                if (!loaded)
                {
                    Unload();
                }
            }
        }
Exemple #10
0
        public override void Unload()
        {
            if (Test != null)
            {
                log.Info("Unloading " + Path.GetFileName(Test.TestName.Name));
                this.TestRunner.Unload();
                this.TestRunner = null;
            }

            if (this.agent != null)
            {
                log.Info("Stopping remote agent");
                agent.Stop();
                this.agent = null;
            }
        }
            public AgentRecord this[TestAgent agent]
            {
                get
                {
                    foreach (System.Collections.DictionaryEntry entry in agentData)
                    {
                        AgentRecord r = (AgentRecord)entry.Value;
                        if (r.Agent == agent)
                        {
                            return(r);
                        }
                    }

                    return(null);
                }
            }
Exemple #12
0
        public override void Dispose()
        {
            // Do this first, because the next step will
            // make the downstream runner inaccessible.
            base.Dispose();

            if (this.agent != null)
            {
                log.Info("Stopping remote agent");
                try
                {
                    agent.Stop();
                }
                catch
                {
                    // Ignore any exception
                }
                finally
                {
                    this.agent = null;
                }
            }
        }