Bump HealthcareSharedPackageVersion from 6.2.149 to 7.0.2 (#3515)

* Bump HealthcareSharedPackageVersion from 6.2.149 to 7.0.2

Bumps `HealthcareSharedPackageVersion` from 6.2.149 to 7.0.2.

Updates `Microsoft.Health.Abstractions` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Api` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Client` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Core` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Extensions.BuildTimeCodeGenerator` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Extensions.DependencyInjection` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.SqlServer.Api` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.SqlServer` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Test.Utilities` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

Updates `Microsoft.Health.Tools.Sql.Tasks` from 6.2.149 to 7.0.2
- [Release notes](https://github.com/microsoft/healthcare-shared-components/releases)
- [Commits](https://github.com/microsoft/healthcare-shared-components/compare/6.2.149...7.0.2)

---
updated-dependencies:
- dependency-name: Microsoft.Health.Abstractions
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Api
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Client
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Core
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Extensions.BuildTimeCodeGenerator
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Extensions.DependencyInjection
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.SqlServer.Api
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.SqlServer
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Test.Utilities
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Health.Tools.Sql.Tasks
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fixes build error

* Fix unit test

* Fix test

* Update tests fixture

* revert removing impl

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Richa Bansal <ribans@microsoft.com>
This commit is contained in:
dependabot[bot] 2023-09-21 09:20:45 -07:00 коммит произвёл GitHub
Родитель 3ce6bbe3c2
Коммит 44157b0746
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 92 добавлений и 37 удалений

Просмотреть файл

@ -1,7 +1,7 @@
<Project>
<!-- Shared dependencies versions.-->
<PropertyGroup>
<HealthcareSharedPackageVersion>6.2.149</HealthcareSharedPackageVersion>
<HealthcareSharedPackageVersion>7.0.2</HealthcareSharedPackageVersion>
<Hl7FhirVersion>4.3.0</Hl7FhirVersion>
</PropertyGroup>

Просмотреть файл

@ -79,10 +79,12 @@ public static class CommandCollectionExtensions
string? authenticationTypeValue = config[OptionAliases.AuthenticationType];
if (!string.IsNullOrWhiteSpace(authenticationTypeValue))
{
#pragma warning disable CS0618 // Type or member is obsolete
if (Enum.TryParse(authenticationTypeValue, true, out SqlServerAuthenticationType sqlServerAuthenticationType))
{
x.AuthenticationType = sqlServerAuthenticationType;
}
#pragma warning restore CS0618 // Type or member is obsolete
}
});

Просмотреть файл

@ -13,7 +13,9 @@ public class CommandLineOptions
public string? ConnectionString { get; set; }
#pragma warning disable CS0618 // Type or member is obsolete
public SqlServerAuthenticationType? AuthenticationType { get; set; }
#pragma warning restore CS0618 // Type or member is obsolete
public string? ManagedIdentityClientId { get; set; }
}

Просмотреть файл

@ -26,12 +26,14 @@ public static class SchemaManagerServiceCollectionBuilder
services.AddOptions<SqlServerDataStoreConfiguration>().Configure<IOptions<CommandLineOptions>>((s, c) =>
{
s.ConnectionString = c.Value.ConnectionString;
#pragma warning disable CS0618 // Type or member is obsolet
s.AuthenticationType = c.Value.AuthenticationType ?? SqlServerAuthenticationType.ConnectionString;
if (!string.IsNullOrWhiteSpace(c.Value.ManagedIdentityClientId))
{
s.ManagedIdentityClientId = c.Value.ManagedIdentityClientId;
}
#pragma warning restore CS0618 // Type or member is obsolete
});
services.AddSqlServerConnection();

Просмотреть файл

@ -69,15 +69,15 @@ namespace Microsoft.Health.Fhir.SqlServer.UnitTests.Features.ChangeFeed
[Fact]
public async Task GivenEmptyConnectionString_WhenGetResourceChanges_ThenInvalidOperationExceptionShouldBeThrown()
{
var resourceChangeDataStore = GetResourcChangeDataStoreWithGivenConnectionString(string.Empty);
try
{
var resourceChangeDataStore = GetResourcChangeDataStoreWithGivenConnectionString(string.Empty);
await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None);
}
catch (Exception ex)
{
Assert.Equal(nameof(InvalidOperationException), ex.GetType().Name);
Assert.Equal(nameof(ArgumentException), ex.GetType().Name);
}
}
@ -105,8 +105,7 @@ namespace Microsoft.Health.Fhir.SqlServer.UnitTests.Features.ChangeFeed
var schemaOptions = new SqlServerSchemaOptions { AutomaticUpdatesEnabled = true };
var config = Options.Create(new SqlServerDataStoreConfiguration { ConnectionString = connectionString, Initialize = true, SchemaOptions = schemaOptions, StatementTimeout = TimeSpan.FromMinutes(10) });
var sqlRetryLogicBaseProvider = SqlConfigurableRetryFactory.CreateNoneRetryProvider();
var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(config);
var sqlConnectionBuilder = new DefaultSqlConnectionBuilder(sqlConnectionStringProvider, sqlRetryLogicBaseProvider);
var sqlConnectionBuilder = new DefaultSqlConnectionBuilder(config, sqlRetryLogicBaseProvider);
var sqlConnectionWrapperFactory = new SqlConnectionWrapperFactory(new SqlTransactionHandler(), sqlConnectionBuilder, sqlRetryLogicBaseProvider, config);
var schemaInformation = new SchemaInformation(SchemaVersionConstants.Min, SchemaVersionConstants.Max);

Просмотреть файл

@ -312,7 +312,9 @@ namespace Microsoft.Health.Fhir.SqlServer.Features.Search
await _sqlRetryService.ExecuteSql(
async (cancellationToken, sqlException) =>
{
#pragma warning disable CS0618 // Type or member is obsolete
using (SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(initialCatalog: null, cancellationToken: cancellationToken).ConfigureAwait(false))
#pragma warning restore CS0618 // Type or member is obsolete
using (SqlCommand sqlCommand = connection.CreateCommand()) // WARNING, this code will not set sqlCommand.Transaction. Sql transactions via C#/.NET are not supported in this method.
{
// NOTE: connection is created by SqlConnectionHelper.GetBaseSqlConnectionAsync differently, depending on the _sqlConnectionBuilder implementation.

Просмотреть файл

@ -257,8 +257,9 @@ namespace Microsoft.Health.Fhir.SqlServer.Features.Storage
try
{
// NOTE: connection is created by SqlConnectionHelper.GetBaseSqlConnectionAsync differently, depending on the _sqlConnectionBuilder implementation.
#pragma warning disable CS0618 // Type or member is obsolete
using SqlConnection sqlConnection = await _sqlConnectionBuilder.GetSqlConnectionAsync(initialCatalog: null, cancellationToken: cancellationToken).ConfigureAwait(false);
#pragma warning restore CS0618 // Type or member is obsolete
// Connection is never opened by the _sqlConnectionBuilder but RetryLogicProvider is set to the old, deprecated retry implementation. According to the .NET spec, RetryLogicProvider
// must be set before opening connection to take effect. Therefore we must reset it to null here before opening the connection.
sqlConnection.RetryLogicProvider = null; // To remove this line _sqlConnectionBuilder in healthcare-shared-components must be modified.
@ -368,7 +369,9 @@ namespace Microsoft.Health.Fhir.SqlServer.Features.Storage
cmd.Parameters.AddWithValue("@Start", startDate.Value);
}
#pragma warning disable CS0618 // Type or member is obsolete
using var conn = await _sqlConnectionBuilder.GetSqlConnectionAsync(initialCatalog: null, cancellationToken: cancellationToken).ConfigureAwait(false);
#pragma warning restore CS0618 // Type or member is obsolete
conn.RetryLogicProvider = null;
await conn.OpenAsync(cancellationToken);
cmd.Connection = conn;

Просмотреть файл

@ -131,8 +131,7 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Features.Operations.Import
IOptions<SqlServerDataStoreConfiguration> config = Options.Create(new SqlServerDataStoreConfiguration { ConnectionString = connectionString, Initialize = true, SchemaOptions = schemaOptions, StatementTimeout = TimeSpan.FromMinutes(10) });
var sqlRetryLogicBaseProvider = SqlConfigurableRetryFactory.CreateNoneRetryProvider();
var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(config);
var defaultSqlConnectionBuilder = new DefaultSqlConnectionBuilder(sqlConnectionStringProvider, sqlRetryLogicBaseProvider);
var defaultSqlConnectionBuilder = new DefaultSqlConnectionBuilder(config, sqlRetryLogicBaseProvider);
var securityConfiguration = new SecurityConfiguration { PrincipalClaims = { "oid" } };
var sqlTransactionHandler = new SqlTransactionHandler();
@ -171,11 +170,9 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Features.Operations.Import
Func<IServiceProvider, SchemaUpgradeRunner> schemaUpgradeRunnerFactory = p => schemaUpgradeRunner;
Func<IServiceProvider, IReadOnlySchemaManagerDataStore> schemaManagerDataStoreFactory = p => schemaManagerDataStore;
Func<IServiceProvider, ISqlConnectionStringProvider> sqlConnectionStringProviderFunc = p => sqlConnectionStringProvider;
Func<IServiceProvider, SqlConnectionWrapperFactory> sqlConnectionWrapperFactoryFunc = p => defaultSqlConnectionWrapperFactory;
var collection = new ServiceCollection();
collection.AddScoped(sqlConnectionStringProviderFunc);
collection.AddScoped(sqlConnectionWrapperFactoryFunc);
collection.AddScoped(schemaUpgradeRunnerFactory);
collection.AddScoped(schemaManagerDataStoreFactory);

Просмотреть файл

@ -108,7 +108,7 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
private async Task ExecuteSql(string commandText)
{
using SqlConnection sqlConnection = await _fixture.SqlConnectionBuilder.GetSqlConnectionAsync();
using SqlConnection sqlConnection = _fixture.SqlConnectionBuilder.GetSqlConnection();
using SqlCommand sqlCommand = sqlConnection.CreateCommand();
await sqlConnection.OpenAsync();
sqlCommand.CommandText = commandText;
@ -589,7 +589,7 @@ END
var t = new Thread(new ThreadStart(() =>
{
_output.WriteLine($"{DateTime.Now:O}: Start KillConnection thread.");
using SqlConnection sqlConnection = _fixture.SqlConnectionBuilder.GetSqlConnectionAsync().GetAwaiter().GetResult();
using SqlConnection sqlConnection = _fixture.SqlConnectionBuilder.GetSqlConnection();
var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(sqlConnection.ConnectionString)
{
Pooling = false,
@ -618,9 +618,29 @@ END
_allRetriesFail = allRetriesFail;
}
public string DefaultDatabase => _sqlConnectionBuilder.DefaultDatabase;
public SqlConnection GetSqlConnection(string initialCatalog = null, int? maxPoolSize = null)
{
SqlConnection sqlConnection = _sqlConnectionBuilder.GetSqlConnection(initialCatalog, null);
_retryCount++;
if (_allRetriesFail || _retryCount == 1)
{
var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(sqlConnection.ConnectionString)
{
InitialCatalog = "FHIRINTEGRATIONTEST_DATABASE_DOES_NOT_EXIST",
};
sqlConnection.ConnectionString = sqlConnectionStringBuilder.ConnectionString;
}
return sqlConnection;
}
public async Task<SqlConnection> GetSqlConnectionAsync(string initialCatalog = null, int? maxPoolSize = null, CancellationToken cancellationToken = default)
{
#pragma warning disable CS0618 // Type or member is obsolete
SqlConnection sqlConnection = await _sqlConnectionBuilder.GetSqlConnectionAsync(initialCatalog, null, cancellationToken);
#pragma warning restore CS0618 // Type or member is obsolete
_retryCount++;
if (_allRetriesFail || _retryCount == 1)
{
@ -644,9 +664,24 @@ END
_sqlConnectionBuilder = sqlConnectionBuilder;
}
public string DefaultDatabase => _sqlConnectionBuilder.DefaultDatabase;
public SqlConnection GetSqlConnection(string initialCatalog = null, int? maxPoolSize = null)
{
SqlConnection sqlConnection = _sqlConnectionBuilder.GetSqlConnection(initialCatalog, null);
var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(sqlConnection.ConnectionString)
{
Pooling = false,
};
sqlConnection.ConnectionString = sqlConnectionStringBuilder.ConnectionString;
return sqlConnection;
}
public async Task<SqlConnection> GetSqlConnectionAsync(string initialCatalog = null, int? maxPoolSize = null, CancellationToken cancellationToken = default)
{
#pragma warning disable CS0618 // Type or member is obsolete
SqlConnection sqlConnection = await _sqlConnectionBuilder.GetSqlConnectionAsync(initialCatalog, null, cancellationToken);
#pragma warning restore CS0618 // Type or member is obsolete
var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(sqlConnection.ConnectionString)
{
Pooling = false,

Просмотреть файл

@ -72,7 +72,7 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
await _dbSetupRetryPolicy.ExecuteAsync(async () =>
{
// Create the database.
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(_masterDatabaseName, null, cancellationToken);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection(_masterDatabaseName, null);
await connection.OpenAsync(cancellationToken);
await using SqlCommand command = connection.CreateCommand();
@ -90,7 +90,7 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
await _dbSetupRetryPolicy.ExecuteAsync(async () =>
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(databaseName, null, cancellationToken);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection(databaseName, null);
await connection.OpenAsync(cancellationToken);
await using SqlCommand sqlCommand = connection.CreateCommand();
sqlCommand.CommandText = "SELECT 1";
@ -108,7 +108,7 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
public async Task InitWatchdogsParameters()
{
await using var conn = await _sqlConnectionBuilder.GetSqlConnectionAsync(cancellationToken: CancellationToken.None);
await using var conn = _sqlConnectionBuilder.GetSqlConnection();
await conn.OpenAsync(CancellationToken.None);
using var cmd = new SqlCommand(
@"
@ -173,7 +173,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
public async Task ExecuteSqlCmd(string sql)
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(cancellationToken: CancellationToken.None);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection();
using SqlCommand command = new SqlCommand(sql, connection);
await connection.OpenAsync(CancellationToken.None);
await command.ExecuteNonQueryAsync(CancellationToken.None);
@ -186,7 +186,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
await _dbSetupRetryPolicy.ExecuteAsync(async () =>
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(_masterDatabaseName, null, cancellationToken);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection(_masterDatabaseName, null);
await connection.OpenAsync(cancellationToken);
await using SqlCommand command = connection.CreateCommand();
command.CommandTimeout = 600;
@ -210,7 +210,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
public async Task DeleteSearchParameterStatusAsync(string uri, CancellationToken cancellationToken = default)
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(cancellationToken: cancellationToken);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection();
var command = new SqlCommand("DELETE FROM dbo.SearchParam WHERE Uri = @uri", connection);
command.Parameters.AddWithValue("@uri", uri);
@ -222,7 +222,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
public async Task DeleteAllReindexJobRecordsAsync(CancellationToken cancellationToken = default)
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(cancellationToken: cancellationToken);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection();
var command = new SqlCommand("DELETE FROM dbo.ReindexJob", connection);
await command.Connection.OpenAsync(cancellationToken);
@ -232,7 +232,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
public async Task DeleteReindexJobRecordAsync(string id, CancellationToken cancellationToken = default)
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync(cancellationToken: cancellationToken);
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection();
var command = new SqlCommand("DELETE FROM dbo.ReindexJob WHERE Id = @id", connection);
var parameter = new SqlParameter { ParameterName = "@id", Value = id };
@ -245,7 +245,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
async Task<object> IFhirStorageTestHelper.GetSnapshotToken()
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync();
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection();
await connection.OpenAsync();
SqlCommand command = connection.CreateCommand();
@ -255,7 +255,7 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
async Task IFhirStorageTestHelper.ValidateSnapshotTokenIsCurrent(object snapshotToken)
{
await using SqlConnection connection = await _sqlConnectionBuilder.GetSqlConnectionAsync();
await using SqlConnection connection = _sqlConnectionBuilder.GetSqlConnection();
await connection.OpenAsync();
var sb = new StringBuilder();
@ -304,22 +304,23 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
var schemaInformation = new SchemaInformation(SchemaVersionConstants.Min, maxSupportedSchemaVersion);
var sqlConnection = Substitute.For<ISqlConnectionBuilder>();
#pragma warning disable CS0618 // Type or member is obsolete
sqlConnection.GetSqlConnectionAsync(Arg.Any<string>(), Arg.Any<int?>(), Arg.Any<CancellationToken>()).ReturnsForAnyArgs((x) => Task.FromResult(GetSqlConnection(testConnectionString)));
#pragma warning restore CS0618 // Type or member is obsolete
SqlRetryLogicBaseProvider sqlRetryLogicBaseProvider = SqlConfigurableRetryFactory.CreateFixedRetryProvider(new SqlClientRetryOptions().Settings);
var sqlServerDataStoreConfiguration = new SqlServerDataStoreConfiguration() { ConnectionString = testConnectionString };
ISqlConnectionStringProvider sqlConnectionString = new DefaultSqlConnectionStringProvider(Options.Create(sqlServerDataStoreConfiguration));
var sqlConnectionWrapperFactory = new SqlConnectionWrapperFactory(new SqlTransactionHandler(), sqlConnection, sqlRetryLogicBaseProvider, config);
var schemaManagerDataStore = new SchemaManagerDataStore(sqlConnectionWrapperFactory, config, NullLogger<SchemaManagerDataStore>.Instance);
var schemaUpgradeRunner = new SchemaUpgradeRunner(new ScriptProvider<SchemaVersion>(), new BaseScriptProvider(), NullLogger<SchemaUpgradeRunner>.Instance, sqlConnectionWrapperFactory, schemaManagerDataStore);
Func<IServiceProvider, ISqlConnectionStringProvider> sqlConnectionStringProvider = p => sqlConnectionString;
////Func<IServiceProvider, ISqlConnectionStringProvider> sqlConnectionStringProvider = p => sqlConnectionString;
Func<IServiceProvider, SqlConnectionWrapperFactory> sqlConnectionWrapperFactoryFunc = p => sqlConnectionWrapperFactory;
Func<IServiceProvider, SchemaUpgradeRunner> schemaUpgradeRunnerFactory = p => schemaUpgradeRunner;
Func<IServiceProvider, IReadOnlySchemaManagerDataStore> schemaManagerDataStoreFactory = p => schemaManagerDataStore;
var collection = new ServiceCollection();
collection.AddScoped(sqlConnectionStringProvider);
////collection.AddScoped(sqlConnectionStringProvider);
collection.AddScoped(sqlConnectionWrapperFactoryFunc);
collection.AddScoped(schemaManagerDataStoreFactory);
collection.AddScoped(schemaUpgradeRunnerFactory);
@ -329,7 +330,9 @@ INSERT INTO dbo.Parameters (Id,Number) SELECT @LeasePeriodSecId, 10
public async Task<SqlConnection> GetSqlConnectionAsync()
{
#pragma warning disable CS0618
return await _sqlConnectionBuilder.GetSqlConnectionAsync(cancellationToken: CancellationToken.None);
#pragma warning restore CS0618
}
protected SqlConnection GetSqlConnection(string connectionString)

Просмотреть файл

@ -101,22 +101,22 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
var sqlSortingValidator = new SqlServerSortingValidator(SchemaInformation);
SqlRetryLogicBaseProvider sqlRetryLogicBaseProvider = SqlConfigurableRetryFactory.CreateFixedRetryProvider(new SqlClientRetryOptions().Settings);
var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(SqlServerDataStoreConfiguration);
SqlConnectionBuilder = new DefaultSqlConnectionBuilder(sqlConnectionStringProvider, sqlRetryLogicBaseProvider);
SqlConnectionBuilder = new DefaultSqlConnectionBuilder(SqlServerDataStoreConfiguration, sqlRetryLogicBaseProvider);
var sqlConnection = Substitute.For<ISqlConnectionBuilder>();
#pragma warning disable CS0618
sqlConnection.GetSqlConnectionAsync(Arg.Any<string>(), Arg.Any<int?>(), Arg.Any<CancellationToken>()).ReturnsForAnyArgs((x) => Task.FromResult(GetSqlConnection(TestConnectionString)));
var sqlConnectionWrapperFactory = new SqlConnectionWrapperFactory(new SqlTransactionHandler(), sqlConnection, sqlRetryLogicBaseProvider, SqlServerDataStoreConfiguration);
#pragma warning restore CS0618
var sqlConnectionWrapperFactory = new SqlConnectionWrapperFactory(new SqlTransactionHandler(), SqlConnectionBuilder, sqlRetryLogicBaseProvider, SqlServerDataStoreConfiguration);
var schemaManagerDataStore = new SchemaManagerDataStore(sqlConnectionWrapperFactory, SqlServerDataStoreConfiguration, NullLogger<SchemaManagerDataStore>.Instance);
_schemaUpgradeRunner = new SchemaUpgradeRunner(scriptProvider, baseScriptProvider, NullLogger<SchemaUpgradeRunner>.Instance, sqlConnectionWrapperFactory, schemaManagerDataStore);
Func<IServiceProvider, SchemaUpgradeRunner> schemaUpgradeRunnerFactory = p => _schemaUpgradeRunner;
Func<IServiceProvider, IReadOnlySchemaManagerDataStore> schemaManagerDataStoreFactory = p => schemaManagerDataStore;
Func<IServiceProvider, ISqlConnectionStringProvider> sqlConnectionStringProviderFunc = p => sqlConnectionStringProvider;
Func<IServiceProvider, SqlConnectionWrapperFactory> sqlConnectionWrapperFactoryFunc = p => sqlConnectionWrapperFactory;
var collection = new ServiceCollection();
collection.AddScoped(sqlConnectionStringProviderFunc);
collection.AddScoped(sqlConnectionWrapperFactoryFunc);
collection.AddScoped(schemaUpgradeRunnerFactory);
collection.AddScoped(schemaManagerDataStoreFactory);

Просмотреть файл

@ -129,8 +129,7 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
IOptions<SqlServerDataStoreConfiguration> config = Options.Create(new SqlServerDataStoreConfiguration { ConnectionString = connectionString, Initialize = true, SchemaOptions = schemaOptions, StatementTimeout = TimeSpan.FromMinutes(10) });
var sqlRetryLogicBaseProvider = SqlConfigurableRetryFactory.CreateNoneRetryProvider();
var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(config);
var defaultSqlConnectionBuilder = new DefaultSqlConnectionBuilder(sqlConnectionStringProvider, sqlRetryLogicBaseProvider);
var defaultSqlConnectionBuilder = new DefaultSqlConnectionBuilder(config, sqlRetryLogicBaseProvider);
var securityConfiguration = new SecurityConfiguration { PrincipalClaims = { "oid" } };
var sqlTransactionHandler = new SqlTransactionHandler();
@ -169,11 +168,9 @@ namespace Microsoft.Health.Fhir.Tests.Integration.Persistence
Func<IServiceProvider, SchemaUpgradeRunner> schemaUpgradeRunnerFactory = p => schemaUpgradeRunner;
Func<IServiceProvider, IReadOnlySchemaManagerDataStore> schemaManagerDataStoreFactory = p => schemaManagerDataStore;
Func<IServiceProvider, ISqlConnectionStringProvider> sqlConnectionStringProviderFunc = p => sqlConnectionStringProvider;
Func<IServiceProvider, SqlConnectionWrapperFactory> sqlConnectionWrapperFactoryFunc = p => defaultSqlConnectionWrapperFactory;
var collection = new ServiceCollection();
collection.AddScoped(sqlConnectionStringProviderFunc);
collection.AddScoped(sqlConnectionWrapperFactoryFunc);
collection.AddScoped(schemaUpgradeRunnerFactory);
collection.AddScoped(schemaManagerDataStoreFactory);

Просмотреть файл

@ -17,7 +17,14 @@ namespace Microsoft.Health.Internal.Fhir.EventsReader
_connectionString = connectionString;
}
#pragma warning disable CA2000
public string DefaultDatabase { get; }
public SqlConnection GetSqlConnection(string initialCatalog = null, int? maxPoolSize = null)
{
return new SqlConnection(_connectionString);
}
#pragma warning disable CA2000
public async Task<SqlConnection> GetSqlConnectionAsync(string initialCatalog = null, int? maxPoolSize = null, CancellationToken cancellationToken = default)
{

Просмотреть файл

@ -19,7 +19,13 @@ namespace Microsoft.Health.Internal.Fhir.Exporter
_connectionString = connectionString;
}
#pragma warning disable CA2000
public string DefaultDatabase { get; }
public SqlConnection GetSqlConnection(string initialCatalog = null, int? maxPoolSize = null)
{
return new SqlConnection(_connectionString);
}
#pragma warning disable CA2000
public async Task<SqlConnection> GetSqlConnectionAsync(string initialCatalog = null, int? maxPoolSize = null, CancellationToken cancellationToken = default)
{