Gallio.Host Issues using Gallio v3.3.458.0

180 views
Skip to first unread message

Dan S

unread,
Jan 3, 2013, 11:34:16 PM1/3/13
to galli...@googlegroups.com
Hi,
I'm building a test execution system based on Gallio to do some internal, scheduled testing. I've got a Windows service that periodically monitors a DB table. When if finds work to do, as determined by a new record in the table, it adds a method call to a ThreadPool that wraps the following code:

        public static TestLauncherResult RunTests(List<string> testSuites, List<string> testMethods, List<string> testFilePatterns, string testResultsDir)
        {
            GallioRuntimeLoader.InitializeRuntime();

            TestLauncher.Logger = new TextLogger(new StreamWriter(new FileStream(@"c:\logroot\GallioTestLauncher.log", FileMode.Append)));
            TestLauncher.EchoResults = true;

            foreach (string s in testFilePatterns)
            {
                TestLauncher.AddFilePattern(s);
            }
            Log.Info(string.Format("Test file patterns for test run: {0}", String.Join("|", testFilePatterns)));

            var filters = testSuites.Select(s => FilterUtils.ParseTestFilter("Type: " + s)).ToList();

            filters.AddRange(testMethods.Select(m => FilterUtils.ParseTestFilter("Member: " + m)));

            Log.Info(string.Format("Filters for test run: {0}", String.Join("|", filters)));

            TestLauncher.TestExecutionOptions.FilterSet = new FilterSet<ITestDescriptor>(new OrFilter<ITestDescriptor>(filters));

            TestLauncherResult result = null;
            try
            {
                Log.Debug("Calling TestLauncher.Run();");
                
                result = TestLauncher.Run();
                Log.Debug(string.Format("TestLauncher.Run() returned: {0}", result.ResultSummary));
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Exception caught when executing the tests: {0}", e.Message));
                throw;
            }
            var reportFormats = new List<string>();
            reportFormats.Add("html");

            string reportName = string.Format("{0:M-d-yyyy_HH_mm_ss}", DateTime.Now);

            var reportFormatOptions = new ReportFormatterOptions();
            IProgressMonitor progressMonitor = NullProgressMonitor.CreateInstance();

            if (result != null)
            {
                result.GenerateReports(testResultsDir, reportName,
                                       ReportArchive.Normal, reportFormats, reportFormatOptions,
                                       RuntimeAccessor.ServiceLocator.Resolve<IReportManager>(), NullProgressMonitor.CreateInstance());
            }// if (result != null)
            return result;
        }// public static TestLauncherResult RunTests(List<string> testSuites, List<string> testMethods, List<string> testFilePatterns, string testResultsDir)


This code works perfectly when I run it on my dev box. It runs whatever test suites and/or methods I pass into it, and generates the appropriate reports.

However, I'm seeing some odd behavior when I run it on our test server. Here's a description of the odd-ness:

  • In the GallioTestLauncher.log file, the only entry that is written is "Start time: 7:39 PM". This implies that the Gallio.Host is not initializing correctly. When I run the code on my Dev box, I get a many more log entries in this file, including the line "Host started at ". Again, it seems like the Host task is not started correctly.
  • This line (from the above method) 'result = TestLauncher.Run();' never returns. It just seems to get swallowed.
  • There is a config file that gets written to my code's 'bin' directory. It seems to be the Gallio.exe.config file, but I'm not sure. It's named with what appears to be a guid, such as: ''.7bd49d538ecf2e1e.tmp.config"
Here's an example of the command line that Gallio.Host.exe is being invoked with, as taken from the Winddows Task Manager:
"C:\Program Files\Gallio\bin\Gallio.Host.exe" /ipc-port:IsolatedProcessHost.89518a08f802b1af /timeout:120 /owner-process:4984 /application-base-directory:"C:\src\_Release_Branches\qa_automation\qa_automation\Apps\Services\TAAG.SchedulingService\bin\Debug" /configuration-file:"C:\src\_Release_Branches\qa_automation\qa_automation\Apps\Services\TAAG.SchedulingService\bin\Debug\fd4fe11402563b66.tmp.config" /severity-prefix

I've tried to attach my debugger to Gallio.Host hoping to catch an exception, but I am always too late.

Here are my questions:
1. What would cause this not to work on some servers, but work perfectly on my Dev box?

2. How can I invoke Gallio.Host via the TestLauncher object such that the debug statements will print in my Gallio logger object?

3. Am I better off constructing a call to Gallio.Echo.exe and capturing the result of that program?

Thanks in advance,
Dan S

Dan S

unread,
Jan 7, 2013, 1:44:07 PM1/7/13
to galli...@googlegroups.com
I've made some progress on this, but the issue is not yet fully solved. I moved the invocation of the method below FROM within the ThreadPool.QueueUserWorkerItem. So now this code executes in the same thread as that which watches the DB for work to do.

In addition, I've upgraded to the latest Gallio build. The host now appears to start, but there seems to be an issue communicating with Gallio.Host via IPC. Here's what the TestLauncher.log has as of now:



Start time: 10:30 AM
Host started at 1/7/2013 10:30:45 AM.
Running under CLR v4.0.30319 runtime.
Listening for connections on IPC port: 'IsolatedProcessHost.2606decec47c2847'
Watchdog timer expired!
Host stopped at 1/7/2013 10:32:46 AM.
Could not send Ping message to the remote host service.
  Gallio.Runtime.Hosting.HostException: The remote host service threw an exception or could not be reached. ---> System.Runtime.Remoting.RemotingException: Failed to write to an IPC Port: The pipe is being closed.


Server stack trace: 
   at System.Runtime.Remoting.Channels.Ipc.IpcPort.Write(Byte[] data, Int32 offset, Int32 size)
   at System.Runtime.Remoting.Channels.ChunkedMemoryStream.WriteTo(Stream stream)
   at System.Runtime.Remoting.Channels.Ipc.IpcClientHandler.SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
   at System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Gallio.Runtime.Hosting.IHostService.Ping()
   at Gallio.Runtime.Hosting.RemoteHost.ProxyHostService.PingImpl() in c:\Server\Projects\MbUnit v3\Work\src\Gallio\Gallio\Runtime\Hosting\RemoteHost.cs:line 193
   --- End of inner exception stack trace ---
   at Gallio.Runtime.Hosting.RemoteHost.ProxyHostService.PingImpl() in c:\Server\Projects\MbUnit v3\Work\src\Gallio\Gallio\Runtime\Hosting\RemoteHost.cs:line 197
   at Gallio.Runtime.Hosting.RemoteHost.PingTimerElapsed(Object state) in c:\Server\Projects\MbUnit v3\Work\src\Gallio\Gallio\Runtime\Hosting\RemoteHost.cs:line 142


Thank you in advance for any help.

Cheers,
Dan S.

sandeep kumar

unread,
Apr 5, 2013, 7:05:26 AM4/5/13
to galli...@googlegroups.com
Thanks a lot, this code works for me
Reply all
Reply to author
Forward
0 new messages