From 943331f7483bafee5394fe3ed4d06f7a76be545f Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 26 Feb 2024 23:23:22 +0100 Subject: [PATCH] Switch to using testcontainers Closes #57 --- .github/workflows/Build.yml | 21 ------- Directory.Packages.props | 1 + Milvus.Client.Tests/AliasTests.cs | 15 +++-- Milvus.Client.Tests/CollectionTests.cs | 19 +++++- Milvus.Client.Tests/DataTests.cs | 39 +++++++++--- Milvus.Client.Tests/DatabaseTests.cs | 13 ++-- Milvus.Client.Tests/IndexTests.cs | 15 +++-- .../Milvus.Client.Tests.csproj | 8 +-- Milvus.Client.Tests/MilvusFixture.cs | 28 +++++++++ Milvus.Client.Tests/MiscTests.cs | 21 ++++--- Milvus.Client.Tests/PartitionTests.cs | 17 ++++-- Milvus.Client.Tests/SearchQueryTests.cs | 30 ++++++--- .../TestContainer/MilvusBuilder.cs | 61 +++++++++++++++++++ .../TestContainer/MilvusConfiguration.cs | 54 ++++++++++++++++ .../TestContainer/MilvusContainer.cs | 7 +++ Milvus.Client.Tests/UserTests.cs | 18 +++--- Milvus.Client.Tests/config.json | 11 ---- 17 files changed, 283 insertions(+), 95 deletions(-) create mode 100644 Milvus.Client.Tests/MilvusFixture.cs create mode 100644 Milvus.Client.Tests/TestContainer/MilvusBuilder.cs create mode 100644 Milvus.Client.Tests/TestContainer/MilvusConfiguration.cs create mode 100644 Milvus.Client.Tests/TestContainer/MilvusContainer.cs delete mode 100644 Milvus.Client.Tests/config.json diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 41b43b4..5176442 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -23,30 +23,9 @@ jobs: submodules: 'recursive' fetch-depth: 0 - - name: Start Milvus - run: | - wget https://github.com/milvus-io/milvus/releases/download/${{ matrix.milvus_version }}/milvus-standalone-docker-compose.yml -O docker-compose.yml - - # Turn on authorization. This involves downloading milvus.yml and setting authorization to true, and then - # using a docker-compose.override.yml file to get it picked up. - wget https://raw.githubusercontent.com/milvus-io/milvus/${{ matrix.milvus_version }}/configs/milvus.yaml - sed -i 's/authorizationEnabled: false/authorizationEnabled: true/' milvus.yaml - - cat < docker-compose.override.yml - services: - standalone: - volumes: - - ${PWD}/milvus.yaml:/milvus/configs/milvus.yaml - EOF - - sudo docker-compose up -d - - name: Setup .NET SDKs uses: actions/setup-dotnet@v3 - - name: Wait for Milvus to become available - run: sleep 30 # TODO: Find a better way to do this, e.g. try polling with curl until we detect that milvus is up - - name: Test run: dotnet test --logger "GitHubActions;report-warnings=false" diff --git a/Directory.Packages.props b/Directory.Packages.props index 5c98e06..cec16cb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,6 +15,7 @@ + \ No newline at end of file diff --git a/Milvus.Client.Tests/AliasTests.cs b/Milvus.Client.Tests/AliasTests.cs index 7185b48..c364631 100644 --- a/Milvus.Client.Tests/AliasTests.cs +++ b/Milvus.Client.Tests/AliasTests.cs @@ -2,6 +2,7 @@ namespace Milvus.Client.Tests; +[Collection("Milvus")] public class AliasTests : IAsyncLifetime { [Fact] @@ -50,8 +51,11 @@ public async Task Drop() private MilvusCollection Collection { get; set; } - public AliasTests() - => Collection = Client.GetCollection(CollectionName); + public AliasTests(MilvusFixture milvusFixture) + { + Client = milvusFixture.CreateClient(); + Collection = Client.GetCollection(CollectionName); + } public async Task InitializeAsync() { @@ -69,8 +73,11 @@ public async Task InitializeAsync() }); } - private MilvusClient Client => TestEnvironment.Client; + private readonly MilvusClient Client; public Task DisposeAsync() - => Task.CompletedTask; + { + Client.Dispose(); + return Task.CompletedTask; + } } diff --git a/Milvus.Client.Tests/CollectionTests.cs b/Milvus.Client.Tests/CollectionTests.cs index 2c5d66b..56dbd5c 100644 --- a/Milvus.Client.Tests/CollectionTests.cs +++ b/Milvus.Client.Tests/CollectionTests.cs @@ -2,6 +2,7 @@ namespace Milvus.Client.Tests; +[Collection("Milvus")] public class CollectionTests : IAsyncLifetime { [Fact] @@ -300,7 +301,8 @@ public async Task Compact() [Fact] public async Task Create_in_non_existing_database_fails() { - using MilvusClient databaseClient = TestEnvironment.CreateClientForDatabase("non_existing_db"); + // using MilvusClient databaseClient = TestEnvironment.CreateClientForDatabase("non_existing_db"); + using MilvusClient databaseClient = Fixture.CreateClient("non_existing_db"); var exception = await Assert.ThrowsAsync(() => databaseClient.CreateCollectionAsync( "foo", @@ -310,13 +312,24 @@ public async Task Create_in_non_existing_database_fails() Assert.Equal("ErrorCode: UnexpectedError Reason: database:non_existing_db not found", exception.Message); } + public CollectionTests(MilvusFixture milvusFixture) + { + ArgumentNullException.ThrowIfNull(milvusFixture); + Fixture = milvusFixture; + Client = milvusFixture.CreateClient(); + } + public Task InitializeAsync() => Client.GetCollection(CollectionName).DropAsync(); public Task DisposeAsync() - => Task.CompletedTask; + { + Client.Dispose(); + return Task.CompletedTask; + } private const string CollectionName = nameof(CollectionTests); - private MilvusClient Client => TestEnvironment.Client; + private readonly MilvusFixture Fixture; + private readonly MilvusClient Client; } diff --git a/Milvus.Client.Tests/DataTests.cs b/Milvus.Client.Tests/DataTests.cs index 490af09..68311c4 100644 --- a/Milvus.Client.Tests/DataTests.cs +++ b/Milvus.Client.Tests/DataTests.cs @@ -2,7 +2,8 @@ namespace Milvus.Client.Tests; -public class DataTests : IClassFixture +[Collection("Milvus")] +public class DataTests : IClassFixture, IAsyncLifetime { [Fact] public async Task Insert_Drop() @@ -137,7 +138,7 @@ public async Task Insert_dynamic_field() { await Collection.DropAsync(); - await TestEnvironment.Client.CreateCollectionAsync( + await Client.CreateCollectionAsync( Collection.Name, new CollectionSchema { @@ -177,13 +178,21 @@ private async Task InsertDataAsync(long id1, long id2) public class DataCollectionFixture : IAsyncLifetime { - public MilvusCollection Collection { get; } = TestEnvironment.Client.GetCollection(CollectionName); + private readonly MilvusClient Client; + + public DataCollectionFixture(MilvusFixture milvusFixture) + { + Client = milvusFixture.CreateClient(); + Collection = Client.GetCollection(CollectionName); + } + + public MilvusCollection Collection; public async Task InitializeAsync() { await Collection.DropAsync(); - await TestEnvironment.Client.CreateCollectionAsync( + await Client.CreateCollectionAsync( Collection.Name, new[] { @@ -198,14 +207,28 @@ await TestEnvironment.Client.CreateCollectionAsync( } public Task DisposeAsync() - => Task.CompletedTask; + { + Client.Dispose(); + return Task.CompletedTask; + } } private readonly DataCollectionFixture _dataCollectionFixture; private const string CollectionName = nameof(DataTests); private MilvusCollection Collection => _dataCollectionFixture.Collection; - private MilvusClient Client => TestEnvironment.Client; + private readonly MilvusClient Client; - public DataTests(DataCollectionFixture dataCollectionFixture) - => _dataCollectionFixture = dataCollectionFixture; + public DataTests(MilvusFixture milvusFixture, DataCollectionFixture dataCollectionFixture) + { + Client = milvusFixture.CreateClient(); + _dataCollectionFixture = dataCollectionFixture; + } + + public Task InitializeAsync() => Task.CompletedTask; + + public Task DisposeAsync() + { + Client.Dispose(); + return Task.CompletedTask; + } } diff --git a/Milvus.Client.Tests/DatabaseTests.cs b/Milvus.Client.Tests/DatabaseTests.cs index 75e38ed..6501948 100644 --- a/Milvus.Client.Tests/DatabaseTests.cs +++ b/Milvus.Client.Tests/DatabaseTests.cs @@ -2,7 +2,8 @@ namespace Milvus.Client.Tests; -public class DatabaseTests : IAsyncLifetime +[Collection("Milvus")] +public class DatabaseTests(MilvusFixture milvusFixture) : IAsyncLifetime { [Fact] public async Task Create_List_Drop() @@ -36,7 +37,7 @@ public async Task Search_on_non_default_database() { string databaseName = nameof(Search_on_non_default_database); - using var databaseClient = TestEnvironment.CreateClientForDatabase(databaseName); + using var databaseClient = milvusFixture.CreateClient(databaseName); // If the database exists, drop it using the regular client and recreate it. if ((await DefaultClient.ListDatabasesAsync()).Contains(databaseName)) @@ -105,8 +106,6 @@ await collection.WaitForCollectionLoadAsync( public async Task InitializeAsync() { - DatabaseClient = TestEnvironment.CreateClientForDatabase(DatabaseName); - if ((await DefaultClient.ListDatabasesAsync()).Contains(DatabaseName)) { // First drop all collections from a possible previous test run, otherwise dropping fails @@ -121,13 +120,13 @@ public async Task InitializeAsync() public Task DisposeAsync() { + DefaultClient.Dispose(); DatabaseClient.Dispose(); return Task.CompletedTask; } - private MilvusClient DefaultClient => TestEnvironment.Client; - - private MilvusClient DatabaseClient { get; set; } = null!; + private readonly MilvusClient DefaultClient = milvusFixture.CreateClient(); + private readonly MilvusClient DatabaseClient = milvusFixture.CreateClient(DatabaseName); private const string DatabaseName = nameof(DatabaseTests); } diff --git a/Milvus.Client.Tests/IndexTests.cs b/Milvus.Client.Tests/IndexTests.cs index 9f9520b..7b2f105 100644 --- a/Milvus.Client.Tests/IndexTests.cs +++ b/Milvus.Client.Tests/IndexTests.cs @@ -3,6 +3,7 @@ namespace Milvus.Client.Tests; +[Collection("Milvus")] public class IndexTests : IAsyncLifetime { [Fact] @@ -186,14 +187,20 @@ await Client.CreateCollectionAsync( } public Task DisposeAsync() - => Task.CompletedTask; + { + Client.Dispose(); + return Task.CompletedTask; + } private const string CollectionName = nameof(IndexTests); - private MilvusClient Client => TestEnvironment.Client; + private readonly MilvusClient Client; private MilvusCollection Collection { get; } - public IndexTests() - => Collection = Client.GetCollection(CollectionName); + public IndexTests(MilvusFixture milvusFixture) + { + Client = milvusFixture.CreateClient(); + Collection = Client.GetCollection(CollectionName); + } } diff --git a/Milvus.Client.Tests/Milvus.Client.Tests.csproj b/Milvus.Client.Tests/Milvus.Client.Tests.csproj index 13755f2..8afd05c 100644 --- a/Milvus.Client.Tests/Milvus.Client.Tests.csproj +++ b/Milvus.Client.Tests/Milvus.Client.Tests.csproj @@ -3,6 +3,7 @@ net7.0 false + $(NoWarn);CA1062 @@ -18,6 +19,7 @@ + @@ -25,10 +27,4 @@ - - - PreserveNewest - - - diff --git a/Milvus.Client.Tests/MilvusFixture.cs b/Milvus.Client.Tests/MilvusFixture.cs new file mode 100644 index 0000000..8c25807 --- /dev/null +++ b/Milvus.Client.Tests/MilvusFixture.cs @@ -0,0 +1,28 @@ +using System.Globalization; +using Microsoft.Extensions.Configuration; +using Milvus.Client.Tests.TestContainer; +using Xunit; + +namespace Milvus.Client.Tests; + +[CollectionDefinition("Milvus")] +public sealed class QdrantCollection : ICollectionFixture; + +public sealed class MilvusFixture : IAsyncLifetime +{ + private readonly MilvusContainer _container = new MilvusBuilder().Build(); + + public string Host => _container.Hostname; + public int Port => _container.GetMappedPublicPort(MilvusBuilder.MilvusGrpcPort); + public string Username => "root"; + public string Password => "Milvus"; + + public MilvusClient CreateClient() + => new(Host, Username, Password, Port, ssl: false); + + public MilvusClient CreateClient(string database) + => new(Host, Username, Password, Port, ssl: false, database); + + public Task InitializeAsync() => _container.StartAsync(); + public Task DisposeAsync() => _container.DisposeAsync().AsTask(); +} diff --git a/Milvus.Client.Tests/MiscTests.cs b/Milvus.Client.Tests/MiscTests.cs index c22d80d..4817318 100644 --- a/Milvus.Client.Tests/MiscTests.cs +++ b/Milvus.Client.Tests/MiscTests.cs @@ -3,7 +3,8 @@ namespace Milvus.Client.Tests; -public class MiscTests +[Collection("Milvus")] +public class MiscTests(MilvusFixture milvusFixture) : IDisposable { // If this test is failing for you, that means you haven't enabled authorization in Milvus; follow the instructions // in https://milvus.io/docs/authenticate.md. @@ -11,7 +12,7 @@ public class MiscTests public async Task Auth_failure_with_wrong_password() { using var badClient = new MilvusClient( - TestEnvironment.Host, username: TestEnvironment.Username, password: "incorrect_password"); + milvusFixture.Host, username: milvusFixture.Username, password: "incorrect_password"); try { @@ -44,17 +45,17 @@ public async Task GetVersion() } [Fact] - public async Task Dispose() + public async Task Dispose_client() { - var client = TestEnvironment.CreateClient(); - - MilvusHealthState state = await client.HealthAsync(); + MilvusHealthState state = await Client.HealthAsync(); Assert.True(state.IsHealthy); - client.Dispose(); + Client.Dispose(); - await Assert.ThrowsAsync(() => client.HealthAsync()); - } + await Assert.ThrowsAsync(() => Client.HealthAsync()); + } + + private readonly MilvusClient Client = milvusFixture.CreateClient(); - private MilvusClient Client => TestEnvironment.Client; + public void Dispose() => Client.Dispose(); } diff --git a/Milvus.Client.Tests/PartitionTests.cs b/Milvus.Client.Tests/PartitionTests.cs index 3da0351..300b180 100644 --- a/Milvus.Client.Tests/PartitionTests.cs +++ b/Milvus.Client.Tests/PartitionTests.cs @@ -2,6 +2,7 @@ namespace Milvus.Client.Tests; +[Collection("Milvus")] public class PartitionTests : IAsyncLifetime { [Fact] @@ -48,6 +49,12 @@ public async Task Drop() Assert.False(await Collection.HasPartitionAsync("partition")); } + public PartitionTests(MilvusFixture milvusFixture) + { + Client = milvusFixture.CreateClient(); + Collection = Client.GetCollection(CollectionName); + } + public async Task InitializeAsync() { await Collection.DropAsync(); @@ -62,13 +69,13 @@ await Client.CreateCollectionAsync( } public Task DisposeAsync() - => Task.CompletedTask; + { + Client.Dispose(); + return Task.CompletedTask; + } private const string CollectionName = nameof(PartitionTests); - private MilvusClient Client => TestEnvironment.Client; + private readonly MilvusClient Client; private MilvusCollection Collection { get; } - - public PartitionTests() - => Collection = Client.GetCollection(CollectionName); } diff --git a/Milvus.Client.Tests/SearchQueryTests.cs b/Milvus.Client.Tests/SearchQueryTests.cs index 750ff7b..99d50aa 100644 --- a/Milvus.Client.Tests/SearchQueryTests.cs +++ b/Milvus.Client.Tests/SearchQueryTests.cs @@ -3,7 +3,11 @@ namespace Milvus.Client.Tests; -public class SearchQueryTests : IClassFixture +[Collection("Milvus")] +public class SearchQueryTests( + MilvusFixture milvusFixture, + SearchQueryTests.QueryCollectionFixture queryCollectionFixture) + : IClassFixture, IDisposable { [Fact] public async Task Query() @@ -526,12 +530,19 @@ public async Task Search_with_unsupported_vector_type_throws() public class QueryCollectionFixture : IAsyncLifetime { - public MilvusCollection Collection { get; } = TestEnvironment.Client.GetCollection(nameof(SearchQueryTests)); + public QueryCollectionFixture(MilvusFixture milvusFixture) + { + Client = milvusFixture.CreateClient(); + Collection = Client.GetCollection(nameof(SearchQueryTests)); + } + + private readonly MilvusClient Client; + public readonly MilvusCollection Collection; public async Task InitializeAsync() { await Collection.DropAsync(); - await TestEnvironment.Client.CreateCollectionAsync( + await Client.CreateCollectionAsync( Collection.Name, new[] { @@ -574,17 +585,18 @@ await Collection.WaitForCollectionLoadAsync( } public Task DisposeAsync() - => Task.CompletedTask; + { + Client.Dispose(); + return Task.CompletedTask; + } } - private MilvusClient Client => TestEnvironment.Client; + private readonly MilvusClient Client = milvusFixture.CreateClient(); - private readonly QueryCollectionFixture _queryCollectionFixture; - private MilvusCollection Collection => _queryCollectionFixture.Collection; + private MilvusCollection Collection => queryCollectionFixture.Collection; private string CollectionName => Collection.Name; - public SearchQueryTests(QueryCollectionFixture queryCollectionFixture) - => _queryCollectionFixture = queryCollectionFixture; + public void Dispose() => Client.Dispose(); internal class JsonThing { diff --git a/Milvus.Client.Tests/TestContainer/MilvusBuilder.cs b/Milvus.Client.Tests/TestContainer/MilvusBuilder.cs new file mode 100644 index 0000000..959df0e --- /dev/null +++ b/Milvus.Client.Tests/TestContainer/MilvusBuilder.cs @@ -0,0 +1,61 @@ +using System.Reflection; +using System.Text; +using Docker.DotNet.Models; +using DotNet.Testcontainers.Builders; +using DotNet.Testcontainers.Configurations; + +namespace Milvus.Client.Tests.TestContainer; + +public class MilvusBuilder : ContainerBuilder +{ + public const string MilvusImage = "milvusdb/milvus:v2.3.0"; // TODO: Configurable + public const ushort MilvusGrpcPort = 19530; + public const ushort MilvusManagementPort = 9091; + + public MilvusBuilder() : this(new MilvusConfiguration()) + => DockerResourceConfiguration = Init().DockerResourceConfiguration; + + private MilvusBuilder(MilvusConfiguration dockerResourceConfiguration) : base(dockerResourceConfiguration) + => DockerResourceConfiguration = dockerResourceConfiguration; + + public override MilvusContainer Build() + { + Validate(); + return new MilvusContainer(DockerResourceConfiguration, TestcontainersSettings.Logger); + } + + protected override MilvusBuilder Init() + { + string etcdYaml = """ + listen-client-urls: http://0.0.0.0:2379 + advertise-client-urls: http://0.0.0.0:2379 + """; + + return base.Init() + .WithImage(MilvusImage) + .WithEnvironment("COMMON_STORAGETYPE", "local") + .WithEnvironment("ETCD_USE_EMBED", "true") + .WithEnvironment("ETCD_DATA_DIR", "/var/lib/milvus/etcd") + .WithEnvironment("ETCD_CONFIG_PATH", "/milvus/configs/embedEtcd.yaml") + .WithResourceMapping(Encoding.UTF8.GetBytes(etcdYaml), "/milvus/configs/embedEtcd.yaml") + .WithCommand("milvus", "run", "standalone") + .WithPortBinding(MilvusGrpcPort, true) + .WithPortBinding(MilvusManagementPort, true) + .WithWaitStrategy( + Wait.ForUnixContainer() + .UntilHttpRequestIsSucceeded(h => h + .ForPort(MilvusManagementPort) + .ForPath("/healthz"))); + } + + protected override MilvusBuilder Clone(IResourceConfiguration resourceConfiguration) + => Merge(DockerResourceConfiguration, new MilvusConfiguration(resourceConfiguration)); + + protected override MilvusBuilder Merge(MilvusConfiguration oldValue, MilvusConfiguration newValue) + => new(new MilvusConfiguration(oldValue, newValue)); + + protected override MilvusConfiguration DockerResourceConfiguration { get; } + + protected override MilvusBuilder Clone(IContainerConfiguration resourceConfiguration) + => Merge(DockerResourceConfiguration, new MilvusConfiguration(resourceConfiguration)); +} diff --git a/Milvus.Client.Tests/TestContainer/MilvusConfiguration.cs b/Milvus.Client.Tests/TestContainer/MilvusConfiguration.cs new file mode 100644 index 0000000..2ab53f6 --- /dev/null +++ b/Milvus.Client.Tests/TestContainer/MilvusConfiguration.cs @@ -0,0 +1,54 @@ +using Docker.DotNet.Models; +using DotNet.Testcontainers.Builders; +using DotNet.Testcontainers.Configurations; + +namespace Milvus.Client.Tests.TestContainer; + +public sealed class MilvusConfiguration : ContainerConfiguration +{ + /// + /// Initializes a new instance of the class. + /// + public MilvusConfiguration() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public MilvusConfiguration(IResourceConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public MilvusConfiguration(IContainerConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + // Passes the configuration upwards to the base implementations to create an updated immutable copy. + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public MilvusConfiguration(MilvusConfiguration resourceConfiguration) + : this(new MilvusConfiguration(), resourceConfiguration) + { + // Passes the configuration upwards to the base implementations to create an updated immutable copy. + } + + /// + /// Initializes a new instance of the class. + /// + /// The old Docker resource configuration. + /// The new Docker resource configuration. + public MilvusConfiguration(MilvusConfiguration oldValue, MilvusConfiguration newValue) + : base(oldValue, newValue) + { + } +} diff --git a/Milvus.Client.Tests/TestContainer/MilvusContainer.cs b/Milvus.Client.Tests/TestContainer/MilvusContainer.cs new file mode 100644 index 0000000..7e8afa5 --- /dev/null +++ b/Milvus.Client.Tests/TestContainer/MilvusContainer.cs @@ -0,0 +1,7 @@ +using DotNet.Testcontainers.Containers; +using Microsoft.Extensions.Logging; + +namespace Milvus.Client.Tests.TestContainer; + +public class MilvusContainer(MilvusConfiguration configuration, ILogger logger) + : DockerContainer(configuration, logger); diff --git a/Milvus.Client.Tests/UserTests.cs b/Milvus.Client.Tests/UserTests.cs index 625913d..4891cb6 100644 --- a/Milvus.Client.Tests/UserTests.cs +++ b/Milvus.Client.Tests/UserTests.cs @@ -2,14 +2,15 @@ namespace Milvus.Client.Tests; -public class UserTests : IAsyncLifetime +[Collection("Milvus")] +public class UserTests(MilvusFixture milvusFixture) : IAsyncLifetime { [Fact] public async Task Create() { await Client.CreateUserAsync(Username, "some_password"); - using var client = new MilvusClient(TestEnvironment.Host, username: Username, password: "some_password"); + using var client = new MilvusClient(milvusFixture.Host, Username, "some_password", milvusFixture.Port); _ = await client.HasCollectionAsync("foo"); } @@ -28,7 +29,7 @@ public async Task Update() await Client.UpdatePassword(Username, "some_old_password", "some_new_password"); - using var client = new MilvusClient(TestEnvironment.Host, username: Username, password: "some_new_password"); + using var client = new MilvusClient(milvusFixture.Host, Username, "some_new_password", milvusFixture.Port); _ = await client.HasCollectionAsync("foo"); } @@ -37,9 +38,8 @@ public async Task Update_failed_with_wrong_old_password() { await Client.CreateUserAsync(Username, "some_password"); - var exception = await Assert.ThrowsAsync( + await Assert.ThrowsAsync( () => Client.UpdatePassword(Username, "wrong_password", "some_new_password")); - Assert.Equal(MilvusErrorCode.UpdateCredentialFailure, exception.ErrorCode); } [Fact] @@ -152,7 +152,11 @@ await Client.RevokeRolePrivilegeAsync( private const string Username = "some_user"; private const string RoleName = "some_role"; - public Task DisposeAsync() => Task.CompletedTask; + private readonly MilvusClient Client = milvusFixture.CreateClient(); - private MilvusClient Client => TestEnvironment.Client; + public Task DisposeAsync() + { + Client.Dispose(); + return Task.CompletedTask; + } } diff --git a/Milvus.Client.Tests/config.json b/Milvus.Client.Tests/config.json deleted file mode 100644 index 7be62a9..0000000 --- a/Milvus.Client.Tests/config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Test": - { - "Milvus": - { - "Host": "localhost", - "Username": "root", - "Password": "Milvus" - } - } -}