Skip to content

Commit ef324a7

Browse files
committed
Unique database names.
1 parent 288b324 commit ef324a7

3 files changed

Lines changed: 32 additions & 34 deletions

File tree

Provider/src/FirebirdSql.Data.UnitTests/FbServicesTests.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void BackupRestoreTest_BackupPart(Guid id)
7777
{
7878
FbBackup backupSvc = new FbBackup();
7979

80-
backupSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
80+
backupSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
8181
backupSvc.Options = FbBackupFlags.IgnoreLimbo;
8282
backupSvc.BackupFiles.Add(new FbBackupFile(CreateBackupFilename(id), 2048));
8383
backupSvc.Verbose = true;
@@ -90,7 +90,7 @@ void BackupRestoreTest_RestorePart(Guid id)
9090
{
9191
FbRestore restoreSvc = new FbRestore();
9292

93-
restoreSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
93+
restoreSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
9494
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
9595
restoreSvc.PageSize = TestsSetup.PageSize;
9696
restoreSvc.Verbose = true;
@@ -153,7 +153,7 @@ private void StreamingBackupRestoreTest_BackupPart(MemoryStream buffer)
153153
{
154154
FbStreamingBackup backupSvc = new FbStreamingBackup();
155155

156-
backupSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
156+
backupSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
157157
backupSvc.Options = FbBackupFlags.IgnoreLimbo;
158158
backupSvc.OutputStream = buffer;
159159

@@ -165,7 +165,7 @@ private void StreamingBackupRestoreTest_RestorePart(MemoryStream buffer, bool ve
165165
{
166166
FbStreamingRestore restoreSvc = new FbStreamingRestore();
167167

168-
restoreSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
168+
restoreSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
169169
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
170170
restoreSvc.PageSize = TestsSetup.PageSize;
171171
restoreSvc.Verbose = verbose;
@@ -181,7 +181,7 @@ public void ValidationTest()
181181
{
182182
FbValidation validationSvc = new FbValidation();
183183

184-
validationSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
184+
validationSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
185185
validationSvc.Options = FbValidationFlags.ValidateDatabase;
186186

187187
validationSvc.ServiceOutput += ServiceOutput;
@@ -194,7 +194,7 @@ public void SweepTest()
194194
{
195195
FbValidation validationSvc = new FbValidation();
196196

197-
validationSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
197+
validationSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
198198
validationSvc.Options = FbValidationFlags.SweepDatabase;
199199

200200
validationSvc.ServiceOutput += ServiceOutput;
@@ -207,7 +207,7 @@ public void SetPropertiesTest()
207207
{
208208
FbConfiguration configurationSvc = new FbConfiguration();
209209

210-
configurationSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
210+
configurationSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
211211

212212
configurationSvc.SetSweepInterval(1000);
213213
configurationSvc.SetReserveSpace(true);
@@ -219,7 +219,7 @@ public void ShutdownOnlineTest()
219219
{
220220
FbConfiguration configurationSvc = new FbConfiguration();
221221

222-
configurationSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
222+
configurationSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
223223

224224
configurationSvc.DatabaseShutdown(FbShutdownMode.Forced, 10);
225225
configurationSvc.DatabaseOnline();
@@ -233,7 +233,7 @@ public void ShutdownOnline2Test()
233233

234234
FbConfiguration configurationSvc = new FbConfiguration();
235235

236-
configurationSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
236+
configurationSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
237237

238238
configurationSvc.DatabaseShutdown2(FbShutdownOnlineMode.Full, FbShutdownType.ForceShutdown, 10);
239239
configurationSvc.DatabaseOnline2(FbShutdownOnlineMode.Normal);
@@ -244,7 +244,7 @@ public void StatisticsTest()
244244
{
245245
FbStatistical statisticalSvc = new FbStatistical();
246246

247-
statisticalSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
247+
statisticalSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
248248
statisticalSvc.Options = FbStatisticalFlags.SystemTablesRelations;
249249

250250
statisticalSvc.ServiceOutput += ServiceOutput;
@@ -257,7 +257,7 @@ public void FbLogTest()
257257
{
258258
FbLog logSvc = new FbLog();
259259

260-
logSvc.ConnectionString = BuildServicesConnectionString(FbServerType, false);
260+
logSvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
261261

262262
logSvc.ServiceOutput += ServiceOutput;
263263

@@ -269,7 +269,7 @@ public void AddUserTest()
269269
{
270270
FbSecurity securitySvc = new FbSecurity();
271271

272-
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, false);
272+
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
273273

274274
FbUserData user = new FbUserData();
275275

@@ -284,7 +284,7 @@ public void DeleteUser()
284284
{
285285
FbSecurity securitySvc = new FbSecurity();
286286

287-
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, false);
287+
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
288288

289289
FbUserData user = new FbUserData();
290290

@@ -298,7 +298,7 @@ public void DisplayUser()
298298
{
299299
FbSecurity securitySvc = new FbSecurity();
300300

301-
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, false);
301+
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
302302

303303
FbUserData user = securitySvc.DisplayUser("SYSDBA");
304304

@@ -310,7 +310,7 @@ public void DisplayUsers()
310310
{
311311
FbSecurity securitySvc = new FbSecurity();
312312

313-
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, false);
313+
securitySvc.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
314314

315315
FbUserData[] users = securitySvc.DisplayUsers();
316316

@@ -327,7 +327,7 @@ public void ServerPropertiesTest()
327327
{
328328
FbServerProperties serverProp = new FbServerProperties();
329329

330-
serverProp.ConnectionString = BuildServicesConnectionString(FbServerType, false);
330+
serverProp.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
331331

332332
FbServerConfig serverConfig = serverProp.GetServerConfig();
333333
FbDatabasesInfo databasesInfo = serverProp.GetDatabasesInfo();
@@ -356,7 +356,7 @@ void NBackupBackupRestoreTest_BackupPart(Guid id)
356356
{
357357
var nbak = new FbNBackup();
358358

359-
nbak.ConnectionString = BuildServicesConnectionString(FbServerType);
359+
nbak.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
360360
nbak.Level = l;
361361
nbak.BackupFile = CreateBackupFilename(id) + l.ToString();
362362
nbak.DirectIO = true;
@@ -375,7 +375,7 @@ void NBackupBackupRestoreTest_RestorePart(Guid id)
375375

376376
var nrest = new FbNRestore();
377377

378-
nrest.ConnectionString = BuildServicesConnectionString(FbServerType);
378+
nrest.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
379379
nrest.BackupFiles = Enumerable.Range(0, 2).Select(l => CreateBackupFilename(id) + l.ToString());
380380
nrest.DirectIO = true;
381381

@@ -388,7 +388,7 @@ void NBackupBackupRestoreTest_RestorePart(Guid id)
388388
public void TraceTest()
389389
{
390390
var trace = new FbTrace();
391-
trace.ConnectionString = BuildServicesConnectionString(FbServerType, false);
391+
trace.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
392392
trace.DatabasesConfigurations.Add(new FbDatabaseTraceConfiguration()
393393
{
394394
Enabled = true,
@@ -413,7 +413,7 @@ public void TraceTest()
413413
ThreadPool.QueueUserWorkItem(_ =>
414414
{
415415
Thread.Sleep(2000);
416-
new FbTrace(BuildServicesConnectionString(FbServerType, false)).Stop(sessionId);
416+
new FbTrace(BuildServicesConnectionString(FbServerType, Compression, false)).Stop(sessionId);
417417
});
418418
trace.Start("test");
419419
}
@@ -427,9 +427,9 @@ void ServiceOutput(object sender, ServiceOutputEventArgs e)
427427
TestContext.WriteLine(e.Message);
428428
}
429429

430-
static string CreateBackupFilename(Guid id)
430+
string CreateBackupFilename(Guid id)
431431
{
432-
return $"{TestsSetup.FilenameBase}_{id}.fbk";
432+
return $"{TestsSetup.Database(FbServerType, Compression)}_{id}.fbk";
433433
}
434434

435435
#endregion

Provider/src/FirebirdSql.Data.UnitTests/TestsBase.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,15 @@ public static string BuildConnectionString(FbServerType serverType, bool compres
187187
return BuildConnectionStringBuilder(serverType, compression).ToString();
188188
}
189189

190-
public static string BuildServicesConnectionString(FbServerType serverType)
191-
{
192-
return BuildServicesConnectionString(serverType, true);
193-
}
194-
195-
public static string BuildServicesConnectionString(FbServerType serverType, bool includeDatabase)
190+
public static string BuildServicesConnectionString(FbServerType serverType, bool compression, bool includeDatabase)
196191
{
197192
FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
198193
cs.UserID = TestsSetup.UserID;
199194
cs.Password = TestsSetup.Password;
200195
cs.DataSource = TestsSetup.DataSource;
201196
if (includeDatabase)
202197
{
203-
cs.Database = TestsSetup.Database;
198+
cs.Database = TestsSetup.Database(serverType, compression);
204199
}
205200
cs.ServerType = serverType;
206201
return cs.ToString();
@@ -212,7 +207,7 @@ public static FbConnectionStringBuilder BuildConnectionStringBuilder(FbServerTyp
212207
cs.UserID = TestsSetup.UserID;
213208
cs.Password = TestsSetup.Password;
214209
cs.DataSource = TestsSetup.DataSource;
215-
cs.Database = TestsSetup.Database;
210+
cs.Database = TestsSetup.Database(serverType, compression);
216211
cs.Port = TestsSetup.Port;
217212
cs.Charset = TestsSetup.Charset;
218213
cs.Pooling = TestsSetup.Pooling;
@@ -243,7 +238,7 @@ protected int GetActiveConnections()
243238
protected Version GetServerVersion()
244239
{
245240
var server = new FbServerProperties();
246-
server.ConnectionString = BuildServicesConnectionString(FbServerType);
241+
server.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, false);
247242
return FbServerProperties.ParseServerVersion(server.GetServerVersion());
248243
}
249244

@@ -263,7 +258,6 @@ protected bool EnsureServerType(FbServerType type)
263258
return false;
264259
}
265260

266-
267261
protected static int GetId()
268262
{
269263
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

Provider/src/FirebirdSql.Data.UnitTests/TestsSetup.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ namespace FirebirdSql.Data.UnitTests
3030
[SetUpFixture]
3131
public class TestsSetup
3232
{
33-
internal const string FilenameBase = "netprovider_tests";
33+
private const string DatabaseBase = "netprovider_tests";
3434
internal const string UserID = "SYSDBA";
3535
internal const string Password = "masterkey";
36-
internal const string Database = FilenameBase + ".fdb";
3736
internal const string DataSource = "localhost";
3837
internal const int Port = 3050;
3938
internal const string Charset = "utf8";
@@ -53,6 +52,11 @@ public static void SetUp(FbServerType serverType, bool compression)
5352
}
5453
}
5554

55+
public static string Database(FbServerType serverType, bool compression)
56+
{
57+
return $"{DatabaseBase}_{serverType}_{compression}.fdb";
58+
}
59+
5660
[OneTimeTearDown]
5761
public void TearDown()
5862
{

0 commit comments

Comments
 (0)