Ejemplo n.º 1
0
        bool TestsAreAlive()
        {
            foreach (TestConf test in mTestGroup.Tests)
            {
                if (test.Machine.StartsWith(AGENT_KEY))
                {
                    test.Machine = mTestGroup.Agents[int.Parse(test.Machine.Substring(AGENT_KEY.Length))];
                }

                IPNUnitAgent agent = GetAgent(test);

                try
                {
                    if (!agent.IsTestRunning(test.Name))
                    {
                        mLog.WarnFormat("Test {0} is not running on {1}", test.Name, test.Machine);
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    mLog.ErrorFormat("Error trying to check if test {0} is running on {1}. {2}",
                                     test.Name, test.Machine, e.Message);
                    mLog.Debug(e.StackTrace);

                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        static IPNUnitAgent GetAgent(TestConf test)
        {
            IPNUnitAgent agent = (IPNUnitAgent)Activator.GetObject(
                typeof(IPNUnitAgent),
                string.Format("tcp://{0}/{1}",
                              test.Machine,
                              Names.PNUnitAgentServiceName));

            return(agent);
        }
Ejemplo n.º 3
0
        private void ThreadProc()
        {
            log.DebugFormat(
                "Thread created for TestGroup {0} with {1} tests",
                mTestGroup.Name, mTestGroup.Tests.Length);

            mFinish          = new ManualResetEvent(false);
            mBarriers        = new Hashtable();
            mBarriersOfTests = new Hashtable();
            init             = false;
            RemotingServices.Marshal(this, mTestGroup.Name);

            mLaunchedTests = 0;
            foreach (TestConf test in mTestGroup.Tests)
            {
                if (test.Machine.StartsWith(agentkey))
                {
                    test.Machine = mTestGroup.Agents[int.Parse(test.Machine.Substring(agentkey.Length))];
                }

                Launcher.Log(string.Format("Starting {0} test {1} on {2}",
                                           mTestGroup.Name, test.Name, test.Machine));
                // contact the machine
                try
                {
                    IPNUnitAgent agent = (IPNUnitAgent)
                                         Activator.GetObject(
                        typeof(IPNUnitAgent),
                        string.Format(
                            "tcp://{0}/{1}",
                            test.Machine,
                            PNUnit.Framework.Names.PNUnitAgentServiceName));

                    lock ( mResultLock )
                    {
                        ++mLaunchedTests;
                    }

                    PNUnitTestInfo testToRun = new PNUnitTestInfo(
                        test.Name, test.Assembly, test.TestToRun,
                        test.TestParams, this, test.StartBarrier,
                        test.EndBarrier, test.WaitBarriers);

                    testToRun.UserValues = mUserValues;

                    agent.RunTest(testToRun);
                }
                catch (Exception e)
                {
                    Launcher.LogError(string.Format(
                                          "An error occurred trying to contact {0} [{1}]",
                                          test.Machine, e.Message));

                    lock ( mResultLock )
                    {
                        --mLaunchedTests;
                    }
                }
            }

            log.DebugFormat("Thread going to wait for results for TestGroup {0}", mTestGroup.Name);
            if (HasToWait())
            {
                // wait for all tests to end
                mFinish.WaitOne();
            }

            log.DebugFormat("Thread going to wait for NotifyResult to finish for TestGroup {0}", mTestGroup.Name);
            Thread.Sleep(500); // wait for the NotifyResult call to finish
            RemotingServices.Disconnect(this);
            log.DebugFormat("Thread going to finish for TestGroup {0}", mTestGroup.Name);
        }