Exemplo n.º 1
0
        /// <summary>
        /// Run the recovery tests.
        /// </summary>
        /// <param name="table">The name of the table to check.</param>
        private static void RecoveryTests(string table)
        {
            JET_SESID sesid;
            JET_DBID  dbid;

            Console.WriteLine("Recovery tests");

            Console.WriteLine("\tCrash recovery");
            JET_INSTANCE instance = CreateInstance();

            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            var dmltests = new DmlTests(instance, Database, table);

            dmltests.VerifyRecords();
            dmltests.Term();
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            Api.JetTerm(instance);

            Console.WriteLine("\tRecreating database");
            File.Delete(Database);
            File.Delete(Checkpoint);
            instance = CreateInstance();
            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            dmltests = new DmlTests(instance, Database, table);
            dmltests.VerifyRecords();
            dmltests.Term();
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            Api.JetTerm(instance);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run the basic test.
        /// </summary>
        public static void Main()
        {
            const string Table = "testtable";

            DateTime startTime = DateTime.Now;

            CreateDirectory(DirectoryPath);

            const int CacheSizeInBytes = 32 * 1024 * 0124;
            SystemParameters.DatabasePageSize = 8192;
            SystemParameters.CacheSizeMin = CacheSizeInBytes / SystemParameters.DatabasePageSize;
            SystemParameters.CacheSizeMax = CacheSizeInBytes / SystemParameters.DatabasePageSize;

            // Create an instance, session and database
            JET_INSTANCE instance = CreateInstance();
            JET_SESID sesid;
            JET_DBID dbid;
            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetCreateDatabase(sesid, Database, null, out dbid, CreateDatabaseGrbit.None);
            Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None);
            Api.JetDetachDatabase(sesid, Database);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            // DDL creation
            // Creates the tables/columns/indexes used by the DDLTest
            var ddltests = new DdlTests(sesid, dbid, Table);
            ddltests.Create();

            // DMLTests
            // Create/Retrieve/Update/Delete records
            var dmltests = new DmlTests(instance, Database, Table);
            dmltests.Create();
            dmltests.Term();

            // DDL update
            // Delete a column/index and add a new index
            ddltests.Update();

            // Temp table tests
            var temptabletests = new TempTableTests(instance);
            temptabletests.Run();

            // Run recovery
            Api.JetStopServiceInstance(instance);
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            try
            {
                Api.JetTerm2(instance, Windows7Grbits.Dirty);
            }
            catch (EsentDirtyShutdownException)
            {
            }

            RecoveryTests(Table);

            Directory.Delete(DirectoryPath, true);

            DateTime endTime = DateTime.Now;
            TimeSpan timespan = endTime - startTime;
            Console.WriteLine("Test completed in {0}", timespan);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Run the recovery tests.
        /// </summary>
        /// <param name="table">The name of the table to check.</param>
        private static void RecoveryTests(string table)
        {
            JET_SESID sesid;
            JET_DBID dbid;

            Console.WriteLine("Recovery tests");

            Console.WriteLine("\tCrash recovery");
            JET_INSTANCE instance = CreateInstance();
            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            var dmltests = new DmlTests(instance, Database, table);
            dmltests.VerifyRecords();
            dmltests.Term();
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            Api.JetTerm(instance);

            Console.WriteLine("\tRecreating database");
            File.Delete(Database);
            File.Delete(Checkpoint);
            instance = CreateInstance();
            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            dmltests = new DmlTests(instance, Database, table);
            dmltests.VerifyRecords();
            dmltests.Term();
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            Api.JetTerm(instance);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Run the basic test.
        /// </summary>
        public static void Main()
        {
            const string Table = "testtable";

            DateTime startTime = DateTime.Now;

            CreateDirectory(DirectoryPath);

            const int CacheSizeInBytes = 32 * 1024 * 0124;

            SystemParameters.DatabasePageSize = 8192;
            SystemParameters.CacheSizeMin     = CacheSizeInBytes / SystemParameters.DatabasePageSize;
            SystemParameters.CacheSizeMax     = CacheSizeInBytes / SystemParameters.DatabasePageSize;

            // Create an instance, session and database
            JET_INSTANCE instance = CreateInstance();
            JET_SESID    sesid;
            JET_DBID     dbid;

            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetCreateDatabase(sesid, Database, null, out dbid, CreateDatabaseGrbit.None);
            Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None);
            Api.JetDetachDatabase(sesid, Database);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            // DDL creation
            // Creates the tables/columns/indexes used by the DDLTest
            var ddltests = new DdlTests(sesid, dbid, Table);

            ddltests.Create();

            // DMLTests
            // Create/Retrieve/Update/Delete records
            var dmltests = new DmlTests(instance, Database, Table);

            dmltests.Create();
            dmltests.Term();

            // DDL update
            // Delete a column/index and add a new index
            ddltests.Update();

            // Temp table tests
            var temptabletests = new TempTableTests(instance);

            temptabletests.Run();

            // Run recovery
            Api.JetStopServiceInstance(instance);
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            try
            {
                Api.JetTerm2(instance, Windows7Grbits.Dirty);
            }
            catch (EsentDirtyShutdownException)
            {
            }

            RecoveryTests(Table);

            Directory.Delete(DirectoryPath, true);

            DateTime endTime  = DateTime.Now;
            TimeSpan timespan = endTime - startTime;

            Console.WriteLine("Test completed in {0}", timespan);
        }