-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Andre Hofmeister <[email protected]>
- Loading branch information
1 parent
2c6c915
commit 40227bf
Showing
14 changed files
with
221 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -34,4 +34,5 @@ testcontainer | |
testcontainers | ||
tlsverify | ||
toml | ||
vstest | ||
vstest | ||
weaviate |
This file contains 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 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 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 |
12 changes: 12 additions & 0 deletions
12
src/Testcontainers.Weaviate/Testcontainers.Weaviate.csproj
This file contains 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>net8.0;net9.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 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; | ||
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 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,61 @@ | ||
namespace Testcontainers.Weaviate; | ||
|
||
/// <inheritdoc cref="ContainerBuilder{TBuilderEntity, TContainerEntity, TConfigurationEntity}" /> | ||
[PublicAPI] | ||
public sealed class WeaviateBuilder : ContainerBuilder<WeaviateBuilder, WeaviateContainer, WeaviateConfiguration> | ||
{ | ||
public const string WeaviateImage = "semitechnologies/weaviate:1.26.14"; | ||
|
||
public const ushort WeaviateHttpPort = 8080; | ||
|
||
public const ushort WeaviateGrpcPort = 50051; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WeaviateBuilder" /> class. | ||
/// </summary> | ||
public WeaviateBuilder() : this(new WeaviateConfiguration()) | ||
=> DockerResourceConfiguration = Init().DockerResourceConfiguration; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WeaviateBuilder" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
private WeaviateBuilder(WeaviateConfiguration resourceConfiguration) : base(resourceConfiguration) | ||
=> DockerResourceConfiguration = resourceConfiguration; | ||
|
||
/// <inheritdoc /> | ||
protected override WeaviateConfiguration DockerResourceConfiguration { get; } | ||
|
||
/// <inheritdoc /> | ||
public override WeaviateContainer Build() | ||
{ | ||
Validate(); | ||
return new WeaviateContainer(DockerResourceConfiguration); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override WeaviateBuilder Init() | ||
=> base.Init() | ||
.WithImage(WeaviateImage) | ||
.WithPortBinding(WeaviateHttpPort, true) | ||
.WithPortBinding(WeaviateGrpcPort, true) | ||
.WithEnvironment("AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED", "true") | ||
.WithEnvironment("PERSISTENCE_DATA_PATH", "/var/lib/weaviate") | ||
.WithWaitStrategy(Wait.ForUnixContainer() | ||
.UntilPortIsAvailable(WeaviateHttpPort) | ||
.UntilPortIsAvailable(WeaviateGrpcPort) | ||
.UntilHttpRequestIsSucceeded(request => | ||
request.ForPath("/v1/.well-known/ready").ForPort(WeaviateHttpPort))); | ||
|
||
/// <inheritdoc /> | ||
protected override WeaviateBuilder Clone(IResourceConfiguration<CreateContainerParameters> resourceConfiguration) | ||
=> Merge(DockerResourceConfiguration, new WeaviateConfiguration(resourceConfiguration)); | ||
|
||
/// <inheritdoc /> | ||
protected override WeaviateBuilder Clone(IContainerConfiguration resourceConfiguration) | ||
=> Merge(DockerResourceConfiguration, new WeaviateConfiguration(resourceConfiguration)); | ||
|
||
/// <inheritdoc /> | ||
protected override WeaviateBuilder Merge(WeaviateConfiguration oldValue, WeaviateConfiguration newValue) | ||
=> new(new WeaviateConfiguration(oldValue, newValue)); | ||
} |
This file contains 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,53 @@ | ||
namespace Testcontainers.Weaviate; | ||
|
||
/// <inheritdoc cref="ContainerConfiguration" /> | ||
[PublicAPI] | ||
public sealed class WeaviateConfiguration : ContainerConfiguration | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class. | ||
/// </summary> | ||
public WeaviateConfiguration() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
public WeaviateConfiguration(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="WeaviateConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
public WeaviateConfiguration(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="WeaviateConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="resourceConfiguration">The Docker resource configuration.</param> | ||
public WeaviateConfiguration(WeaviateConfiguration resourceConfiguration) | ||
: this(new WeaviateConfiguration(), resourceConfiguration) | ||
{ | ||
// Passes the configuration upwards to the base implementations to create an updated immutable copy. | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class. | ||
/// </summary> | ||
/// <param name="oldValue">The old Docker resource configuration.</param> | ||
/// <param name="newValue">The new Docker resource configuration.</param> | ||
public WeaviateConfiguration(WeaviateConfiguration oldValue, WeaviateConfiguration newValue) | ||
: base(oldValue, newValue) | ||
{ | ||
} | ||
} |
This file contains 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,15 @@ | ||
namespace Testcontainers.Weaviate; | ||
|
||
/// <inheritdoc cref="DockerContainer" /> | ||
[PublicAPI] | ||
public sealed class WeaviateContainer(WeaviateConfiguration configuration) : DockerContainer(configuration) | ||
{ | ||
/// <summary> | ||
/// Gets the Weaviate base address. | ||
/// </summary> | ||
/// <returns>The Weaviate base address.</returns> | ||
public string GetBaseAddress() | ||
{ | ||
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(WeaviateBuilder.WeaviateHttpPort)).ToString(); | ||
} | ||
} |
This file contains 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 |
17 changes: 17 additions & 0 deletions
17
tests/Testcontainers.Weaviate.Tests/Testcontainers.Weaviate.Tests.csproj
This file contains 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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net9.0</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<IsPublishable>false</IsPublishable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk"/> | ||
<PackageReference Include="coverlet.collector"/> | ||
<PackageReference Include="xunit.runner.visualstudio"/> | ||
<PackageReference Include="xunit"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="../../src/Testcontainers.Weaviate/Testcontainers.Weaviate.csproj"/> | ||
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/> | ||
</ItemGroup> | ||
</Project> |
This file contains 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; | ||
global using System.Net; | ||
global using System.Net.Http; | ||
global using System.Threading.Tasks; | ||
global using DotNet.Testcontainers.Commons; | ||
global using Xunit; |
26 changes: 26 additions & 0 deletions
26
tests/Testcontainers.Weaviate.Tests/WeaviateContainerTest.cs
This file contains 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 @@ | ||
namespace Testcontainers.Weaviate; | ||
|
||
public sealed class WeaviateContainerTest : IAsyncLifetime | ||
{ | ||
private readonly WeaviateContainer _weaviateContainer = new WeaviateBuilder().Build(); | ||
|
||
public Task InitializeAsync() => _weaviateContainer.StartAsync(); | ||
|
||
public Task DisposeAsync() => _weaviateContainer.DisposeAsync().AsTask(); | ||
|
||
[Fact] | ||
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] | ||
public async Task GetSchemaReturnsHttpStatusCodeOk() | ||
{ | ||
// Given | ||
using var httpClient = new HttpClient(); | ||
httpClient.BaseAddress = new Uri(_weaviateContainer.GetBaseAddress()); | ||
|
||
// When | ||
using var httpResponse = await httpClient.GetAsync("v1/schema") | ||
.ConfigureAwait(true); | ||
|
||
// Then | ||
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode); | ||
} | ||
} |