You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/07/07 08:07:23 UTC
[11/18] ignite git commit: IGNITE-5502 .NET: Persistent Store test
IGNITE-5502 .NET: Persistent Store test
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9675061e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9675061e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9675061e
Branch: refs/heads/ignite-gg-12306-1
Commit: 9675061e3f1d190d46f55d1de6ce962b9da7dc8c
Parents: d8a50e4
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Jul 6 14:33:13 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Jul 6 14:33:50 2017 +0300
----------------------------------------------------------------------
.../Cache/PersistentStoreTest.cs | 74 ++++++++++++++++++++
1 file changed, 74 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9675061e/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
index adb91ef..96ae47c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
@@ -17,7 +17,9 @@
namespace Apache.Ignite.Core.Tests.Cache
{
+ using System.IO;
using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.PersistentStore;
using NUnit.Framework;
@@ -26,6 +28,78 @@ namespace Apache.Ignite.Core.Tests.Cache
/// </summary>
public class PersistentStoreTest
{
+ /** Temp dir for WAL. */
+ private readonly string _tempDir = IgniteUtils.GetTempDirectoryName();
+
+ /// <summary>
+ /// Tears down the test.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ Ignition.StopAll(true);
+
+ if (Directory.Exists(_tempDir))
+ {
+ Directory.Delete(_tempDir, true);
+ }
+ }
+
+ /// <summary>
+ /// Tests that cache data survives node restart.
+ /// </summary>
+ [Test]
+ public void TestCacheDataSurvivesNodeRestart()
+ {
+ var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ {
+ PersistentStoreConfiguration = new PersistentStoreConfiguration
+ {
+ PersistentStorePath = Path.Combine(_tempDir, "Store"),
+ WalStorePath = Path.Combine(_tempDir, "WalStore"),
+ WalArchivePath = Path.Combine(_tempDir, "WalArchive")
+ }
+ };
+
+ const string cacheName = "persistentCache";
+
+ // Start Ignite, put data, stop.
+ using (var ignite = Ignition.Start(cfg))
+ {
+ ignite.SetActive(true);
+
+ var cache = ignite.CreateCache<int, int>(cacheName);
+
+ cache[1] = 1;
+ }
+
+ // Verify directories.
+ Assert.IsTrue(Directory.Exists(cfg.PersistentStoreConfiguration.PersistentStorePath));
+ Assert.IsTrue(Directory.Exists(cfg.PersistentStoreConfiguration.WalStorePath));
+ Assert.IsTrue(Directory.Exists(cfg.PersistentStoreConfiguration.WalArchivePath));
+
+ // Start Ignite, verify data survival.
+ using (var ignite = Ignition.Start(cfg))
+ {
+ ignite.SetActive(true);
+
+ var cache = ignite.GetCache<int, int>(cacheName);
+
+ Assert.AreEqual(1, cache[1]);
+ }
+
+ // Delete store directory.
+ Directory.Delete(_tempDir, true);
+
+ // Start Ignite, verify data loss.
+ using (var ignite = Ignition.Start(cfg))
+ {
+ ignite.SetActive(true);
+
+ Assert.IsFalse(ignite.GetCacheNames().Contains(cacheName));
+ }
+ }
+
/// <summary>
/// Tests the grid activation with persistence (inactive by default).
/// </summary>