Permalink
Browse files

Fixed: projections handling $deleted notification also receive $Strea…

…mDeleted

event at the same position
  • Loading branch information...
1 parent 91ce718 commit 7eb4eeac870be439f8a6ddf4b2adf10e718875ef @ysw ysw committed Feb 20, 2014
Showing with 745 additions and 22 deletions.
  1. +1 −1 src/EventStore/EventStore.ClientAPI/Common/SystemNames.cs
  2. +77 −0 ...rom_all_any_foreach_projection/recovery/when_running_and_a_stream_gets_deleted_before_recovery.cs
  3. +77 −0 ...ndling_delete/with_from_all_any_foreach_projection/recovery/when_running_and_events_are_posted.cs
  4. +72 −0 .../when_handling_delete/with_from_all_any_foreach_projection/when_running_and_events_are_indexed.cs
  5. +72 −0 ...I/when_handling_delete/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs
  6. +75 −0 ...any_foreach_projection/when_running_and_events_are_posted_but_a_stream_and_tombstone_postponed.cs
  7. +71 −0 ...g_delete/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_tombstone.cs
  8. +75 −0 ...te/with_from_all_any_foreach_projection/when_running_and_events_are_posted_including_tombstone.cs
  9. +78 −0 ..._from_all_any_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs
  10. +0 −1 ...ry_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone_postponed.cs
  11. +8 −0 src/EventStore/EventStore.Projections.Core.Tests/EventStore.Projections.Core.Tests.csproj
  12. +9 −0 ...tStore/EventStore.Projections.Core.Tests/Services/event_filter/include_everything_event_filter.cs
  13. +69 −0 ...ore.Tests/Services/event_filter/include_everything_handling_deleted_notifications_event_filter.cs
  14. +4 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/ByStreamCatalogEventReader.cs
  15. +1 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/BypassingEventFilter.cs
  16. +1 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/CategoryEventFilter.cs
  17. +1 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/EventByTypeIndexEventFilter.cs
  18. +15 −3 src/EventStore/EventStore.Projections.Core/Services/Processing/EventFilter.cs
  19. +4 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/ExternallyFedByStreamEventReader.cs
  20. +1 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/MultiStreamEventFilter.cs
  21. +5 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/ReaderStrategy.cs
  22. +3 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/ReaderSubscriptionBase.cs
  23. +10 −0 src/EventStore/EventStore.Projections.Core/Services/Processing/ResolvedEvent.cs
  24. +5 −0 src/EventStore/EventStore.Projections.Core/Services/Processing/SourceDefinitionBuilder.cs
  25. +1 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/StreamEventFilter.cs
  26. +1 −1 src/EventStore/EventStore.Projections.Core/Services/Processing/StreamEventReader.cs
  27. +3 −2 src/EventStore/EventStore.Projections.Core/Services/Processing/TransactionFileEventFilter.cs
  28. +6 −5 src/EventStore/EventStore.Projections.Core/Services/Processing/TransactionFileEventReader.cs
@@ -68,7 +68,7 @@ static class SystemMetadata
public const string SystemStreamAcl = "$systemStreamAcl";
}
- static class SystemEventTypes
+ public static class SystemEventTypes
{
public const string StreamDeleted = "$streamDeleted";
public const string StatsCollection = "$statsCollected";
@@ -0,0 +1,77 @@
+// Copyright (c) 2012, Event Store LLP
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Event Store LLP nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using NUnit.Framework;
+
+namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_delete.with_from_all_any_foreach_projection.recovery
+{
+ [TestFixture]
+ public class when_running_and_a_stream_gets_deleted_before_recovery : specification_with_standard_projections_runnning
+ {
+ protected override bool GivenStandardProjectionsRunning()
+ {
+ return false;
+ }
+
+ protected override void Given()
+ {
+ base.Given();
+ PostEvent("stream-1", "type1", "{}");
+ PostEvent("stream-2", "type1", "{}");
+ PostEvent("stream-1", "type2", "{}");
+ PostEvent("stream-2", "type2", "{}");
+ WaitIdle();
+ PostProjection(@"
+fromAll().foreachStream().when({
+ $init: function(){return {a:0}},
+ $any: function(s,e){s.a++},
+ $deleted: function(s,e){s.deleted=1;},
+}).outputState();
+");
+ WaitIdle();
+ _manager.Abort("test-projection", _admin);
+ WaitIdle();
+ }
+
+ protected override void When()
+ {
+ base.When();
+ HardDeleteStream("stream-1");
+ WaitIdle();
+ _manager.Enable("test-projection", _admin);
+ WaitIdle();
+ }
+
+ [Test, Category("Network")]
+ public void receives_deleted_notification()
+ {
+ AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}");
+ AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}");
+ }
+ }
+}
@@ -0,0 +1,77 @@
+// Copyright (c) 2012, Event Store LLP
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Event Store LLP nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using NUnit.Framework;
+
+namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_delete.with_from_all_any_foreach_projection.recovery
+{
+ [TestFixture]
+ public class when_running_and_events_are_posted : specification_with_standard_projections_runnning
+ {
+ protected override bool GivenStandardProjectionsRunning()
+ {
+ return false;
+ }
+
+ protected override void Given()
+ {
+ base.Given();
+ PostEvent("stream-1", "type1", "{}");
+ PostEvent("stream-1", "type2", "{}");
+ PostEvent("stream-2", "type1", "{}");
+ PostEvent("stream-2", "type2", "{}");
+ WaitIdle();
+ PostProjection(@"
+fromAll().foreachStream().when({
+ $init: function(){return {a:0}},
+ $any: function(s,e){s.a++},
+ $deleted: function(s,e){s.deleted=1;},
+}).outputState();
+");
+ WaitIdle();
+ HardDeleteStream("stream-1");
+ WaitIdle();
+ }
+
+ protected override void When()
+ {
+ base.When();
+ _manager.Abort("test-projection", _admin);
+ WaitIdle();
+ _manager.Enable("test-projection", _admin);
+ WaitIdle();
+ }
+
+ [Test, Category("Network")]
+ public void receives_deleted_notification()
+ {
+ AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}");
+ AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}");
+ }
+ }
+}
@@ -0,0 +1,72 @@
+// Copyright (c) 2012, Event Store LLP
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Event Store LLP nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using NUnit.Framework;
+
+namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_delete.with_from_all_any_foreach_projection
+{
+ [TestFixture]
+ public class when_running_and_events_are_indexed : specification_with_standard_projections_runnning
+ {
+ protected override bool GivenStandardProjectionsRunning()
+ {
+ return false;
+ }
+
+ protected override void Given()
+ {
+ base.Given();
+ PostEvent("stream-1", "type1", "{}");
+ PostEvent("stream-1", "type2", "{}");
+ PostEvent("stream-2", "type1", "{}");
+ PostEvent("stream-2", "type2", "{}");
+ HardDeleteStream("stream-1");
+ WaitIdle();
+ }
+
+ protected override void When()
+ {
+ base.When();
+ PostProjection(@"
+fromAll().foreachStream().when({
+ $init: function(){return {a:0}},
+ $any: function(s,e){s.a++},
+ $deleted: function(s,e){s.deleted=1;},
+}).outputState();
+");
+ WaitIdle();
+ }
+
+ [Test, Category("Network")]
+ public void receives_deleted_notification()
+ {
+ AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"deleted\":1}");
+ AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}");
+ }
+ }
+}
@@ -0,0 +1,72 @@
+// Copyright (c) 2012, Event Store LLP
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Event Store LLP nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using NUnit.Framework;
+
+namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_delete.with_from_all_any_foreach_projection
+{
+ [TestFixture]
+ public class when_running_and_events_are_posted : specification_with_standard_projections_runnning
+ {
+ protected override bool GivenStandardProjectionsRunning()
+ {
+ return false;
+ }
+
+ protected override void Given()
+ {
+ base.Given();
+ PostEvent("stream-1", "type1", "{}");
+ PostEvent("stream-1", "type2", "{}");
+ PostEvent("stream-2", "type1", "{}");
+ PostEvent("stream-2", "type2", "{}");
+ HardDeleteStream("stream-1");
+ WaitIdle();
+ }
+
+ protected override void When()
+ {
+ base.When();
+ PostProjection(@"
+fromAll().foreachStream().when({
+ $init: function(){return {a:0}},
+ $any: function(s,e){s.a++},
+ $deleted: function(s,e){s.deleted=1;},
+}).outputState();
+");
+ WaitIdle();
+ }
+
+ [Test, Category("Network")]
+ public void receives_deleted_notification()
+ {
+ AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}");
+ AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}");
+ }
+ }
+}
@@ -0,0 +1,75 @@
+// Copyright (c) 2012, Event Store LLP
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Event Store LLP nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using NUnit.Framework;
+
+namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_delete.with_from_all_any_foreach_projection
+{
+ [TestFixture]
+ public class when_running_and_events_are_posted_but_a_stream_and_tombstone_postponed :
+ specification_with_standard_projections_runnning
+ {
+ protected override bool GivenStandardProjectionsRunning()
+ {
+ return false;
+ }
+
+ protected override void Given()
+ {
+ base.Given();
+ PostEvent("stream-2", "type1", "{}");
+ PostEvent("stream-2", "type2", "{}");
+ WaitIdle();
+
+ PostProjection(@"
+fromAll().foreachStream().when({
+ $init: function(){return {a:0}},
+ $any: function(s,e){s.a++},
+ $deleted: function(s,e){s.deleted=1;},
+}).outputState();
+");
+ WaitIdle();
+ }
+
+ protected override void When()
+ {
+ base.When();
+ PostEvent("stream-1", "type1", "{}");
+ PostEvent("stream-1", "type2", "{}");
+ WaitIdle();
+ HardDeleteStream("stream-1");
+ WaitIdle();
+ }
+
+ [Test, Category("Network")]
+ public void receives_deleted_notification()
+ {
+ AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}");
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 7eb4eea

Please sign in to comment.