Daily Usage Issues

Console tool, -GridServerReferencesForSolution results in InvalidCastException

Started by GreenMoose on 7,692 views

[v3.17.0.2]

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

 &"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:

[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
Nothing? :)
FWIW, I also get same error if using multiple nodes in the parameter like "node>encryptedText123=;node2>encryptedText123=" .
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.
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.

Edited

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.
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.
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
-GridServerReferencesForSolution ""

and
-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.

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.


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.
[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.

-GridServerReferencesForSolution "dontwantgridnodes>123=" -GridServerReferencesForComputer "dontwantgridnodes>123="
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.

Post a reply

Log in to reply.