Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8b1967b
Duplicate persistence tests and add to solution
DavidBoike Sep 14, 2023
d57736f
Switch reference to Raven5 persistence
DavidBoike Sep 14, 2023
cd33a3c
Namespaces & InternalsVisibleTo
DavidBoike Sep 14, 2023
a70f6f4
Don't need tests for expiring audit & saga audit messages
DavidBoike Sep 14, 2023
5cc6366
RavenLastModifiedScope was only used for expiration tests (and was br…
DavidBoike Sep 14, 2023
61f3784
Don't need to test saga audits
DavidBoike Sep 14, 2023
3d8e460
Remove FailedAuditImportCustomChecktests
DavidBoike Sep 14, 2023
049aefe
Magic string tests need to be persister-specific
DavidBoike Sep 14, 2023
c1ce576
EmbeddedDatabase test
tmasternak Sep 15, 2023
56c44eb
commenting out transformer tests
tmasternak Sep 15, 2023
3b082bb
get stats fixes - not sure this is still needed
tmasternak Sep 15, 2023
9830b24
subscription tests
tmasternak Sep 15, 2023
bb13b6a
we don't need tests for in index body storing (this is never happenin…
tmasternak Sep 15, 2023
b4124a0
commenting out tansformer tests
tmasternak Sep 15, 2023
da15c0c
starting lifecycle in the test setup
tmasternak Sep 15, 2023
c62c4e8
Duplicate acceptance tests and add to solution
DavidBoike Sep 15, 2023
818e390
Switch reference to RavenDB 5
DavidBoike Sep 15, 2023
a204646
Simple namespace fixes
DavidBoike Sep 15, 2023
7befe45
Remove audit-related tests
DavidBoike Sep 15, 2023
c8bbb7f
TestsFilter
DavidBoike Sep 15, 2023
acf23a1
couple compile fixes
DavidBoike Sep 15, 2023
9aaf73c
🩹 RavenDB5 Cannot do in memory so tests need to run sequentially
ramonsmits Sep 20, 2023
42ed692
🩹 Persister lifecycle wasn't disposed by host as it was injected thus…
ramonsmits Sep 20, 2023
d9627b2
🩹 Fixed a couple of transformations, added TODO's for sort that is br…
ramonsmits Sep 20, 2023
2c325a1
🩹 Some simple tests to prep the database with known documents for tes…
ramonsmits Sep 20, 2023
623a55e
Provide config for database to start in test
DavidBoike Sep 20, 2023
8257dfb
Change migration tests to a type that still exists in primary instance
DavidBoike Sep 20, 2023
369b432
Fix controller dependencies test
DavidBoike Sep 20, 2023
b01214f
That test wasn't even right on Raven35
DavidBoike Sep 20, 2023
b92d7fe
Make sure to find all the indexes
DavidBoike Sep 20, 2023
cfe38d5
That patch can't be null
DavidBoike Sep 20, 2023
92dac32
⚜️ cleanup
ramonsmits Sep 21, 2023
9fb11f3
Refactored PersistenceTestBase to manage a single EmbeddedDatabase in…
tmasternak Sep 21, 2023
d52976d
🩹 Removed obsolete settings for RavenDB 5
ramonsmits Sep 21, 2023
91befc4
Fix where the test filter attributes live
DavidBoike Sep 21, 2023
68cc750
Don't want to delete the whole database server directory
DavidBoike Sep 21, 2023
a12bc70
Make acceptance tests create DB properly
DavidBoike Sep 21, 2023
cd0f37e
Should also dispose the SharedInstance
DavidBoike Sep 21, 2023
cd7b107
Try to fix KnownEndpoints related errors from Guid vs String Ids
DavidBoike Sep 21, 2023
7282883
compile plz
DavidBoike Sep 21, 2023
da066ce
Approval changed because Raven5 does not have audit/saga data
DavidBoike Sep 21, 2023
226b2e1
EmbeddedDatabaseTests.CanStart() serves no purpose now
DavidBoike Sep 21, 2023
16a1fe7
Database named by guid so they aren't too long
DavidBoike Sep 21, 2023
6f824b0
Minor
DavidBoike Sep 21, 2023
6631620
Database name shouldn't be "audit"
DavidBoike Sep 21, 2023
56e7f8c
Be sure to run RavenDB out of a non-virtual drive
DavidBoike Sep 21, 2023
b30f940
body storage fixes
tmasternak Sep 22, 2023
b014748
failed message builder
tmasternak Sep 22, 2023
57788df
MessageViewTransformer defaults
tmasternak Sep 22, 2023
e0a7a27
MessageViewTest part 1
tmasternak Sep 22, 2023
6e20f48
CompositeViewTests
tmasternak Sep 22, 2023
5e2ba8b
minor clean-up
tmasternak Sep 22, 2023
2eb123e
Solution-wide remove unused usings
DavidBoike Sep 22, 2023
582a570
Shared database setup for Raven5 acceptance tests
DavidBoike Sep 22, 2023
24dca41
Better DB management and cleanup
DavidBoike Sep 22, 2023
5fc3908
Improvements to sequence testing so it doesn't query in such tight loops
DavidBoike Sep 22, 2023
73e37a3
Fixing a bunch of bugs with error ingestion and recoverability
DavidBoike Sep 22, 2023
dd9cc9e
🩹 Removed Yield that was there to please the editor config demon dur…
ramonsmits Sep 25, 2023
f7ae06a
🩹 Transformer was incorrectly using MessageId from METADATA from sort…
ramonsmits Sep 25, 2023
6d14705
🩹 Apply previous commit change also on transformer of RavenDB 3.5 imp…
ramonsmits Sep 25, 2023
b0dabe0
🩹 RavenQuery.LastModified only works in query expressions, replaced w…
ramonsmits Sep 25, 2023
e3249e4
controller dep
tmasternak Sep 25, 2023
5da77a2
failed error import test
tmasternak Sep 25, 2023
2366def
🩹 Forgot to pass the cancellation token source token and made both Sh…
ramonsmits Sep 25, 2023
0cbca56
🩹 DocumentStore was disposed in test it is resolved via host containe…
ramonsmits Sep 25, 2023
7f766cf
🩹 Removed the audit types but keeping `ServiceControl.EventLog.EventL…
ramonsmits Sep 25, 2023
2fb2be5
🩹 Missing closing bracket, test is still failing
ramonsmits Sep 25, 2023
dbc6865
copying over properties to insert know endpoints
tmasternak Sep 26, 2023
b9fe1dc
eventlogitem cleanup
tmasternak Sep 26, 2023
90ae7a8
Consolidate use of "Memory" into Infrastructure project
DavidBoike Sep 25, 2023
58ca2cb
Move Raven35-specific body storage enricher details into Raven35 impl…
DavidBoike Sep 25, 2023
427d460
Fix error ingestion for Raven5 to use empty MessageBodies/X documents…
DavidBoike Sep 26, 2023
e46caf6
Allow StartupModeTests to use shared DB
DavidBoike Sep 26, 2023
d9de3ef
Enable acceptance tests to run in parallel
DavidBoike Sep 26, 2023
f1a4485
Set FullText searching related temp setting to true to get LOH-relate…
DavidBoike Sep 26, 2023
2b237c3
Fix failed message patching
DavidBoike Sep 26, 2023
e622cdd
Handle full-text indexing of failed messages
DavidBoike Sep 27, 2023
a4b5d6e
Clean learning transport directory once before all acceptance tests
DavidBoike Sep 27, 2023
874f1da
Standardize use of MessageBodyIdGenerator
DavidBoike Sep 27, 2023
1f629b7
Non-parallel acceptance tests for now
DavidBoike Sep 27, 2023
c7c6260
Moving the full-text setting to persister won't affect platform sample
DavidBoike Sep 27, 2023
6bd1a9b
Make Raven35 tests support parallel execution as well
DavidBoike Sep 27, 2023
1146818
Fix neat little hidden assumption that message metadata containing "B…
DavidBoike Sep 27, 2023
dad2f38
This is set declaratively, no need to touch global ConfigurationManager
DavidBoike Sep 27, 2023
61e657e
ignore SagaAudit acceptance tests in Raven5
DavidBoike Sep 27, 2023
5c7af94
And back to sequential
DavidBoike Sep 27, 2023
07fcd65
🩹 Fixed the MessageViewTransformer, in its mapping it used the `Input…
ramonsmits Sep 28, 2023
e3b8e26
🔨 Applied same refactoring on FailedMessageViewTransformer as on Tra…
ramonsmits Sep 28, 2023
0a44822
Added DebuggerDisplay for easier debugging
ramonsmits Sep 28, 2023
ae46e2f
when_a_pending_retry test fix
tmasternak Sep 28, 2023
3be1657
yet another todo fixed
tmasternak Sep 28, 2023
2a1de98
moar fixes
tmasternak Sep 28, 2023
5a1f0bc
tests are green?
tmasternak Sep 28, 2023
4fe47bd
The message body docs should have a collection name
DavidBoike Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ windows-2022 ]
test-category: [ Default, SqlServer, AzureServiceBus, RabbitMQ, AzureStorageQueues, MSMQ, SQS, Raven35Acceptance ]
test-category: [ Default, SqlServer, AzureServiceBus, RabbitMQ, AzureStorageQueues, MSMQ, SQS, Raven35Acceptance, Raven5Acceptance, Raven5Persistence ]
include:
- os: windows-2022
os-name: Windows
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ServiceControl.AcceptanceTesting.InfrastructureConfig
{
using System;
using System.IO;
using System.Threading.Tasks;
using NServiceBus;
Expand All @@ -11,14 +12,14 @@ public class ConfigureEndpointLearningTransport : ITransportIntegration
{
public ConfigureEndpointLearningTransport()
{
var relativePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..", "..", "..", ".transport");
ConnectionString = Path.GetFullPath(relativePath);
ConnectionString = Path.Combine(Path.GetTempPath(), "ServiceControlTests", "TestTransport", TestContext.CurrentContext.Test.ID);
}

public string ConnectionString { get; set; }

public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
{
Console.WriteLine($"Transport Directory: {ConnectionString}");
Directory.CreateDirectory(ConnectionString);

var transportConfig = configuration.UseTransport<LearningTransport>();
Expand Down
69 changes: 69 additions & 0 deletions src/ServiceControl.AcceptanceTesting/PortPool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
namespace ServiceControl.AcceptanceTesting
{
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using TestHelper;

public class PortPool
{
readonly int startingPort;
readonly HashSet<int> inUse;

public PortPool(int startingPort)
{
this.startingPort = startingPort;
inUse = new HashSet<int>();
}

public PortLease GetLease() => new PortLease(this);

internal int LeasePort()
{
lock (inUse)
{
var start = inUse.Any() ? inUse.Max() + 1 : startingPort;
var port = PortUtility.FindAvailablePort(start);
inUse.Add(port);
TestContext.Out.WriteLine($"Port leased: {port}");
return port;
}
}

internal void Return(int port)
{
lock (inUse)
{
inUse.Remove(port);
}
}
}

public class PortLease : IDisposable
{
readonly PortPool owner;
readonly List<int> leasedPorts;

internal PortLease(PortPool owner)
{
this.owner = owner;
leasedPorts = new List<int>();
}

public int GetPort()
{
var port = owner.LeasePort();
leasedPorts.Add(port);
return port;
}

public void Dispose()
{
foreach (var port in leasedPorts)
{
owner.Return(port);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,24 @@ public SequenceBuilder<TContext> Do(string step, Func<TContext, Task> handler)
public IScenarioWithEndpointBehavior<TContext> Done(Func<TContext, bool> doneCriteria = null)
{
var behavior = new ServiceControlClient<TContext>(context => sequence.Continue(context));
return endpointBehavior.WithComponent(behavior).Done(ctx => sequence.IsFinished(ctx) && (doneCriteria == null || doneCriteria(ctx)));
return endpointBehavior.WithComponent(behavior).Done(async ctx =>
{
if (sequence.IsFinished(ctx))
{
if (doneCriteria == null || doneCriteria(ctx))
{
return true;
}
else
{
// If sequence is done but test is not finished, small delay to avoid tight loop check
await Task.Delay(250);
}
}

// If sequence is not finished immediately return false, since each step will enforce delays
return false;
});
}

IScenarioWithEndpointBehavior<TContext> endpointBehavior;
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceControl.AcceptanceTesting/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public async Task<bool> Continue(TContext context)
context.Step = nextStep;
return finished;
}
else
{
await Task.Delay(250);
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ItemGroup>
<ProjectReference Include="..\ServiceControl.Transports.Learning\ServiceControl.Transports.Learning.csproj" />
<ProjectReference Include="..\ServiceControlInstaller.Engine\ServiceControlInstaller.Engine.csproj" />
<ProjectReference Include="..\TestHelper\TestHelper.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
{
using System;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using Persistence.RavenDb;
using ServiceBus.Management.Infrastructure.Settings;
using ServiceControl.AcceptanceTesting;

class AcceptanceTestStorageConfiguration
{
static readonly PortPool portPool = new PortPool(33334);
readonly PortLease portLease = portPool.GetLease();

public string PersistenceType { get; protected set; }

public void CustomizeSettings(Settings settings)
{
settings.Port = portLease.GetPort();

settings.PersisterSpecificSettings = new RavenDBPersisterSettings
{
RunInMemory = true,
DatabaseMaintenancePort = FindAvailablePort(settings.Port + 1),
DatabaseMaintenancePort = portLease.GetPort(),
DatabasePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()),
ErrorRetentionPeriod = TimeSpan.FromDays(10),
};
Expand All @@ -30,24 +34,10 @@ public Task Configure()
return Task.CompletedTask;
}

static int FindAvailablePort(int startPort)
public Task Cleanup()
{
var activeTcpListeners = IPGlobalProperties
.GetIPGlobalProperties()
.GetActiveTcpListeners();

for (var port = startPort; port < startPort + 1024; port++)
{
var portCopy = port;
if (activeTcpListeners.All(endPoint => endPoint.Port != portCopy))
{
return port;
}
}

return startPort;
portLease.Dispose();
return Task.CompletedTask;
}

public Task Cleanup() => Task.CompletedTask;
}
}
1 change: 1 addition & 0 deletions src/ServiceControl.AcceptanceTests.RavenDB5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.transport
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace ServiceControl.AcceptanceTests
{
using System.Threading.Tasks;
using Persistence.RavenDb;
using ServiceBus.Management.Infrastructure.Settings;
using ServiceControl.AcceptanceTesting;

class AcceptanceTestStorageConfiguration
{
static readonly PortPool portPool = new PortPool(33334);

readonly DatabaseLease databaseLease = SharedDatabaseSetup.LeaseDatabase();
readonly PortLease portLease = portPool.GetLease();

public string PersistenceType { get; protected set; }

public void CustomizeSettings(Settings settings)
{
databaseLease.CustomizeSettings(settings);
settings.Port = portLease.GetPort();
}

public Task Configure()
{
PersistenceType = typeof(RavenDbPersistenceConfiguration).AssemblyQualifiedName;

return Task.CompletedTask;
}

public async ValueTask Cleanup()
{
portLease.Dispose();
await databaseLease.DisposeAsync();
}
}
}
9 changes: 9 additions & 0 deletions src/ServiceControl.AcceptanceTests.RavenDB5/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Raven/Esent/MaxVerPages" value="4096" />
</appSettings>
<runtime>
<gcServer enabled="true" />
</runtime>
</configuration>
28 changes: 28 additions & 0 deletions src/ServiceControl.AcceptanceTests.RavenDB5/DatabaseLease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Threading.Tasks;
using Raven.Client.ServerWide.Operations;
using ServiceBus.Management.Infrastructure.Settings;

public class DatabaseLease : IAsyncDisposable
{
public string DatabaseName { get; } = Guid.NewGuid().ToString("n");

public void CustomizeSettings(Settings settings)
{
settings.PersisterSpecificSettings = new RavenDBPersisterSettings
{
ErrorRetentionPeriod = TimeSpan.FromDays(10),
ConnectionString = SharedDatabaseSetup.SharedInstance.ServerUrl,
DatabaseName = DatabaseName
};
}

public async ValueTask DisposeAsync()
{
var documentStore = await SharedDatabaseSetup.SharedInstance.Connect();

// Comment this out temporarily to be able to inspect a database after the test has completed
var deleteDatabasesOperation = new DeleteDatabasesOperation(new DeleteDatabasesOperation.Parameters { DatabaseNames = new[] { DatabaseName }, HardDelete = true });
await documentStore.Maintenance.Server.SendAsync(deleteDatabasesOperation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
namespace ServiceControl.AcceptanceTests.RavenDB.Recoverability.MessageFailures
{
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using Infrastructure.WebApi;
using Operations;
using Raven.Client.Documents;
using Raven.Client.Documents.Operations;

public class FailedErrorsCountReponse
{
public int Count { get; set; }
}

class FailedErrorsController : ApiController
{
public FailedErrorsController(IDocumentStore store, ImportFailedErrors importFailedErrors)
{
this.store = store;
this.importFailedErrors = importFailedErrors;
}

[Route("failederrors/count")]
[HttpGet]
public async Task<HttpResponseMessage> GetFailedErrorsCount()
{
using (var session = store.OpenAsyncSession())
{
var query =
session.Query<FailedErrorImport, FailedErrorImportIndex>().Statistics(out var stats);

var count = await query.CountAsync();

return Request.CreateResponse(HttpStatusCode.OK, new FailedErrorsCountReponse
{
Count = count
})
.WithEtag(stats.ResultEtag.ToString());
}
}

[Route("failederrors/import")]
[HttpPost]
public async Task<HttpResponseMessage> ImportFailedErrors(CancellationToken cancellationToken = default)
{
var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
await importFailedErrors.Run(tokenSource.Token);
return Request.CreateResponse(HttpStatusCode.OK);
}

[Route("failederrors/forcecleanerrors")]
[HttpPost]
public Task<HttpResponseMessage> ForceErrorMessageCleanerRun()
{
// TODO: Is there a way to force the Raven5 expiration to happen? Or does it just happen? Won't be able to tell until we redesign that.

// May not even need WaitForIndexes given Raven5 implementation isn't index-based
WaitForIndexes(store);

return Task.FromResult(Request.CreateResponse(HttpStatusCode.OK));
}

static void WaitForIndexes(IDocumentStore store)
{
SpinWait.SpinUntil(() => store.Maintenance.Send(new GetStatisticsOperation()).StaleIndexes.Length == 0, TimeSpan.FromSeconds(10));
}

readonly IDocumentStore store;
readonly ImportFailedErrors importFailedErrors;
}
}
Loading