2 using System.Collections.Generic;
3 using System.Threading.Tasks;
14 [Trait(
"Category",
"Integration")]
15 [Trait(
"Category",
"Async")]
24 var typeDefinition =
@"{ 26 ""name"": ""test_record"", 28 {""name"": ""id"", ""type"": ""int""}, 29 {""name"": ""name"", ""type"": ""string""} 33 var properties =
new Dictionary<string, IList<string>>
35 {
"id",
new List<string> {
"int",
"primary_key" } }
39 var createResponse = await ctx.Kinetica.CreateTypeAsync(typeDefinition,
"test_type_async", properties,
new Dictionary<string, string>());
40 var typeId = createResponse.type_id;
43 var hasTypeResponse = await ctx.Kinetica.HasTypeAsync(typeId,
new Dictionary<string, string>());
44 Assert.True(hasTypeResponse.type_exists,
"Type should exist");
47 var hasTypeResponseNonexistent = await ctx.Kinetica.HasTypeAsync(
"nonexistent_type_async_12345",
new Dictionary<string, string>());
48 Assert.False(hasTypeResponseNonexistent.type_exists,
"Non-existent type should not exist");
57 var typeDefinition =
@"{ 59 ""name"": ""test_record"", 61 {""name"": ""id"", ""type"": ""int""}, 62 {""name"": ""value"", ""type"": ""double""} 66 var properties =
new Dictionary<string, IList<string>>
68 {
"id",
new List<string> {
"int",
"primary_key" } }
71 var typeResponse = await ctx.Kinetica.CreateTypeAsync(typeDefinition,
"async_has_table_type", properties,
new Dictionary<string, string>());
74 var tableName = ctx.QualifiedTable(
"test_table_async");
75 await ctx.Kinetica.CreateTableAsync(tableName, typeResponse.type_id,
new Dictionary<string, string>());
78 var hasTableResponse = await ctx.Kinetica.HasTableAsync(tableName,
new Dictionary<string, string>());
79 Assert.True(hasTableResponse.table_exists,
"Table should exist");
80 Assert.Equal(tableName, hasTableResponse.table_name);
83 var nonexistentTable = ctx.QualifiedTable(
"nonexistent_table_async");
84 var hasTableResponseNonexistent = await ctx.Kinetica.HasTableAsync(nonexistentTable,
new Dictionary<string, string>());
85 Assert.False(hasTableResponseNonexistent.table_exists,
"Non-existent table should not exist");
91 using var ctx =
new TestContext(
"async_create_clear");
94 var typeDefinition =
@"{ 96 ""name"": ""simple_record"", 98 {""name"": ""id"", ""type"": ""int""} 102 var properties =
new Dictionary<string, IList<string>>
104 {
"id",
new List<string> {
"int",
"primary_key" } }
107 var typeResponse = await ctx.Kinetica.CreateTypeAsync(typeDefinition,
"simple_type_async", properties,
new Dictionary<string, string>());
110 var tableName = ctx.QualifiedTable(
"simple_table_async");
111 var createTableResponse = await ctx.Kinetica.CreateTableAsync(tableName, typeResponse.type_id,
new Dictionary<string, string>());
112 Assert.Equal(tableName, createTableResponse.table_name);
115 var hasTableResponse = await ctx.Kinetica.HasTableAsync(tableName,
new Dictionary<string, string>());
116 Assert.True(hasTableResponse.table_exists);
119 var clearResponse = await ctx.Kinetica.ClearTableAsync(tableName,
null,
new Dictionary<string, string>());
120 Assert.Equal(tableName, clearResponse.table_name);
123 var hasTableResponseAfter = await ctx.Kinetica.HasTableAsync(tableName,
new Dictionary<string, string>());
124 Assert.False(hasTableResponseAfter.table_exists,
"Table should not exist after clear");
130 using var ctx =
new TestContext(
"async_show_system_props");
133 var response = await ctx.Kinetica.ShowSystemPropertiesAsync(
new Dictionary<string, string>());
135 Assert.NotNull(response);
136 Assert.NotNull(response.property_map);
137 Assert.True(response.property_map.Count > 0,
"Should have system properties");
140 Assert.True(response.property_map.ContainsKey(
"conf.version") ||
141 response.property_map.ContainsKey(
"version.gpudb_core_version"),
142 "Should contain version information");
148 using var ctx =
new TestContext(
"async_show_system_status");
151 var response = await ctx.Kinetica.ShowSystemStatusAsync(
new Dictionary<string, string>());
153 Assert.NotNull(response);
154 Assert.NotNull(response.status_map);
155 Assert.True(response.status_map.Count > 0,
"Should have system status information");
161 using var ctx =
new TestContext(
"async_concurrent");
164 var typeDefinition =
@"{ 165 ""type"": ""record"", 166 ""name"": ""concurrent_record"", 168 {""name"": ""id"", ""type"": ""int""}, 169 {""name"": ""data"", ""type"": ""string""} 173 var properties =
new Dictionary<string, IList<string>>
175 {
"id",
new List<string> {
"int",
"primary_key" } }
178 var typeResponse = await ctx.Kinetica.CreateTypeAsync(typeDefinition,
"concurrent_type", properties,
new Dictionary<string, string>());
181 var tasks =
new List<Task>();
182 var tableNames =
new List<string>();
184 for (
int i = 0; i < 5; i++)
186 var tableName = ctx.QualifiedTable($
"concurrent_table_{i}");
187 tableNames.Add(tableName);
188 tasks.Add(ctx.Kinetica.CreateTableAsync(tableName, typeResponse.type_id,
new Dictionary<string, string>()));
192 await Task.WhenAll(tasks);
195 var verifyTasks = tableNames.Select(async tableName =>
197 var hasTableResponse = await ctx.Kinetica.HasTableAsync(tableName,
new Dictionary<string, string>());
198 Assert.True(hasTableResponse.table_exists, $
"Table {tableName} should exist");
201 await Task.WhenAll(verifyTasks);
207 using var ctx =
new TestContext(
"async_cancellation");
209 var cts =
new System.Threading.CancellationTokenSource();
212 var response = await ctx.Kinetica.ShowSystemPropertiesAsync(
new Dictionary<string, string>(), cts.Token);
213 Assert.NotNull(response);
216 var cancelledCts =
new System.Threading.CancellationTokenSource();
217 cancelledCts.Cancel();
222 await ctx.Kinetica.ShowSystemPropertiesAsync(
new Dictionary<string, string>(), cancelledCts.Token);
226 Assert.Contains(
"timed out", exception.Message.ToLower());
Async integration tests for core API functionality.
Test context that manages schema and cleanup for integration tests.
async Task TestConcurrentAsyncOperations()
async Task TestCreateAndClearTableAsync()
async Task TestHasTableAsync()
async Task TestShowSystemStatusAsync()
async Task TestHasTypeAsync()
async Task TestShowSystemPropertiesAsync()
async Task TestAsyncWithCancellationToken()