summaryrefslogtreecommitdiff
path: root/test/csharp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-02-17 17:25:57 +0000
committer <>2015-03-17 16:26:24 +0000
commit780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch)
tree598f8b9fa431b228d29897e798de4ac0c1d3d970 /test/csharp
parent7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff)
downloadberkeleydb-master.tar.gz
Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz.HEADdb-6.1.23master
Diffstat (limited to 'test/csharp')
-rw-r--r--test/csharp/AllTestData.xml8
-rw-r--r--test/csharp/BTreeCursorTest.cs2
-rw-r--r--test/csharp/BTreeDatabaseConfigTest.cs2
-rw-r--r--test/csharp/BTreeDatabaseTest.cs460
-rw-r--r--test/csharp/CSharpTestFixture.cs2
-rw-r--r--test/csharp/Configuration.cs2
-rw-r--r--test/csharp/CursorConfigTest.cs2
-rw-r--r--test/csharp/CursorTest.cs2
-rw-r--r--test/csharp/DatabaseConfigTest.cs2
-rw-r--r--test/csharp/DatabaseEnvironmentConfigTest.cs2
-rw-r--r--test/csharp/DatabaseEnvironmentTest.cs742
-rw-r--r--test/csharp/DatabaseExceptionTest.cs2
-rw-r--r--test/csharp/DatabaseTest.cs2
-rw-r--r--test/csharp/DotNetTest.csproj4
-rw-r--r--test/csharp/ForeignKeyTest.cs2
-rw-r--r--test/csharp/HashCursorTest.cs2
-rw-r--r--test/csharp/HashDatabaseConfigTest.cs2
-rw-r--r--test/csharp/HashDatabaseTest.cs294
-rw-r--r--test/csharp/HeapDatabaseConfigTest.cs2
-rw-r--r--test/csharp/HeapDatabaseTest.cs229
-rw-r--r--test/csharp/JoinCursorTest.cs2
-rw-r--r--test/csharp/LockTest.cs112
-rw-r--r--test/csharp/LockingConfigTest.cs2
-rw-r--r--test/csharp/LogConfigTest.cs107
-rw-r--r--test/csharp/LogCursorTest.cs2
-rw-r--r--test/csharp/MPoolConfigTest.cs2
-rw-r--r--test/csharp/MutexConfigTest.cs2
-rw-r--r--test/csharp/MutexTest.cs2
-rw-r--r--test/csharp/QueueDatabaseConfigTest.cs2
-rw-r--r--test/csharp/QueueDatabaseTest.cs59
-rw-r--r--test/csharp/RecnoCursorTest.cs2
-rw-r--r--test/csharp/RecnoDatabaseConfigTest.cs2
-rw-r--r--test/csharp/RecnoDatabaseTest.cs59
-rw-r--r--test/csharp/ReplicationConfigTest.cs6
-rw-r--r--test/csharp/ReplicationTest.cs228
-rw-r--r--test/csharp/SecondaryBTreeDatabaseConfigTest.cs2
-rw-r--r--test/csharp/SecondaryBTreeDatabaseTest.cs2
-rw-r--r--test/csharp/SecondaryCursorTest.cs2
-rw-r--r--test/csharp/SecondaryDatabaseConfigTest.cs2
-rw-r--r--test/csharp/SecondaryDatabaseTest.cs2
-rw-r--r--test/csharp/SecondaryHashDatabaseConfigTest.cs2
-rw-r--r--test/csharp/SecondaryHashDatabaseTest.cs2
-rw-r--r--test/csharp/SecondaryQueueDatabaseConfigTest.cs2
-rw-r--r--test/csharp/SecondaryQueueDatabaseTest.cs2
-rw-r--r--test/csharp/SecondaryRecnoDatabaseConfigTest.cs2
-rw-r--r--test/csharp/SecondaryRecnoDatabaseTest.cs2
-rw-r--r--test/csharp/SequenceConfigTest.cs12
-rw-r--r--test/csharp/SequenceTest.cs69
-rw-r--r--test/csharp/TestException.cs2
-rw-r--r--test/csharp/TransactionCommitTokenTest.cs2
-rw-r--r--test/csharp/TransactionConfigTest.cs2
-rw-r--r--test/csharp/TransactionTest.cs2
-rw-r--r--test/csharp/XMLReader.cs2
53 files changed, 2393 insertions, 74 deletions
diff --git a/test/csharp/AllTestData.xml b/test/csharp/AllTestData.xml
index f372a8f6..43a07c7a 100644
--- a/test/csharp/AllTestData.xml
+++ b/test/csharp/AllTestData.xml
@@ -395,8 +395,10 @@
<FileMode>755</FileMode>
<ForceSync>True</ForceSync>
<InMemory>True</InMemory>
+ <LogBlobContent>True</LogBlobContent>
<MaxFileSize>1048576</MaxFileSize>
<NoBuffer>True</NoBuffer>
+ <NoSync>True</NoSync>
<RegionSize>30720</RegionSize>
<ZeroOnCreate>True</ZeroOnCreate>
</Test>
@@ -638,8 +640,10 @@
<FileMode>755</FileMode>
<ForceSync>True</ForceSync>
<InMemory>True</InMemory>
+ <LogBlobContent>True</LogBlobContent>
<MaxFileSize>1048576</MaxFileSize>
<NoBuffer>True</NoBuffer>
+ <NoSync>True</NoSync>
<RegionSize>20480</RegionSize>
<ZeroOnCreate>True</ZeroOnCreate>
</Test>
@@ -758,8 +762,10 @@
<FileMode>755</FileMode>
<ForceSync>True</ForceSync>
<InMemory>False</InMemory>
+ <LogBlobContent>False</LogBlobContent>
<MaxFileSize>1048576</MaxFileSize>
<NoBuffer>False</NoBuffer>
+ <NoSync>True</NoSync>
<RegionSize>204800</RegionSize>
<ZeroOnCreate>True</ZeroOnCreate>
</LogConfig>
@@ -848,4 +854,4 @@
<UseMasterLeases>True</UseMasterLeases>
</Test>
</TestFixture>
-</Assembly> \ No newline at end of file
+</Assembly>
diff --git a/test/csharp/BTreeCursorTest.cs b/test/csharp/BTreeCursorTest.cs
index f0d537b6..d03ce9eb 100644
--- a/test/csharp/BTreeCursorTest.cs
+++ b/test/csharp/BTreeCursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/BTreeDatabaseConfigTest.cs b/test/csharp/BTreeDatabaseConfigTest.cs
index fe5a5aad..5e4a5797 100644
--- a/test/csharp/BTreeDatabaseConfigTest.cs
+++ b/test/csharp/BTreeDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/BTreeDatabaseTest.cs b/test/csharp/BTreeDatabaseTest.cs
index 4fca281f..1d5f8d1a 100644
--- a/test/csharp/BTreeDatabaseTest.cs
+++ b/test/csharp/BTreeDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -27,6 +27,251 @@ namespace CsharpAPITest
}
[Test]
+ public void TestBlob()
+ {
+ testName = "TestBlob";
+ SetUpTest(false);
+ // Test opening the blob database without environment.
+ TestBlobBtreeDatabase(0, null, 6, null, false);
+
+ /*
+ * Test opening the blob database without environment
+ * but specifying blob directory.
+ */
+ TestBlobBtreeDatabase(0, null, 6,
+ testHome + "/DBBLOB", true);
+
+ // Test opening the blob database with environment.
+ TestBlobBtreeDatabase(3, "ENVBLOB", 6, null, false);
+
+ /*
+ * Test opening the blob database with environment
+ * and specifying blob directory.
+ */
+ TestBlobBtreeDatabase(3, null, 6, "/DBBLOB", true);
+ }
+
+ /*
+ * Test the blob database with or without environment.
+ * 1. Config and open the environment;
+ * 2. Verify the environment blob configs;
+ * 3. Config and open the database;
+ * 4. Verify the database blob configs;
+ * 5. Insert and verify some blob data by database methods;
+ * 6. Insert some blob data by cursor, update it and verify
+ * the update by database stream and cursor;
+ * 7. Verify the stats;
+ * 8. Close all handles.
+ * If "blobdbt" is true, set the data DatabaseEntry.Blob as
+ * true, otherwise make the data DatabaseEntry reach the blob
+ * threshold in size.
+ */
+ void TestBlobBtreeDatabase(uint env_threshold,
+ string env_blobdir, uint db_threshold,
+ string db_blobdir, bool blobdbt)
+ {
+ if (env_threshold == 0 && db_threshold == 0)
+ return;
+
+ string btreeDBName =
+ testHome + "/" + testName + ".db";
+
+ Configuration.ClearDir(testHome);
+ BTreeDatabaseConfig cfg = new BTreeDatabaseConfig();
+ cfg.Creation = CreatePolicy.ALWAYS;
+ string blrootdir = "__db_bl";
+
+ // Open the environment and verify the blob configs.
+ if (env_threshold > 0)
+ {
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.AutoCommit = true;
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ envConfig.UseLogging = true;
+ envConfig.UseTxns = true;
+ envConfig.UseLocking = true;
+ envConfig.BlobThreshold = env_threshold;
+ if (env_blobdir != null)
+ {
+ envConfig.BlobDir = env_blobdir;
+ blrootdir = env_blobdir;
+ }
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(
+ testHome, envConfig);
+ if (env_blobdir == null)
+ Assert.IsNull(env.BlobDir);
+ else
+ Assert.AreEqual(0, env.BlobDir.
+ CompareTo(env_blobdir));
+ Assert.AreEqual(env_threshold,
+ env.BlobThreshold);
+ cfg.Env = env;
+ btreeDBName = testName + ".db";
+ }
+
+ // Open the database and verify the blob configs.
+ if (db_threshold > 0)
+ cfg.BlobThreshold = db_threshold;
+ if (db_blobdir != null)
+ {
+ cfg.BlobDir = db_blobdir;
+ /*
+ * The blob directory setting in the database
+ * is effective only when it is opened without
+ * an environment.
+ */
+ if (cfg.Env == null)
+ blrootdir = db_blobdir;
+ }
+
+ BTreeDatabase db =
+ BTreeDatabase.Open(btreeDBName, cfg);
+ Assert.AreEqual(
+ db_threshold > 0 ? db_threshold : env_threshold,
+ db.BlobThreshold);
+ if (db_blobdir == null && cfg.Env == null)
+ Assert.IsNull(db.BlobDir);
+ else
+ Assert.AreEqual(0,
+ db.BlobDir.CompareTo(blrootdir));
+
+ // Insert and verify some blob data by database methods.
+ string[] records = {"a", "b", "c", "d", "e", "f", "g",
+ "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
+ "r", "s", "t", "u", "v", "w", "x", "y", "z"};
+ DatabaseEntry kdbt = new DatabaseEntry();
+ DatabaseEntry ddbt = new DatabaseEntry();
+ byte[] kdata, ddata;
+ string str;
+ KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
+ ddbt.Blob = blobdbt;
+ Assert.AreEqual(blobdbt, ddbt.Blob);
+ for (int i = 0; i < records.Length; i++)
+ {
+ kdata = BitConverter.GetBytes(i);
+ str = records[i];
+ if (!blobdbt) {
+ for (int j = 0; j < db_threshold; j++)
+ str = str + records[i];
+ }
+ ddata = Encoding.ASCII.GetBytes(str);
+ kdbt.Data = kdata;
+ ddbt.Data = ddata;
+ db.Put(kdbt, ddbt);
+ try
+ {
+ pair = db.Get(kdbt);
+ }
+ catch (DatabaseException)
+ {
+ db.Close();
+ if (cfg.Env != null)
+ cfg.Env.Close();
+ throw new TestException();
+ }
+ Assert.AreEqual(ddata, pair.Value.Data);
+ }
+
+ /*
+ * Insert some blob data by cursor, update it and verify
+ * the update by database stream.
+ */
+ kdata = BitConverter.GetBytes(records.Length);
+ ddata = Encoding.ASCII.GetBytes("abc");
+ kdbt.Data = kdata;
+ ddbt.Data = ddata;
+ ddbt.Blob = true;
+ Assert.IsTrue(ddbt.Blob);
+ pair = new KeyValuePair<
+ DatabaseEntry, DatabaseEntry>(kdbt, ddbt);
+ CursorConfig dbcConfig = new CursorConfig();
+ Transaction txn = null;
+ if (cfg.Env != null)
+ txn = cfg.Env.BeginTransaction();
+ BTreeCursor cursor = db.Cursor(dbcConfig, txn);
+ cursor.Add(pair);
+ DatabaseStreamConfig dbsc = new DatabaseStreamConfig();
+ dbsc.SyncPerWrite = true;
+ DatabaseStream dbs = cursor.DbStream(dbsc);
+ Assert.AreNotEqual(null, dbs);
+ Assert.IsFalse(dbs.GetConfig.ReadOnly);
+ Assert.IsTrue(dbs.GetConfig.SyncPerWrite);
+ Assert.AreEqual(3, dbs.Size());
+ DatabaseEntry sdbt = dbs.Read(0, 3);
+ Assert.IsNotNull(sdbt);
+ Assert.AreEqual(ddata, sdbt.Data);
+ sdbt = new DatabaseEntry(
+ Encoding.ASCII.GetBytes("defg"));
+ Assert.IsTrue(dbs.Write(sdbt, 3));
+ Assert.AreEqual(7, dbs.Size());
+ sdbt = dbs.Read(0, 7);
+ Assert.IsNotNull(sdbt);
+ Assert.AreEqual(
+ Encoding.ASCII.GetBytes("abcdefg"), sdbt.Data);
+ dbs.Close();
+
+ /*
+ * Verify the database stream can not write when it is
+ * configured to be read-only.
+ */
+ dbsc.ReadOnly = true;
+ dbs = cursor.DbStream(dbsc);
+ Assert.IsTrue(dbs.GetConfig.ReadOnly);
+ try
+ {
+ dbs.Write(sdbt, 7);
+ throw new TestException();
+ }
+ catch (DatabaseException)
+ {
+ }
+ dbs.Close();
+
+ // Verify the update by cursor.
+ Assert.IsTrue(cursor.Move(kdbt, true));
+ pair = cursor.Current;
+ Assert.AreEqual(Encoding.ASCII.GetBytes("abcdefg"),
+ pair.Value.Data);
+ cursor.Close();
+ if (cfg.Env != null)
+ txn.Commit();
+
+ /*
+ * Verify the blob files are created
+ * in the expected location.
+ * This part of test code is disabled since
+ * BTreeDatabase.BlobSubDir is not exposed to users.
+ */
+
+ //if (cfg.Env != null)
+ // blrootdir = testHome + "/" + blrootdir;
+ //string blobdir = blrootdir + "/" + db.BlobSubDir;
+ //Assert.AreEqual(records.Length + 1,
+ // Directory.GetFiles(blobdir, "__db.bl*").Length);
+ //Assert.AreEqual(1, Directory.GetFiles(
+ // blobdir, "__db_blob_meta.db").Length);
+
+ // Verify the stats.
+ BTreeStats st = db.Stats();
+ Assert.AreEqual(records.Length + 1, st.nBlobRecords);
+
+ // Close all handles.
+ db.Close();
+ if (cfg.Env != null)
+ cfg.Env.Close();
+
+ /*
+ * Remove the default blob directory when it
+ * is not under the test home.
+ */
+ if (db_blobdir == null && cfg.Env == null)
+ Directory.Delete("__db_bl", true);
+ }
+
+ [Test]
public void TestCompactWithoutTxn()
{
int i, nRecs;
@@ -1083,6 +1328,124 @@ ASCIIEncoding.ASCII.GetBytes(Configuration.RandomString(100)));
}
[Test]
+ public void TestMessageCall()
+ {
+ testName = "TestMessageCall";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+
+ // Configure and open a database.
+ BTreeDatabaseConfig DBConfig =
+ new BTreeDatabaseConfig();
+ DBConfig.Env = env;
+ DBConfig.Creation = CreatePolicy.IF_NEEDED;
+
+ string DBFileName = testName + ".db";
+ BTreeDatabase db = BTreeDatabase.Open(DBFileName, DBConfig);
+
+ // Confirm message file does not exist.
+ string messageCallFile = testHome + "/" + "MessageCallFile";
+ Assert.AreEqual(false, File.Exists(messageCallFile));
+
+ string messageInfo = "Message come from db.set_msgcall!";
+
+ // Call set_msgcall() of env.
+ db.messageFeedback = new MessageFeedbackDelegate(Msgcall_fcn);
+ db.messageFeedback(messageInfo);
+
+ // Unconfigures the callback interface.
+ db.messageFeedback = null;
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageCallFile));
+
+ // Read the first line of message file.
+ string line = null;
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageCallFile);
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, messageInfo);
+ file.Close();
+
+ // Close database and environment.
+ db.Close();
+ env.Close();
+ }
+
+ public void Msgcall_fcn(string message)
+ {
+ string msgfile = testHome + "/" + "MessageCallFile";
+ FileStream fs = new FileStream(msgfile, FileMode.OpenOrCreate);
+ StreamWriter sw = new StreamWriter(fs);
+ sw.Write(message);
+ sw.Flush();
+ sw.Close();
+ fs.Close();
+ }
+
+ [Test]
+ public void TestMessageFile()
+ {
+ testName = "TestMessageFile";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+
+ // Configure and open a database.
+ BTreeDatabaseConfig DBConfig =
+ new BTreeDatabaseConfig();
+ DBConfig.Env = env;
+ DBConfig.Creation = CreatePolicy.IF_NEEDED;
+
+ string DBFileName = testName + ".db";
+ BTreeDatabase db = BTreeDatabase.Open(DBFileName, DBConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of db.
+ db.Msgfile = messageFile;
+
+ // Print db statistic to message file.
+ db.PrintStats(true);
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ db.Msgfile = "";
+ string line = null;
+
+ // Read the third line of message file.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ line = file.ReadLine();
+ line = file.ReadLine();
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, "DB handle information:");
+ file.Close();
+
+ // Close database and environment.
+ db.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestNoWaitDbExclusiveLock()
{
testName = "TestNoWaitDbExclusiveLock";
@@ -1390,6 +1753,97 @@ ASCIIEncoding.ASCII.GetBytes(Configuration.RandomString(100)));
}
[Test]
+ public void TestPartition()
+ {
+ testName = "TestPartition";
+ SetUpTest(true);
+ string btreeDBName = testHome + "/" + testName + ".db";
+
+ BTreeDatabaseConfig cfg = new BTreeDatabaseConfig();
+ BTreeDatabase db;
+ DatabaseEntry[] keys;
+ DatabaseEntry key, data;
+ string[] keyData =
+ { "a", "b", "i", "k", "l", "q", "v", "z" };
+ int i;
+ uint parts;
+
+ cfg.Creation = CreatePolicy.ALWAYS;
+ parts = 3;
+ keys = new DatabaseEntry[parts - 1];
+ keys[0] = new DatabaseEntry(
+ ASCIIEncoding.ASCII.GetBytes("i"));
+ keys[1] = new DatabaseEntry(
+ ASCIIEncoding.ASCII.GetBytes("q"));
+
+ /*
+ * Test that neither key array nor
+ * partiton callback is set.
+ */
+ Assert.AreEqual(false, cfg.SetPartitionByKeys(null));
+ Assert.AreEqual(false,
+ cfg.SetPartitionByCallback(parts, null));
+
+ /* Test creating the partitioned database by keys. */
+ Assert.AreEqual(true, cfg.SetPartitionByKeys(keys));
+ db = BTreeDatabase.Open(btreeDBName, cfg);
+ for (i = 0; i < keyData.Length; i++)
+ {
+ key = new DatabaseEntry(
+ ASCIIEncoding.ASCII.GetBytes(keyData[i]));
+ data = new DatabaseEntry(
+ ASCIIEncoding.ASCII.GetBytes(keyData[i]));
+ db.Put(key, data);
+ }
+ Assert.AreEqual(parts, db.NParts);
+ Assert.AreEqual(parts - 1, db.PartitionKeys.Length);
+ Assert.AreEqual(
+ keys[0].Data, db.PartitionKeys[0].Data);
+ Assert.AreEqual(
+ keys[1].Data, db.PartitionKeys[1].Data);
+ Assert.AreEqual(db.Partition, null);
+ db.Close();
+ string[] files =
+ Directory.GetFiles(testHome, "__dbp.*");
+ Assert.AreEqual(parts, files.Length);
+
+ /*
+ * Test creating the partitioned database by callback.
+ */
+ Directory.Delete(testHome, true);
+ Directory.CreateDirectory(testHome);
+ Assert.AreEqual(true,
+ cfg.SetPartitionByCallback(parts, partition));
+ db = BTreeDatabase.Open(btreeDBName, cfg);
+ for (i = 0; i < keyData.Length; i++)
+ {
+ key = new DatabaseEntry(
+ ASCIIEncoding.ASCII.GetBytes(keyData[i]));
+ data = new DatabaseEntry(
+ ASCIIEncoding.ASCII.GetBytes(keyData[i]));
+ db.Put(key, data);
+ }
+ Assert.AreEqual(parts, db.NParts);
+ Assert.AreEqual(
+ new PartitionDelegate(partition), db.Partition);
+ db.Close();
+ files = Directory.GetFiles(testHome, "__dbp.*");
+ Assert.AreEqual(parts, files.Length);
+ }
+
+ uint partition(DatabaseEntry key)
+ {
+ if (String.Compare(
+ ASCIIEncoding.ASCII.GetString(key.Data), "i") < 0)
+ return 0;
+ else if (String.Compare(
+ ASCIIEncoding.ASCII.GetString(key.Data), "q") < 0)
+ return 1;
+ else
+ return 2;
+ }
+
+ [Test]
public void TestPrefixCompare()
{
testName = "TestPrefixCompare";
@@ -2465,6 +2919,7 @@ ASCIIEncoding.ASCII.GetBytes(Configuration.RandomString(100)));
byte[] bigArray = new byte[10240];
db.Delete(new DatabaseEntry(bigArray));
+ db.Msgfile = testHome + "/" + testName+ ".log";
db.PrintStats();
db.PrintFastStats();
@@ -2570,6 +3025,7 @@ ASCIIEncoding.ASCII.GetBytes(Configuration.RandomString(100)));
stats = db.Stats(statsTxn, Isolation.DEGREE_THREE);
ConfirmStatsPart3Case1(stats);
+ db.Msgfile = home + "/" + name+ ".log";
db.PrintStats(true);
Assert.AreEqual(0, stats.EmptyPages);
@@ -2627,7 +3083,7 @@ ASCIIEncoding.ASCII.GetBytes(Configuration.RandomString(100)));
Assert.AreEqual(10, stats.MinKey);
Assert.AreEqual(2, stats.nPages);
Assert.AreEqual(4096, stats.PageSize);
- Assert.AreEqual(9, stats.Version);
+ Assert.AreEqual(10, stats.Version);
}
public void ConfirmStatsPart2Case1(BTreeStats stats)
diff --git a/test/csharp/CSharpTestFixture.cs b/test/csharp/CSharpTestFixture.cs
index ad05ad62..e6df6aa8 100644
--- a/test/csharp/CSharpTestFixture.cs
+++ b/test/csharp/CSharpTestFixture.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/Configuration.cs b/test/csharp/Configuration.cs
index 132e8b38..09419a40 100644
--- a/test/csharp/Configuration.cs
+++ b/test/csharp/Configuration.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/CursorConfigTest.cs b/test/csharp/CursorConfigTest.cs
index 9d7855f0..4d6479dd 100644
--- a/test/csharp/CursorConfigTest.cs
+++ b/test/csharp/CursorConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/CursorTest.cs b/test/csharp/CursorTest.cs
index 11e003bc..885dec81 100644
--- a/test/csharp/CursorTest.cs
+++ b/test/csharp/CursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/DatabaseConfigTest.cs b/test/csharp/DatabaseConfigTest.cs
index 2dad6b50..5e5e24b2 100644
--- a/test/csharp/DatabaseConfigTest.cs
+++ b/test/csharp/DatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/DatabaseEnvironmentConfigTest.cs b/test/csharp/DatabaseEnvironmentConfigTest.cs
index ea53058d..9c1a2ff9 100644
--- a/test/csharp/DatabaseEnvironmentConfigTest.cs
+++ b/test/csharp/DatabaseEnvironmentConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/DatabaseEnvironmentTest.cs b/test/csharp/DatabaseEnvironmentTest.cs
index 3851d084..236bfda4 100644
--- a/test/csharp/DatabaseEnvironmentTest.cs
+++ b/test/csharp/DatabaseEnvironmentTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -312,7 +312,7 @@ namespace CsharpAPITest
/* We should only copy one file, the database. */
env.BackupDatabase(target, dbFileName, true);
- Assert.AreEqual(Directory.GetFiles(target).Length, 1);
+ Assert.AreEqual(1, Directory.GetFiles(target).Length);
Directory.Delete(target, true);
env.Close();
@@ -339,13 +339,13 @@ namespace CsharpAPITest
* are other tests to check that the backup options are obeyed.
*/
env.BackupBufferSize = (uint)1024;
- Assert.AreEqual(env.BackupBufferSize, (uint)1024);
+ Assert.AreEqual((uint)1024, env.BackupBufferSize);
env.BackupReadCount = (uint)4096;
- Assert.AreEqual(env.BackupReadCount, (uint)4096);
+ Assert.AreEqual((uint)4096, env.BackupReadCount);
env.BackupReadSleepDuration = (uint)1000;
- Assert.AreEqual(env.BackupReadSleepDuration, (uint)1000);
+ Assert.AreEqual((uint)1000, env.BackupReadSleepDuration);
env.BackupWriteDirect = true;
Assert.IsTrue(env.BackupWriteDirect);
@@ -518,6 +518,48 @@ namespace CsharpAPITest
}
[Test]
+ public void TestBlob()
+ {
+ testName = "TestBlob";
+ SetUpTest(true);
+
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.AutoCommit = true;
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ envConfig.UseLogging = true;
+ envConfig.UseTxns = true;
+
+ // Not set the blob file directory when enabling blob.
+ envConfig.BlobThreshold = 10485760;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+ Assert.AreEqual(null, env.BlobDir);
+ Assert.AreEqual(10485760, env.BlobThreshold);
+ env.Close();
+
+ Configuration.ClearDir(testHome);
+
+ // Set the blob file directory with an empty string.
+ envConfig.BlobDir = "";
+ env = DatabaseEnvironment.Open(testHome, envConfig);
+ Assert.AreEqual("", env.BlobDir);
+ Assert.AreEqual(10485760, env.BlobThreshold);
+ env.Close();
+
+ Configuration.ClearDir(testHome);
+
+ // Set the blob file directory with a non-emptry
+ // string.
+ envConfig.BlobDir = "BLOBDIR";
+ env = DatabaseEnvironment.Open(testHome, envConfig);
+ Assert.AreEqual("BLOBDIR", env.BlobDir);
+ Assert.AreEqual(10485760, env.BlobThreshold);
+ env.Close();
+ }
+
+ [Test]
public void TestCheckpoint()
{
testName = "TestCheckpoint";
@@ -635,6 +677,7 @@ namespace CsharpAPITest
Confirm(xmlElem, env, true, true, true, true, true, true);
// Print statistics of the current environment.
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintStats(true, true);
// Print statistics of all subsytems.
@@ -965,6 +1008,102 @@ namespace CsharpAPITest
}
[Test]
+ public void TestMessageCall()
+ {
+ testName = "TestMessageCall";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageCallFile = testHome + "/" + "MessageCallFile";
+ Assert.AreEqual(false, File.Exists(messageCallFile));
+
+ string messageInfo = "Message come from db.set_msgcall!";
+
+ // Call set_msgcall() of env.
+ env.messageFeedback = new MessageFeedbackDelegate(Msgcall_fcn);
+ env.messageFeedback(messageInfo);
+
+ // Unconfigures the callback interface.
+ env.messageFeedback = null;
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageCallFile));
+
+ // Read the first line of message file.
+ string line = null;
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageCallFile);
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, messageInfo);
+
+ file.Close();
+ env.Close();
+ }
+
+ public void Msgcall_fcn(string message)
+ {
+ string msgfile = testHome + "/" + "MessageCallFile";
+ FileStream fs = new FileStream(msgfile, FileMode.OpenOrCreate);
+ StreamWriter sw = new StreamWriter(fs);
+ sw.Write(message);
+ sw.Flush();
+ sw.Close();
+ fs.Close();
+ }
+
+ [Test]
+ public void TestMessageFile()
+ {
+ testName = "TestMessageFile";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of db.
+ env.Msgfile = messageFile;
+
+ // Print db statistic to message file.
+ env.PrintStats(true, true);
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ string line = null;
+
+ // Read the third line of message file.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ line = file.ReadLine();
+ line = file.ReadLine();
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, "Default database environment information:");
+
+ file.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestMetadataDir()
{
testName = "TestMetadataDir";
@@ -1040,6 +1179,7 @@ namespace CsharpAPITest
DatabaseEnvironment env = DatabaseEnvironment.Open(testHome, cfg);
MutexStats stats = env.MutexSystemStats();
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintMutexSystemStats(true, true);
Assert.AreEqual(512, stats.Alignment);
Assert.AreEqual(stats.Count, stats.Available + stats.InUse);
@@ -1075,6 +1215,80 @@ namespace CsharpAPITest
}
[Test]
+ public void TestMutexStatPrint()
+ {
+ testName = "TestMutexStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "Mutex region size",
+ "Mutex region max size",
+ "The number of region locks that required waiting (0%)",
+ "Mutex alignment",
+ "Mutex test-and-set spins",
+ "Mutex initial count",
+ "Mutex total count",
+ "Mutex max count",
+ "Mutex free count",
+ "Mutex in-use count",
+ "Mutex maximum in-use count",
+ "",
+ "Unallocated",
+ "env region",
+ "mutex region",
+ };
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.MutexSystemCfg = new MutexConfig();
+ envConfig.MutexSystemCfg.Alignment = 512;
+ envConfig.MutexSystemCfg.Increment = 128;
+ envConfig.MutexSystemCfg.MaxMutexes = 150;
+ envConfig.MutexSystemCfg.NumTestAndSetSpins = 10;
+
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintMutexSystemStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ if (tempStr[0] != "Mutex counts")
+ {
+ Assert.AreEqual(tempStr[1], messageInfo[counter]);
+ }
+ counter++;
+ }
+ Assert.AreNotEqual(0, counter);
+
+ file.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestLogFile()
{
testName = "TestLogFile";
@@ -1099,8 +1313,10 @@ namespace CsharpAPITest
cfg.LogSystemCfg.FileMode = 755;
cfg.LogSystemCfg.ForceSync = true;
cfg.LogSystemCfg.InMemory = false;
+ cfg.LogSystemCfg.LogBlobContent = false;
cfg.LogSystemCfg.MaxFileSize = 1048576;
cfg.LogSystemCfg.NoBuffer = false;
+ cfg.LogSystemCfg.NoSync = true;
cfg.LogSystemCfg.RegionSize = 204800;
cfg.LogSystemCfg.ZeroOnCreate = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(testHome, cfg);
@@ -1337,6 +1553,7 @@ namespace CsharpAPITest
Assert.AreEqual(testHome, env.Home);
// Print statistics of the current environment.
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintStats();
// Print statistics of all subsytems.
@@ -1346,6 +1563,326 @@ namespace CsharpAPITest
}
[Test]
+ public void TestStatPrint()
+ {
+ testName = "TestStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "Local time",
+ "Magic number",
+ "Panic value",
+ "Environment version",
+ "Btree version",
+ "Hash version",
+ "Lock version",
+ "Log version",
+ "Queue version",
+ "Sequence version",
+ "Txn version",
+ "Creation time",
+ "Environment ID",
+ "Primary region allocation and reference count mutex [0/4 0% !Own], env region (alloc)",
+ "References",
+ "Current region size",
+ "Maximum region size",
+ "Process failure detected" // This appears only with HAVE_FAILCHK_BROADCAST.
+ };
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.FreeThreaded = true;
+ envConfig.LockTimeout = 1000;
+ envConfig.MPoolSystemCfg = new MPoolConfig();
+ envConfig.MPoolSystemCfg.CacheSize = new CacheInfo(0, 104800, 1);
+ envConfig.NoLocking = false;
+ envConfig.TxnTimeout = 2000;
+ envConfig.UseLocking = true;
+ envConfig.UseMPool = true;
+ envConfig.UseTxns = true;
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ Assert.AreEqual(messageInfo[counter], tempStr[1]);
+ counter++;
+ }
+ Assert.AreNotEqual(0, counter);
+
+ file.Close();
+ env.Close();
+ }
+
+ [Test]
+ public void TestSubsystemStatPrint()
+ {
+ testName = "TestSubsystemStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "Local time",
+ "Magic number",
+ "Panic value",
+ "Environment version",
+ "Btree version",
+ "Hash version",
+ "Lock version",
+ "Log version",
+ "Queue version",
+ "Sequence version",
+ "Txn version",
+ "Creation time",
+ "Environment ID",
+ "Primary region allocation and reference count mutex [0/4 0% !Own], env region (alloc)",
+ "References",
+ "Current region size",
+ "Maximum region size",
+ "",
+ "Log magic number",
+ "Log version number",
+ "Log record cache size",
+ "Log file mode",
+ "Current log file size",
+ "Initial fileid allocation",
+ "Current fileids in use",
+ "Maximum fileids used",
+ "Records entered into the log",
+ "Log bytes written",
+ "Log bytes written since last checkpoint",
+ "Total log file I/O writes",
+ "Total log file I/O writes due to overflow",
+ "Total log file flushes",
+ "Total log file I/O reads",
+ "Current log file number",
+ "Current log file offset",
+ "On-disk log file number",
+ "On-disk log file offset",
+ "Maximum commits in a log flush",
+ "Minimum commits in a log flush",
+ "Region size",
+ "The number of region locks that required waiting (0%)",
+ "",
+ "",
+ "Last allocated locker ID",
+ "Current maximum unused locker ID",
+ "Number of lock modes",
+ "Initial number of locks allocated",
+ "Initial number of lockers allocated",
+ "Initial number of lock objects allocated",
+ "Maximum number of locks possible",
+ "Maximum number of lockers possible",
+ "Maximum number of lock objects possible",
+ "Current number of locks allocated",
+ "Current number of lockers allocated",
+ "Current number of lock objects allocated",
+ "Number of lock object partitions",
+ "Size of object hash table",
+ "Number of current locks",
+ "Maximum number of locks at any one time",
+ "Maximum number of locks in any one bucket",
+ "Maximum number of locks stolen by for an empty partition",
+ "Maximum number of locks stolen for any one partition",
+ "Number of current lockers",
+ "Maximum number of lockers at any one time",
+ "Number of hits in the thread locker cache",
+ "Total number of lockers reused",
+ "Number of current lock objects",
+ "Maximum number of lock objects at any one time",
+ "Maximum number of lock objects in any one bucket",
+ "Maximum number of objects stolen by for an empty partition",
+ "Maximum number of objects stolen for any one partition",
+ "Total number of locks requested",
+ "Total number of locks released",
+ "Total number of locks upgraded",
+ "Total number of locks downgraded",
+ "Lock requests not available due to conflicts, for which we waited",
+ "Lock requests not available due to conflicts, for which we did not wait",
+ "Number of deadlocks",
+ "Lock timeout value",
+ "Number of locks that have timed out",
+ "Transaction timeout value",
+ "Number of transactions that have timed out",
+ "Region size",
+ "The number of partition locks that required waiting (0%)",
+ "The maximum number of times any partition lock was waited for (0%)",
+ "The number of object queue operations that required waiting (0%)",
+ "The number of locker allocations that required waiting (0%)",
+ "The number of region locks that required waiting (0%)",
+ "Maximum hash bucket length",
+ "",
+ "Total cache size",
+ "Number of caches",
+ "Maximum number of caches",
+ "Pool individual cache size",
+ "Pool individual cache max",
+ "Maximum memory-mapped file size",
+ "Maximum open file descriptors",
+ "Maximum sequential buffer writes",
+ "Sleep after writing maximum sequential buffers",
+ "Requested pages mapped into the process' address space",
+ "Requested pages found in the cache (0%)",
+ "Requested pages not found in the cache",
+ "Pages created in the cache",
+ "Pages read into the cache",
+ "Pages written from the cache to the backing file",
+ "Clean pages forced from the cache",
+ "Dirty pages forced from the cache",
+ "Dirty pages written by trickle-sync thread",
+ "Current total page count",
+ "Current clean page count",
+ "Current dirty page count",
+ "Number of hash buckets used for page location",
+ "Number of mutexes for the hash buckets",
+ "Assumed page size used",
+ "Total number of times hash chains searched for a page",
+ "The longest hash chain searched for a page",
+ "Total number of hash chain entries checked for page",
+ "The number of hash bucket locks that required waiting (0%)",
+ "The maximum number of times any hash bucket lock was waited for (0%)",
+ "The number of region locks that required waiting (0%)",
+ "The number of buffers frozen",
+ "The number of buffers thawed",
+ "The number of frozen buffers freed",
+ "The number of outdated intermediate versions reused",
+ "The number of page allocations",
+ "The number of hash buckets examined during allocations",
+ "The maximum number of hash buckets examined for an allocation",
+ "The number of pages examined during allocations",
+ "The max number of pages examined for an allocation",
+ "Threads waited on page I/O",
+ "The number of times a sync is interrupted",
+ "",
+ "No checkpoint LSN",
+ "Checkpoint timestamp",
+ "Last transaction ID allocated",
+ "Maximum number of active transactions configured",
+ "Initial number of transactions configured",
+ "Active transactions",
+ "Maximum active transactions",
+ "Number of transactions begun",
+ "Number of transactions aborted",
+ "Number of transactions committed",
+ "Snapshot transactions",
+ "Maximum snapshot transactions",
+ "Number of transactions restored",
+ "Region size",
+ "The number of region locks that required waiting (0%)",
+ "",
+ "",
+ "Mutex region size",
+ "Mutex region max size",
+ "The number of region locks that required waiting (0%)",
+ "Mutex alignment",
+ "Mutex test-and-set spins",
+ "Mutex initial count",
+ "Mutex total count",
+ "Mutex max count",
+ "Mutex free count",
+ "Mutex in-use count",
+ "Mutex maximum in-use count",
+ "",
+ "Unallocated",
+ "env dblist",
+ "env handle",
+ "env region",
+ "lock region",
+ "log filename",
+ "log flush",
+ "log region",
+ "mpool file bucket",
+ "mpool handle",
+ "mpool hash bucket",
+ "mpool region",
+ "mutex region",
+ "twister",
+ "txn active list",
+ "transaction checkpoint"
+ };
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.FreeThreaded = true;
+ envConfig.LockTimeout = 1000;
+ envConfig.MPoolSystemCfg = new MPoolConfig();
+ envConfig.MPoolSystemCfg.CacheSize = new CacheInfo(0, 104800, 1);
+ envConfig.NoLocking = false;
+ envConfig.TxnTimeout = 2000;
+ envConfig.UseLocking = true;
+ envConfig.UseMPool = true;
+ envConfig.UseTxns = true;
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintSubsystemStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ if (tempStr[0] != "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" &&
+ tempStr[0] != "Active transactions:" && tempStr[0] != "Mutex counts")
+ {
+ // Ignore statistics lines which appear only some of the time.
+ if (tempStr[1] == "Process failure detected")
+ continue;
+ Assert.AreEqual(messageInfo[counter], tempStr[1]);
+ }
+ counter++;
+ }
+ Assert.AreNotEqual(0, counter);
+
+ file.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestMPoolSystemStats()
{
testName = "TestMPoolSystemStats";
@@ -1367,6 +1904,7 @@ namespace CsharpAPITest
testHome, envConfig);
MPoolStats stats = env.MPoolSystemStats();
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintMPoolSystemStats();
Assert.AreEqual(0, stats.BlockedOperations);
@@ -1399,6 +1937,8 @@ namespace CsharpAPITest
Assert.AreEqual(0, stats.MaxMMapSize);
Assert.AreEqual(0, stats.MaxOpenFileDescriptors);
Assert.AreEqual(0, stats.MaxPagesCheckedDuringAlloc);
+ Assert.AreEqual(0, stats.OddFileSizeDetected);
+ Assert.AreEqual(0, stats.OddFileSizeResolve);
Assert.AreEqual(0, stats.PageAllocations);
Assert.AreEqual(0, stats.Pages);
Assert.AreEqual(0, stats.PagesCheckedDuringAlloc);
@@ -1461,6 +2001,100 @@ namespace CsharpAPITest
}
[Test]
+ public void TestMPoolStatPrint()
+ {
+ testName = "TestMPoolStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "Total cache size",
+ "Number of caches",
+ "Maximum number of caches",
+ "Pool individual cache size",
+ "Pool individual cache max",
+ "Maximum memory-mapped file size",
+ "Maximum open file descriptors",
+ "Maximum sequential buffer writes",
+ "Sleep after writing maximum sequential buffers",
+ "Requested pages mapped into the process' address space",
+ "Requested pages found in the cache (0%)",
+ "Requested pages not found in the cache",
+ "Pages created in the cache",
+ "Pages read into the cache",
+ "Pages written from the cache to the backing file",
+ "Clean pages forced from the cache",
+ "Dirty pages forced from the cache",
+ "Dirty pages written by trickle-sync thread",
+ "Current total page count",
+ "Current clean page count",
+ "Current dirty page count",
+ "Number of hash buckets used for page location",
+ "Number of mutexes for the hash buckets",
+ "Assumed page size used",
+ "Total number of times hash chains searched for a page",
+ "The longest hash chain searched for a page",
+ "Total number of hash chain entries checked for page",
+ "The number of hash bucket locks that required waiting (0%)",
+ "The maximum number of times any hash bucket lock was waited for (0%)",
+ "The number of region locks that required waiting (0%)",
+ "The number of buffers frozen",
+ "The number of buffers thawed",
+ "The number of frozen buffers freed",
+ "The number of outdated intermediate versions reused",
+ "The number of page allocations",
+ "The number of hash buckets examined during allocations",
+ "The maximum number of hash buckets examined for an allocation",
+ "The number of pages examined during allocations",
+ "The max number of pages examined for an allocation",
+ "Threads waited on page I/O",
+ "The number of times a sync is interrupted"
+ };
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.MPoolSystemCfg = new MPoolConfig();
+ envConfig.MPoolSystemCfg.CacheSize = new CacheInfo(0, 104800, 1);
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintMPoolSystemStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ Assert.AreEqual(messageInfo[counter], tempStr[1]);
+ counter++;
+ }
+ Assert.AreNotEqual(0, counter);
+
+ file.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestRemove()
{
testName = "TestRemove";
@@ -1779,7 +2413,7 @@ namespace CsharpAPITest
envConfig.Create = true;
envConfig.MaxTransactions = 50;
envConfig.UseLogging = true;
- envConfig.UseLocking = true;
+ envConfig.UseLocking = true;
envConfig.UseMPool = true;
envConfig.UseTxns = true;
envConfig.TxnNoSync = false;
@@ -1796,6 +2430,7 @@ namespace CsharpAPITest
{
// Confirm initial transaction subsystem statistics.
stats = env.TransactionSystemStats();
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintTransactionSystemStats(true, true);
Assert.AreEqual(0, stats.Aborted);
Assert.AreEqual(0, stats.Active);
@@ -1948,6 +2583,96 @@ namespace CsharpAPITest
}
}
+ [Test]
+ public void TestTransactionStatPrint()
+ {
+ testName = "TestTransactionStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "No checkpoint LSN",
+ "Checkpoint timestamp",
+ "Last transaction ID allocated",
+ "Maximum number of active transactions configured",
+ "Initial number of transactions configured",
+ "Active transactions",
+ "Maximum active transactions",
+ "Number of transactions begun",
+ "Number of transactions aborted",
+ "Number of transactions committed",
+ "Snapshot transactions",
+ "Maximum snapshot transactions",
+ "Number of transactions restored",
+ "Region size",
+ "The number of region locks that required waiting (0%)",
+ ""
+ };
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.FreeThreaded = true;
+ envConfig.LockTimeout = 1000;
+ envConfig.MPoolSystemCfg = new MPoolConfig();
+ envConfig.MPoolSystemCfg.CacheSize = new CacheInfo(0, 104800, 1);
+ envConfig.UseLocking = true;
+ envConfig.UseMPool = true;
+ envConfig.UseTxns = true;
+ envConfig.MaxTransactions = 50;
+
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ //Begin a transaction called openTxn and open a database.
+ Transaction openTxn = null;
+ TransactionConfig openTxnCfg = new TransactionConfig();
+ openTxnCfg.Name = "openTxn";
+ openTxn = env.BeginTransaction(openTxnCfg);
+ openTxn.Priority = 50;
+ BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
+ dbConfig.Creation = CreatePolicy.IF_NEEDED;
+ dbConfig.Env = env;
+ BTreeDatabase db;
+ db = BTreeDatabase.Open(testName + ".db", dbConfig, openTxn);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintTransactionSystemStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ if (tempStr[0] == "Active transactions:")
+ break;
+ Assert.AreEqual(messageInfo[counter], tempStr[1]);
+ counter++;
+ }
+ Assert.AreNotEqual(0, counter);
+
+ openTxn.Commit();
+ file.Close();
+ env.Close();
+ }
+
/*
* Configure an environment. Here only configure those that could be
* set before environment open.
@@ -2145,7 +2870,12 @@ namespace CsharpAPITest
Configuration.ConfirmBool(childElem,
"InMemory", env.LogInMemory, compulsory);
Configuration.ConfirmBool(childElem,
+ "LogBlobContent", env.LogBlobContent,
+ compulsory);
+ Configuration.ConfirmBool(childElem,
"NoBuffer", env.LogNoBuffer, compulsory);
+ Configuration.ConfirmBool(childElem,
+ "NoSync", env.LogNoSync, compulsory);
Configuration.ConfirmUint(childElem,
"RegionSize", env.LogRegionSize,
compulsory);
diff --git a/test/csharp/DatabaseExceptionTest.cs b/test/csharp/DatabaseExceptionTest.cs
index e5240f31..de509083 100644
--- a/test/csharp/DatabaseExceptionTest.cs
+++ b/test/csharp/DatabaseExceptionTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/DatabaseTest.cs b/test/csharp/DatabaseTest.cs
index c144ff71..e608ad53 100644
--- a/test/csharp/DatabaseTest.cs
+++ b/test/csharp/DatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/DotNetTest.csproj b/test/csharp/DotNetTest.csproj
index 87fd9875..1d3ac40c 100644
--- a/test/csharp/DotNetTest.csproj
+++ b/test/csharp/DotNetTest.csproj
@@ -106,8 +106,8 @@
IF $(ConfigurationName) == Debug SET LIBEXT=d
IF $(ConfigurationName) == Release SET LIBEXT
-copy /B "$(SolutionDir)Win32\$(ConfigurationName)\libdb53%25LIBEXT%25.dll" "$(TargetDir)"
-copy /B "$(SolutionDir)Win32\$(ConfigurationName)\libdb_csharp53%25LIBEXT%25.dll" "$(TargetDir)"
+copy /B "$(SolutionDir)Win32\$(ConfigurationName)\libdb61%25LIBEXT%25.dll" "$(TargetDir)"
+copy /B "$(SolutionDir)Win32\$(ConfigurationName)\libdb_csharp61%25LIBEXT%25.dll" "$(TargetDir)"
copy "$(ProjectDir)AllTestData.xml" "$(TargetDir)"
</PreBuildEvent>
</PropertyGroup>
diff --git a/test/csharp/ForeignKeyTest.cs b/test/csharp/ForeignKeyTest.cs
index c4b54c5b..3f0b7295 100644
--- a/test/csharp/ForeignKeyTest.cs
+++ b/test/csharp/ForeignKeyTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/HashCursorTest.cs b/test/csharp/HashCursorTest.cs
index f6b4235f..0cd54627 100644
--- a/test/csharp/HashCursorTest.cs
+++ b/test/csharp/HashCursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/HashDatabaseConfigTest.cs b/test/csharp/HashDatabaseConfigTest.cs
index 2c74f2da..dedc1e8e 100644
--- a/test/csharp/HashDatabaseConfigTest.cs
+++ b/test/csharp/HashDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/HashDatabaseTest.cs b/test/csharp/HashDatabaseTest.cs
index cba722f8..b03319d9 100644
--- a/test/csharp/HashDatabaseTest.cs
+++ b/test/csharp/HashDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -25,6 +25,242 @@ namespace CsharpAPITest
base.SetUpTestfixture();
}
+ [Test]
+ public void TestBlob() {
+ testName = "TestBlob";
+ SetUpTest(false);
+ // Test opening the blob database without environment.
+ TestBlobHashDatabase(0, null, 6, null, false);
+
+ /*
+ * Test opening the blob database without environment
+ * but specifying blob directory.
+ */
+ TestBlobHashDatabase(0, null, 6, testHome + "/DBBLOB", true);
+
+ // Test opening the blob database with environment.
+ TestBlobHashDatabase(3, "ENVBLOB", 6, null, false);
+
+ /*
+ * Test opening the blob database with environment
+ * and specifying blob directory.
+ */
+ TestBlobHashDatabase(3, null, 6, "/DBBLOB", true);
+ }
+
+ /*
+ * Test the blob database with or without environment.
+ * 1. Config and open the environment;
+ * 2. Verify the environment blob configs;
+ * 3. Config and open the database;
+ * 4. Verify the database blob configs;
+ * 5. Insert and verify some blob data by database methods;
+ * 6. Insert some blob data by cursor, update it and verify
+ * the update by database stream and cursor;
+ * 7. Verify the stats;
+ * 8. Close all handles.
+ * If "blobdbt" is true, set the data DatabaseEntry.Blob as
+ * true, otherwise make the data DatabaseEntry reach the blob
+ * threshold in size.
+ */
+ void TestBlobHashDatabase(uint env_threshold, string env_blobdir,
+ uint db_threshold, string db_blobdir, bool blobdbt)
+ {
+ if (env_threshold == 0 && db_threshold == 0)
+ return;
+
+ string hashDBName =
+ testHome + "/" + testName + ".db";
+
+ Configuration.ClearDir(testHome);
+ HashDatabaseConfig cfg = new HashDatabaseConfig();
+ cfg.Creation = CreatePolicy.ALWAYS;
+ string blrootdir = "__db_bl";
+
+ // Open the environment and verify the blob config.
+ if (env_threshold > 0)
+ {
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.AutoCommit = true;
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ envConfig.UseLogging = true;
+ envConfig.UseTxns = true;
+ envConfig.UseLocking = true;
+ envConfig.BlobThreshold = env_threshold;
+ if (env_blobdir != null)
+ {
+ envConfig.BlobDir = env_blobdir;
+ blrootdir = env_blobdir;
+ }
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+ if (env_blobdir == null)
+ Assert.IsNull(env.BlobDir);
+ else
+ Assert.AreEqual(0,
+ env.BlobDir.CompareTo(env_blobdir));
+ Assert.AreEqual(env_threshold, env.BlobThreshold);
+ cfg.Env = env;
+ hashDBName = testName + ".db";
+ }
+
+ // Open the database and verify the blob config.
+ if (db_threshold > 0)
+ cfg.BlobThreshold = db_threshold;
+ if (db_blobdir != null)
+ {
+ cfg.BlobDir = db_blobdir;
+ /*
+ * The blob directory setting in the database
+ * is effective only when it is opened without
+ * an environment.
+ */
+ if (cfg.Env == null)
+ blrootdir = db_blobdir;
+ }
+
+ HashDatabase db = HashDatabase.Open(hashDBName, cfg);
+ Assert.AreEqual(
+ db_threshold > 0 ? db_threshold : env_threshold,
+ db.BlobThreshold);
+ if (db_blobdir == null && cfg.Env == null)
+ Assert.IsNull(db.BlobDir);
+ else
+ Assert.AreEqual(0,
+ db.BlobDir.CompareTo(blrootdir));
+
+ // Insert and verify some blob data by database methods.
+ string[] records = {"a", "b", "c", "d", "e", "f", "g", "h",
+ "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
+ "t", "u", "v", "w", "x", "y", "z"};
+ DatabaseEntry kdbt = new DatabaseEntry();
+ DatabaseEntry ddbt = new DatabaseEntry();
+ byte[] kdata, ddata;
+ string str;
+ KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
+ ddbt.Blob = blobdbt;
+ Assert.AreEqual(blobdbt, ddbt.Blob);
+ for (int i = 0; i < records.Length; i++)
+ {
+ kdata = BitConverter.GetBytes(i);
+ str = records[i];
+ if (!blobdbt)
+ {
+ for (int j = 0; j < db_threshold; j++)
+ str = str + records[i];
+ }
+ ddata = Encoding.ASCII.GetBytes(str);
+ kdbt.Data = kdata;
+ ddbt.Data = ddata;
+ db.Put(kdbt, ddbt);
+ try
+ {
+ pair = db.Get(kdbt);
+ }
+ catch (DatabaseException)
+ {
+ db.Close();
+ if (cfg.Env != null)
+ cfg.Env.Close();
+ throw new TestException();
+ }
+ Assert.AreEqual(ddata, pair.Value.Data);
+ }
+
+ /*
+ * Insert some blob data by cursor, update it and verify
+ * the update by database stream.
+ */
+ kdata = BitConverter.GetBytes(records.Length);
+ ddata = Encoding.ASCII.GetBytes("abc");
+ kdbt.Data = kdata;
+ ddbt.Data = ddata;
+ ddbt.Blob = true;
+ Assert.IsTrue(ddbt.Blob);
+ pair =
+ new KeyValuePair<DatabaseEntry, DatabaseEntry>(kdbt, ddbt);
+ CursorConfig dbcConfig = new CursorConfig();
+ Transaction txn = null;
+ if (cfg.Env != null)
+ txn = cfg.Env.BeginTransaction();
+ HashCursor cursor = db.Cursor(dbcConfig, txn);
+ cursor.Add(pair);
+ DatabaseStreamConfig dbsc = new DatabaseStreamConfig();
+ dbsc.SyncPerWrite = true;
+ DatabaseStream dbs = cursor.DbStream(dbsc);
+ Assert.AreNotEqual(null, dbs);
+ Assert.IsFalse(dbs.GetConfig.ReadOnly);
+ Assert.IsTrue(dbs.GetConfig.SyncPerWrite);
+ Assert.AreEqual(3, dbs.Size());
+ DatabaseEntry sdbt = dbs.Read(0, 3);
+ Assert.IsNotNull(sdbt);
+ Assert.AreEqual(ddata, sdbt.Data);
+ sdbt = new DatabaseEntry(Encoding.ASCII.GetBytes("defg"));
+ Assert.IsTrue(dbs.Write(sdbt, 3));
+ Assert.AreEqual(7, dbs.Size());
+ sdbt = dbs.Read(0, 7);
+ Assert.IsNotNull(sdbt);
+ Assert.AreEqual(Encoding.ASCII.GetBytes("abcdefg"), sdbt.Data);
+ dbs.Close();
+
+ /*
+ * Verify the database stream can not write when it is
+ * configured to be read-only.
+ */
+ dbsc.ReadOnly = true;
+ dbs = cursor.DbStream(dbsc);
+ Assert.IsTrue(dbs.GetConfig.ReadOnly);
+ try
+ {
+ Assert.IsFalse(dbs.Write(sdbt, 7));
+ throw new TestException();
+ }
+ catch (DatabaseException)
+ {
+ }
+ dbs.Close();
+
+ // Verify the update by cursor.
+ Assert.IsTrue(cursor.Move(kdbt, true));
+ pair = cursor.Current;
+ Assert.AreEqual(Encoding.ASCII.GetBytes("abcdefg"),
+ pair.Value.Data);
+ cursor.Close();
+ if (cfg.Env != null)
+ txn.Commit();
+
+ /*
+ * Verify the blob files are created in the expected location.
+ * This part of test is disabled since BTreeDatabase.BlobSubDir
+ * is not exposed to users.
+ */
+ //if (cfg.Env != null)
+ // blrootdir = testHome + "/" + blrootdir;
+ //string blobdir = blrootdir + "/" + db.BlobSubDir;
+ //Assert.AreEqual(records.Length + 1,
+ // Directory.GetFiles(blobdir, "__db.bl*").Length);
+ //Assert.AreEqual(1,
+ // Directory.GetFiles(blobdir, "__db_blob_meta.db").Length);
+
+ // Verify the stats.
+ HashStats st = db.Stats();
+ Assert.AreEqual(records.Length + 1, st.nBlobRecords);
+
+ // Close all handles.
+ db.Close();
+ if (cfg.Env != null)
+ cfg.Env.Close();
+
+ /*
+ * Remove the default blob directory
+ * when it is not under the test home.
+ */
+ if (db_blobdir == null && cfg.Env == null)
+ Directory.Delete("__db_bl", true);
+ }
+
[Test]
public void TestCompactWithoutTxn() {
int i, nRecs;
@@ -163,6 +399,60 @@ namespace CsharpAPITest
}
[Test]
+ public void TestMessageFile()
+ {
+ testName = "TestMessageFile";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+
+ // Configure and open a database.
+ HashDatabaseConfig DBConfig =
+ new HashDatabaseConfig();
+ DBConfig.Env = env;
+ DBConfig.Creation = CreatePolicy.IF_NEEDED;
+
+ string DBFileName = testName + ".db";
+ HashDatabase db = HashDatabase.Open(DBFileName, DBConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of db.
+ db.Msgfile = messageFile;
+
+ // Print db statistic to message file.
+ db.PrintStats(true);
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ db.Msgfile = "";
+ string line = null;
+
+ // Read the third line of message file.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ line = file.ReadLine();
+ line = file.ReadLine();
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, "DB handle information:");
+ file.Close();
+
+ // Close database and environment.
+ db.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestOpenNewHashDB()
{
testName = "TestOpenNewHashDB";
@@ -463,7 +753,7 @@ namespace CsharpAPITest
{
Assert.AreEqual(10, stats.FillFactor);
Assert.AreEqual(4096, stats.PageSize);
- Assert.AreNotEqual(0, stats.Version);
+ Assert.AreEqual(10, stats.Version);
}
public void ConfirmStatsPart2Case1(HashStats stats)
diff --git a/test/csharp/HeapDatabaseConfigTest.cs b/test/csharp/HeapDatabaseConfigTest.cs
index 6db7bd93..a3f65f81 100644
--- a/test/csharp/HeapDatabaseConfigTest.cs
+++ b/test/csharp/HeapDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/HeapDatabaseTest.cs b/test/csharp/HeapDatabaseTest.cs
index c0461e8b..3270710b 100644
--- a/test/csharp/HeapDatabaseTest.cs
+++ b/test/csharp/HeapDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -94,6 +94,175 @@ namespace CsharpAPITest {
}
+ [Test]
+ public void TestBlob() {
+ testName = "TestBlob";
+ SetUpTest(false);
+ // Test opening the blob database without environment.
+ TestBlobHeapDatabase(0, null, 6, null, false);
+
+ /*
+ * Test opening the blob database without environment
+ * but specifying blob directory.
+ */
+ TestBlobHeapDatabase(0, null, 6, testHome + "/DBBLOB", true);
+
+ // Test opening the blob database with environment.
+ TestBlobHeapDatabase(3, "ENVBLOB", 6, null, false);
+
+ /*
+ * Test opening the blob database with environment
+ * and specifying blob directory.
+ */
+ TestBlobHeapDatabase(3, null, 6, "/DBBLOB", true);
+ }
+
+ /*
+ * Test the blob database with or without environment.
+ * 1. Config and open the environment;
+ * 2. Verify the environment blob configs;
+ * 3. Config and open the database;
+ * 4. Verify the database blob configs;
+ * 5. Insert and verify some blob data by database methods;
+ * 6. Verify the stats;
+ * 7. Close all handles.
+ * If "blobdbt" is true, set the data DatabaseEntry.Blob as
+ * true, otherwise make the data DatabaseEntry reach the blob
+ * threshold in size.
+ */
+ void TestBlobHeapDatabase(uint env_threshold, string env_blobdir,
+ uint db_threshold, string db_blobdir, bool blobdbt)
+ {
+ if (env_threshold == 0 && db_threshold == 0)
+ return;
+
+ string heapDBName =
+ testHome + "/" + testName + ".db";
+
+ Configuration.ClearDir(testHome);
+ HeapDatabaseConfig cfg = new HeapDatabaseConfig();
+ cfg.Creation = CreatePolicy.ALWAYS;
+ string blrootdir = "__db_bl";
+
+ // Open the environment and verify the blob configs.
+ if (env_threshold > 0)
+ {
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.AutoCommit = true;
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ envConfig.UseLogging = true;
+ envConfig.UseTxns = true;
+ envConfig.UseLocking = true;
+ envConfig.BlobThreshold = env_threshold;
+ if (env_blobdir != null)
+ {
+ envConfig.BlobDir = env_blobdir;
+ blrootdir = env_blobdir;
+ }
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+ if (env_blobdir == null)
+ Assert.IsNull(env.BlobDir);
+ else
+ Assert.AreEqual(0,
+ env.BlobDir.CompareTo(env_blobdir));
+ Assert.AreEqual(env_threshold, env.BlobThreshold);
+ cfg.Env = env;
+ heapDBName = testName + ".db";
+ }
+
+ // Open the database and verify the blob configs.
+ if (db_threshold > 0)
+ cfg.BlobThreshold = db_threshold;
+ if (db_blobdir != null)
+ {
+ cfg.BlobDir = db_blobdir;
+ /*
+ * The blob directory setting in the database
+ * is effective only when it is opened without
+ * an environment.
+ */
+ if (cfg.Env == null)
+ blrootdir = db_blobdir;
+ }
+
+ HeapDatabase db = HeapDatabase.Open(heapDBName, cfg);
+ Assert.AreEqual(
+ db_threshold > 0 ? db_threshold : env_threshold,
+ db.BlobThreshold);
+ if (db_blobdir == null && cfg.Env == null)
+ Assert.IsNull(db.BlobDir);
+ else
+ Assert.AreEqual(0, db.BlobDir.CompareTo(blrootdir));
+
+ // Insert and verify some blob data by database methods.
+ string[] records = {"a", "b", "c", "d", "e", "f", "g", "h",
+ "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
+ "t", "u", "v", "w", "x", "y", "z"};
+ DatabaseEntry kdbt = new DatabaseEntry();
+ DatabaseEntry ddbt = new DatabaseEntry();
+ byte[] ddata;
+ string str;
+ KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
+ ddbt.Blob = blobdbt;
+ Assert.AreEqual(blobdbt, ddbt.Blob);
+ for (int i = 0; i < records.Length; i++)
+ {
+ str = records[i];
+ if (!blobdbt)
+ {
+ for (int j = 0; j < db_threshold; j++)
+ str = str + records[i];
+ }
+ ddata = Encoding.ASCII.GetBytes(str);
+ ddbt.Data = ddata;
+ kdbt = new DatabaseEntry((db.Append(ddbt)).toArray()) ;
+ try
+ {
+ pair = db.Get(kdbt);
+ }
+ catch (DatabaseException)
+ {
+ db.Close();
+ if (cfg.Env != null)
+ cfg.Env.Close();
+ throw new TestException();
+ }
+ Assert.AreEqual(ddata, pair.Value.Data);
+ }
+
+ /*
+ * Verify the blob files are created in the expected location.
+ * This part of test is disabled since BTreeDatabase.BlobSubDir
+ * is not exposed to users.
+ */
+ //if (cfg.Env != null)
+ // blrootdir = testHome + "/" + blrootdir;
+ //string blobdir = blrootdir + "/" + db.BlobSubDir;
+ //Assert.AreEqual(records.Length,
+ // Directory.GetFiles(blobdir, "__db.bl*").Length);
+ //Assert.AreEqual(1,
+ // Directory.GetFiles(blobdir, "__db_blob_meta.db").Length);
+
+ // Verify the stats.
+ HeapStats st = db.Stats();
+ Assert.AreEqual(records.Length, st.nBlobRecords);
+
+ // Close all handles.
+ db.Close();
+ if (cfg.Env != null)
+ cfg.Env.Close();
+
+ /*
+ * Remove the default blob directory
+ * when it is not under the test home.
+ */
+ if (db_blobdir == null && cfg.Env == null)
+ Directory.Delete("__db_bl", true);
+ }
+
[Test]
public void TestCursor() {
testName = "TestCursor";
@@ -214,6 +383,60 @@ namespace CsharpAPITest {
}
[Test]
+ public void TestMessageFile()
+ {
+ testName = "TestMessageFile";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+
+ // Configure and open a database.
+ HeapDatabaseConfig DBConfig =
+ new HeapDatabaseConfig();
+ DBConfig.Env = env;
+ DBConfig.Creation = CreatePolicy.IF_NEEDED;
+
+ string DBFileName = testName + ".db";
+ HeapDatabase db = HeapDatabase.Open(DBFileName, DBConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of db.
+ db.Msgfile = messageFile;
+
+ // Print db statistic to message file.
+ db.PrintStats(true);
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ db.Msgfile = "";
+ string line = null;
+
+ // Read the third line of message file.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ line = file.ReadLine();
+ line = file.ReadLine();
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, "DB handle information:");
+ file.Close();
+
+ // Close database and environment.
+ db.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestOpenExistingHeapDB() {
testName = "TestOpenExistingHeapDB";
SetUpTest(true);
@@ -300,6 +523,7 @@ namespace CsharpAPITest {
HeapStats stats = db.Stats();
ConfirmStatsPart1Case1(stats);
+ db.Msgfile = testHome + "/" + testName+ ".log";
db.PrintFastStats(true);
// Put 500 records into the database.
@@ -385,6 +609,7 @@ namespace CsharpAPITest {
stats = db.Stats(statsTxn, Isolation.DEGREE_ONE);
ConfirmStatsPart1Case1(stats);
+ db.Msgfile = home + "/" + name+ ".log";
db.PrintStats(true);
// Put 500 records into the database.
@@ -438,7 +663,7 @@ namespace CsharpAPITest {
Assert.AreNotEqual(0, stats.MagicNumber);
Assert.AreEqual(4096, stats.PageSize);
Assert.AreNotEqual(0, stats.RegionSize);
- Assert.AreNotEqual(0, stats.Version);
+ Assert.AreEqual(2, stats.Version);
}
public void ConfirmStatsPart2Case1(HeapStats stats) {
diff --git a/test/csharp/JoinCursorTest.cs b/test/csharp/JoinCursorTest.cs
index de40338b..18d279ad 100644
--- a/test/csharp/JoinCursorTest.cs
+++ b/test/csharp/JoinCursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/LockTest.cs b/test/csharp/LockTest.cs
index 55237e6f..ea2115e6 100644
--- a/test/csharp/LockTest.cs
+++ b/test/csharp/LockTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -60,6 +60,7 @@ namespace CsharpAPITest {
// Get and confirm locking subsystem statistics.
LockStats stats = env.LockingSystemStats();
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintLockingSystemStats(true, true);
Assert.AreEqual(0, stats.AllocatedLockers);
Assert.AreNotEqual(0, stats.AllocatedLocks);
@@ -200,6 +201,115 @@ namespace CsharpAPITest {
env.Close();
}
+
+ [Test]
+ public void TestLockStatPrint()
+ {
+ testName = "TestLockStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "Last allocated locker ID",
+ "Current maximum unused locker ID",
+ "Number of lock modes",
+ "Initial number of locks allocated",
+ "Initial number of lockers allocated",
+ "Initial number of lock objects allocated",
+ "Maximum number of locks possible",
+ "Maximum number of lockers possible",
+ "Maximum number of lock objects possible",
+ "Current number of locks allocated",
+ "Current number of lockers allocated",
+ "Current number of lock objects allocated",
+ "Number of lock object partitions",
+ "Size of object hash table",
+ "Number of current locks",
+ "Maximum number of locks at any one time",
+ "Maximum number of locks in any one bucket",
+ "Maximum number of locks stolen by for an empty partition",
+ "Maximum number of locks stolen for any one partition",
+ "Number of current lockers",
+ "Maximum number of lockers at any one time",
+ "Number of hits in the thread locker cache",
+ "Total number of lockers reused",
+ "Number of current lock objects",
+ "Maximum number of lock objects at any one time",
+ "Maximum number of lock objects in any one bucket",
+ "Maximum number of objects stolen by for an empty partition",
+ "Maximum number of objects stolen for any one partition",
+ "Total number of locks requested",
+ "Total number of locks released",
+ "Total number of locks upgraded",
+ "Total number of locks downgraded",
+ "Lock requests not available due to conflicts, for which we waited",
+ "Lock requests not available due to conflicts, for which we did not wait",
+ "Number of deadlocks",
+ "Lock timeout value",
+ "Number of locks that have timed out",
+ "Transaction timeout value",
+ "Number of transactions that have timed out",
+ "Region size",
+ "The number of partition locks that required waiting (0%)",
+ "The maximum number of times any partition lock was waited for (0%)",
+ "The number of object queue operations that required waiting (0%)",
+ "The number of locker allocations that required waiting (0%)",
+ "The number of region locks that required waiting (0%)",
+ "Maximum hash bucket length"
+ };
+
+ // Configure locking subsystem.
+ LockingConfig lkConfig = new LockingConfig();
+ lkConfig.MaxLockers = 60;
+ lkConfig.MaxLocks = 50;
+ lkConfig.MaxObjects = 70;
+ lkConfig.Partitions = 20;
+ lkConfig.DeadlockResolution = DeadlockPolicy.DEFAULT;
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.LockSystemCfg = lkConfig;
+ envConfig.LockTimeout = 1000;
+ envConfig.NoLocking = false;
+ envConfig.UseLocking = true;
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintLockingSystemStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ Assert.AreEqual(tempStr[1], messageInfo[counter]);
+ counter++;
+ }
+ Assert.AreNotEqual(counter, 0);
+
+ file.Close();
+ env.Close();
+ }
+
public void GenerateDeadlock()
{
Transaction txn = testLockStatsEnv.BeginTransaction();
diff --git a/test/csharp/LockingConfigTest.cs b/test/csharp/LockingConfigTest.cs
index 978bf424..01e138f5 100644
--- a/test/csharp/LockingConfigTest.cs
+++ b/test/csharp/LockingConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/LogConfigTest.cs b/test/csharp/LogConfigTest.cs
index 9c9ee520..fa99a4e5 100644
--- a/test/csharp/LogConfigTest.cs
+++ b/test/csharp/LogConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -61,8 +61,10 @@ namespace CsharpAPITest
cfg.LogSystemCfg.BufferSize = 409600;
cfg.LogSystemCfg.MaxFileSize = 10480;
cfg.LogSystemCfg.NoBuffer = false;
+ cfg.LogSystemCfg.NoSync = true;
cfg.LogSystemCfg.ZeroOnCreate = true;
cfg.LogSystemCfg.InMemory = true;
+ cfg.LogSystemCfg.LogBlobContent = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(testHome, cfg);
BTreeDatabase db;
@@ -146,14 +148,17 @@ namespace CsharpAPITest
cfg.LogSystemCfg.FileMode = 755;
cfg.LogSystemCfg.ForceSync = true;
cfg.LogSystemCfg.InMemory = false;
+ cfg.LogSystemCfg.LogBlobContent = false;
cfg.LogSystemCfg.MaxFileSize = 1048576;
cfg.LogSystemCfg.NoBuffer = false;
+ cfg.LogSystemCfg.NoSync = true;
cfg.LogSystemCfg.RegionSize = 204800;
cfg.LogSystemCfg.ZeroOnCreate = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(testHome, cfg);
LogStats stats = env.LoggingSystemStats();
+ env.Msgfile = testHome + "/" + testName+ ".log";
env.PrintLoggingSystemStats();
Assert.AreEqual(10240, stats.BufferSize);
Assert.AreEqual(1, stats.CurrentFile);
@@ -216,6 +221,98 @@ namespace CsharpAPITest
db.Close();
env.Close();
}
+
+ [Test]
+ public void TestLogStatPrint()
+ {
+ testName = "TestLogStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ {
+ "Log magic number",
+ "Log version number",
+ "Log record cache size",
+ "Log file mode",
+ "Current log file size",
+ "Initial fileid allocation",
+ "Current fileids in use",
+ "Maximum fileids used",
+ "Records entered into the log",
+ "Log bytes written",
+ "Log bytes written since last checkpoint",
+ "Total log file I/O writes",
+ "Total log file I/O writes due to overflow",
+ "Total log file flushes",
+ "Total log file I/O reads",
+ "Current log file number",
+ "Current log file offset",
+ "On-disk log file number",
+ "On-disk log file offset",
+ "Maximum commits in a log flush",
+ "Minimum commits in a log flush",
+ "Region size",
+ "The number of region locks that required waiting (0%)"
+ };
+
+ string logDir = "./";
+ Directory.CreateDirectory(testHome + "/" + logDir);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseTxns = true;
+
+ envConfig.LogSystemCfg = new LogConfig();
+ envConfig.LogSystemCfg.AutoRemove = false;
+ envConfig.LogSystemCfg.BufferSize = 10240;
+ envConfig.LogSystemCfg.Dir = logDir;
+ envConfig.LogSystemCfg.FileMode = 755;
+ envConfig.LogSystemCfg.ForceSync = true;
+ envConfig.LogSystemCfg.InMemory = false;
+ envConfig.LogSystemCfg.LogBlobContent = false;
+ envConfig.LogSystemCfg.MaxFileSize = 1048576;
+ envConfig.LogSystemCfg.NoBuffer = false;
+ envConfig.LogSystemCfg.NoSync = true;
+ envConfig.LogSystemCfg.RegionSize = 204800;
+ envConfig.LogSystemCfg.ZeroOnCreate = true;
+
+ DatabaseEnvironment env =
+ DatabaseEnvironment.Open(testHome, envConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ env.PrintLoggingSystemStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ Assert.AreEqual(tempStr[1], messageInfo[counter]);
+ counter++;
+ }
+ Assert.AreNotEqual(counter, 0);
+
+ file.Close();
+ env.Close();
+ }
[Test]
public void TestLsn()
@@ -247,10 +344,14 @@ namespace CsharpAPITest
logConfig.ForceSync, compulsory);
Configuration.ConfirmBool(xmlElement, "InMemory",
logConfig.InMemory, compulsory);
+ Configuration.ConfirmBool(xmlElement, "LogBlobContent",
+ logConfig.LogBlobContent, compulsory);
Configuration.ConfirmUint(xmlElement, "MaxFileSize",
logConfig.MaxFileSize, compulsory);
Configuration.ConfirmBool(xmlElement, "NoBuffer",
logConfig.NoBuffer, compulsory);
+ Configuration.ConfirmBool(xmlElement, "NoSync",
+ logConfig.NoSync, compulsory);
Configuration.ConfirmUint(xmlElement, "RegionSize",
logConfig.RegionSize, compulsory);
Configuration.ConfirmBool(xmlElement, "ZeroOnCreate",
@@ -277,11 +378,15 @@ namespace CsharpAPITest
ref logConfig.ForceSync, compulsory);
Configuration.ConfigBool(xmlElement, "InMemory",
ref logConfig.InMemory, compulsory);
+ Configuration.ConfigBool(xmlElement, "LogBlobContent",
+ ref logConfig.LogBlobContent, compulsory);
if (Configuration.ConfigUint(xmlElement, "MaxFileSize",
ref uintValue, compulsory))
logConfig.MaxFileSize = uintValue;
Configuration.ConfigBool(xmlElement, "NoBuffer",
ref logConfig.NoBuffer, compulsory);
+ Configuration.ConfigBool(xmlElement, "NoSync",
+ ref logConfig.NoSync, compulsory);
if (Configuration.ConfigUint(xmlElement, "RegionSize",
ref uintValue, compulsory))
logConfig.RegionSize = uintValue;
diff --git a/test/csharp/LogCursorTest.cs b/test/csharp/LogCursorTest.cs
index a3dd1e48..ee6523ac 100644
--- a/test/csharp/LogCursorTest.cs
+++ b/test/csharp/LogCursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/MPoolConfigTest.cs b/test/csharp/MPoolConfigTest.cs
index f87d9f69..82b9b952 100644
--- a/test/csharp/MPoolConfigTest.cs
+++ b/test/csharp/MPoolConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/MutexConfigTest.cs b/test/csharp/MutexConfigTest.cs
index a11f05a2..d262fd06 100644
--- a/test/csharp/MutexConfigTest.cs
+++ b/test/csharp/MutexConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/MutexTest.cs b/test/csharp/MutexTest.cs
index 9563305e..6f2c7fe3 100644
--- a/test/csharp/MutexTest.cs
+++ b/test/csharp/MutexTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/QueueDatabaseConfigTest.cs b/test/csharp/QueueDatabaseConfigTest.cs
index 91f7ffec..7ad25af2 100644
--- a/test/csharp/QueueDatabaseConfigTest.cs
+++ b/test/csharp/QueueDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/QueueDatabaseTest.cs b/test/csharp/QueueDatabaseTest.cs
index d60f6fe0..87477feb 100644
--- a/test/csharp/QueueDatabaseTest.cs
+++ b/test/csharp/QueueDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -442,6 +442,61 @@ namespace CsharpAPITest
}
[Test]
+ public void TestMessageFile()
+ {
+ testName = "TestMessageFile";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+
+ // Configure and open a database.
+ QueueDatabaseConfig DBConfig =
+ new QueueDatabaseConfig();
+ DBConfig.Env = env;
+ DBConfig.Creation = CreatePolicy.IF_NEEDED;
+
+ string DBFileName = testName + ".db";
+ QueueDatabase db = QueueDatabase.Open(
+ DBFileName, DBConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of db.
+ db.Msgfile = messageFile;
+
+ // Print db statistic to message file.
+ db.PrintStats(true);
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ db.Msgfile = "";
+ string line = null;
+
+ // Read the third line of message file.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ line = file.ReadLine();
+ line = file.ReadLine();
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, "DB handle information:");
+ file.Close();
+
+ // Close database and environment.
+ db.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestOpenExistingQueueDB()
{
testName = "TestOpenExistingQueueDB";
@@ -619,6 +674,7 @@ namespace CsharpAPITest
QueueStats stats = db.Stats();
ConfirmStatsPart1Case1(stats);
+ db.Msgfile = testHome + "/" + testName+ ".log";
db.PrintFastStats(true);
// Put 500 records into the database.
@@ -674,6 +730,7 @@ namespace CsharpAPITest
stats = db.Stats(statsTxn, Isolation.DEGREE_ONE);
ConfirmStatsPart1Case1(stats);
+ db.Msgfile = home + "/" + name+ ".log";
db.PrintStats(true);
// Put 500 records into the database.
diff --git a/test/csharp/RecnoCursorTest.cs b/test/csharp/RecnoCursorTest.cs
index 32f6204b..d6a10019 100644
--- a/test/csharp/RecnoCursorTest.cs
+++ b/test/csharp/RecnoCursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/RecnoDatabaseConfigTest.cs b/test/csharp/RecnoDatabaseConfigTest.cs
index aa5ad775..84d98fb3 100644
--- a/test/csharp/RecnoDatabaseConfigTest.cs
+++ b/test/csharp/RecnoDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/RecnoDatabaseTest.cs b/test/csharp/RecnoDatabaseTest.cs
index efa64442..691a20c6 100644
--- a/test/csharp/RecnoDatabaseTest.cs
+++ b/test/csharp/RecnoDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -163,6 +163,61 @@ namespace CsharpAPITest
}
[Test]
+ public void TestMessageFile()
+ {
+ testName = "TestMessageFile";
+ SetUpTest(true);
+
+ // Configure and open an environment.
+ DatabaseEnvironmentConfig envConfig =
+ new DatabaseEnvironmentConfig();
+ envConfig.Create = true;
+ envConfig.UseMPool = true;
+ DatabaseEnvironment env = DatabaseEnvironment.Open(
+ testHome, envConfig);
+
+ // Configure and open a database.
+ RecnoDatabaseConfig DBConfig =
+ new RecnoDatabaseConfig();
+ DBConfig.Env = env;
+ DBConfig.Creation = CreatePolicy.IF_NEEDED;
+
+ string DBFileName = testName + ".db";
+ RecnoDatabase db = RecnoDatabase.Open(
+ DBFileName, DBConfig);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of db.
+ db.Msgfile = messageFile;
+
+ // Print db statistic to message file.
+ db.PrintStats(true);
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ db.Msgfile = "";
+ string line = null;
+
+ // Read the third line of message file.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ line = file.ReadLine();
+ line = file.ReadLine();
+ line = file.ReadLine();
+
+ // Confirm the message file is not empty.
+ Assert.AreEqual(line, "DB handle information:");
+ file.Close();
+
+ // Close database and environment.
+ db.Close();
+ env.Close();
+ }
+
+ [Test]
public void TestStats()
{
testName = "TestStats";
@@ -325,7 +380,7 @@ namespace CsharpAPITest
Assert.AreEqual(4096, stats.PageSize);
Assert.AreEqual(4000, stats.RecordLength);
Assert.AreEqual(256, stats.RecordPadByte);
- Assert.AreEqual(9, stats.Version);
+ Assert.AreEqual(10, stats.Version);
}
public void ConfirmStatsPart2Case1(RecnoStats stats)
diff --git a/test/csharp/ReplicationConfigTest.cs b/test/csharp/ReplicationConfigTest.cs
index 1ccef9c4..e8e6f38c 100644
--- a/test/csharp/ReplicationConfigTest.cs
+++ b/test/csharp/ReplicationConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -49,6 +49,10 @@ namespace CsharpAPITest
repConfig.RetransmissionRequest(10, 100);
Assert.AreEqual(100, repConfig.RetransmissionRequestMax);
Assert.AreEqual(10, repConfig.RetransmissionRequestMin);
+
+ repConfig.RepmgrIncomingQueueMax(123, 456);
+ Assert.AreEqual(123, repConfig.RepmgrIncomingQueueMaxGBytes);
+ Assert.AreEqual(456, repConfig.RepmgrIncomingQueueMaxBytes);
}
[Test]
diff --git a/test/csharp/ReplicationTest.cs b/test/csharp/ReplicationTest.cs
index 6e9fd995..a57455a6 100644
--- a/test/csharp/ReplicationTest.cs
+++ b/test/csharp/ReplicationTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -44,6 +44,196 @@ namespace CsharpAPITest
}
[Test]
+ public void TestReplicationView()
+ {
+ testName = "TestReplicationView";
+ SetUpTest(true);
+
+ string masterHome = testHome + "\\Master";
+ Configuration.ClearDir(masterHome);
+
+ string clientHome1 = testHome + "\\Client1";
+ Configuration.ClearDir(clientHome1);
+
+ string clientHome2 = testHome + "\\Client2";
+ Configuration.ClearDir(clientHome2);
+
+ ports.Clear();
+ AvailablePorts portGen = new AvailablePorts();
+ uint mPort = portGen.Current;
+ portGen.MoveNext();
+ uint cPort1 = portGen.Current;
+ portGen.MoveNext();
+ uint cPort2 = portGen.Current;
+
+ /* Open environment with replication configuration. */
+ DatabaseEnvironmentConfig cfg =
+ new DatabaseEnvironmentConfig();
+ cfg.Create = true;
+ cfg.RunRecovery = true;
+ cfg.UseLocking = true;
+ cfg.UseLogging = true;
+ cfg.UseMPool = true;
+ cfg.UseReplication = true;
+ cfg.FreeThreaded = true;
+ cfg.UseTxns = true;
+ cfg.EventNotify = new EventNotifyDelegate(stuffHappened);
+
+ cfg.RepSystemCfg = new ReplicationConfig();
+ cfg.RepSystemCfg.RepmgrSitesConfig.Add(new DbSiteConfig());
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].Host = "127.0.0.1";
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].Port = mPort;
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].LocalSite = true;
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].GroupCreator = true;
+ cfg.RepSystemCfg.Priority = 100;
+
+ /* Start up the master site. */
+ DatabaseEnvironment mEnv = DatabaseEnvironment.Open(
+ masterHome, cfg);
+ mEnv.DeadlockResolution = DeadlockPolicy.DEFAULT;
+ mEnv.RepMgrStartMaster(2);
+
+ /* Open the environment of the client 1 site. */
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].Port = cPort1;
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].GroupCreator = false;
+ cfg.RepSystemCfg.Priority = 10;
+ cfg.RepSystemCfg.RepmgrSitesConfig.Add(new DbSiteConfig());
+ cfg.RepSystemCfg.RepmgrSitesConfig[1].Host = "127.0.0.1";
+ cfg.RepSystemCfg.RepmgrSitesConfig[1].Port = mPort;
+ cfg.RepSystemCfg.RepmgrSitesConfig[1].Helper = true;
+ /* Set the site as a partial view. */
+ cfg.RepSystemCfg.ReplicationView = repView;
+ DatabaseEnvironment cEnv1 = DatabaseEnvironment.Open(
+ clientHome1, cfg);
+
+ /* Open the environment of the client 2 site. */
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].Port = cPort2;
+ cfg.RepSystemCfg.RepmgrSitesConfig[0].GroupCreator = false;
+ cfg.RepSystemCfg.Priority = 10;
+ /* Set the site as a full view. */
+ cfg.RepSystemCfg.ReplicationView = null;
+ DatabaseEnvironment cEnv2 = DatabaseEnvironment.Open(
+ clientHome2, cfg);
+
+ /*
+ * Create two database files db1.db and db2.db
+ * on the master.
+ */
+ BTreeDatabaseConfig btreeDBConfig =
+ new BTreeDatabaseConfig();
+ btreeDBConfig.Env = mEnv;
+ btreeDBConfig.Creation = CreatePolicy.ALWAYS;
+ btreeDBConfig.AutoCommit = true;
+ BTreeDatabase db1 =
+ BTreeDatabase.Open("db1.db", btreeDBConfig);
+ BTreeDatabase db2 =
+ BTreeDatabase.Open("db2.db", btreeDBConfig);
+ db1.Close();
+ db2.Close();
+
+ /* Start up the client sites. */
+ cEnv1.RepMgrStartClient(2, false);
+ cEnv2.RepMgrStartClient(2, false);
+
+ /* Wait for clients to start up */
+ int i = 0;
+ while (!cEnv1.ReplicationSystemStats().ClientStartupComplete)
+ {
+ if (i < 20)
+ {
+ Thread.Sleep(1000);
+ i++;
+ }
+ else
+ throw new TestException();
+ }
+ i = 0;
+ while (!cEnv2.ReplicationSystemStats().ClientStartupComplete)
+ {
+ if (i < 20)
+ {
+ Thread.Sleep(1000);
+ i++;
+ }
+ else
+ throw new TestException();
+ }
+
+ /*
+ * Verify that the file db2.db is replicated to the
+ * client 2 (full view), but not to the client 1
+ * (partial view), and the file db1.db is
+ * replicated to both sites.
+ */
+ btreeDBConfig.Env = cEnv1;
+ btreeDBConfig.Creation = CreatePolicy.NEVER;
+ db1 = BTreeDatabase.Open("db1.db", btreeDBConfig);
+ try
+ {
+ db2 = BTreeDatabase.Open("db2.db", btreeDBConfig);
+ throw new TestException();
+ }
+ catch (DatabaseException e){
+ Assert.AreEqual(0, String.Compare(
+ "No such file or directory", e.Message));
+ }
+ db1.Close();
+ btreeDBConfig.Env = cEnv2;
+ db1 = BTreeDatabase.Open("db1.db", btreeDBConfig);
+ db2 = BTreeDatabase.Open("db2.db", btreeDBConfig);
+ db1.Close();
+ db2.Close();
+
+ /* Get the replication manager statistic. */
+ RepMgrStats repMgrStats = mEnv.RepMgrSystemStats();
+ Assert.AreEqual(1, repMgrStats.ParticipantSites);
+ Assert.AreEqual(3, repMgrStats.TotalSites);
+ Assert.AreEqual(2, repMgrStats.ViewSites);
+
+ /*
+ * Verify the master is not a view locally
+ * or from remote site.
+ */
+ ReplicationStats repstats =
+ mEnv.ReplicationSystemStats();
+ Assert.AreEqual(false, repstats.View);
+ RepMgrSite[] rsite = cEnv1.RepMgrRemoteSites;
+ Assert.AreEqual(2, rsite.Length);
+ for (i = 0; i < rsite.Length; i++) {
+ if (rsite[i].Address.Port == mPort)
+ break;
+ }
+ Assert.Greater(rsite.Length, i);
+ Assert.AreEqual(false, rsite[i].isView);
+
+ /*
+ * Verify the clients are views locally
+ * and from remote site.
+ */
+ rsite = mEnv.RepMgrRemoteSites;
+ Assert.AreEqual(2, rsite.Length);
+ Assert.AreEqual(true, rsite[0].isView);
+ Assert.AreEqual(true, rsite[1].isView);
+ repstats = cEnv1.ReplicationSystemStats();
+ Assert.AreEqual(true, repstats.View);
+ repstats = cEnv2.ReplicationSystemStats();
+ Assert.AreEqual(true, repstats.View);
+
+ cEnv2.Close();
+ cEnv1.Close();
+ mEnv.Close();
+ }
+
+ int repView(string name, ref int result, uint flags)
+ {
+ if (name == "db1.db")
+ result = 1;
+ else
+ result = 0;
+ return (0);
+ }
+
+ [Test]
public void TestRepMgrSite()
{
testName = "TestRepMgrSite";
@@ -194,6 +384,7 @@ namespace CsharpAPITest
{
string home = testHome + "/Master";
string dbName = "rep.db";
+ uint metabyte = 1048576;
Configuration.ClearDir(home);
/*
@@ -246,6 +437,7 @@ namespace CsharpAPITest
// Get initial replication stats.
ReplicationStats repStats = env.ReplicationSystemStats();
+ env.Msgfile = home + "/master.log";
env.PrintReplicationSystemStats();
Assert.AreEqual(100, repStats.EnvPriority);
Assert.AreEqual(1,
@@ -254,9 +446,18 @@ namespace CsharpAPITest
Assert.AreEqual(0, repStats.AppliedTransactions);
Assert.AreEqual(0, repStats.ElectionDataGeneration);
+ // Get repmgr incoming queue max setting.
+ Assert.AreEqual(0, env.RepmgrIncomingQueueMaxGBytes);
+ Assert.AreEqual(100 * metabyte, env.RepmgrIncomingQueueMaxBytes);
+
// Start a master site with replication manager.
env.RepMgrStartMaster(3);
+ // Change repmgr incoming queue setting and verify it.
+ env.RepmgrSetIncomingQueueMax(123, 321);
+ Assert.AreEqual(123, env.RepmgrIncomingQueueMaxGBytes);
+ Assert.AreEqual(321, env.RepmgrIncomingQueueMaxBytes);
+
// Open a btree database and write some data.
Transaction txn = env.BeginTransaction();
BTreeDatabaseConfig dbConfig =
@@ -363,11 +564,18 @@ namespace CsharpAPITest
// Get replication manager statistics.
RepMgrStats repMgrStats = env.RepMgrSystemStats(true);
+ Assert.AreEqual(0, repMgrStats.AutoTakeovers);
Assert.LessOrEqual(0, repMgrStats.DroppedConnections);
Assert.LessOrEqual(0, repMgrStats.DroppedMessages);
+ Assert.LessOrEqual(0, repMgrStats.ElectionThreads);
Assert.LessOrEqual(0, repMgrStats.FailedConnections);
Assert.LessOrEqual(0, repMgrStats.FailedMessages);
+ Assert.Less(0, repMgrStats.MaxElectionThreads);
Assert.LessOrEqual(0, repMgrStats.QueuedMessages);
+ // There should be no messages dropped and in the queue now.
+ Assert.AreEqual(0, repMgrStats.IncomingDroppedMessages);
+ Assert.AreEqual(0, repMgrStats.IncomingQueueGBytes);
+ Assert.AreEqual(0, repMgrStats.IncomingQueueBytes);
// Print them out.
env.PrintRepMgrSystemStats();
@@ -416,6 +624,8 @@ namespace CsharpAPITest
cfg.RepSystemCfg.RepmgrSitesConfig[1].Host = "127.0.0.1";
cfg.RepSystemCfg.RepmgrSitesConfig[1].Port = ports[0];
cfg.RepSystemCfg.RepmgrSitesConfig[1].Helper = true;
+ // Set the incoming queue max.
+ cfg.RepSystemCfg.RepmgrIncomingQueueMax(2, 123456);
cfg.EventNotify = new EventNotifyDelegate(stuffHappened);
DatabaseEnvironment env = DatabaseEnvironment.Open(
home, cfg);
@@ -423,6 +633,10 @@ namespace CsharpAPITest
// Start a client site with replication manager.
env.RepMgrStartClient(3, false);
+ // Get repmgr incoming queue max setting.
+ Assert.AreEqual(2, env.RepmgrIncomingQueueMaxGBytes);
+ Assert.AreEqual(123456, env.RepmgrIncomingQueueMaxBytes);
+
// Leave enough time to sync.
Thread.Sleep(20000);
@@ -464,6 +678,11 @@ namespace CsharpAPITest
Assert.LessOrEqual(0, repStats.NextPage);
Assert.LessOrEqual(0, repStats.ReceivedPages);
Assert.AreEqual(1, repStats.Status);
+ // There should be no messages dropped and in the queue now.
+ RepMgrStats repMgrStats = env.RepMgrSystemStats();
+ Assert.AreEqual(0, repMgrStats.IncomingDroppedMessages);
+ Assert.AreEqual(0, repMgrStats.IncomingQueueGBytes);
+ Assert.AreEqual(0, repMgrStats.IncomingQueueBytes);
// Close all.
db.Close(false);
@@ -480,6 +699,9 @@ namespace CsharpAPITest
{
switch (eventCode)
{
+ case NotificationEvent.REP_AUTOTAKEOVER_FAILED:
+ Console.WriteLine("Event: REP_AUTOTAKEOVER_FAILED");
+ break;
case NotificationEvent.REP_CLIENT:
Console.WriteLine("Event: CLIENT");
break;
@@ -677,7 +899,6 @@ namespace CsharpAPITest
} catch(Exception e) {
Console.WriteLine(e.Message);
} finally {
- env.Close();
/*
* Clean up electionDone and startUpDone to
* check election for new master and start-up
@@ -685,6 +906,9 @@ namespace CsharpAPITest
*/
electionDone = false;
startUpDone = 0;
+
+ env.Close();
+
/*
* Need to set signals for three times, each
* site would wait for one.
diff --git a/test/csharp/SecondaryBTreeDatabaseConfigTest.cs b/test/csharp/SecondaryBTreeDatabaseConfigTest.cs
index aec7a49d..1b91fa8b 100644
--- a/test/csharp/SecondaryBTreeDatabaseConfigTest.cs
+++ b/test/csharp/SecondaryBTreeDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryBTreeDatabaseTest.cs b/test/csharp/SecondaryBTreeDatabaseTest.cs
index c3c96e35..460de8f2 100644
--- a/test/csharp/SecondaryBTreeDatabaseTest.cs
+++ b/test/csharp/SecondaryBTreeDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryCursorTest.cs b/test/csharp/SecondaryCursorTest.cs
index 6c4c9ad9..a33cb16e 100644
--- a/test/csharp/SecondaryCursorTest.cs
+++ b/test/csharp/SecondaryCursorTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryDatabaseConfigTest.cs b/test/csharp/SecondaryDatabaseConfigTest.cs
index f12df913..eaa56558 100644
--- a/test/csharp/SecondaryDatabaseConfigTest.cs
+++ b/test/csharp/SecondaryDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryDatabaseTest.cs b/test/csharp/SecondaryDatabaseTest.cs
index 64f00d0d..cab4f8a0 100644
--- a/test/csharp/SecondaryDatabaseTest.cs
+++ b/test/csharp/SecondaryDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryHashDatabaseConfigTest.cs b/test/csharp/SecondaryHashDatabaseConfigTest.cs
index 85752b32..387c74b2 100644
--- a/test/csharp/SecondaryHashDatabaseConfigTest.cs
+++ b/test/csharp/SecondaryHashDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryHashDatabaseTest.cs b/test/csharp/SecondaryHashDatabaseTest.cs
index c2273f1b..a8532f19 100644
--- a/test/csharp/SecondaryHashDatabaseTest.cs
+++ b/test/csharp/SecondaryHashDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryQueueDatabaseConfigTest.cs b/test/csharp/SecondaryQueueDatabaseConfigTest.cs
index f075a9d2..a7199fb1 100644
--- a/test/csharp/SecondaryQueueDatabaseConfigTest.cs
+++ b/test/csharp/SecondaryQueueDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryQueueDatabaseTest.cs b/test/csharp/SecondaryQueueDatabaseTest.cs
index 3a6e5068..f3cc2e5a 100644
--- a/test/csharp/SecondaryQueueDatabaseTest.cs
+++ b/test/csharp/SecondaryQueueDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryRecnoDatabaseConfigTest.cs b/test/csharp/SecondaryRecnoDatabaseConfigTest.cs
index aa3fd373..444cb6c1 100644
--- a/test/csharp/SecondaryRecnoDatabaseConfigTest.cs
+++ b/test/csharp/SecondaryRecnoDatabaseConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SecondaryRecnoDatabaseTest.cs b/test/csharp/SecondaryRecnoDatabaseTest.cs
index 52c2f030..b76beafa 100644
--- a/test/csharp/SecondaryRecnoDatabaseTest.cs
+++ b/test/csharp/SecondaryRecnoDatabaseTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/SequenceConfigTest.cs b/test/csharp/SequenceConfigTest.cs
index 3be9d10b..a2667069 100644
--- a/test/csharp/SequenceConfigTest.cs
+++ b/test/csharp/SequenceConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -77,7 +77,7 @@ namespace CsharpAPITest
public static void Confirm(XmlElement xmlElement,
SequenceConfig seqConfig, bool compulsory)
{
- Configuration.ConfirmInt(xmlElement, "CacheSize",
+ Configuration.ConfirmUint(xmlElement, "CacheSize",
seqConfig.CacheSize, compulsory);
Configuration.ConfirmCreatePolicy(xmlElement, "Creation",
seqConfig.Creation, compulsory);
@@ -96,13 +96,13 @@ namespace CsharpAPITest
public static void Config(XmlElement xmlElement,
ref SequenceConfig seqConfig, bool compulsory)
{
- int intValue = new int();
+ uint uintValue = new uint();
bool boolValue = new bool();
long longValue = new long();
- if (Configuration.ConfigInt(xmlElement, "CacheSize",
- ref intValue, compulsory))
- seqConfig.CacheSize = intValue;
+ if (Configuration.ConfigUint(xmlElement, "CacheSize",
+ ref uintValue, compulsory))
+ seqConfig.CacheSize = uintValue;
Configuration.ConfigCreatePolicy(xmlElement, "Creation",
ref seqConfig.Creation, compulsory);
if (Configuration.ConfigBool(xmlElement, "Decrement",
diff --git a/test/csharp/SequenceTest.cs b/test/csharp/SequenceTest.cs
index 1e965965..16143e92 100644
--- a/test/csharp/SequenceTest.cs
+++ b/test/csharp/SequenceTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
@@ -108,7 +108,7 @@ namespace CsharpAPITest
* Check the delta of two sequence number get
* from sequence.
*/
- int delta = 100;
+ uint delta = 100;
long seqNum1 = seq.Get(delta);
long seqNum2 = seq.Get(delta);
Assert.AreEqual(delta, seqNum2 - seqNum1);
@@ -136,7 +136,7 @@ namespace CsharpAPITest
* Check the delta of two sequence number get
* from sequence.
*/
- int delta = 100;
+ uint delta = 100;
long seqNum1 = seq.Get(delta, true);
long seqNum2 = seq.Get(delta, true);
Assert.AreEqual(delta, seqNum2 - seqNum1);
@@ -165,7 +165,7 @@ namespace CsharpAPITest
* Check the delta of two sequence number get
* from sequence.
*/
- int delta = 100;
+ uint delta = 100;
Transaction txn = env.BeginTransaction();
long seqNum1 = seq.Get(delta, txn);
long seqNum2 = seq.Get(delta, txn);
@@ -300,6 +300,63 @@ namespace CsharpAPITest
db.Close();
}
+ [Test]
+ public void TestSequenceStatPrint()
+ {
+ testName = "TestSequenceStatPrint";
+ SetUpTest(true);
+
+ string[] messageInfo = new string[]
+ { "The number of sequence locks that required waiting (0%)",
+ "The current sequence value",
+ "The cached sequence value",
+ "The last cached sequence value",
+ "The minimum sequence value",
+ "The maximum sequence value",
+ "The cache size",
+ "Sequence flags"
+ };
+
+ DatabaseEnvironment env;
+ BTreeDatabase db;
+ Sequence seq;
+ OpenNewSequenceInEnv(testHome, testName, out env, out db, out seq);
+
+ // Confirm message file does not exist.
+ string messageFile = testHome + "/" + "msgfile";
+ Assert.AreEqual(false, File.Exists(messageFile));
+
+ // Call set_msgfile() of env.
+ env.Msgfile = messageFile;
+
+ // Print env statistic to message file.
+ seq.PrintStats();
+
+ // Confirm message file exists now.
+ Assert.AreEqual(true, File.Exists(messageFile));
+
+ env.Msgfile = "";
+ int counter = 0;
+ string line;
+ line = null;
+
+ // Read the message file line by line.
+ System.IO.StreamReader file = new System.IO.StreamReader(@"" + messageFile);
+ while ((line = file.ReadLine()) != null)
+ {
+ string[] tempStr = line.Split('\t');
+ // Confirm the content of the message file.
+ Assert.AreEqual(tempStr[1], messageInfo[counter]);
+ counter++;
+ }
+ Assert.AreNotEqual(counter, 0);
+
+ file.Close();
+ seq.Close();
+ db.Close();
+ env.Close();
+ }
+
public void OpenNewSequence(string dbFileName,
out BTreeDatabase db, out Sequence seq)
{
@@ -313,7 +370,7 @@ namespace CsharpAPITest
SequenceConfig seqConfig = new SequenceConfig();
seqConfig.BackingDatabase = db;
seqConfig.CacheSize = 1000;
- seqConfig.Creation = CreatePolicy.ALWAYS;
+ seqConfig.Creation = CreatePolicy.ALWAYS;
seqConfig.Decrement = false;
seqConfig.FreeThreaded = true;
seqConfig.Increment = true;
@@ -365,7 +422,7 @@ namespace CsharpAPITest
public static void Confirm(XmlElement xmlElement,
Sequence seq, bool compulsory)
{
- Configuration.ConfirmInt(xmlElement, "CacheSize",
+ Configuration.ConfirmUint(xmlElement, "CacheSize",
seq.Cachesize, compulsory);
Configuration.ConfirmBool(xmlElement, "Decrement",
seq.Decrement, compulsory);
diff --git a/test/csharp/TestException.cs b/test/csharp/TestException.cs
index b8ad88c9..899c618d 100644
--- a/test/csharp/TestException.cs
+++ b/test/csharp/TestException.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/TransactionCommitTokenTest.cs b/test/csharp/TransactionCommitTokenTest.cs
index 174dffef..6119e012 100644
--- a/test/csharp/TransactionCommitTokenTest.cs
+++ b/test/csharp/TransactionCommitTokenTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/TransactionConfigTest.cs b/test/csharp/TransactionConfigTest.cs
index 6ffd1745..bb99ffa8 100644
--- a/test/csharp/TransactionConfigTest.cs
+++ b/test/csharp/TransactionConfigTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/TransactionTest.cs b/test/csharp/TransactionTest.cs
index d5bb1d39..b901ad15 100644
--- a/test/csharp/TransactionTest.cs
+++ b/test/csharp/TransactionTest.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;
diff --git a/test/csharp/XMLReader.cs b/test/csharp/XMLReader.cs
index 36192b1a..568536e5 100644
--- a/test/csharp/XMLReader.cs
+++ b/test/csharp/XMLReader.cs
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 2009, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015 Oracle and/or its affiliates. All rights reserved.
*
*/
using System;