ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/testsuite/Test12.pas
Revision: 380
Committed: Mon Jan 10 10:13:17 2022 UTC (2 years, 11 months ago) by tony
Content type: text/x-pascal
File size: 23053 byte(s)
Log Message:
propset for eol-style

File Contents

# User Rev Content
1 tony 323 (*
2     * IBX Test suite. This program is used to test the IBX non-visual
3     * components and provides a semi-automated pass/fail check for each test.
4     *
5     * The contents of this file are subject to the Initial Developer's
6     * Public License Version 1.0 (the "License"); you may not use this
7     * file except in compliance with the License. You may obtain a copy
8     * of the License here:
9     *
10     * http://www.firebirdsql.org/index.php?op=doc&id=idpl
11     *
12     * Software distributed under the License is distributed on an "AS
13     * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14     * implied. See the License for the specific language governing rights
15     * and limitations under the License.
16     *
17     * The Initial Developer of the Original Code is Tony Whyman.
18     *
19     * The Original Code is (C) 2021 Tony Whyman, MWA Software
20     * (http://www.mwasoftware.co.uk).
21     *
22     * All Rights Reserved.
23     *
24     * Contributor(s): ______________________________________.
25     *
26     *)
27 tony 315 unit Test12;
28    
29     {$mode objfpc}{$H+}
30    
31     {Test 12 Test use of Services Connection}
32    
33     { Tests out the Services Interface for functions:
34     1. Show Server Properties
35     2. Show Database Stats
36     3. Show Server Log
37     4. Validate Database
38     5. Database Sweep
39     6. User List Handling (Show users, create user, Edit user, Delete User)
40     7. Shutdown DB and bring back online
41     8. Client side backup/restore
42     9. Server Side Backup/restore
43     10. Limbo Transaction Resolution.
44     11. Show Database Properties
45     12. Update Database Properties
46     13. Create, Remove and Activate a Shadow File.
47     }
48    
49     interface
50    
51     uses
52     Classes, SysUtils, TestApplication, IBXTestBase, DB, IB, IBXServices,
53     IBDatabaseInfo, IBQuery, IBSQL, IBDatabase;
54    
55     const
56     aTestID = '12';
57     aTestTitle = 'Test use of Services Connection';
58    
59     type
60    
61     { TTest12 }
62    
63     TTest12 = class(TIBXTestBase)
64     private
65     FIBConfigService: TIBXConfigService;
66     FIBXServicesConnection: TIBXServicesConnection;
67     FIBLogService: TIBXLogService;
68     FIBOnlineValidationService: TIBXOnlineValidationService;
69     FIBServerProperties: TIBXServerProperties;
70     FIBStatisticalService: TIBXStatisticalService;
71     FIBValidationService: TIBXValidationService;
72     FIBXSecurityService: TIBXSecurityService;
73     FUserList: TIBXServicesUserList;
74     FBackupService: TIBXClientSideBackupService;
75     FRestoreService: TIBXClientSideRestoreService;
76     FSSBackupService: TIBXServerSideBackupService;
77     FSSRestoreService: TIBXServerSideRestoreService;
78     FLimboTransactionsList: TIBXServicesLimboTransactionsList;
79     FLimboTransResolutionService: TIBXLimboTransactionResolutionService;
80     FIBDatabaseInfo: TIBDatabaseInfo;
81     FIBShadowDatabase: TIBDatabase;
82     function IsDatabaseOnline (DBName: AnsiString): boolean;
83     function IsShadowDatabase(DBName: AnsiString): boolean;
84     procedure ShowServerProperties;
85     procedure ShowStatistics;
86     procedure ShowServerLog;
87     procedure ValidateDatabase;
88     procedure UserListHandling;
89     procedure DBUpDown;
90     procedure DatabaseSweepDB;
91     procedure BackupRestore;
92     procedure SSBackupRestore;
93     procedure LimboTransactionResolution;
94     procedure DatabasePropertiesTests;
95     procedure ShowDatabaseProperties;
96     procedure CreateShadow;
97     procedure RemoveShadow;
98     procedure ShowShadowFiles;
99     procedure ActivateShadow;
100     protected
101     procedure CreateObjects(Application: TTestApplication); override;
102     function GetTestID: AnsiString; override;
103     function GetTestTitle: AnsiString; override;
104     procedure InitTest; override;
105     procedure ProcessResults; override;
106     public
107     destructor Destroy; override;
108     procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
109     end;
110    
111    
112     implementation
113    
114     uses IBUtils;
115    
116     const First2 = 2;
117    
118     { TTest12 }
119    
120     function TTest12.IsDatabaseOnline(DBName: AnsiString): boolean;
121     var Lines: TStringList;
122     i: integer;
123     line: string;
124     begin
125     {Scan header page to see if database is online }
126     Result := true;
127     with TIBXStatisticalService.Create(nil) do
128     try
129     ServicesConnection := FIBXServicesConnection;
130     DatabaseName := DBName;
131     Options := [HeaderPages];
132     Lines := TStringList.Create;
133     try
134     Execute(Lines);
135     for i := 0 to Lines.Count - 1 do
136     begin
137     line := Lines[i];
138     if (Pos('Attributes',Line) <> 0) and ((Pos('database shutdown',Line) <> 0)
139     or (Pos('multi-user maintenance',Line) <> 0)) then
140     begin
141     Result := false;
142     break;
143     end;
144    
145     end;
146     finally
147     Lines.Free;
148     end
149     finally
150     Free
151     end;
152     end;
153    
154     function TTest12.IsShadowDatabase(DBName: AnsiString): boolean;
155     var Lines: TStringList;
156     i: integer;
157     line: string;
158     begin
159     {Scan header page to see if database is a shadow}
160     Result := false;
161     with TIBXStatisticalService.Create(nil) do
162     try
163     ServicesConnection := FIBXServicesConnection;
164     DatabaseName := DBName;
165     Options := [HeaderPages];
166     Lines := TStringList.Create;
167     try
168     Execute(Lines);
169     for i := 0 to Lines.Count - 1 do
170     begin
171     line := Lines[i];
172     if (Pos('Attributes',Line) <> 0) and (Pos('shadow',Line) <> 0) then
173     begin
174     Result := true;
175     break;
176     end;
177    
178     end;
179     finally
180     Lines.Free;
181     end
182     finally
183     Free
184     end;
185     end;
186    
187     procedure TTest12.ShowServerProperties;
188     var i: integer;
189     begin
190     with FIBServerProperties, FIBXServicesConnection do
191     begin
192     writeln(OutFile,'Firebird Library PathName = ' + FirebirdAPI.GetFBLibrary.GetLibraryFilePath);
193     writeln(OutFile,'Connect String = ',FIBXServicesConnection.ConnectString);
194     writeln(OutFile,'Server Version = ' + VersionInfo.ServerVersion);
195     writeln(OutFile,'Server Implementation = ' + VersionInfo.ServerImplementation);
196     writeln(OutFile,'Service Version = ' + IntToStr(VersionInfo.ServiceVersion));
197     writeln(OutFile,Format('Firebird Release = %d.%d.%d (Build no. %d)',[ServerVersionNo[1],
198     ServerVersionNo[2],
199     ServerVersionNo[3],
200     ServerVersionNo[4]]));
201     writeln(OutFile,'No. of attachments = ' + IntToStr(DatabaseInfo.NoOfAttachments));
202     writeln(OutFile,'No. of databases = ' + IntToStr(DatabaseInfo.NoOfDatabases));
203     for i := 0 to DatabaseInfo.NoOfDatabases - 1 do
204     writeln(OutFile,'DB Name = ' + DatabaseInfo.DbName[i]);
205     writeln(OutFile,'Base Location = ' + ConfigParams.BaseLocation);
206     writeln(OutFile,'Lock File Location = ' + ConfigParams.LockFileLocation);
207     writeln(OutFile,'Security Database Location = ' + ConfigParams.SecurityDatabaseLocation);
208     writeln(OutFile,'Message File Location = ' + ConfigParams.MessageFileLocation);
209     for i := Low(ConfigParams.ConfigFileParams) to High(ConfigParams.ConfigFileParams) do
210     writeln(OutFile,ConfigParams.ConfigFileParams[i]);
211     for i := Low(ConfigParams.ConfigFileData.ConfigFileKey) to High(ConfigParams.ConfigFileData.ConfigFileKey) do
212     writeln(OutFile,Format('%d=%s',[ConfigParams.ConfigFileData.ConfigFileKey[i],ConfigParams.ConfigFileData.ConfigFileValue[i]]));
213     end;
214     end;
215    
216     procedure TTest12.ShowStatistics;
217     var S: TStringList;
218     begin
219     writeln(OutFile,'Database Statistics for ' + FIBStatisticalService.DatabaseName);
220     S := TStringList.Create;
221     try
222     FIBStatisticalService.Execute(S);
223     WriteStrings(S);
224     finally
225     S.Free;
226     end;
227     end;
228    
229     procedure TTest12.ShowServerLog;
230     var S: TStringList;
231     begin
232     writeln(OutFile,'Server Log');
233     S := TStringList.Create;
234     try
235     FIBLogService.Execute(S);
236     WriteStrings(S,First2);
237     finally
238     S.Free;
239     end;
240     end;
241    
242     procedure TTest12.ValidateDatabase;
243     var S: TStringList;
244     begin
245     S := TStringList.Create;
246     try
247     writeln(OutFile,'Online Validation');
248     FIBOnlineValidationService.Execute(S);
249     WriteStrings(S);
250     S.Clear;
251     writeln(OutFile,'Normal Validation');
252     FIBConfigService.ShutDownDatabase(Forced,0);
253     try
254     FIBValidationService.Options := [ValidateFull];
255     FIBValidationService.Execute(S);
256     finally
257     FIBConfigService.BringDatabaseOnline;
258     end;
259     WriteStrings(S);
260     finally
261     S.Free;
262     end;
263     writeln(OutFile,'Validation Completed');
264     end;
265    
266     procedure TTest12.UserListHandling;
267     begin
268     writeln(Outfile,' Current User List');
269     FUserList.Active := true;
270     PrintDataSet(FUserList);
271     writeln(Outfile,'Add user');
272     with FUserList do
273     begin
274     Append;
275     FieldByName('SEC$USER_NAME').AsString := 'Test12Tester';
276     FieldByName('SEC$PASSWORD').AsString := 'LetMeIn';
277     FieldByName('SEC$LAST_NAME').AsString := 'Tester';
278     Post;
279     end;
280     writeln(Outfile,'Updated User List');
281     PrintDataSet(FUserList);
282     writeln(Outfile,'Close and re-open user list');
283     FUserList.Active := false;
284     FUserList.Active := true;
285     PrintDataSet(FUserList);
286     writeln(Outfile,'Modify the new user');
287     if FUserList.Locate('SEC$USER_NAME','Test12Tester',[loCaseInsensitive]) then
288     with FUserList do
289     begin
290     Edit;
291     FieldByName('SEC$FIRST_NAME').AsString := 'The';
292     Post;
293     PrintDataSet(FUserList);
294     writeln(Outfile,'Close and re-open user list');
295     Active := false;
296     Active := true;
297     PrintDataSet(FUserList);
298     end
299     else
300     writeln(Outfile,'Added user not found');
301     writeln(Outfile,'Now delete the new user');
302     if FUserList.Locate('SEC$USER_NAME','Test12Tester',[loCaseInsensitive]) then
303     FUserList.Delete;
304     FUserList.Active := false;
305     FUserList.Active := true;
306     writeln(Outfile,'Updated User List');
307     PrintDataSet(FUserList);
308     FUserList.Active := false;
309     end;
310    
311     procedure TTest12.DBUpDown;
312     begin
313     writeln(OutFile,'Employee Database is Online = ',IsDatabaseOnline(FIBConfigService.DatabaseName));
314     FIBConfigService.ShutDownDatabase(Forced,0);
315     writeln(OutFile,'Employee Database is Online = ',IsDatabaseOnline(FIBConfigService.DatabaseName));
316     FIBConfigService.BringDatabaseOnline;
317     writeln(OutFile,'Employee Database is Online = ',IsDatabaseOnline(FIBConfigService.DatabaseName));
318     end;
319    
320     procedure TTest12.DatabaseSweepDB;
321     var S: TStringList;
322     begin
323     writeln(OutFile,'Database Sweep');
324     FIBValidationService.Options := [SweepDB];
325     S := TStringList.Create;
326     try
327     FIBValidationService.Execute(S);
328     WriteStrings(S);
329     finally
330     S.Free;
331     end;
332     writeln(OutFile,'Database Swept');
333     end;
334    
335     procedure TTest12.BackupRestore;
336     var BackupCount: integer;
337     S: TStringList;
338     begin
339     writeln(OutFile);
340     writeln(OutFile,'Starting Backup');
341     FBackupService.BackupToFile(Owner.GetBackupFileName,BackupCount);
342     writeln(OutFile,Format('Backup Completed - File Size = %d bytes',[BackupCount]));
343     writeln(OutFile,'Restore Started');
344     S := TStringList.Create;
345     try
346     FRestoreService.RestoreFromFile(Owner.GetBackupFileName,S);
347     WriteStrings(S);
348     finally
349     S.Free;
350     end;
351     writeln(Outfile,'Restore Completed');
352     DeleteFile(Owner.GetBackupFileName);
353     end;
354    
355     procedure TTest12.SSBackupRestore;
356     var S: TStringList;
357     ServerDatabase: TIBDatabase;
358     ServerTransaction: TIBTransaction;
359     ServerQuery: TIBQuery;
360     begin
361     writeln(OutFile);
362     writeln(OutFile,'Starting Server Side Backup');
363     S := TStringList.Create;
364     try
365     FSSBackupService.BackupFiles.Add(GetSSBackupFile);
366     FSSBackupService.Verbose := true;
367     FSSBackupService.Execute(S);
368     WriteStrings(S);
369     writeln(OutFile,'Backup Completed');
370     writeln(OutFile,'Restore Started');
371     FSSRestoreService.BackupFiles.Assign(FSSBackupService.BackupFiles);
372     FSSRestoreService.Execute(S);
373     WriteStrings(S);
374     finally
375     S.Free;
376     end;
377     writeln(Outfile,'Restore Completed');
378     ServerDatabase := TIBDatabase.Create(Owner);
379     ServerTransaction := TIBTransaction.Create(Owner);
380     ServerQuery := TIBQuery.Create(Owner);
381     try
382     with FIBXServicesConnection do
383     ServerDatabase.DatabaseName := MakeConnectString(ServerName,FSSRestoreService.DatabaseFiles[0],Protocol,PortNo);
384     ServerDatabase.FirebirdLibraryPathName := Owner.ClientLibraryPath;
385     ServerDatabase.LoginPrompt := false;
386     ServerDatabase.Params.Assign(IBDatabase.Params);
387     ServerTransaction.DefaultDatabase := ServerDatabase;
388     ServerTransaction.Params.Assign(IBTransaction.Params);
389     ServerDatabase.DefaultTransaction := ServerTransaction;
390     ServerQuery.Database := ServerDatabase;
391     ServerQuery.SQL.Text := 'Select * From EMPLOYEE Order by EMP_NO';
392     ServerDatabase.Connected := true;
393     try
394     ServerTransaction.Active := true;
395     ServerQuery.Active := true;
396     writeln(OutFile,'Show the EMPLOYEE Table from the restored database');
397     PrintDataset(ServerQuery);
398     finally
399     ServerDatabase.DropDatabase;
400     end;
401     finally
402     ServerQuery.Free;
403     ServerTransaction.Free;
404     ServerDatabase.Free;
405     end;
406     end;
407    
408     procedure TTest12.LimboTransactionResolution;
409     var S: TStrings;
410     begin
411     writeln(Outfile,'Show Limbo Transactions');
412     S := TStringList.Create;
413     try
414     FLimboTransactionsList.Active := true;
415     PrintDataSet(FLimboTransactionsList);
416     writeln(Outfile,'Call Fix Limbo transactions');
417     FLimboTransactionsList.FixErrors(CommitGlobal,S);
418     WriteStrings(S);
419     finally
420     S.Free;
421     end;
422     end;
423    
424     procedure TTest12.DatabasePropertiesTests;
425     begin
426     writeln(Outfile,'Update properties for ',IBDatabase.DatabaseName);
427     IBDatabase.Connected := false;
428     with FIBConfigService do
429     begin
430     SetNoLinger;
431     SetSweepInterval(10000);
432     SetDBSqlDialect(1);
433     SetPageBuffers(1024);
434     SetAsyncMode(true);
435     SetReserveSpace(false);
436     SetReadOnly(true);
437     end;
438     IBDatabase.Connected := true;
439     ShowDatabaseProperties;
440     end;
441    
442     procedure TTest12.ShowDatabaseProperties;
443     var Linger,
444     ForcedWrites,
445     ReserveSpace: TField;
446     begin
447     with FIBDatabaseInfo do
448     begin
449     writeln(Outfile,'Database Properties for ',DBFileName );
450     writeln(OutFile,'ODS Minor Version = ' + IntToStr(ODSMinorVersion));
451     writeln(OutFile,'ODS Major Version = ' + IntToStr(ODSMajorVersion));
452     writeln(OutFile,'DB SQLDialect = ' + IntToStr(DBSQLDialect));
453     writeln(OutFile,'Page Size = ' + IntToStr(PageSize));
454     writeln(OutFile,'Number of Buffers = ' + IntToStr(NumBuffers));
455     writeln(OutFile,'Version = ' + Version);
456     ShowBoolValue(ForcedWrites,'Forced Writes Enabled','Forced Writes Disabled');
457     writeln(OutFile,'Sweep Interval = ' + IntToStr(SweepInterval));
458     ShowBoolValue(ReadOnly,'Database is Read Only','Database is Read/Write');
459     writeln(Outfile,'Database Online = ',IsDatabaseOnline(DBFileName));
460     writeln(Outfile,'Database is Shadow = ',IsShadowDatabase(DBFileName));
461     end;
462     with TIBQuery.Create(nil) do
463     try
464     Database := FIBDatabaseInfo.Database;
465     Transaction := IBTransaction;
466     Transaction.Active := true;
467     SQL.Text := 'Select * From RDB$Database, MON$Database';
468     Active := true;
469     Linger := FindField('RDB$LINGER');
470     if Linger <> nil then
471     begin
472     if Linger.IsNull then
473     writeln(Outfile,'Linger = 0')
474     else
475     writeln(Outfile,'Linger = ',Linger.AsString);
476     end
477     else
478     writeln(OutFile,'Linger not found');
479     ForcedWrites := FindField('MON$FORCED_WRITES');
480     if ForcedWrites <> nil then
481     ShowBoolValue(ForcedWrites.AsInteger,'Database in Synchronous Mode','Database in Asynchronous Mode')
482     else
483     writeln(Outfile,'Sync State unknown');
484     ReserveSpace := FieldByName('MON$RESERVE_SPACE');
485     if ReserveSpace <> nil then
486     writeln(Outfile,'Reserve Space = ',ReserveSpace.AsBoolean)
487     else
488     writeln(Outfile,'Reserve Space unknown');
489     finally
490     Free
491     end;
492     end;
493    
494     procedure TTest12.CreateShadow;
495     var ShadowFileName: AnsiString;
496     begin
497     ShadowFileName := GetTempFileName;
498     with TIBSQL.Create(nil) do
499     try
500     Database := IBDatabase;
501     Transaction := IBTransaction;
502     ReadWriteTransaction;
503     SQL.Text := 'Create Shadow 1 AUTO ''' + ShadowFileName + '''';
504     Transaction.Active := true;
505     ExecQuery;
506     Transaction.Commit;
507     finally
508     Free
509     end;
510     FIBShadowDatabase.DatabaseName := MakeConnectString('',ShadowFileName,inet);
511     end;
512    
513     procedure TTest12.RemoveShadow;
514     begin
515     with TIBSQL.Create(nil) do
516     try
517     Database := IBDatabase;
518     Transaction := IBTransaction;
519     ReadWriteTransaction;
520     SQL.Text := 'Drop Shadow 1 PRESERVE FILE';
521     Transaction.Active := true;
522     ExecQuery;
523     Transaction.Commit;
524     finally
525     Free
526     end;
527     end;
528    
529     procedure TTest12.ShowShadowFiles;
530     var Qry: TIBQuery;
531     begin
532     Qry := TIBQuery.Create(nil);
533     with Qry do
534     try
535     Database := IBDatabase;
536     Transaction := IBTransaction;
537     SQl.Text := 'Select * From RDB$Files Where RDB$Shadow_Number <> 0 '+
538     'Order by RDB$Shadow_Number, RDB$FILE_SEQUENCE';
539     Transaction.Active := true;
540     Active := true;
541     writeln(Outfile,'Shadow Files');
542     PrintDataSet(Qry);
543     Transaction.Commit;
544     finally
545     Free
546     end;
547     end;
548    
549     procedure TTest12.ActivateShadow;
550     begin
551     FIBConfigService.DatabaseName := FIBShadowDatabase.DatabaseName;
552     writeln(Outfile,'Activating Shadow');
553     FIBConfigService.ActivateShadow;
554     end;
555    
556     procedure TTest12.CreateObjects(Application: TTestApplication);
557     begin
558     inherited CreateObjects(Application);
559     FIBXServicesConnection := TIBXServicesConnection.Create(Application);
560     FIBConfigService := TIBXConfigService.Create(Application);
561     FIBConfigService.ServicesConnection := FIBXServicesConnection;
562     FIBLogService := TIBXLogService.Create(Application);
563     FIBLogService.ServicesConnection := FIBXServicesConnection;
564     FIBOnlineValidationService := TIBXOnlineValidationService.Create(Application);
565     FIBOnlineValidationService.ServicesConnection := FIBXServicesConnection;
566     FIBServerProperties := TIBXServerProperties.Create(Application);
567     FIBServerProperties.ServicesConnection := FIBXServicesConnection;
568     FIBStatisticalService := TIBXStatisticalService.Create(Application);
569     FIBStatisticalService.ServicesConnection := FIBXServicesConnection;
570     FIBValidationService := TIBXValidationService.Create(Application);
571     FIBValidationService.ServicesConnection := FIBXServicesConnection;
572     FIBXSecurityService := TIBXSecurityService.Create(Application);
573     FIBXSecurityService.ServicesConnection := FIBXServicesConnection;
574     FUserList := TIBXServicesUserList.Create(Application);
575     FUserList.Source := FIBXSecurityService;
576     FBackupService := TIBXClientSideBackupService.Create(Application);
577     FBackupService.ServicesConnection := FIBXServicesConnection;
578     FRestoreService := TIBXClientSideRestoreService.Create(Application);
579     FRestoreService.ServicesConnection := FIBXServicesConnection;
580     FSSBackupService := TIBXServerSideBackupService.Create(Application);
581     FSSBackupService.ServicesConnection := FIBXServicesConnection;
582     FSSRestoreService := TIBXServerSideRestoreService.Create(Application);
583     FSSRestoreService.ServicesConnection := FIBXServicesConnection;
584     FLimboTransResolutionService := TIBXLimboTransactionResolutionService.Create(Application);
585     FLimboTransResolutionService.ServicesConnection := FIBXServicesConnection;
586     FLimboTransactionsList := TIBXServicesLimboTransactionsList.Create(Application);
587     FLimboTransactionsList.Source := FLimboTransResolutionService;
588     FIBDatabaseInfo := TIBDatabaseInfo.Create(Application);
589     FIBShadowDatabase := TIBDatabase.Create(Application);
590     end;
591    
592     function TTest12.GetTestID: AnsiString;
593     begin
594     Result := aTestID;
595     end;
596    
597     function TTest12.GetTestTitle: AnsiString;
598     begin
599     Result := aTestTitle;
600     end;
601    
602     procedure TTest12.InitTest;
603     begin
604     IBDatabase.DatabaseName := Owner.GetNewDatabaseName;
605     IBQuery.SQL.Text := 'Select * From EMPLOYEE Order by EMP_NO';
606     FIBXServicesConnection.ServerName := Owner.Server;
607     FIBXServicesConnection.Protocol := TCP;
608     FIBXServicesConnection.PortNo := Owner.PortNo;
609     FIBXServicesConnection.Params.Values['user_name'] := Owner.GetUserName;
610     FIBXServicesConnection.Params.Values['password'] := Owner.GetPassword;
611     FIBXServicesConnection.FirebirdLibraryPathName := Owner.ClientLibraryPath;
612     FIBStatisticalService.Options := [DataPages];
613     FIBStatisticalService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
614     FIBOnlineValidationService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
615     FIBValidationService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
616     FIBConfigService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
617     FBackupService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
618     FBackupService.Options := [IgnoreLimbo];
619     FRestoreService.DatabaseFiles.Add(ExtractDBName(Owner.GetNewDatabaseName));
620     FRestoreService.StatisticsRequested := [bsTotalTime];
621     FSSBackupService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
622     FSSBackupService.Options := [IgnoreLimbo];
623     FSSRestoreService.DatabaseFiles.Add(ExtractDBName(Owner.GetNewDatabaseName));
624     FSSRestoreService.StatisticsRequested := [bsTotalTime];
625     FLimboTransResolutionService.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName);
626     FIBDatabaseInfo.Database := IBDatabase;
627     ReadOnlyTransaction;
628     FIBShadowDatabase.Params.Assign(IBDatabase.Params);
629     end;
630    
631     procedure TTest12.ProcessResults;
632     begin
633     inherited ProcessResults;
634     FIBShadowDatabase.Connected := false;
635     FIBXServicesConnection.Connected := false;
636     end;
637    
638     destructor TTest12.Destroy;
639     begin
640     if FIBShadowDatabase <> nil then
641     FIBShadowDatabase.Connected := false;
642     if FIBXServicesConnection <> nil then
643     FIBXServicesConnection.Connected := false;
644     inherited Destroy;
645     end;
646    
647     procedure TTest12.RunTest(CharSet: AnsiString; SQLDialect: integer);
648     begin
649     FIBXServicesConnection.Connected := true;
650     try
651     ShowServerProperties;
652     ShowStatistics;
653     ShowServerLog;
654     ValidateDatabase;
655     DatabaseSweepDB;
656     UserListHandling;
657     DBUpDown;
658     BackupRestore;
659     writeln(OutFile,'Show the EMPLOYEE Table from the restored database');
660     IBDatabase.Connected := true;
661     try
662     IBTransaction.Active := true;
663     IBQuery.Active := true;
664     PrintDataset(IBQuery);
665     finally
666     IBDatabase.DropDatabase;
667     end;
668     SSBackupRestore;
669     exit;
670     LimboTransactionResolution;
671     IBDatabase.DatabaseName := Owner.GetNewDatabaseName;
672     FIBConfigService.DatabaseName := IBDatabase.DatabaseName;
673     FIBXServicesConnection.Connected := false;
674     writeln(Outfile,'Creating an empty database ',IBDatabase.DatabaseName);
675     IBDatabase.CreateDatabase;
676     try
677     FIBXServicesConnection.Connected := true;
678     ShowDatabaseProperties;
679     DatabasePropertiesTests;
680     finally
681     IBDatabase.DropDatabase;
682     end;
683     writeln(Outfile,'Create and activate a shadow file');
684     IBDatabase.CreateDatabase;
685     try
686     CreateShadow;
687     ShowShadowFiles;
688     RemoveShadow;
689     IBDatabase.Connected := false;
690     writeln(Outfile,FIBShadowDatabase.DatabaseName,' Is Shadow Database = ',IsShadowDatabase(FIBShadowDatabase.DatabaseName));
691     ActivateShadow;
692     writeln(Outfile,FIBShadowDatabase.DatabaseName,' Is Shadow Database = ',IsShadowDatabase(FIBShadowDatabase.DatabaseName));
693     finally
694     IBDatabase.DropDatabase;
695     FIBShadowDatabase.DropDatabase;
696     end;
697     finally
698     FIBXServicesConnection.Connected := false;
699     end;
700     end;
701    
702     initialization
703     RegisterTest(TTest12);
704    
705     end.
706    

Properties

Name Value
svn:eol-style native