-
-
Notifications
You must be signed in to change notification settings - Fork 316
Add Seq Module #1276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
montanehamilton
wants to merge
1
commit into
testcontainers:develop
Choose a base branch
from
montanehamilton:feature/add-seq-module
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Seq Module #1276
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
root = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
namespace Testcontainers.Seq; | ||
|
||
/// <inheritdoc cref="ContainerBuilder{TBuilderEntity, TContainerEntity, TConfigurationEntity}" /> | ||
[PublicAPI] | ||
public sealed class SeqBuilder : ContainerBuilder<SeqBuilder, SeqContainer, SeqConfiguration> | ||
{ | ||
public const string SeqImage = "datalust/seq:2024.2.11456"; | ||
|
||
public const ushort SeqApiPort = 80; | ||
public const ushort SeqIngestionPort = 5341; | ||
|
||
/// <inheritdoc /> | ||
protected override SeqConfiguration DockerResourceConfiguration { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqBuilder" /> class. | ||
/// </summary> | ||
public SeqBuilder() | ||
: this(new SeqConfiguration()) | ||
{ | ||
DockerResourceConfiguration = Init().DockerResourceConfiguration; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqBuilder" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
private SeqBuilder(SeqConfiguration resourceConfiguration) | ||
: base(resourceConfiguration) | ||
{ | ||
DockerResourceConfiguration = resourceConfiguration; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override SeqContainer Build() | ||
{ | ||
Validate(); | ||
return new SeqContainer(DockerResourceConfiguration); | ||
} | ||
/// <inheritdoc /> | ||
protected override SeqBuilder Init() | ||
{ | ||
return base.Init() | ||
.WithImage(SeqImage) | ||
.WithPortBinding(SeqApiPort, true) | ||
.WithPortBinding(SeqIngestionPort, true) | ||
.WithEnvironment(new Dictionary<string, string> | ||
{ | ||
{"ACCEPT_EULA", "Y" } | ||
}) | ||
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => | ||
request.ForPath("/health").ForPort(SeqApiPort))); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override SeqBuilder Clone(IResourceConfiguration<CreateContainerParameters> resourceConfiguration) | ||
{ | ||
return Merge(DockerResourceConfiguration, new SeqConfiguration(resourceConfiguration)); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override SeqBuilder Clone(IContainerConfiguration resourceConfiguration) | ||
{ | ||
return Merge(DockerResourceConfiguration, new SeqConfiguration(resourceConfiguration)); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override SeqBuilder Merge(SeqConfiguration oldValue, SeqConfiguration newValue) | ||
{ | ||
return new SeqBuilder(new SeqConfiguration(oldValue, newValue)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace Testcontainers.Seq; | ||
|
||
/// <inheritdoc cref="ContainerConfiguration" /> | ||
[PublicAPI] | ||
public sealed class SeqConfiguration : ContainerConfiguration | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="config">The Orion.TestContainers.Seq config.</param> | ||
public SeqConfiguration(object config = null) | ||
{ | ||
// Sets the custom builder methods property values. | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
public SeqConfiguration(IResourceConfiguration<CreateContainerParameters> resourceConfiguration) | ||
: base(resourceConfiguration) | ||
{ | ||
// Passes the configuration upwards to the base implementations to create an updated immutable copy. | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
public SeqConfiguration(IContainerConfiguration resourceConfiguration) | ||
: base(resourceConfiguration) | ||
{ | ||
// Passes the configuration upwards to the base implementations to create an updated immutable copy. | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
public SeqConfiguration(SeqConfiguration resourceConfiguration) | ||
: this(new SeqConfiguration(), resourceConfiguration) | ||
{ | ||
// Passes the configuration upwards to the base implementations to create an updated immutable copy. | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="oldValue">The old Docker resource configuration.</param> | ||
/// <param name="newValue">The new Docker resource configuration.</param> | ||
public SeqConfiguration(SeqConfiguration oldValue, SeqConfiguration newValue) | ||
: base(oldValue, newValue) | ||
{ | ||
// Create an updated immutable copy of the module configuration. | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
|
||
namespace Testcontainers.Seq; | ||
|
||
/// <inheritdoc cref="DockerContainer" /> | ||
[PublicAPI] | ||
public sealed class SeqContainer : DockerContainer | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SeqContainer" /> class. | ||
/// </summary> | ||
/// <param name="configuration">The container configuration.</param> | ||
public SeqContainer(SeqConfiguration configuration) | ||
: base(configuration) | ||
{ | ||
} | ||
|
||
public string GetServerApiUrl() | ||
{ | ||
return new UriBuilder("http", Hostname, GetMappedPublicPort(SeqBuilder.SeqApiPort)).Uri.ToString(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net8.0;netstandard2.0;netstandard2.1</TargetFrameworks> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="JetBrains.Annotations" VersionOverride="2023.3.0" PrivateAssets="All"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="../Testcontainers/Testcontainers.csproj"/> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global using System.Collections.Generic; | ||
global using Docker.DotNet.Models; | ||
global using DotNet.Testcontainers.Builders; | ||
global using DotNet.Testcontainers.Configurations; | ||
global using DotNet.Testcontainers.Containers; | ||
global using JetBrains.Annotations; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,59 @@ | |
<IsPublishable>false</IsPublishable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk"/> | ||
<PackageReference Include="coverlet.collector"/> | ||
<PackageReference Include="xunit.runner.visualstudio"/> | ||
<PackageReference Include="xunit"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="coverlet.collector" /> | ||
<PackageReference Include="xunit.runner.visualstudio" /> | ||
<PackageReference Include="xunit" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="../Testcontainers.*.Tests/Testcontainers.*.Tests.csproj"/> | ||
<ProjectReference Remove="Testcontainers.Databases.Tests.csproj"/> | ||
<ProjectReference Include="..\..\..\testcontainers-dotnet\src\Testcontainers.Seq\Testcontainers.Seq.csproj" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why changing the include mechanism that uses the |
||
<ProjectReference Include="..\Testcontainers.ActiveMq.Tests\Testcontainers.ActiveMq.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.ArangoDb.Tests\Testcontainers.ArangoDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Azurite.Tests\Testcontainers.Azurite.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.BigQuery.Tests\Testcontainers.BigQuery.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Bigtable.Tests\Testcontainers.Bigtable.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.ClickHouse.Tests\Testcontainers.ClickHouse.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.CockroachDb.Tests\Testcontainers.CockroachDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Consul.Tests\Testcontainers.Consul.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.CosmosDb.Tests\Testcontainers.CosmosDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Couchbase.Tests\Testcontainers.Couchbase.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.CouchDb.Tests\Testcontainers.CouchDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.DynamoDb.Tests\Testcontainers.DynamoDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Elasticsearch.Tests\Testcontainers.Elasticsearch.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.EventStoreDb.Tests\Testcontainers.EventStoreDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.FakeGcsServer.Tests\Testcontainers.FakeGcsServer.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.FirebirdSql.Tests\Testcontainers.FirebirdSql.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Firestore.Tests\Testcontainers.Firestore.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.InfluxDb.Tests\Testcontainers.InfluxDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.JanusGraph.Tests\Testcontainers.JanusGraph.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.K3s.Tests\Testcontainers.K3s.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Kafka.Tests\Testcontainers.Kafka.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Keycloak.Tests\Testcontainers.Keycloak.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Kusto.Tests\Testcontainers.Kusto.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.LocalStack.Tests\Testcontainers.LocalStack.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.MariaDb.Tests\Testcontainers.MariaDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Milvus.Tests\Testcontainers.Milvus.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Minio.Tests\Testcontainers.Minio.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.MongoDb.Tests\Testcontainers.MongoDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.MsSql.Tests\Testcontainers.MsSql.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.MySql.Tests\Testcontainers.MySql.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Nats.Tests\Testcontainers.Nats.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Neo4j.Tests\Testcontainers.Neo4j.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Oracle.Tests\Testcontainers.Oracle.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Papercut.Tests\Testcontainers.Papercut.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Platform.Linux.Tests\Testcontainers.Platform.Linux.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Platform.Windows.Tests\Testcontainers.Platform.Windows.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.PostgreSql.Tests\Testcontainers.PostgreSql.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.PubSub.Tests\Testcontainers.PubSub.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Pulsar.Tests\Testcontainers.Pulsar.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.RabbitMq.Tests\Testcontainers.RabbitMq.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.RavenDb.Tests\Testcontainers.RavenDb.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Redis.Tests\Testcontainers.Redis.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Redpanda.Tests\Testcontainers.Redpanda.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.ResourceReaper.Tests\Testcontainers.ResourceReaper.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.WebDriver.Tests\Testcontainers.WebDriver.Tests.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Xunit.Tests\Testcontainers.Xunit.Tests.csproj" /> | ||
<ProjectReference Remove="Testcontainers.Databases.Tests.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
root = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Seq.Api; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Testcontainers.Seq; | ||
|
||
public sealed class SeqContainerTest : IAsyncLifetime | ||
{ | ||
private readonly SeqContainer _seqContainer = new SeqBuilder().Build(); | ||
|
||
public Task InitializeAsync() | ||
{ | ||
return _seqContainer.StartAsync(); | ||
} | ||
|
||
public Task DisposeAsync() | ||
{ | ||
return _seqContainer.DisposeAsync().AsTask(); | ||
} | ||
|
||
[Fact] | ||
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] | ||
public async Task CanLog() | ||
{ | ||
var currentSeqApiPort = _seqContainer.GetMappedPublicPort(80); | ||
var currentSeqHostname = _seqContainer.Hostname; | ||
|
||
ILoggerFactory loggerFactory = new LoggerFactory(); | ||
loggerFactory.AddSeq(_seqContainer.GetServerApiUrl()); | ||
var testLogger = loggerFactory.CreateLogger("testlogger"); | ||
testLogger.LogInformation("TRY THIS"); | ||
|
||
var seqConnection = new SeqConnection(_seqContainer.GetServerApiUrl()); | ||
var eventList = await seqConnection.Events.ListAsync(fromDateUtc: DateTime.Now.AddMinutes(-1)); | ||
Assert.Contains(eventList, e => e.MessageTemplateTokens.Last().Text == "TRY THIS"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net8.0</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<IsPublishable>false</IsPublishable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Logging" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Seq.Api" /> | ||
<PackageReference Include="Seq.Extensions.Logging" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Testcontainers.Seq\Testcontainers.Seq.csproj" /> | ||
<ProjectReference Include="..\Testcontainers.Commons\Testcontainers.Commons.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
global using System.Threading.Tasks; | ||
global using DotNet.Testcontainers.Commons; | ||
global using Xunit; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.