-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
4 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
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,93 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Ydb.Sdk.Services.Table; | ||
|
||
namespace Ydb.Sdk.Tests.Table; | ||
|
||
[Trait("Category", "Integration")] | ||
public class TestGracefulShutdown | ||
{ | ||
private readonly ITestOutputHelper _testOutputHelper; | ||
Check warning on line 12 in src/Ydb.Sdk/tests/Table/TestGracefulShutdown.cs GitHub Actions / Inspection
|
||
private readonly ILoggerFactory _loggerFactory; | ||
|
||
private readonly DriverConfig _driverConfig = new( | ||
endpoint: "grpc://localhost:2136", | ||
database: "/local" | ||
); | ||
|
||
private const string ShutdownUrl = "http://localhost:8765/actors/kqp_proxy?force_shutdown=all"; | ||
|
||
public TestGracefulShutdown(ITestOutputHelper testOutputHelper) | ||
{ | ||
_testOutputHelper = testOutputHelper; | ||
_loggerFactory = Utils.GetLoggerFactory() ?? NullLoggerFactory.Instance; | ||
} | ||
|
||
[Fact] | ||
public async Task Test() | ||
{ | ||
await using var driver = await Driver.CreateInitialized(_driverConfig, _loggerFactory); | ||
using var tableClient = new TableClient(driver); | ||
|
||
|
||
var session1 = ""; | ||
await tableClient.SessionExec( | ||
async session => | ||
{ | ||
session1 = session.Id; | ||
return await session.ExecuteDataQuery("SELECT 1", TxControl.BeginSerializableRW().Commit()); | ||
} | ||
); | ||
|
||
// _testOutputHelper.WriteLine(session1); | ||
await Task.Delay(1000); | ||
|
||
var session2 = ""; | ||
await tableClient.SessionExec( | ||
async session => | ||
{ | ||
session2 = session.Id; | ||
return await session.ExecuteDataQuery("SELECT 1", TxControl.BeginSerializableRW().Commit()); | ||
} | ||
); | ||
|
||
// _testOutputHelper.WriteLine(session2); | ||
await Task.Delay(1000); | ||
|
||
|
||
// control check | ||
Assert.NotEqual("", session1); | ||
Assert.Equal(session1, session2); | ||
|
||
// SHUTDOWN | ||
using var httpClient = new HttpClient(); | ||
await httpClient.GetAsync(ShutdownUrl); | ||
await Task.Delay(1000); | ||
|
||
// new session | ||
var session3 = ""; | ||
await tableClient.SessionExec( | ||
async session => | ||
{ | ||
session3 = session.Id; | ||
return await session.ExecuteDataQuery("SELECT 1", TxControl.BeginSerializableRW().Commit()); | ||
} | ||
); | ||
|
||
Assert.Equal(session2, session3); | ||
|
||
var session4 = ""; | ||
await tableClient.SessionExec( | ||
async session => | ||
{ | ||
session4 = session.Id; | ||
return await session.ExecuteDataQuery("SELECT 1", TxControl.BeginSerializableRW().Commit()); | ||
} | ||
); | ||
|
||
Assert.NotEqual("", session3); | ||
Assert.NotEqual(session3, session4); | ||
} | ||
} |