diff --git a/csharp/test/Drivers/Apache/Spark/SparkConnectionTest.cs b/csharp/test/Drivers/Apache/Spark/SparkConnectionTest.cs index 6c10bcf922..c1a7606811 100644 --- a/csharp/test/Drivers/Apache/Spark/SparkConnectionTest.cs +++ b/csharp/test/Drivers/Apache/Spark/SparkConnectionTest.cs @@ -53,6 +53,12 @@ internal void CanDetectConnectionParameterErrors(ParametersWithExceptions test) OutputHelper?.WriteLine(exeption.Message); } + /// + /// Tests connection timeout to establish a session with the backend. + /// + /// The timeout (in ms) + /// The exception type to expect (if any) + /// An alternate exception that may occur (if any) [SkippableTheory] [InlineData(1, typeof(TimeoutException), typeof(TTransportException))] [InlineData(10, typeof(TimeoutException), typeof(TTransportException))] @@ -83,6 +89,10 @@ public void ConnectionTimeoutTest(int? connectTimeoutMilliseconds, Type? excepti // a TTransportException is inside a HiveServer2Exception Assert.IsType(alternateExceptionType, aex.InnerException!.InnerException); } + else + { + throw; + } } else { @@ -135,6 +145,9 @@ internal void MetadataTimeoutTest(MetadataWithExceptions metadataWithException) } } + /// + /// Data type used for metadata timeout tests. + /// internal class MetadataWithExceptions { public MetadataWithExceptions(int? queryTimeoutSeconds, string actionName, Action action, Type? exceptionType, Type? alternateExceptionType) @@ -225,6 +238,12 @@ public MetadataTimeoutTestData() AddAction("getTableSchema", getTableSchema); } + /// + /// Adds the action with the default timeouts. + /// + /// The friendly name of the action. + /// The action to perform. + /// Optional list of alternate exceptions that are possible. Must have 5 items if present. private void AddAction(string name, Action action, List? alternateExceptions = null) { List expectedExceptions = new List() @@ -256,6 +275,11 @@ private void AddAction(string name, Action action, List< { Assert.True(expectedExceptions.Count == 5); + if (alternateExceptions != null) + { + Assert.True(alternateExceptions.Count == 5); + } + Add(new(-1, name, action, expectedExceptions[0], alternateExceptions?[0])); Add(new(1, name, action, expectedExceptions[1], alternateExceptions?[1])); Add(new(10, name, action, expectedExceptions[2], alternateExceptions?[2])); diff --git a/csharp/test/Drivers/Apache/Spark/StatementTests.cs b/csharp/test/Drivers/Apache/Spark/StatementTests.cs index 2baf40b0d9..cecbaa66f6 100644 --- a/csharp/test/Drivers/Apache/Spark/StatementTests.cs +++ b/csharp/test/Drivers/Apache/Spark/StatementTests.cs @@ -23,7 +23,6 @@ using Thrift.Transport; using Xunit; using Xunit.Abstractions; -using static Apache.Arrow.Adbc.Tests.Drivers.Apache.Spark.SparkConnectionTest; namespace Apache.Arrow.Adbc.Tests.Drivers.Apache.Spark { @@ -139,6 +138,10 @@ public void CanSetOptionQueryTimeout(string value, bool throws = false) } } + /// + /// Queries the backend with various timeouts. + /// + /// [SkippableTheory] [ClassData(typeof(StatementTimeoutTestData))] internal void StatementTimeoutTest(StatementWithExceptions statementWithExceptions) @@ -188,6 +191,9 @@ public async Task CanInteractUsingSetOptions() } } + /// + /// Data type used for metadata timeout tests. + /// internal class StatementWithExceptions { public StatementWithExceptions(int? queryTimeoutSeconds, string? query, Type? exceptionType) @@ -208,11 +214,14 @@ public StatementWithExceptions(int? queryTimeoutSeconds, string? query, Type? ex public Type? ExceptionType { get; } /// - /// If null, uses the default TestConfiguration + /// If null, uses the default TestConfiguration. /// public string? Query { get; } } + /// + /// Collection of for testing statement timeouts."/> + /// internal class StatementTimeoutTestData : TheoryData { public StatementTimeoutTestData()