Reputation: 100
Currently I have a common database used for component tests in xunit, the problem is that when a build is running on teamcity other builds cannot start as while one build is being run a number of tests are being executed which take quite some time. I need some help of how can I have my current class modified/changed in order to have multiple builds executing in parallel using multiple database instances.
public class DatabaseFixture : IDisposable
{
public TestCluster Cluster { get; }
public IGrainFactory GrainFactory => Cluster?.GrainFactory;
public IClusterClient Client => Cluster?.Client;
private const string _databaseConnection = @"Server=(localdb)\MSSQLLocalDB;Integrated Security=true";
public DatabaseFixture()
{
// Find a valid folder for now
foreach (var folder in _dbFolders)
{
if (!Directory.Exists(folder))
continue;
_databaseRootFolder = folder;
break;
}
Assert.NotNull(_databaseRootFolder);
// Create the test database
CreateDatabase();
CreateConfigDatabase();
// Setup and start the cluster
var builder = new TestClusterBuilder(2);
builder.AddSiloBuilderConfigurator<DbTestSiloBuilderConfigurator>();
var testCluster = builder.Build();
if (testCluster?.Primary == null)
{
testCluster?.Deploy();
}
Cluster = testCluster;
}
// other methods that follow have been removed for keeping question short
}
Upvotes: 1
Views: 232
Reputation: 336
I may be missing something, but in during build you should only run unit tests. And unit tests shouldn't need database connection.
This means one of two things:
Upvotes: 1