Skip to content

Commit

Permalink
Isolating more troublesome tests in the stress tests project
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Oct 22, 2024
1 parent dba2328 commit 0d9d5a7
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 84 deletions.
6 changes: 6 additions & 0 deletions src/CoreTests/CoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
<Compile Include="..\Marten.Testing\Harness\TestsSettings.cs">
<Link>Harness\TestsSettings.cs</Link>
</Compile>
<Compile Include="..\Marten.Testing\MartenHostEnvironment.cs">
<Link>MartenHostEnvironment.cs</Link>
</Compile>
<Compile Include="..\Marten.Testing\RecordingLogger.cs">
<Link>RecordingLogger.cs</Link>
</Compile>
<Compile Include="..\Marten.Testing\SchemaMigrationExtensions.cs">
<Link>SchemaMigrationExtensions.cs</Link>
</Compile>
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/CoreTests/MartenServiceCollectionExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Marten.Internal.Sessions;
using Marten.Services;
using Marten.Sessions;
using Marten.Testing;
using Marten.Testing.Documents;
using Marten.Testing.Harness;
using Microsoft.Extensions.DependencyInjection;
Expand Down
59 changes: 1 addition & 58 deletions src/CoreTests/request_count_tracking.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Marten;
using Marten.Exceptions;
using Marten.Services;
using Marten.Testing;
using Marten.Testing.Harness;
using Npgsql;
using Shouldly;
Expand Down Expand Up @@ -124,59 +123,3 @@ public async Task log_execute_success_2_async()
logger.LastCommand.ShouldBeSameAs(cmd);
}
}

public class RecordingLogger: IMartenSessionLogger
{
public NpgsqlCommand LastCommand;
public Exception LastException;
public readonly IList<IChangeSet> Commits = new List<IChangeSet>();
public IChangeSet LastCommit { get; set; }

public IDocumentSession LastSession { get; set; }

public int OnBeforeExecuted { get; set; }

public void LogFailure(NpgsqlBatch batch, Exception ex)
{

}

public void LogFailure(Exception ex, string message)
{

}

public void RecordSavedChanges(IDocumentSession session, IChangeSet commit)
{
LastSession = session;
LastCommit = commit.Clone();

Commits.Add(commit);
}

public void OnBeforeExecute(NpgsqlCommand command)
{
OnBeforeExecuted++;
}

public void OnBeforeExecute(NpgsqlBatch batch)
{

}

public void LogSuccess(NpgsqlCommand command)
{
LastCommand = command;
}

public void LogFailure(NpgsqlCommand command, Exception ex)
{
LastCommand = command;
LastException = ex;
}

public void LogSuccess(NpgsqlBatch batch)
{

}
}
1 change: 1 addition & 0 deletions src/Marten.Testing/Marten.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Jil" Version="3.0.0-alpha2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;

namespace CoreTests;
namespace Marten.Testing;

internal class MartenHostEnvironment : IHostEnvironment
{
Expand Down
62 changes: 62 additions & 0 deletions src/Marten.Testing/RecordingLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using Marten.Services;
using Npgsql;

namespace Marten.Testing;

public class RecordingLogger: IMartenSessionLogger
{
public NpgsqlCommand LastCommand;
public Exception LastException;
public readonly IList<IChangeSet> Commits = new List<IChangeSet>();
public IChangeSet LastCommit { get; set; }

public IDocumentSession LastSession { get; set; }

public int OnBeforeExecuted { get; set; }

public void LogFailure(NpgsqlBatch batch, Exception ex)
{

}

public void LogFailure(Exception ex, string message)
{

}

public void RecordSavedChanges(IDocumentSession session, IChangeSet commit)
{
LastSession = session;
LastCommit = commit.Clone();

Commits.Add(commit);
}

public void OnBeforeExecute(NpgsqlCommand command)
{
OnBeforeExecuted++;
}

public void OnBeforeExecute(NpgsqlBatch batch)
{

}

public void LogSuccess(NpgsqlCommand command)
{
LastCommand = command;
}

public void LogFailure(NpgsqlCommand command, Exception ex)
{
LastCommand = command;
LastException = ex;
}

public void LogSuccess(NpgsqlBatch batch)
{

}
}
9 changes: 9 additions & 0 deletions src/StressTests/StressTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
<PackageReference Include="Shouldly" Version="4.2.1" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Marten.Testing\MartenHostEnvironment.cs">
<Link>MartenHostEnvironment.cs</Link>
</Compile>
<Compile Include="..\Marten.Testing\RecordingLogger.cs">
<Link>RecordingLogger.cs</Link>
</Compile>
</ItemGroup>

<PropertyGroup>
<NoWarn>xUnit1013</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Marten.Events.Daemon.Resiliency;
using Marten.Internal;
using Marten.Services;
using Marten.Testing;
using Marten.Testing.Documents;
using Marten.Testing.Harness;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -46,7 +47,7 @@ public using_multiple_document_stores_in_same_host()
});
// Just to prove that this doesn't blow up, see GH-2892
services.AddKeyedSingleton<IMartenSessionLogger>("blue", new StoreOptionsTests.RecordingLogger());
services.AddKeyedSingleton<IMartenSessionLogger>("blue", new RecordingLogger());
services.AddMartenStore<ISecondStore>(services =>
{
Expand Down

0 comments on commit 0d9d5a7

Please sign in to comment.