Skip to content

Commit 40227bf

Browse files
rojiHofmeisterAn
andauthored
feat: Add Weaviate module (#1356)
Co-authored-by: Andre Hofmeister <[email protected]>
1 parent 2c6c915 commit 40227bf

File tree

14 files changed

+221
-6
lines changed

14 files changed

+221
-6
lines changed

.github/workflows/cicd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
{ name: "Testcontainers.Redis", runs-on: "ubuntu-22.04" },
8080
{ name: "Testcontainers.Redpanda", runs-on: "ubuntu-22.04" },
8181
{ name: "Testcontainers.ServiceBus", runs-on: "ubuntu-22.04" },
82+
{ name: "Testcontainers.Weaviate", runs-on: "ubuntu-22.04" },
8283
{ name: "Testcontainers.WebDriver", runs-on: "ubuntu-22.04" },
8384
{ name: "Testcontainers.Xunit", runs-on: "ubuntu-22.04" }
8485
]

Testcontainers.dic

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ testcontainer
3434
testcontainers
3535
tlsverify
3636
toml
37-
vstest
37+
vstest
38+
weaviate

Testcontainers.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Redpanda", "
9797
EndProject
9898
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ServiceBus", "src\Testcontainers.ServiceBus\Testcontainers.ServiceBus.csproj", "{2E39E532-B81E-4B48-A004-FAE18EDF9E79}"
9999
EndProject
100+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Weaviate", "src\Testcontainers.Weaviate\Testcontainers.Weaviate.csproj", "{68F8600D-24E9-4E03-9E25-5F6EB338EAC1}"
101+
EndProject
100102
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver", "src\Testcontainers.WebDriver\Testcontainers.WebDriver.csproj", "{64A87DE5-29B0-4A54-9E74-560484D8C7C0}"
101103
EndProject
102104
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Xunit", "src\Testcontainers.Xunit\Testcontainers.Xunit.csproj", "{380BB29B-F556-404D-B13B-CA250599C565}"
@@ -201,6 +203,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ServiceBus.T
201203
EndProject
202204
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Tests", "tests\Testcontainers.Tests\Testcontainers.Tests.csproj", "{27CDB869-A150-4593-958F-6F26E5391E7C}"
203205
EndProject
206+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Weaviate.Tests", "tests\Testcontainers.Weaviate.Tests\Testcontainers.Weaviate.Tests.csproj", "{DDB41BC8-5826-4D97-9C5F-001151E3FFD6}"
207+
EndProject
204208
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver.Tests", "tests\Testcontainers.WebDriver.Tests\Testcontainers.WebDriver.Tests.csproj", "{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}"
205209
EndProject
206210
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Xunit.Tests", "tests\Testcontainers.Xunit.Tests\Testcontainers.Xunit.Tests.csproj", "{E901DF14-6F05-4FC2-825A-3055FAD33561}"
@@ -382,6 +386,10 @@ Global
382386
{2E39E532-B81E-4B48-A004-FAE18EDF9E79}.Debug|Any CPU.Build.0 = Debug|Any CPU
383387
{2E39E532-B81E-4B48-A004-FAE18EDF9E79}.Release|Any CPU.ActiveCfg = Release|Any CPU
384388
{2E39E532-B81E-4B48-A004-FAE18EDF9E79}.Release|Any CPU.Build.0 = Release|Any CPU
389+
{68F8600D-24E9-4E03-9E25-5F6EB338EAC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
390+
{68F8600D-24E9-4E03-9E25-5F6EB338EAC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
391+
{68F8600D-24E9-4E03-9E25-5F6EB338EAC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
392+
{68F8600D-24E9-4E03-9E25-5F6EB338EAC1}.Release|Any CPU.Build.0 = Release|Any CPU
385393
{64A87DE5-29B0-4A54-9E74-560484D8C7C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
386394
{64A87DE5-29B0-4A54-9E74-560484D8C7C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
387395
{64A87DE5-29B0-4A54-9E74-560484D8C7C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -590,6 +598,10 @@ Global
590598
{27CDB869-A150-4593-958F-6F26E5391E7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
591599
{27CDB869-A150-4593-958F-6F26E5391E7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
592600
{27CDB869-A150-4593-958F-6F26E5391E7C}.Release|Any CPU.Build.0 = Release|Any CPU
601+
{DDB41BC8-5826-4D97-9C5F-001151E3FFD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
602+
{DDB41BC8-5826-4D97-9C5F-001151E3FFD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
603+
{DDB41BC8-5826-4D97-9C5F-001151E3FFD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
604+
{DDB41BC8-5826-4D97-9C5F-001151E3FFD6}.Release|Any CPU.Build.0 = Release|Any CPU
593605
{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
594606
{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
595607
{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -642,6 +654,7 @@ Global
642654
{BFDA179A-40EB-4CEB-B8E9-0DF32C65E2C5} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
643655
{45D6F69C-4D87-4130-AA90-0DB2F7460DAE} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
644656
{2E39E532-B81E-4B48-A004-FAE18EDF9E79} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
657+
{68F8600D-24E9-4E03-9E25-5F6EB338EAC1} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
645658
{64A87DE5-29B0-4A54-9E74-560484D8C7C0} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
646659
{380BB29B-F556-404D-B13B-CA250599C565} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
647660
{84911C93-C2A9-46E9-AE5E-D567306589E5} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
@@ -694,6 +707,7 @@ Global
694707
{9E8E6AA5-65D1-498F-BEAB-BA34723A0050} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
695708
{232DD918-46ED-4BA8-B383-1A9146D83064} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
696709
{27CDB869-A150-4593-958F-6F26E5391E7C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
710+
{DDB41BC8-5826-4D97-9C5F-001151E3FFD6} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
697711
{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
698712
{E901DF14-6F05-4FC2-825A-3055FAD33561} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
699713
EndGlobalSection

Testcontainers.sln.DotSettings

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/NAMESPACE_BODY/@EntryValue">BlockScoped</s:String>
77
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean>
88
<s:Boolean x:Key="/Default/InstalledDictionaries/InstalledDictionaries/=Testcontainers_002Edic/@EntryIndexedValue">True</s:Boolean>
9-
<s:Boolean x:Key="/Default/UserDictionary/Words/=azurite/@EntryIndexedValue">True</s:Boolean>
109
<s:Boolean x:Key="/Default/UserDictionary/Words/=awslocal/@EntryIndexedValue">True</s:Boolean>
1110
<s:Boolean x:Key="/Default/UserDictionary/Words/=azurecr/@EntryIndexedValue">True</s:Boolean>
11+
<s:Boolean x:Key="/Default/UserDictionary/Words/=azurite/@EntryIndexedValue">True</s:Boolean>
1212
<s:Boolean x:Key="/Default/UserDictionary/Words/=capi/@EntryIndexedValue">True</s:Boolean>
1313
<s:Boolean x:Key="/Default/UserDictionary/Words/=creds/@EntryIndexedValue">True</s:Boolean>
1414
<s:Boolean x:Key="/Default/UserDictionary/Words/=dind/@EntryIndexedValue">True</s:Boolean>
@@ -42,10 +42,11 @@
4242
<s:Boolean x:Key="/Default/UserDictionary/Words/=testcontainer/@EntryIndexedValue">True</s:Boolean>
4343
<s:Boolean x:Key="/Default/UserDictionary/Words/=testcontainers/@EntryIndexedValue">True</s:Boolean>
4444
<s:Boolean x:Key="/Default/UserDictionary/Words/=tlsverify/@EntryIndexedValue">True</s:Boolean>
45-
<s:Boolean x:Key="/Default/UserDictionary/Words/=toml/@EntryIndexedValue">True</s:Boolean>
45+
<s:Boolean x:Key="/Default/UserDictionary/Words/=toml/@EntryIndexedValue">True</s:Boolean>
4646
<s:Boolean x:Key="/Default/UserDictionary/Words/=vstest/@EntryIndexedValue">True</s:Boolean>
47-
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String>
48-
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToUsingDeclaration/@EntryIndexedValue">DO_NOT_SHOW</s:String>
49-
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseAwaitUsing/@EntryIndexedValue">DO_NOT_SHOW</s:String>
47+
<s:Boolean x:Key="/Default/UserDictionary/Words/=weaviate/@EntryIndexedValue">True</s:Boolean>
48+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String>
49+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToUsingDeclaration/@EntryIndexedValue">DO_NOT_SHOW</s:String>
50+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseAwaitUsing/@EntryIndexedValue">DO_NOT_SHOW</s:String>
5051
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
5152
</wpf:ResourceDictionary>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
root = true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>net8.0;net9.0;netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<LangVersion>latest</LangVersion>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="JetBrains.Annotations" VersionOverride="2023.3.0" PrivateAssets="All"/>
8+
</ItemGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="../Testcontainers/Testcontainers.csproj"/>
11+
</ItemGroup>
12+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
global using System;
2+
global using Docker.DotNet.Models;
3+
global using DotNet.Testcontainers.Builders;
4+
global using DotNet.Testcontainers.Configurations;
5+
global using DotNet.Testcontainers.Containers;
6+
global using JetBrains.Annotations;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
namespace Testcontainers.Weaviate;
2+
3+
/// <inheritdoc cref="ContainerBuilder{TBuilderEntity, TContainerEntity, TConfigurationEntity}" />
4+
[PublicAPI]
5+
public sealed class WeaviateBuilder : ContainerBuilder<WeaviateBuilder, WeaviateContainer, WeaviateConfiguration>
6+
{
7+
public const string WeaviateImage = "semitechnologies/weaviate:1.26.14";
8+
9+
public const ushort WeaviateHttpPort = 8080;
10+
11+
public const ushort WeaviateGrpcPort = 50051;
12+
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="WeaviateBuilder" /> class.
15+
/// </summary>
16+
public WeaviateBuilder() : this(new WeaviateConfiguration())
17+
=> DockerResourceConfiguration = Init().DockerResourceConfiguration;
18+
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="WeaviateBuilder" /> class.
21+
/// </summary>
22+
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
23+
private WeaviateBuilder(WeaviateConfiguration resourceConfiguration) : base(resourceConfiguration)
24+
=> DockerResourceConfiguration = resourceConfiguration;
25+
26+
/// <inheritdoc />
27+
protected override WeaviateConfiguration DockerResourceConfiguration { get; }
28+
29+
/// <inheritdoc />
30+
public override WeaviateContainer Build()
31+
{
32+
Validate();
33+
return new WeaviateContainer(DockerResourceConfiguration);
34+
}
35+
36+
/// <inheritdoc />
37+
protected override WeaviateBuilder Init()
38+
=> base.Init()
39+
.WithImage(WeaviateImage)
40+
.WithPortBinding(WeaviateHttpPort, true)
41+
.WithPortBinding(WeaviateGrpcPort, true)
42+
.WithEnvironment("AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED", "true")
43+
.WithEnvironment("PERSISTENCE_DATA_PATH", "/var/lib/weaviate")
44+
.WithWaitStrategy(Wait.ForUnixContainer()
45+
.UntilPortIsAvailable(WeaviateHttpPort)
46+
.UntilPortIsAvailable(WeaviateGrpcPort)
47+
.UntilHttpRequestIsSucceeded(request =>
48+
request.ForPath("/v1/.well-known/ready").ForPort(WeaviateHttpPort)));
49+
50+
/// <inheritdoc />
51+
protected override WeaviateBuilder Clone(IResourceConfiguration<CreateContainerParameters> resourceConfiguration)
52+
=> Merge(DockerResourceConfiguration, new WeaviateConfiguration(resourceConfiguration));
53+
54+
/// <inheritdoc />
55+
protected override WeaviateBuilder Clone(IContainerConfiguration resourceConfiguration)
56+
=> Merge(DockerResourceConfiguration, new WeaviateConfiguration(resourceConfiguration));
57+
58+
/// <inheritdoc />
59+
protected override WeaviateBuilder Merge(WeaviateConfiguration oldValue, WeaviateConfiguration newValue)
60+
=> new(new WeaviateConfiguration(oldValue, newValue));
61+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
namespace Testcontainers.Weaviate;
2+
3+
/// <inheritdoc cref="ContainerConfiguration" />
4+
[PublicAPI]
5+
public sealed class WeaviateConfiguration : ContainerConfiguration
6+
{
7+
/// <summary>
8+
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class.
9+
/// </summary>
10+
public WeaviateConfiguration()
11+
{
12+
}
13+
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class.
16+
/// </summary>
17+
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
18+
public WeaviateConfiguration(IResourceConfiguration<CreateContainerParameters> resourceConfiguration)
19+
: base(resourceConfiguration)
20+
{
21+
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
22+
}
23+
24+
/// <summary>
25+
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class.
26+
/// </summary>
27+
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
28+
public WeaviateConfiguration(IContainerConfiguration resourceConfiguration)
29+
: base(resourceConfiguration)
30+
{
31+
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
32+
}
33+
34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class.
36+
/// </summary>
37+
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
38+
public WeaviateConfiguration(WeaviateConfiguration resourceConfiguration)
39+
: this(new WeaviateConfiguration(), resourceConfiguration)
40+
{
41+
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
42+
}
43+
44+
/// <summary>
45+
/// Initializes a new instance of the <see cref="WeaviateConfiguration" /> class.
46+
/// </summary>
47+
/// <param name="oldValue">The old Docker resource configuration.</param>
48+
/// <param name="newValue">The new Docker resource configuration.</param>
49+
public WeaviateConfiguration(WeaviateConfiguration oldValue, WeaviateConfiguration newValue)
50+
: base(oldValue, newValue)
51+
{
52+
}
53+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Testcontainers.Weaviate;
2+
3+
/// <inheritdoc cref="DockerContainer" />
4+
[PublicAPI]
5+
public sealed class WeaviateContainer(WeaviateConfiguration configuration) : DockerContainer(configuration)
6+
{
7+
/// <summary>
8+
/// Gets the Weaviate base address.
9+
/// </summary>
10+
/// <returns>The Weaviate base address.</returns>
11+
public string GetBaseAddress()
12+
{
13+
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(WeaviateBuilder.WeaviateHttpPort)).ToString();
14+
}
15+
}

0 commit comments

Comments
 (0)