Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Console tool, -GridServerReferencesForSolution results in InvalidCastException
GreenMoose
#1 Posted : Thursday, June 14, 2018 6:35:55 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
[v3.17.0.2]

I try to execute ncrunch console with a grid node with syntax below:
Code:

&"X:\_tmp\NConsole\NCrunch.exe" Solution.sln /o "X:\_tmp\NCResults" -NCrunchCacheStoragePath "X:\_tmp\NCCache" -WorkspaceBasePath "X:\_tmp\NcWc" /vs "2012" -ConsiderInconclusiveTestsAsPassing True -MaxNumberOfProcessingThreads 3 /TeamCityDisableTestNotRunFailureReporting -GridServerReferencesForSolution "comp.my.domain>encryptedText123=" -TestsToExecuteAutomatically "..."


But I get below error in log:
Code:

[18:44:02][Step 5/7] [Core-8] ERROR (Internal): System.InvalidCastException: Unable to cast object of type 'nCrunch.Core.Configuration.GridServerReference' to type 'nCrunch.Core.Configuration.GridServerReference[]'.
[18:44:02][Step 5/7] [Core-8] at nCrunch.Core.Settings.SettingExtensions.Get[TValueType](NonComponentSetting`1 setting)
[18:44:02][Step 5/7] [Core-8] at nCrunch.Client.Grid.GridServerAddressConfiguration.GetGridServerReferences()
[18:44:02][Step 5/7] [Core-8] at nCrunch.Client.Grid.GridClient. ()
[18:44:02]
[Step 5/7] [Core-8] at nCrunch.Client.Grid.GridClient. (EngineEnabledEvent )


Am I specifying grid node parameter incorrectly?

Thanks
GreenMoose
#2 Posted : Tuesday, June 19, 2018 3:43:29 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
Nothing? :)
FWIW, I also get same error if using multiple nodes in the parameter like "node>encryptedText123=;node2>encryptedText123=" .
Remco
#3 Posted : Tuesday, June 19, 2018 11:09:45 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Sorry! Somehow this request slipped my net.

This particular setting doesn't support injection via the command line. For supplying grid nodes, I recommend using a configuration file instead.
GreenMoose
#4 Posted : Thursday, June 21, 2018 7:11:08 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
Is there a plan to fix this in a foreseeable future?
(It feels awkward having to create a config xml file dynamically just for this setting, in order to support TC build parameters, which also results in another file one needs to take care of cleaning up between builds to avoid undesirable build behavior).

Thanks.

*Edit: Just bumped into same issue that I need CustomEnvironmentVariables as well since grid nodes will not work without it and that is also XML config only, so XML config file is what I will use for now then.
Remco
#5 Posted : Thursday, June 21, 2018 10:41:45 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
The passing of configuration settings via command line has always been intended to be a lightweight approach to configuring the console tool. This is because some of the configuration settings can be quite hard to specify without tricky syntax, making them error prone. It isn't always easy to have the tool behave in a consistent way if the parameters are specified incorrectly. For example, the CustomEnvironmentVariables and grid addresses are actually composite objects that are held in array form, so trying to represent complex types containing arbitrary strings while held in arrays starts to get a bit crazy.

The general idea of the command line options is to give you an easy way to change a setting or two in simple cases, or if you need to inject something into the engine externally. If you're working with fixed parameters or you have a CI working for a big solution, then you most definitely will need to use a config file.
Remco
#6 Posted : Wednesday, August 1, 2018 8:30:06 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
To follow up with this, it's now possible in the just released v3.18 to provide both the CustomEnvironmentVariables and GridServerReferencesForSolution settings via the command line.
1 user thanked Remco for this useful post.
GreenMoose on 8/16/2018(UTC)
GreenMoose
#7 Posted : Friday, September 21, 2018 2:07:36 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
So connecting to a grid node via parameter seems to work :)

But now I have the opposite problem, how do I avoid using grid nodes via command line parameter?
I.e. isn't -GridServerReferencesForSolution meant to override the default values from the global config for the computer? I cannot seem to avoid grid nodes being used if they are set up on the global config for the computer. I tried both
Quote:
-GridServerReferencesForSolution ""

and
Quote:
-GridServerReferencesForSolution "dontwantgridnodes>123="


but still NCrunch connects to a grid node configured in my AppData.../globalconfig.crunch.v3.xml


p.s. You might want to have a better error message for scenario where the input format is invalid, like -GridServerReferencesForSolution "Joe" below :) d.s.
Quote:

E:\Temp\BuildTmp\packages\Gmd.NCrunch.Console.3.20.0.6-dev.20180907T115754\lib\net45\NCrunch.exe E:\dev\...\CsCommon.UnitTest\Cscommon.Unittest\CsCommon.UnitTest.sln /E "TeamCity Bvt NoSqlServer" /TeamCityDisableTestNotRunFailureReporting -LogVerbosity "Low" -GridServerReferencesForSolution "Joe" /O "E:\Temp\BuildTmp\NCrunchConsole\Result" -WorkspaceBasePath "E:\Temp\BuildTmp\NCrunchConsole\WC" -NCrunchCacheStoragePath "E:\Temp\BuildTmp\NCrunchConsole\Cache"
...
NCrunch Console Tool v3.20.0.6
Copyright © 2010-2018 Remco Software Ltd
Usage of this tool is permitted only under the terms described in License.rtf


ERROR: Configuration setting 'GridServerReferencesForSolution' cannot be overridden using the command line. Try specifying it in a configuration file instead.


Remco
#8 Posted : Saturday, September 22, 2018 12:06:37 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
This configuration is a bit of an odd one in that we actually have two instances of it:

GridServerReferencesForSolution
GridServerReferencesForComputer

When creating the list of all servers that should be connected to, the NCrunch client will take values from both of these settings. This means that if you override just one of them, there can still be values coming from the other. Try overriding both using the command line.
1 user thanked Remco for this useful post.
GreenMoose on 9/23/2018(UTC)
GreenMoose
#9 Posted : Tuesday, December 18, 2018 9:34:12 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
[v3.22]
This bit me again when I thought "Oh well I'll just test it locally with ncrunch.exe"... Is there a recommended way to supply an "empty" parameter for these 2 settings, in order to NOT use any grid nodes at all?
I use below but it feels somewhat hacky.
Quote:

-GridServerReferencesForSolution "dontwantgridnodes>123=" -GridServerReferencesForComputer "dontwantgridnodes>123="
Remco
#10 Posted : Tuesday, December 18, 2018 11:18:22 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
I don't think we have a clean way to override those settings with nulls at this point in time. Probably if you set them to an empty string, it'll fail to parse or just assume the override is invalid. I'll make a note to see if we can do something about this.
1 user thanked Remco for this useful post.
GreenMoose on 12/19/2018(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.052 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download