Skip to content
Browse files

Added: test on TFbased tombstone reading in event-by-type-index

  • Loading branch information...
1 parent 2e6704b commit 87a1cff9ca1668502cfe27c852f3a2baef3943e5 @ysw ysw committed Feb 14, 2014
View
14 src/EventStore/EventStore.Core/Bus/QueueStatsCollector.cs
@@ -31,6 +31,7 @@
using System.Threading;
using EventStore.Common.Utils;
using EventStore.Core.Services.Monitoring.Stats;
+using EventStore.Core.TransactionLog.Checkpoint;
namespace EventStore.Core.Bus
{
@@ -221,6 +222,9 @@ public QueueStats GetStatistics(int currentQueueLength)
#if DEBUG
private static object _notifyLock;
private static int _nonIdle = 0;
+ private static ICheckpoint _writerCheckpoint;
+ private static ICheckpoint _chaserCheckpoint;
+
public static void InitializeIdleDetection(bool enable = true)
{
if (enable)
@@ -238,17 +242,25 @@ public static void InitializeIdleDetection(bool enable = true)
[Conditional("DEBUG")]
public static void WaitIdle()
{
+ throw new NotImplementedException("Must account for real queue length as well. for instance interlocked on enqueue and processed");
#if DEBUG
lock (_notifyLock)
{
- while (_nonIdle > 0)
+ while (_nonIdle > 0 || _writerCheckpoint.Read() != _chaserCheckpoint.Read())
{
if (!Monitor.Wait(_notifyLock, 100))
Console.WriteLine("Waiting for IDLE state...");
}
}
#endif
}
+#if DEBUG
+ public static void InitializeCheckpoints(ICheckpoint writerCheckpoint, ICheckpoint chaserCheckpoint)
+ {
+ _chaserCheckpoint = chaserCheckpoint;
+ _writerCheckpoint = writerCheckpoint;
+ }
+#endif
}
}
View
3 src/EventStore/EventStore.Core/SingleVNode.cs
@@ -176,6 +176,9 @@ public class SingleVNode
var chaser = new TFChunkChaser(db, db.Config.WriterCheckpoint, db.Config.ChaserCheckpoint);
var storageChaser = new StorageChaser(_mainQueue, db.Config.WriterCheckpoint, chaser, readIndex.IndexCommitter, epochManager);
+#if DEBUG
+ QueueStatsCollector.InitializeCheckpoints(db.Config.WriterCheckpoint, db.Config.ChaserCheckpoint);
+#endif
_mainBus.Subscribe<SystemMessage.SystemInit>(storageChaser);
_mainBus.Subscribe<SystemMessage.SystemStart>(storageChaser);
_mainBus.Subscribe<SystemMessage.BecomeShuttingDown>(storageChaser);
View
3 src/EventStore/EventStore.Core/TransactionLog/Checkpoint/FileCheckpoint.cs
@@ -122,7 +122,8 @@ public long Read()
return _cached ? Interlocked.Read(ref _lastFlushed) : ReadCurrent();
}
- public long ReadNonFlushed()
+ public long
+ ReadNonFlushed()
{
return Interlocked.Read(ref _last);
}
View
2 ...tore.Projections.Core.Tests/ClientAPI/specification_with_standard_projections_runnning.cs
@@ -165,7 +165,7 @@ protected void AssertStreamTail(string streamId, params string[] events)
Assert.Fail("Stream '{0}' is deleted", streamId);
break;
case SliceReadStatus.StreamNotFound:
- Assert.Fail("Stream '{0}' doe snot exist", streamId);
+ Assert.Fail("Stream '{0}' does not exist", streamId);
break;
case SliceReadStatus.Success:
var resultEventsReversed = result.Events.Reverse().ToArray();
View
2 ...I/when_handling_delete/with_from_all_foreach_projection_running_and_events_are_indexed.cs
@@ -45,7 +45,7 @@ protected override void When()
public void receives_deleted_notification()
{
AssertStreamTail(
- "$projections-test-projection-stream1-result", "Result:{\"a\":1}", "Result:{\"a\":1,\"deleted\":1}");
+ "$projections-test-projection-stream1-result", "Result:{\"deleted\":1}");
}
}
}
View
52 ...g_delete/with_from_all_foreach_projection_running_and_events_are_indexed_but_tombstone.cs
@@ -0,0 +1,52 @@
+using System.Threading;
+using NUnit.Framework;
+
+namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_delete
+{
+ [TestFixture]
+ public class with_from_all_foreach_projection_running_and_events_are_indexed_but_tombstone : specification_with_standard_projections_runnning
+ {
+ protected override bool GivenStandardProjectionsRunning()
+ {
+ return false;
+ }
+
+ protected override void Given()
+ {
+ base.Given();
+ PostEvent("stream1", "type1", "{}");
+ PostEvent("stream1", "type2", "{}");
+ PostEvent("stream2", "type1", "{}");
+ PostEvent("stream2", "type2", "{}");
+ WaitIdle();
+ EnableStandardProjections();
+ WaitIdle();
+ DisableStandardProjections();
+ WaitIdle();
+ HardDeleteStream("stream1");
+ WaitIdle();
+
+ }
+
+ protected override void When()
+ {
+ base.When();
+ PostProjection(@"
+fromAll().foreachStream().when({
+ $init: function(){return {}},
+ type1: function(s,e){s.a=1},
+ type2: function(s,e){s.a=1},
+ $deleted: function(s,e){s.deleted=1},
+}).outputState();
+");
+ WaitIdle();
+ }
+
+ [Test, Category("Network")]
+ public void receives_deleted_notification()
+ {
+ AssertStreamTail(
+ "$projections-test-projection-stream1-result", "Result:{\"a\":1}", "Result:{\"a\":1,\"deleted\":1}");
+ }
+ }
+}
View
1 src/EventStore/EventStore.Projections.Core.Tests/EventStore.Projections.Core.Tests.csproj
@@ -110,6 +110,7 @@
<Compile Include="ClientAPI\specification_with_standard_projections_runnning.cs" />
<Compile Include="ClientAPI\when_handling_delete\with_from_all_foreach_projection_running.cs" />
<Compile Include="ClientAPI\when_handling_delete\with_from_all_foreach_projection_running_and_events_are_indexed.cs" />
+ <Compile Include="ClientAPI\when_handling_delete\with_from_all_foreach_projection_running_and_events_are_indexed_but_tombstone.cs" />
<Compile Include="ClientAPI\with_standard_projections_running.cs" />
<Compile Include="Integration\from_streams_matching\when_running_without_stream_metadata.cs" />
<Compile Include="Integration\from_streams_matching\when_running_wit_stream_metadata.cs" />

0 comments on commit 87a1cff

Please sign in to comment.
Something went wrong with that request. Please try again.