Integration using StatLight to TeamCity

May 15, 2010 at 12:33 PM
Edited May 15, 2010 at 12:37 PM

Hello,

I've read the blog http://www.keith-woods.com/Blog/post/Silverlight-Unit-Test-and-Continuous-Integration-StatLight.aspx

Could you please write the exact steps to configure TeamCity to use StatLight.

On the "Build Runner" page what should I write to launch unit tests?

    MSTest settings?

TIA

Coordinator
May 15, 2010 at 5:08 PM

I just posted a little documentation/how to.

http://statlight.codeplex.com/wikipage?title=TeamCity%20Integration

Let me know if this helps.

May 16, 2010 at 6:11 PM
Edited May 18, 2010 at 12:45 PM

Yes thank you it worked in XP, but in 2008R2 it gives an error:

[14:29:11]: ExampleApp\Bin\Debug\ExampleApp.xap
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] Unhandled Exception: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] at System.Windows.Forms.Form.ShowDialog()
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] at StatLight.Core.WebBrowser.BrowserFormHost.<Start>b__2()
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] at System.Threading.ThreadHelper.ThreadStart()
[14:29:26]: [ExampleApp\Bin\Debug\ExampleApp.xap] Process exited with code -532459699

I guess it depends on settings of Windows 2008R2 what should I change?

May 18, 2010 at 3:25 PM
Edited May 18, 2010 at 3:26 PM
Found workaround: 1. Stop services TeamCity WebServer and TeamCity Build Angent Service 2. Go to <TeamCity>\bin\ 3. Launch runAll.bat start
Coordinator
May 18, 2010 at 3:47 PM

The reason your runAll.bat probably worked is because it is now running the services under an account that can run interactively with the desktop.

If you go to the TeamCity services and check the "Log On" tab, you will have to make the service run as the "System" account since that's the only one that will allow you to check the "Allow service to interact with desktop" option.

So far - I haven't found a better way around this... (I know it's not ideal)

Hope this helps.

Jul 6, 2010 at 6:03 PM
staxmanade wrote:

The reason your runAll.bat probably worked is because it is now running the services under an account that can run interactively with the desktop.

If you go to the TeamCity services and check the "Log On" tab, you will have to make the service run as the "System" account since that's the only one that will allow you to check the "Allow service to interact with desktop" option.

So far - I haven't found a better way around this... (I know it's not ideal)

Hope this helps.

 I was just wondering if you have found any other way since May?

I am in the situation where I need to run an agent under a specific account. Ideally I would like to continue running it as a service.

Cheers,

John

Coordinator
Jul 7, 2010 at 4:04 AM

johnman

It turns out that I broke this when I attempted to remove an Application.DoEvents in a for loop (which caused a single CPU to max out - untill the test run was done). I replaced the working form.Show with a breaking form.ShowDialog.

In short - keep an eye on the github repository - when you see a commit related to this topic (hopefully with in the next couple days) - you should be able to get latest and build the trunk.

I'll look to create a bug fix release soon as well.

Coordinator
Jul 7, 2010 at 2:28 PM

johnman

I managed to fix the issue last night - github.com/staxmanade/statlight

I'm going to give it some test runs at work and look to create a release maybe this weekend.

If you need it before then - you should be able to run the build-Full-Release-skip-tests.bat - to get a later artifact of StatLight.

Hope this helps.

Coordinator
Jul 7, 2010 at 3:07 PM

Looks like my changes only fix the exception - when run in non interactive mode...

My integration test didn't _fail_ with an exception, however reported zero tests run (and 2 ignored) - I was expecting 2 ignored and over 300 tests total...

I don't think I'll get much time to work on this further till later.

Mind letting me know if you find anything?

Aug 16, 2010 at 8:43 PM

I am seeing a similar error on our build server using Visual Build running as a scheduled task..... 

The build hangs until a configured timeout kills the statlight process; without this timeout, the program hangs until a user actually logs into the system and closes a "Report Problem to Microsoft" dialog informing the non-existant user that statlight has stopped working... it magically appears when I log in as the build service account.

The console output logged after process termination consists of:

StatLight - Version 1.1.3802
Copyright (C) 2009 Jason Jarrett
All Rights Reserved.

Starting Test Run: 8/16/2010 2:17:13 PM

Unhandled Exception: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at StatLight.Core.WebBrowser.BrowserFormHost.<Start>b__2()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

I did try to see what happened with the --teamcity option, and it was almost identical to the above, except it had some extra teamcity markup, presumably to communicate these results.

Any chance that the issues you found with it running under team city are identical to the situation with visual build, and that the same fix would apply?  It sounds from the thread history above that the fix is not quite ready yet (we would like to actually run the unit tests in non-interactive mode, afterall. :) )

Coordinator
Aug 16, 2010 at 9:35 PM
Edited Aug 16, 2010 at 9:39 PM

Unfortunately I don't think there's a fix or a work around at this time (from the StatLight side). The problem is deeper than I think StatLight can solve... And yes the problem is not specifically a TeamCity thing, but an interactive/non-interactive issue. So all services running non-interactive will have the issue.

I haven't tried - but think the following could work for a TeamCity implementation.

You could try to configure your build server to auto-login to the windows console as a domain user. Not going to tell how to do this, as different windows version probably do this differently and I'm not an expert here - just know it's possible.

Then start a TeamCity agent http://confluence.jetbrains.net/display/TCD5/Setting+up+and+Running+Additional+Build+Agents#SettingupandRunningAdditionalBuildAgents-StartingtheBuildAgent

For TFS - I believe you can manually start the build service (just a theory). If you do get this accomplished - would love a blog post or comprehensive set of how-to steps to incorporate with the StatLight documentation for the next guy.

Hope this helps.

Oct 15, 2010 at 11:14 AM

Is there an issue with using the --teamcity parameter with the --ShowTestingBrowserHost parameter? If we run our tests with just --ShowTestingBrowserHost then the tests all run and pass.

However, if I add in the --teamcity parameter, a couple of tests fail with a System.InvalidOperationException: Reference is not a valid visual DependencyObject, which I think is due to the

testing browser not being visible.

Does that make sense, taking into account that the last issue I had with StatLight was of our own making!

Coordinator
Oct 15, 2010 at 6:07 PM

The --teamcity and --ShowTestingBrowserHost flags should be completely independent. Have you looked at the full build log in the case where you say it "passed" - do you notice anything there?

 

What version of the MSTesting framework assembly are you using? I'm assuming you're using v1.2 of StatLight (let me know if you're not).