From c439d513cddcb8cb1339f07c655a2565f8c16f1c Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 12 Sep 2026 18:26:22 -0400 Subject: [PATCH] chore(projections): retire redundant TCP client coverage Signed-off-by: Yordis Prieto --- ...tion_with_standard_projections_runnning.cs | 357 ------------------ .../ClientAPI/RecordedEventExtensions.cs | 10 - .../ClientAPI/event_by_type_index.cs | 83 ---- .../when_reverting_after_index_catches_up.cs | 57 --- .../ClientAPI/list_projections.cs | 39 -- ...tion_with_standard_projections_runnning.cs | 325 ---------------- .../when_running_and_events_are_posted.cs | 45 --- .../when_running_and_events_are_indexed.cs | 45 --- .../when_running_and_events_are_indexed.cs | 46 --- ...d_a_stream_gets_deleted_before_recovery.cs | 52 --- .../when_running_and_events_are_posted.cs | 51 --- .../when_running_and_events_are_posted.cs | 45 --- ...ed_but_a_stream_and_tombstone_postponed.cs | 48 --- ...ing_and_events_are_posted_but_tombstone.cs | 44 --- ...d_events_are_posted_including_tombstone.cs | 48 --- ...other_events_tombstone_ant_other_events.cs | 53 --- .../when_running_and_events_are_indexed.cs | 57 --- ..._and_events_get_indexed_before_recovery.cs | 58 --- .../when_running_and_events_are_indexed.cs | 60 --- ..._are_indexed_but_a_stream_and_tombstone.cs | 60 --- ...e_indexed_but_more_events_and_tombstone.cs | 61 --- ...ng_and_events_are_indexed_but_tombstone.cs | 60 --- .../when_running_and_no_indexing.cs | 46 --- ...unning_and_no_indexing_and_other_events.cs | 52 --- .../when_running_and_events_are_indexed.cs | 61 --- ..._and_events_get_indexed_before_recovery.cs | 57 --- .../when_running_and_events_are_indexed.cs | 48 --- ...ed_but_a_stream_and_tombstone_postponed.cs | 64 ---- ...ng_and_events_are_indexed_but_tombstone.cs | 48 --- ..._events_are_indexed_including_tombstone.cs | 51 --- ...other_events_tombstone_ant_other_events.cs | 57 --- .../with_standard_projections_running.cs | 125 ------ 32 files changed, 2313 deletions(-) delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/Cluster/specification_with_standard_projections_runnning.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/RecordedEventExtensions.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index/when_reverting_after_index_catches_up.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/list_projections.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/specification_with_standard_projections_runnning.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_a_stream_gets_deleted_before_recovery.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_events_are_posted.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_a_stream_and_tombstone_postponed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_including_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_are_indexed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_more_events_and_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing_and_other_events.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_are_indexed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone_postponed.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_including_tombstone.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs delete mode 100644 src/EventStore.Projections.Core.Tests/ClientAPI/with_standard_projections_running.cs diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/Cluster/specification_with_standard_projections_runnning.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/Cluster/specification_with_standard_projections_runnning.cs deleted file mode 100644 index 68e0e66259..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/Cluster/specification_with_standard_projections_runnning.cs +++ /dev/null @@ -1,357 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using EventStore.ClientAPI; -using EventStore.ClientAPI.SystemData; -using EventStore.Common.Options; -using EventStore.Core.Data; -using EventStore.Core.Tests; -using EventStore.Core.Tests.Helpers; -using EventStore.Core.Util; -using EventStore.Projections.Core.Services.Processing; -using NUnit.Framework; -using ExpectedVersion = EventStore.ClientAPI.ExpectedVersion; -using ResolvedEvent = EventStore.ClientAPI.ResolvedEvent; - -namespace EventStore.Projections.Core.Tests.ClientAPI.Cluster; - -[Category("ClientAPI")] -public abstract class specification_with_standard_projections_runnning : SpecificationWithDirectoryPerTestFixture -{ - protected MiniClusterNode[] _nodes = new MiniClusterNode[3]; - protected Endpoints[] _nodeEndpoints = new Endpoints[3]; - protected IEventStoreConnection _conn; - private readonly ProjectionsSubsystem[] _projections = new ProjectionsSubsystem[3]; - protected UserCredentials _admin = DefaultData.AdminCredentials; - private protected ProjectionManagementTestClient ProjectionClient; - - protected class Endpoints - { - public readonly IPEndPoint InternalTcp; - public readonly IPEndPoint ExternalTcp; - public readonly IPEndPoint HttpEndPoint; - private readonly int[] _ports; - - public Endpoints(int internalTcp, int externalTcp, int httpPort) - { - var testIp = Environment.GetEnvironmentVariable("ES-TESTIP"); - - var address = string.IsNullOrEmpty(testIp) ? IPAddress.Loopback : IPAddress.Parse(testIp); - InternalTcp = new IPEndPoint(address, internalTcp); - ExternalTcp = new IPEndPoint(address, externalTcp); - HttpEndPoint = new IPEndPoint(address, httpPort); - - _ports = new[] { internalTcp, httpPort, externalTcp }; - } - - public IEnumerable Ports => _ports; - } - - [OneTimeSetUp] - public override async Task TestFixtureSetUp() - { - await base.TestFixtureSetUp(); -#if (!DEBUG) - Assert.Ignore("These tests require DEBUG conditional"); -#else - _nodeEndpoints[0] = new Endpoints( - PortsHelper.GetAvailablePort(IPAddress.Loopback), - PortsHelper.GetAvailablePort(IPAddress.Loopback), - PortsHelper.GetAvailablePort(IPAddress.Loopback)); - _nodeEndpoints[1] = new Endpoints( - PortsHelper.GetAvailablePort(IPAddress.Loopback), - PortsHelper.GetAvailablePort(IPAddress.Loopback), - PortsHelper.GetAvailablePort(IPAddress.Loopback)); - _nodeEndpoints[2] = new Endpoints( - PortsHelper.GetAvailablePort(IPAddress.Loopback), - PortsHelper.GetAvailablePort(IPAddress.Loopback), - PortsHelper.GetAvailablePort(IPAddress.Loopback)); - - _nodes[0] = CreateNode(0, - _nodeEndpoints[0], new[] { _nodeEndpoints[0].HttpEndPoint }); - _nodes[1] = CreateNode(1, - _nodeEndpoints[1], new[] { _nodeEndpoints[1].HttpEndPoint }); - _nodes[2] = CreateNode(2, - _nodeEndpoints[2], new[] { _nodeEndpoints[2].HttpEndPoint }); - WaitIdle(); - - var projectionsStarted = _projections.Select(p => SystemProjections.Created(p.LeaderInputBus)).ToArray(); - - foreach (var node in _nodes) - { - node.Start(); - node.WaitIdle(); - } - - await Task.WhenAll(_nodes.Select(x => x.Started)).WithTimeout(TimeSpan.FromSeconds(30)); - - _conn = EventStoreConnection.Create(_nodes[0].ExternalTcpEndPoint); - await _conn.ConnectAsync().WithTimeout(); - - var leader = _nodes.Single(x => x.NodeState == VNodeState.Leader); - ProjectionClient = new ProjectionManagementTestClient(leader.HttpEndPoint, leader.CreateHttpClient()); - - if (GivenStandardProjectionsRunning()) - { - await Task.WhenAny(projectionsStarted).WithTimeout(TimeSpan.FromSeconds(10)); - await EnableStandardProjections().WithTimeout(TimeSpan.FromMinutes(2)); - } - - WaitIdle(); - - try - { - await Given().WithTimeout(); - } - catch (Exception ex) - { - throw new Exception("Given Failed", ex); - } - - try - { - await When().WithTimeout(); - } - catch (Exception ex) - { - throw new Exception("When Failed", ex); - } -#endif - } - - private MiniClusterNode CreateNode(int index, Endpoints endpoints, EndPoint[] gossipSeeds) - { - _projections[index] = new ProjectionsSubsystem(new ProjectionSubsystemOptions(1, ProjectionType.All, false, TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault), Opts.FaultOutOfOrderProjectionsDefault, 500, 250)); - var node = new MiniClusterNode( - PathName, index, endpoints.InternalTcp, - endpoints.ExternalTcp, endpoints.HttpEndPoint, - subsystems: [_projections[index]], gossipSeeds: gossipSeeds); - return node; - } - - [TearDown] - public async Task PostTestAsserts() - { - var all = await ProjectionClient.StatisticsAll(); - if (all.Any(p => p.Status == "Faulted")) - { - Assert.Fail("Projections faulted while running the test" + "\r\n" + string.Join("\r\n", all)); - } - } - - protected async Task EnableStandardProjections() - { - await EnableProjection(ProjectionNamesBuilder.StandardProjections.EventByCategoryStandardProjection); - await EnableProjection(ProjectionNamesBuilder.StandardProjections.EventByTypeStandardProjection); - await EnableProjection(ProjectionNamesBuilder.StandardProjections.StreamByCategoryStandardProjection); - await EnableProjection(ProjectionNamesBuilder.StandardProjections.StreamsStandardProjection); - } - - protected async Task DisableStandardProjections() - { - await DisableProjection(ProjectionNamesBuilder.StandardProjections.EventByCategoryStandardProjection); - await DisableProjection(ProjectionNamesBuilder.StandardProjections.EventByTypeStandardProjection); - await DisableProjection(ProjectionNamesBuilder.StandardProjections.StreamByCategoryStandardProjection); - await DisableProjection(ProjectionNamesBuilder.StandardProjections.StreamsStandardProjection); - } - - protected virtual bool GivenStandardProjectionsRunning() - { - return true; - } - - protected async Task EnableProjection(string name) - { - for (int i = 1; i <= 10; i++) - { - try - { - await ProjectionClient.Enable(name); - } - catch (Exception) - { - if (i == 10) - { - throw; - } - - await Task.Delay(5000); - } - } - - await Task.Delay(1000); /* workaround for race condition when multiple projections are being enabled simultaneously */ - } - - protected Task DisableProjection(string name) - { - return ProjectionClient.Disable(name); - } - - protected Task AbortProjection(string name) - { - return ProjectionClient.Abort(name); - } - - [OneTimeTearDown] - public override async Task TestFixtureTearDown() - { - ProjectionClient?.Dispose(); - _conn.Close(); - await Task.WhenAll( - _nodes[0].Shutdown(), - _nodes[1].Shutdown(), - _nodes[2].Shutdown()); - await base.TestFixtureTearDown(); - } - - protected virtual Task When() => Task.CompletedTask; - - protected virtual Task Given() => Task.CompletedTask; - - protected Task PostEvent(string stream, string eventType, string data) - { - return _conn.AppendToStreamAsync(stream, ExpectedVersion.Any, new[] { CreateEvent(eventType, data) }); - } - - protected Task HardDeleteStream(string stream) - { - return _conn.DeleteStreamAsync(stream, ExpectedVersion.Any, true, _admin); - } - - protected Task SoftDeleteStream(string stream) - { - return _conn.DeleteStreamAsync(stream, ExpectedVersion.Any, false, _admin); - } - - protected static EventData CreateEvent(string type, string data) - { - return new EventData(Guid.NewGuid(), type, true, Encoding.UTF8.GetBytes(data), Array.Empty()); - } - - protected void WaitIdle() - { -#if DEBUG - _nodes[0].WaitIdle(); - _nodes[1].WaitIdle(); - _nodes[2].WaitIdle(); -#endif - } - -#pragma warning disable 1998 - protected async Task AssertStreamTailAsync(string streamId, params string[] events) - { -#pragma warning restore 1998 -#if DEBUG - var result = await _conn.ReadStreamEventsBackwardAsync(streamId, -1, events.Length, true, _admin); - switch (result.Status) - { - case SliceReadStatus.StreamDeleted: - Assert.Fail("Stream '{0}' is deleted", streamId); - break; - case SliceReadStatus.StreamNotFound: - Assert.Fail("Stream '{0}' does not exist", streamId); - break; - case SliceReadStatus.Success: - var resultEventsReversed = result.Events.Reverse().ToArray(); - if (resultEventsReversed.Length < events.Length) - { - DumpFailed("Stream does not contain enough events", streamId, events, result.Events); - } - else - { - for (var index = 0; index < events.Length; index++) - { - var parts = events[index].Split(new char[] { ':' }, 2); - var eventType = parts[0]; - var eventData = parts[1]; - - if (resultEventsReversed[index].Event.EventType != eventType) - { - DumpFailed("Invalid event type", streamId, events, resultEventsReversed); - } - else if (resultEventsReversed[index].Event.DebugDataView() != eventData) - { - DumpFailed("Invalid event body", streamId, events, resultEventsReversed); - } - } - } - - break; - } -#endif - } - -#pragma warning disable 1998 - protected async Task DumpStreamAsync(string streamId) - { -#pragma warning restore 1998 -#if DEBUG - var result = await _conn.ReadStreamEventsBackwardAsync(streamId, -1, 100, true, _admin); - switch (result.Status) - { - case SliceReadStatus.StreamDeleted: - Assert.Fail("Stream '{0}' is deleted", streamId); - break; - case SliceReadStatus.StreamNotFound: - Assert.Fail("Stream '{0}' does not exist", streamId); - break; - case SliceReadStatus.Success: - Dump("Dumping..", streamId, result.Events.Reverse().ToArray()); - break; - } -#endif - } - -#if DEBUG - private void DumpFailed(string message, string streamId, string[] events, ResolvedEvent[] resultEvents) - { - var expected = events.Aggregate("", (a, v) => a + ", " + v); - var actual = resultEvents.Aggregate( - "", (a, v) => a + ", " + v.Event.EventType + ":" + v.Event.DebugDataView()); - - var actualMeta = resultEvents.Aggregate( - "", (a, v) => a + "\r\n" + v.Event.EventType + ":" + v.Event.DebugMetadataView()); - - - Assert.Fail( - "Stream: '{0}'\r\n{1}\r\n\r\nExisting events: \r\n{2}\r\n Expected events: \r\n{3}\r\n\r\nActual metas:{4}", - streamId, - message, actual, expected, actualMeta); - } - - private void Dump(string message, string streamId, ResolvedEvent[] resultEvents) - { - var actual = resultEvents.Aggregate( - "", (a, v) => a + ", " + v.OriginalEvent.EventType + ":" + v.OriginalEvent.DebugDataView()); - - var actualMeta = resultEvents.Aggregate( - "", (a, v) => a + "\r\n" + v.OriginalEvent.EventType + ":" + v.OriginalEvent.DebugMetadataView()); - - Debug.WriteLine( - "Stream: '{0}'\r\n{1}\r\n\r\nExisting events: \r\n{2}\r\n \r\nActual metas:{3}", streamId, - message, actual, actualMeta); - } -#endif - - protected async Task PostProjection(string query) - { - await ProjectionClient.CreateContinuous("test-projection", query); - WaitIdle(); - } -} - -[Explicit] -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class vnode_cluster_specification : specification_with_standard_projections_runnning -{ - [Test, Explicit] - public async Task vnode_cluster_starts() - { - await PostProjection(@"fromStream('$user-admin').outputState()"); - await AssertStreamTailAsync("$projections-test-projection-result", "Result:{}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/RecordedEventExtensions.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/RecordedEventExtensions.cs deleted file mode 100644 index ae26152b90..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/RecordedEventExtensions.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Text; -using EventStore.ClientAPI; - -namespace EventStore.Projections.Core.Tests.ClientAPI; - -internal static class RecordedEventExtensions -{ - public static string DebugDataView(this RecordedEvent source) => Encoding.UTF8.GetString(source.Data); - public static string DebugMetadataView(this RecordedEvent source) => Encoding.UTF8.GetString(source.Metadata); -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index.cs deleted file mode 100644 index e14b922726..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI -{ - namespace event_by_type_index - { - public abstract class with_existing_events : specification_with_standard_projections_runnning - { - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream1", "type1", "{}"); - await PostEvent("stream1", "type2", "{}"); - await PostEvent("stream1", "type3", "{}"); - await PostEvent("stream2", "type1", "{}"); - await PostEvent("stream2", "type2", "{}"); - await PostEvent("stream2", "type3", "{}"); - } - } - - [TestFixture(typeof(LogFormat.V2), typeof(string))] - public class when_creating : with_existing_events - { - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().when({ - $init: function(){ - return {c: 0}; - }, - type1: count, - type2: count -}).outputState() - -function count(s,e) { - return {c: s.c + 1}; -} -"); - } - - [Test, Category("Network")] - public async Task result_is_correct() - { - await AssertStreamTail("$projections-test-projection-result", "Result:{\"c\":4}"); - } - } - - [TestFixture(typeof(LogFormat.V2), typeof(string))] - public class when_posting_more_events : with_existing_events - { - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().when({ - $init: function(){ - return {c: 0}; - }, - type1: count, - type2: count -}).outputState() - -function count(s,e) { - return {c: s.c + 1}; -} -"); - await PostEvent("stream3", "type2", "{}"); - await PostEvent("stream3", "type3", "{}"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task result_is_correct() - { - await AssertStreamTail("$projections-test-projection-result", "Result:{\"c\":5}"); - } - } - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index/when_reverting_after_index_catches_up.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index/when_reverting_after_index_catches_up.cs deleted file mode 100644 index 182ceb53d1..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/event_by_type_index/when_reverting_after_index_catches_up.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.event_by_type_index; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -[NonParallelizable] -public class when_reverting_after_index_catches_up : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - await AbortProjection("test-projection"); - WaitIdle(); - - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":1}", "Result:{\"a\":2}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":1}", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/list_projections.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/list_projections.cs deleted file mode 100644 index 50a04bae3c..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/list_projections.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class list_projections : specification_with_standard_projections_runnning -{ - const string TestProjection = - "fromAll().when({$init: function (state, ev) {return {};},ConversationStarted: function (state, ev) {state.lastBatchSent = ev;return state;}});"; - - [Test] - public async Task list_all_projections_works() - { - var x = await ProjectionClient.StatisticsAll(); - Assert.AreEqual(true, x.Any()); - Assert.IsTrue(x.Any(p => p.Name == "$streams")); - } - - [Test] - public async Task list_oneTime_projections_works() - { - await ProjectionClient.CreateOneTime(TestProjection); - var x = await ProjectionClient.StatisticsOneTime(); - Assert.AreEqual(true, x.Any(p => p.Mode == "OneTime")); - } - - [Test] - public async Task list_continuous_projections_works() - { - var nameToTest = Guid.NewGuid().ToString(); - await ProjectionClient.CreateContinuous(nameToTest, TestProjection); - var x = await ProjectionClient.StatisticsContinuous(); - Assert.AreEqual(true, x.Any(p => p.Name == nameToTest)); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/specification_with_standard_projections_runnning.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/specification_with_standard_projections_runnning.cs deleted file mode 100644 index 2bad847175..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/specification_with_standard_projections_runnning.cs +++ /dev/null @@ -1,325 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EventStore.ClientAPI; -using EventStore.ClientAPI.SystemData; -using EventStore.Common.Options; -using EventStore.Core.Tests; -using EventStore.Core.Tests.ClientAPI.Helpers; -using EventStore.Core.Tests.Helpers; -using EventStore.Core.Util; -using EventStore.Projections.Core.Services.Processing; -using NUnit.Framework; -using ResolvedEvent = EventStore.ClientAPI.ResolvedEvent; - -namespace EventStore.Projections.Core.Tests.ClientAPI; - -[Category("ClientAPI")] -public abstract class specification_with_standard_projections_runnning : SpecificationWithDirectoryPerTestFixture -{ - protected IEventStoreConnection _conn; - protected UserCredentials _admin = DefaultData.AdminCredentials; - private protected ProjectionManagementTestClient ProjectionClient; - protected virtual TimeSpan StartupTimeout => TimeSpan.FromMinutes(5); - - private Task _projectionsCreated; - private ProjectionsSubsystem _projections; - private MiniNode _node; - - [OneTimeSetUp] - public override async Task TestFixtureSetUp() - { - await base.TestFixtureSetUp(); - - var projectionWorkerThreadCount = GivenWorkerThreadCount(); - var configuration = new ProjectionSubsystemOptions( - projectionWorkerThreadCount, - ProjectionType.All, - false, - TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault), - Opts.FaultOutOfOrderProjectionsDefault, - 500, - 250); - _projections = new ProjectionsSubsystem(configuration); - _node = new MiniNode( - PathName, - subsystems: [_projections]); - _projectionsCreated = SystemProjections.Created(_projections.LeaderInputBus); - - await _node.Start(StartupTimeout); - await _node.WaitForTcpEndPoint().WithTimeout(StartupTimeout); - _conn = await TestConnectionLifecycle.ReconnectUntilReady( - CreateConnection, - connection => connection.ReadAllEventsForwardAsync(Position.Start, 1, false, _admin), - StartupTimeout); - - ProjectionClient = new ProjectionManagementTestClient(_node.HttpEndPoint, _node.HttpMessageHandler); - - WaitIdle(); - - if (GivenStandardProjectionsRunning()) - { - await EnableStandardProjections(); - } - - WaitIdle(); - try - { - await Given().WithTimeout(TimeSpan.FromSeconds(10)); - } - catch (Exception ex) - { - throw new Exception("Given Failed", ex); - } - - try - { - await When().WithTimeout(TimeSpan.FromSeconds(10)); - } - catch (Exception ex) - { - throw new Exception("When Failed", ex); - } - } - - protected virtual int GivenWorkerThreadCount() - { - return 1; - } - - [TearDown] - public async Task PostTestAsserts() - { - var all = await ProjectionClient.StatisticsAll(); - if (all.Any(p => p.Status == "Faulted")) - { - Assert.Fail("Projections faulted while running the test" + "\r\n" + string.Join("\r\n", all)); - } - } - - protected async Task EnableStandardProjections() - { - await _projectionsCreated; - await EnableProjection(ProjectionNamesBuilder.StandardProjections.EventByCategoryStandardProjection); - await EnableProjection(ProjectionNamesBuilder.StandardProjections.EventByTypeStandardProjection); - await EnableProjection(ProjectionNamesBuilder.StandardProjections.StreamByCategoryStandardProjection); - await EnableProjection(ProjectionNamesBuilder.StandardProjections.StreamsStandardProjection); - } - - protected async Task DisableStandardProjections() - { - await DisableProjection(ProjectionNamesBuilder.StandardProjections.EventByCategoryStandardProjection); - await DisableProjection(ProjectionNamesBuilder.StandardProjections.EventByTypeStandardProjection); - await DisableProjection(ProjectionNamesBuilder.StandardProjections.StreamByCategoryStandardProjection); - await DisableProjection(ProjectionNamesBuilder.StandardProjections.StreamsStandardProjection); - } - - protected virtual bool GivenStandardProjectionsRunning() - { - return true; - } - - protected Task EnableProjection(string name) - { - return ProjectionClient.Enable(name); - } - - protected Task DisableProjection(string name) - { - return ProjectionClient.Disable(name); - } - - protected Task AbortProjection(string name) - { - return ProjectionClient.Abort(name); - } - - protected Task CreateContinuousProjection(string name, string query) - { - return ProjectionClient.CreateContinuous(name, query); - } - - protected Task CreateTransientProjection(string name, string query) - { - return ProjectionClient.CreateTransient(name, query); - } - - [OneTimeTearDown] - public override async Task TestFixtureTearDown() - { - if (_conn != null) - { - try - { - await TestConnectionLifecycle.CloseConnectionAndWait(_conn, TimeSpan.FromSeconds(20)); - } - catch - { - TestConnectionLifecycle.TryCloseConnection(_conn); - } - finally - { - TestConnectionLifecycle.DisposeIfNeeded(_conn); - } - } - - ProjectionClient?.Dispose(); - - if (_node != null) - { - await _node.Shutdown(); - } - - await Task.Delay(1000); - - await base.TestFixtureTearDown(); - } - - protected virtual Task When() => Task.CompletedTask; - - protected virtual Task Given() => Task.CompletedTask; - - protected Task PostEvent(string stream, string eventType, string data) - { - return _conn.AppendToStreamAsync(stream, ExpectedVersion.Any, CreateEvent(eventType, data)); - } - - protected Task HardDeleteStream(string stream) - { - return _conn.DeleteStreamAsync(stream, ExpectedVersion.Any, true, _admin); - } - - protected Task SoftDeleteStream(string stream) - { - return _conn.DeleteStreamAsync(stream, ExpectedVersion.Any, false, _admin); - } - - protected static EventData CreateEvent(string type, string data) - { - return new EventData(Guid.NewGuid(), type, true, Encoding.UTF8.GetBytes(data), Array.Empty()); - } - - private IEventStoreConnection CreateConnection() - { - return TestConnection.CreateMiniNodeClient(_node.TcpEndPoint); - } - - protected void WaitIdle(int multiplier = 1) - { -#if DEBUG - _node.WaitIdle(); -#endif - } - -#pragma warning disable 1998 - protected async Task AssertStreamTail(string streamId, params string[] events) - { -#pragma warning restore 1998 -#if DEBUG - await Task.Delay(TimeSpan.FromMilliseconds(500)); - var result = await _conn.ReadStreamEventsBackwardAsync(streamId, -1, events.Length, true, _admin); - switch (result.Status) - { - case SliceReadStatus.StreamDeleted: - Assert.Fail("Stream '{0}' is deleted", streamId); - break; - case SliceReadStatus.StreamNotFound: - Assert.Fail("Stream '{0}' does not exist", streamId); - break; - case SliceReadStatus.Success: - var resultEventsReversed = result.Events.Reverse().ToArray(); - if (resultEventsReversed.Length < events.Length) - { - DumpFailed("Stream does not contain enough events", streamId, events, result.Events); - } - else - { - for (var index = 0; index < events.Length; index++) - { - var parts = events[index].Split(new char[] { ':' }, 2); - var eventType = parts[0]; - var eventData = parts[1]; - - if (resultEventsReversed[index].Event.EventType != eventType) - { - DumpFailed("Invalid event type", streamId, events, resultEventsReversed); - } - else if (resultEventsReversed[index].Event.DebugDataView() != eventData) - { - DumpFailed("Invalid event body", streamId, events, resultEventsReversed); - } - } - } - - break; - } -#endif - } - -#pragma warning disable 1998 - protected async Task DumpStream(string streamId) - { -#pragma warning restore 1998 -#if DEBUG - var result = await _conn.ReadStreamEventsBackwardAsync(streamId, -1, 100, true, _admin); - switch (result.Status) - { - case SliceReadStatus.StreamDeleted: - Assert.Fail("Stream '{0}' is deleted", streamId); - break; - case SliceReadStatus.StreamNotFound: - Assert.Fail("Stream '{0}' does not exist", streamId); - break; - case SliceReadStatus.Success: - Dump("Dumping..", streamId, result.Events.Reverse().ToArray()); - break; - } -#endif - } - -#if DEBUG - private void DumpFailed(string message, string streamId, string[] events, ResolvedEvent[] resultEvents) - { - var expected = events.Aggregate("", (a, v) => a + ", " + v); - var actual = resultEvents.Aggregate( - "", (a, v) => a + ", " + v.Event.EventType + ":" + v.Event.DebugDataView()); - - var actualMeta = resultEvents.Aggregate( - "", (a, v) => a + "\r\n" + v.Event.EventType + ":" + v.Event.DebugMetadataView()); - - - Assert.Fail( - "Stream: '{0}'\r\n{1}\r\n\r\nExisting events: \r\n{2}\r\n Expected events: \r\n{3}\r\n\r\nActual metas:{4}", - streamId, - message, actual, expected, actualMeta); - } - - protected void Dump(string message, string streamId, ResolvedEvent[] resultEvents) - { - var actual = resultEvents.Aggregate( - "", (a, v) => a + ", " + v.OriginalEvent.EventType + ":" + v.OriginalEvent.DebugDataView()); - - var actualMeta = resultEvents.Aggregate( - "", (a, v) => a + "\r\n" + v.OriginalEvent.EventType + ":" + v.OriginalEvent.DebugMetadataView()); - - - Debug.WriteLine( - "Stream: '{0}'\r\n{1}\r\n\r\nExisting events: \r\n{2}\r\n \r\nActual metas:{3}", streamId, - message, actual, actualMeta); - } -#endif - - protected async Task PostProjection(string query) - { - await CreateContinuousProjection("test-projection", query); - WaitIdle(); - } - - protected async Task PostQuery(string query) - { - await CreateTransientProjection("query", query); - WaitIdle(); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs deleted file mode 100644 index f27cc95a2c..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_created.with_from_all_any_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_posted - : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - $any: function(s,e) {s.a++;}, - $created: function(s,e){s.a++;}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_created_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":3}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":3}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs deleted file mode 100644 index ac1abcceda..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_created.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed - : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++;}, - type2: function(s,e){s.a++;}, - $created: function(s,e){s.a++;}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":3}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":3}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs deleted file mode 100644 index 85a10ed533..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_created/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_created.with_from_category_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++;}, - type2: function(s,e){s.a++;}, - $created: function(s,e){s.a++;}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":3}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":3}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_a_stream_gets_deleted_before_recovery.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_a_stream_gets_deleted_before_recovery.cs deleted file mode 100644 index 490457acaa..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_a_stream_gets_deleted_before_recovery.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection. - recovery; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class - when_running_and_a_stream_gets_deleted_before_recovery : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - $any: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - WaitIdle(); - await AbortProjection("test-projection"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_events_are_posted.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_events_are_posted.cs deleted file mode 100644 index b504fd9133..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/recovery/when_running_and_events_are_posted.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection. - recovery; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_posted : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - $any: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await AbortProjection("test-projection"); - WaitIdle(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs deleted file mode 100644 index 4145679908..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_posted : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await 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 async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_a_stream_and_tombstone_postponed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_a_stream_and_tombstone_postponed.cs deleted file mode 100644 index 95c901e8b3..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_a_stream_and_tombstone_postponed.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -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 async Task Given() - { - await base.Given(); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - - await 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 async Task When() - { - await base.When(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_tombstone.cs deleted file mode 100644 index 814b9fdf36..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_but_tombstone.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_posted_but_tombstone : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - $any: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - } - - protected override async Task When() - { - await base.When(); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_including_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_including_tombstone.cs deleted file mode 100644 index 8a6a43d102..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_events_are_posted_including_tombstone.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_posted_including_tombstone : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await HardDeleteStream("stream-1"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - - await 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 async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs deleted file mode 100644 index 92cbdc9750..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_any_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_any_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class - when_running_and_then_other_events_tombstone_ant_other_events : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - $any: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - } - - protected override async Task When() - { - await base.When(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await PostEvent("stream-3", "type1", "{}"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail( - "$projections-test-projection-stream-1-result", "Result:{\"a\":2}", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":4}"); - await AssertStreamTail("$projections-test-projection-stream-3-result", "Result:{\"a\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_are_indexed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_are_indexed.cs deleted file mode 100644 index 78a6e908d1..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_are_indexed.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection.recovery; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await AbortProjection("test-projection"); - WaitIdle(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs deleted file mode 100644 index 007be1cfb5..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection.recovery; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class - when_running_and_events_get_indexed_before_recovery : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await AbortProjection("test-projection"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs deleted file mode 100644 index 5ae721007f..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - - // required to flush index checkpoint - { - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - } - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {}}, - type1: function(s,e){s.a=(s.a||0) + 1}, - type2: function(s,e){s.a=(s.a||0) + 1}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone.cs deleted file mode 100644 index 24bada3fc9..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed_but_a_stream_and_tombstone : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - - // required to flush index checkpoint - { - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - } - - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_more_events_and_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_more_events_and_tombstone.cs deleted file mode 100644 index 805d511110..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_more_events_and_tombstone.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed_but_more_events_and_tombstone : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - ; - WaitIdle(); - - // required to flush index checkpoint - { - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - } - - await PostEvent("stream-1", "type2", "{}"); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":0,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs deleted file mode 100644 index 1d79a0268f..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed_but_tombstone : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - - // required to flush index checkpoint - { - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - } - - - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await 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 async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing.cs deleted file mode 100644 index bce6005c7c..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_no_indexing : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await 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(); -"); - } - - protected override async Task When() - { - await base.When(); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail( - "$projections-test-projection-stream-1-result", "Result:{\"a\":1}", "Result:{\"a\":1,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing_and_other_events.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing_and_other_events.cs deleted file mode 100644 index ee8600e626..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_all_foreach_projection/when_running_and_no_indexing_and_other_events.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_all_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_no_indexing_and_other_events : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await PostProjection(@" -fromAll().foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - } - - protected override async Task When() - { - await base.When(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await PostEvent("stream-3", "type1", "{}"); - WaitIdle(); - } - - [Test, Category("Network")] - public async Task receives_deleted_notification() - { - await AssertStreamTail( - "$projections-test-projection-stream-1-result", "Result:{\"a\":2}", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":4}"); - await AssertStreamTail("$projections-test-projection-stream-3-result", "Result:{\"a\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_are_indexed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_are_indexed.cs deleted file mode 100644 index 29bad35c98..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_are_indexed.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection. - recovery; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -// ReSharper disable once InconsistentNaming -public class when_running_and_events_are_indexed - : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - //todo replace with a deterministic fix rather than just covering the potential race condition #2236 - await PostEvent("stream-3", "type1", "{}"); - await PostEvent("stream-3", "type2", "{}"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await AbortProjection("test-projection"); - WaitIdle(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs deleted file mode 100644 index 4f745d8317..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/recovery/when_running_and_events_get_indexed_before_recovery.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection. - recovery; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class - when_running_and_events_get_indexed_before_recovery - : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await AbortProjection("test-projection"); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await EnableProjection("test-projection"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs deleted file mode 100644 index b3d2878734..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await HardDeleteStream("stream-1"); - WaitIdle(); - await EnableStandardProjections(); - } - - protected override async Task When() - { - await base.When(); - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {}}, - type1: function(s,e){s.a=(s.a||0) + 1}, - type2: function(s,e){s.a=(s.a||0) + 1}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":2}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone_postponed.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone_postponed.cs deleted file mode 100644 index 1d66579cf6..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_a_stream_and_tombstone_postponed.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -// ReSharper disable once InconsistentNaming -public class when_running_and_events_are_indexed_but_a_stream_and_tombstone_postponed : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await DisableStandardProjections(); - WaitIdle(); - - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - // SUT projection must have been joined heading reader - await EnableStandardProjections(); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-3", "type1", "{}"); - await PostEvent("stream-3", "type2", "{}"); - WaitIdle(); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await PostEvent("stream-3", "type1", "{}"); - await PostEvent("stream-3", "type2", "{}"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs deleted file mode 100644 index 5555dfa9a1..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_but_tombstone.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed_but_tombstone : specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - } - - protected override async Task When() - { - await base.When(); - await HardDeleteStream("stream-1"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":2,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_including_tombstone.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_including_tombstone.cs deleted file mode 100644 index 05026ca479..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_events_are_indexed_including_tombstone.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class when_running_and_events_are_indexed_including_tombstone : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await HardDeleteStream("stream-1"); - WaitIdle(); - await EnableStandardProjections(); - WaitIdle(); - } - - protected override async Task When() - { - await base.When(); - - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1}, -}).outputState(); -"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await DumpStream("$ce-stream"); - await AssertStreamTail("$projections-test-projection-stream-1-result", "Result:{\"a\":0,\"deleted\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs deleted file mode 100644 index d8087d6be7..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/when_handling_deleted/with_from_category_foreach_projection/when_running_and_then_other_events_tombstone_ant_other_events.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Threading.Tasks; -using EventStore.Core.Tests; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI.when_handling_deleted.with_from_category_foreach_projection; - -[TestFixture(typeof(LogFormat.V2), typeof(string))] -public class - when_running_and_then_other_events_tombstone_ant_other_events : - specification_with_standard_projections_runnning -{ - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - - protected override async Task Given() - { - await base.Given(); - await PostProjection(@" -fromCategory('stream').foreachStream().when({ - $init: function(){return {a:0}}, - type1: function(s,e){s.a++}, - type2: function(s,e){s.a++}, - $deleted: function(s,e){s.deleted=1;}, -}).outputState(); -"); - WaitIdle(); - await EnableStandardProjections(); - } - - protected override async Task When() - { - await base.When(); - await PostEvent("stream-1", "type1", "{}"); - await PostEvent("stream-1", "type2", "{}"); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - WaitIdle(); - await HardDeleteStream("stream-1"); - WaitIdle(); - await PostEvent("stream-2", "type1", "{}"); - await PostEvent("stream-2", "type2", "{}"); - await PostEvent("stream-3", "type1", "{}"); - WaitIdle(); - } - - [Test, Category("Network")] - [Ignore("Regression")] - public async Task receives_deleted_notification() - { - await AssertStreamTail( - "$projections-test-projection-stream-1-result", "Result:{\"a\":2}", "Result:{\"a\":2,\"deleted\":1}"); - await AssertStreamTail("$projections-test-projection-stream-2-result", "Result:{\"a\":4}"); - await AssertStreamTail("$projections-test-projection-stream-3-result", "Result:{\"a\":1}"); - } -} diff --git a/src/EventStore.Projections.Core.Tests/ClientAPI/with_standard_projections_running.cs b/src/EventStore.Projections.Core.Tests/ClientAPI/with_standard_projections_running.cs deleted file mode 100644 index 6027793c96..0000000000 --- a/src/EventStore.Projections.Core.Tests/ClientAPI/with_standard_projections_running.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Text; -using System.Threading.Tasks; -using EventStore.ClientAPI; -using EventStore.Core.Bus; -using EventStore.Core.Tests; -using EventStore.Projections.Core.Services.Processing; -using EventStore.Projections.Core.Services.Processing.Checkpointing; -using Newtonsoft.Json.Linq; -using NUnit.Framework; - -namespace EventStore.Projections.Core.Tests.ClientAPI -{ - namespace with_standard_projections_running - { - public abstract class when_deleting_stream_base - : specification_with_standard_projections_runnning - { - [Test, Category("Network")] - public async Task streams_stream_exists() - { - Assert.AreEqual( - SliceReadStatus.Success, - (await _conn.ReadStreamEventsForwardAsync("$streams", 0, 10, false, _admin)).Status); - } - - [Test, Category("Network")] - public async Task deleted_stream_events_are_indexed() - { - await Task.Delay(500); //give the projection time to catchup... - var slice = await _conn.ReadStreamEventsForwardAsync("$ce-cat", 0, 10, true, _admin); - Assert.AreEqual(SliceReadStatus.Success, slice.Status); - - Assert.AreEqual(3, slice.Events.Length); - var deletedLinkMetadata = slice.Events[2].Link.Metadata; - Assert.IsNotNull(deletedLinkMetadata); - - var checkpointTag = Encoding.UTF8.GetString(deletedLinkMetadata).ParseCheckpointExtraJson(); - Assert.IsTrue(checkpointTag.TryGetValue("$deleted", out _)); - Assert.IsTrue(checkpointTag.TryGetValue("$o", out var originalStream)); - Assert.AreEqual("cat-1", ((JValue)originalStream).Value); - } - - [Test, Category("Network")] - public async Task deleted_stream_events_are_indexed_as_deleted() - { - var slice = await _conn.ReadStreamEventsForwardAsync("$et-$deleted", 0, 10, true, _admin); - Assert.AreEqual(SliceReadStatus.Success, slice.Status); - - Assert.AreEqual(1, slice.Events.Length); - } - - protected override async Task When() - { - await base.When(); - var r1 = await _conn.AppendToStreamAsync( - "cat-1", ExpectedVersion.NoStream, _admin, - new EventData(Guid.NewGuid(), "type1", true, Encoding.UTF8.GetBytes("{}"), null)) - ; - - var r2 = await _conn.AppendToStreamAsync( - "cat-1", r1.NextExpectedVersion, _admin, - new EventData(Guid.NewGuid(), "type1", true, Encoding.UTF8.GetBytes("{}"), null)); - - await _conn.DeleteStreamAsync("cat-1", r2.NextExpectedVersion, GivenDeleteHardDeleteStreamMode(), - _admin) - ; - WaitIdle(); - if (!GivenStandardProjectionsRunning()) - { - await EnableStandardProjections(); - WaitIdle(); - } - } - - protected abstract bool GivenDeleteHardDeleteStreamMode(); - } - - [TestFixture(typeof(LogFormat.V2), typeof(string))] - public class when_hard_deleting_stream : when_deleting_stream_base - { - protected override bool GivenDeleteHardDeleteStreamMode() - { - return true; - } - } - - [TestFixture(typeof(LogFormat.V2), typeof(string))] - public class when_soft_deleting_stream : when_deleting_stream_base - { - protected override bool GivenDeleteHardDeleteStreamMode() - { - return false; - } - } - - [TestFixture(typeof(LogFormat.V2), typeof(string))] - public class when_hard_deleting_stream_and_starting_standard_projections : when_deleting_stream_base - { - protected override bool GivenDeleteHardDeleteStreamMode() - { - return true; - } - - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - } - - [TestFixture(typeof(LogFormat.V2), typeof(string))] - public class when_soft_deleting_stream_and_starting_standard_projections : when_deleting_stream_base - { - protected override bool GivenDeleteHardDeleteStreamMode() - { - return false; - } - - protected override bool GivenStandardProjectionsRunning() - { - return false; - } - } - } -}