GreenMoose;5254 wrote:
But not for the grid node server AFACT? Wouldn't custom env. variables for each server be a quite natural fit for customizing behavior of them? (comparing with e.g. TeamCity and its build parameters options)
It's definitely true that there is more space for additional configuration on the grid node. Something I'm wondering though is which of the two situations below apply in your case -
1. You're trying to set an environment variable for the node that applies to the node when it is used by any user. In this case, wouldn't this be the same as setting an environment variable on the machine itself? (without the need for NCrunch configuration)
2. You need an environment variable that is user-specific. So as a user, I can set an environment variable in my own NCrunch client config, which is then present in any build/test process executed on my behalf, regardless of where it is. In this case, there isn't really an easy way to handle this without a feature added to NCrunch. I would actually consider this to be a feature-gap.
GreenMoose;5254 wrote:
And apart from our own usage of this, wouldn't it be a pretty nice feature in future to have multiple server instances on same machine but run on e.g. different dbs (set via custom settings per server), thus enabling parallel test execution of db integration tests ? :)
The grid node was designed with the intention of existing with one node service instance per machine. I guess it may be technically possible to install the service multiple times under different names, and have these service processes running concurrently. Where this would likely run into trouble is in the stashing of solution snapshots on the node machine. If the node services are all trying to store snapshots in the same place, they'll usually end up trying to share the same snapshots - which would cause some very crazy things to happen. To make this work, you would need to make sure each node service is configured to store snapshots in a different place. I guess the configuration would need to be separate anyway, as they couldn't all listen on the same TCP port :)
In your situation, I would prefer to find a solution that would work with a single node service per machine. This would be much more resource efficient and would probably perform much better from the client-side. It would also be easier to manage. I think the key question here is how best to adjust the test code so that it can make rotational use of different databases.
I suppose you could rig up something that would use the file system to determine which databases were in use. Or perhaps have a database table that identified which database was being used by a particular process. Because the process IDs are unique between test processes, you can use them for processes to register with databases. Where a database is assigned to a process that isn't running anymore (i.e. it's been killed), the registration is considered invalid and any other process can claim the DB.
If your DB is fast to build, you could implement something in the test code that checks a static state flag to indicate whether the database has been constructed under a name that contains the process ID. In this way, you could effectively separate the databases - one for each process.
I doubt that this is an unusual problem, as many people run integration tests over databases and the ability to run these tests in parallel is highly desirable. Perhaps a feature could be introduced to NCrunch that would automatically set a rotational number to each process (to a maximum of the number of test processes loaded at one time), assigning this as an environment variable? I'd like to know what you think.