Skip to content

Commit c763fd5

Browse files
committed
Merge branch 'release/12.0.0'
2 parents c0ab21c + 7647caf commit c763fd5

38 files changed

Lines changed: 2648 additions & 388 deletions

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"gitversion.tool": {
6-
"version": "6.0.2",
6+
"version": "6.1.0",
77
"commands": [
88
"dotnet-gitversion"
99
],

Changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# NEventStore.Persistence.MongoDB
22

3+
## 12.0.0
4+
5+
- Async methods added to IPersistStreams interfaces [#71](https://github.com/NEventStore/NEventStore.Persistence.MongoDB/issues/71)
6+
- Updated NEventStore to 10.0.0
7+
8+
### Breaking Changes
9+
10+
- `EmptyRecycleBin()` is not called anymore during engine `MongoPersistenceEngine.Initialize()`.
11+
312
## 11.0.0
413

514
- Support: net6.0, netstandard2.1, net472

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dotnet tool run dotnet-gitversion ".\dependencies\NEventStore" /updateAssemblyIn
2525

2626
# Build
2727
Write-Host "Building: "$nugetversion" "$configuration
28-
dotnet build ./src/NEventStore.Persistence.MongoDB.Core.sln -c $configuration --no-restore
28+
dotnet build ./src/NEventStore.Persistence.MongoDB.Core.sln -c $configuration --no-restore /p:ContinuousIntegrationBuild=True
2929

3030
# Testing
3131
if ($runtests -eq "y") {

dependencies/NEventStore

Submodule NEventStore updated 179 files

src/.nuget/NEventStore.Persistence.MongoDB.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
-->
2727
<dependencies>
2828
<group targetFramework=".NETFramework4.7.2">
29-
<dependency id="NEventStore" version="[9.1.1,10.0.0)" exclude="Build,Analyzers"/>
29+
<dependency id="NEventStore" version="[10.0.0,11.0.0)" exclude="Build,Analyzers"/>
3030
<dependency id="MongoDB.Driver" version="[3.0.0,4.0.0)" exclude="Build,Analyzers"/>
3131
</group>
3232
<group targetFramework=".NETStandard2.1">
33-
<dependency id="NEventStore" version="[9.1.1,10.0.0)" exclude="Build,Analyzers"/>
33+
<dependency id="NEventStore" version="[10.0.0,11.0.0)" exclude="Build,Analyzers"/>
3434
<dependency id="MongoDB.Driver" version="[3.0.0,4.0.0)" exclude="Build,Analyzers"/>
3535
</group>
3636
<group targetFramework=".net6.0">
37-
<dependency id="NEventStore" version="[9.1.1,10.0.0)" exclude="Build,Analyzers"/>
37+
<dependency id="NEventStore" version="[10.0.0,11.0.0)" exclude="Build,Analyzers"/>
3838
<dependency id="MongoDB.Driver" version="[3.0.0,4.0.0)" exclude="Build,Analyzers"/>
3939
</group>
4040
</dependencies>

src/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<PropertyGroup>
3+
<LangVersion>13.0</LangVersion>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
</Project>

src/NEventStore.Persistence.MongoDB.Benchmark/NEventStore.Persistence.MongoDB.Benchmark.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<OutputTypeEx>exe</OutputTypeEx>
88
<StartupObject />
99
<OutputType>Exe</OutputType>
10-
<LangVersion>12.0</LangVersion>
1110
</PropertyGroup>
1211

1312
<PropertyGroup>

src/NEventStore.Persistence.MongoDB.Core.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1919
..\appveyor.yml = ..\appveyor.yml
2020
..\build.ps1 = ..\build.ps1
2121
..\Changelog.md = ..\Changelog.md
22+
Directory.Build.props = Directory.Build.props
2223
..\GitVersion.yml = ..\GitVersion.yml
2324
..\icon.png = ..\icon.png
2425
..\README.md = ..\README.md
Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
using MongoDB.Bson;
2+
using NEventStore.Persistence.AcceptanceTests;
3+
using NEventStore.Persistence.MongoDB.Support;
4+
using NEventStore.Persistence.AcceptanceTests.BDD;
5+
using FluentAssertions;
6+
#if MSTEST
7+
using Microsoft.VisualStudio.TestTools.UnitTesting;
8+
#endif
9+
#if NUNIT
10+
#endif
11+
#if XUNIT
12+
using Xunit;
13+
using Xunit.Should;
14+
#endif
15+
16+
namespace NEventStore.Persistence.MongoDB.Tests.AcceptanceTests.Async
17+
{
18+
#if MSTEST
19+
[TestClass]
20+
#endif
21+
public class Verify_safe_generator_not_create_hole : PersistenceEngineConcern
22+
{
23+
private string? _streamId;
24+
private string? _bucketId;
25+
private CommitAttempt? _attempt;
26+
27+
public Verify_safe_generator_not_create_hole()
28+
{
29+
var options = new MongoPersistenceOptions
30+
{
31+
ConcurrencyStrategy = ConcurrencyExceptionStrategy.Continue
32+
};
33+
34+
var db = options.ConnectToDatabase(AcceptanceTestMongoPersistenceFactory.GetConnectionString());
35+
var collection = db.GetCollection<BsonDocument>("Commits");
36+
options.CheckpointGenerator = new AlwaysQueryDbForNextValueCheckpointGenerator(collection);
37+
38+
PersistenceEngineFixture.Options = options;
39+
40+
// workaround for test initialization to have uniform config for all 3 test frameworks
41+
// we can't use ClassInitialize, TestFixtureSetup or SetFixture
42+
Fixture!.Initialize(ConfiguredPageSizeForTesting);
43+
44+
// reset this immediately, hopefully will not impact other tests
45+
PersistenceEngineFixture.Options = null;
46+
}
47+
48+
protected override async Task ContextAsync()
49+
{
50+
_streamId = Guid.NewGuid().ToString();
51+
_attempt = _streamId.BuildAttempt();
52+
var commit = await Persistence.CommitAsync(_attempt).ConfigureAwait(false);
53+
_bucketId = commit!.BucketId;
54+
}
55+
56+
protected override async Task BecauseAsync()
57+
{
58+
try
59+
{
60+
await Persistence.CommitAsync(_streamId!.BuildAttempt()).ConfigureAwait(false);
61+
throw new Exception("Previous message should throw concurrency exception");
62+
}
63+
catch (ConcurrencyException)
64+
{
65+
//do nothing.
66+
}
67+
await Persistence.CommitAsync(_attempt!.BuildNextAttempt()).ConfigureAwait(false);
68+
}
69+
70+
[Fact]
71+
public async Task Holes_are_presents()
72+
{
73+
var observer = new CommitStreamObserver();
74+
await Persistence.GetFromAsync(_bucketId!, _streamId!, int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
75+
var commits = observer.Commits.ToArray();
76+
commits.Length.Should().Be(2);
77+
commits[0].CheckpointToken.Should().Be(1);
78+
commits[1].CheckpointToken.Should().Be(2);
79+
}
80+
}
81+
82+
#if MSTEST
83+
[TestClass]
84+
#endif
85+
public class Holes_are_filled_after_concurrency_exception : PersistenceEngineConcern
86+
{
87+
private string? _streamId;
88+
private string? _bucketId;
89+
private CommitAttempt? _attempt;
90+
91+
public Holes_are_filled_after_concurrency_exception()
92+
{
93+
var options = new MongoPersistenceOptions
94+
{
95+
ConcurrencyStrategy = ConcurrencyExceptionStrategy.FillHole
96+
};
97+
PersistenceEngineFixture.Options = options;
98+
99+
// workaround for test initialization to have uniform config for all 3 test frameworks
100+
// we can't use ClassInitialize, TestFixtureSetup or SetFixture
101+
Fixture!.Initialize(ConfiguredPageSizeForTesting);
102+
103+
// reset this immediately, hopefully will not impact other tests
104+
PersistenceEngineFixture.Options = null;
105+
}
106+
107+
protected override async Task ContextAsync()
108+
{
109+
_streamId = Guid.NewGuid().ToString();
110+
var commit = await Persistence.CommitAsync(_attempt = _streamId.BuildAttempt()).ConfigureAwait(false);
111+
_bucketId = commit!.BucketId;
112+
}
113+
114+
protected override async Task BecauseAsync()
115+
{
116+
try
117+
{
118+
await Persistence.CommitAsync(_streamId!.BuildAttempt()).ConfigureAwait(false);
119+
throw new Exception("Previous message should throw concurrency exception");
120+
}
121+
catch (ConcurrencyException)
122+
{
123+
//do nothing.
124+
}
125+
await Persistence.CommitAsync(_attempt!.BuildNextAttempt()).ConfigureAwait(false);
126+
}
127+
128+
[Fact]
129+
public async Task Holes_are_not_presents()
130+
{
131+
var observer = new CommitStreamObserver();
132+
await Persistence.GetFromAsync(_bucketId!, _streamId!, int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
133+
var commits = observer.Commits.ToArray();
134+
commits.Length.Should().Be(2);
135+
commits[0].CheckpointToken.Should().Be(1);
136+
commits[1].CheckpointToken.Should().Be(3);
137+
138+
observer = new CommitStreamObserver();
139+
await Persistence.GetFromAsync("system", "system.empty.2", int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
140+
commits = observer.Commits.ToArray();
141+
commits.Length.Should().Be(1);
142+
commits[0].CheckpointToken.Should().Be(2);
143+
}
144+
}
145+
146+
#if MSTEST
147+
[TestClass]
148+
#endif
149+
public class Holes_are_not_filled_as_default_behavior : PersistenceEngineConcern
150+
{
151+
private string? _streamId;
152+
private string? _bucketId;
153+
private CommitAttempt? _attempt;
154+
155+
public Holes_are_not_filled_as_default_behavior()
156+
{
157+
var options = new MongoPersistenceOptions
158+
{
159+
ConcurrencyStrategy = ConcurrencyExceptionStrategy.Continue
160+
};
161+
162+
var db = options.ConnectToDatabase(AcceptanceTestMongoPersistenceFactory.GetConnectionString());
163+
var collection = db.GetCollection<BsonDocument>("Commits");
164+
165+
options.CheckpointGenerator = new InMemoryCheckpointGenerator(collection);
166+
PersistenceEngineFixture.Options = options;
167+
168+
// workaround for test initialization to have uniform config for all 3 test frameworks
169+
// we can't use ClassInitialize, TestFixtureSetup or SetFixture
170+
Fixture!.Initialize(ConfiguredPageSizeForTesting);
171+
172+
// reset this immediately, hopefully will not impact other tests
173+
PersistenceEngineFixture.Options = null;
174+
}
175+
176+
protected override async Task ContextAsync()
177+
{
178+
_streamId = Guid.NewGuid().ToString();
179+
var commit = await Persistence.CommitAsync(_attempt = _streamId.BuildAttempt()).ConfigureAwait(false);
180+
_bucketId = commit!.BucketId;
181+
}
182+
183+
protected override async Task BecauseAsync()
184+
{
185+
try
186+
{
187+
await Persistence.CommitAsync(_streamId!.BuildAttempt()).ConfigureAwait(false);
188+
throw new Exception("Previous message should throw concurrency exception");
189+
}
190+
catch (ConcurrencyException)
191+
{
192+
//do nothing.
193+
}
194+
await Persistence.CommitAsync(_attempt!.BuildNextAttempt()).ConfigureAwait(false);
195+
}
196+
197+
[Fact]
198+
public async Task Holes_are_presents()
199+
{
200+
var observer = new CommitStreamObserver();
201+
await Persistence.GetFromAsync(_bucketId!, _streamId!, int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
202+
var commits = observer.Commits.ToArray();
203+
commits.Length.Should().Be(2);
204+
commits[0].CheckpointToken.Should().Be(1);
205+
commits[1].CheckpointToken.Should().Be(3);
206+
207+
observer = new CommitStreamObserver();
208+
await Persistence.GetFromAsync("system", "system.2", int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
209+
commits = observer.Commits.ToArray();
210+
commits.Length.Should().Be(0);
211+
}
212+
}
213+
214+
#if MSTEST
215+
[TestClass]
216+
#endif
217+
public class Default_behavior_after_concurrency_exception : PersistenceEngineConcern
218+
{
219+
private string? _streamId;
220+
private string? _bucketId;
221+
private CommitAttempt? _attempt;
222+
223+
protected override async Task ContextAsync()
224+
{
225+
_streamId = Guid.NewGuid().ToString();
226+
var commit = await Persistence.CommitAsync(_attempt = _streamId.BuildAttempt()).ConfigureAwait(false);
227+
_bucketId = commit!.BucketId;
228+
}
229+
230+
protected override async Task BecauseAsync()
231+
{
232+
try
233+
{
234+
await Persistence.CommitAsync(_streamId!.BuildAttempt()).ConfigureAwait(false);
235+
throw new Exception("Previous message should throw concurrency exception");
236+
}
237+
catch (ConcurrencyException)
238+
{
239+
//do nothing.
240+
}
241+
await Persistence.CommitAsync(_attempt!.BuildNextAttempt()).ConfigureAwait(false);
242+
}
243+
244+
[Fact]
245+
public async Task Holes_are_not_presents()
246+
{
247+
var observer = new CommitStreamObserver();
248+
await Persistence.GetFromAsync(_bucketId!, _streamId!, int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
249+
var commits = observer.Commits.ToArray();
250+
commits.Length.Should().Be(2);
251+
commits[0].CheckpointToken.Should().Be(1);
252+
commits[1].CheckpointToken.Should().Be(2);
253+
254+
observer = new CommitStreamObserver();
255+
await Persistence.GetFromAsync("system", "system.2", int.MinValue, int.MaxValue, observer).ConfigureAwait(false);
256+
commits = observer.Commits.ToArray();
257+
commits.Length.Should().Be(0);
258+
}
259+
}
260+
}

0 commit comments

Comments
 (0)