Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coe committed Nov 19, 2024
1 parent 0d31dbe commit 6aef1b2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
24 changes: 24 additions & 0 deletions csharp/test/Drivers/Apache/Spark/SparkConnectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ internal void CanDetectConnectionParameterErrors(ParametersWithExceptions test)
OutputHelper?.WriteLine(exeption.Message);
}

/// <summary>
/// Tests connection timeout to establish a session with the backend.
/// </summary>
/// <param name="connectTimeoutMilliseconds">The timeout (in ms)</param>
/// <param name="exceptionType">The exception type to expect (if any)</param>
/// <param name="alternateExceptionType">An alternate exception that may occur (if any)</param>
[SkippableTheory]
[InlineData(1, typeof(TimeoutException), typeof(TTransportException))]
[InlineData(10, typeof(TimeoutException), typeof(TTransportException))]
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -135,6 +145,9 @@ internal void MetadataTimeoutTest(MetadataWithExceptions metadataWithException)
}
}

/// <summary>
/// Data type used for metadata timeout tests.
/// </summary>
internal class MetadataWithExceptions
{
public MetadataWithExceptions(int? queryTimeoutSeconds, string actionName, Action<SparkTestConfiguration> action, Type? exceptionType, Type? alternateExceptionType)
Expand Down Expand Up @@ -225,6 +238,12 @@ public MetadataTimeoutTestData()
AddAction("getTableSchema", getTableSchema);
}

/// <summary>
/// Adds the action with the default timeouts.
/// </summary>
/// <param name="name">The friendly name of the action.</param>
/// <param name="action">The action to perform.</param>
/// <param name="alternateExceptions">Optional list of alternate exceptions that are possible. Must have 5 items if present.</param>
private void AddAction(string name, Action<SparkTestConfiguration> action, List<Type?>? alternateExceptions = null)
{
List<Type?> expectedExceptions = new List<Type?>()
Expand Down Expand Up @@ -256,6 +275,11 @@ private void AddAction(string name, Action<SparkTestConfiguration> 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]));
Expand Down
13 changes: 11 additions & 2 deletions csharp/test/Drivers/Apache/Spark/StatementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -139,6 +138,10 @@ public void CanSetOptionQueryTimeout(string value, bool throws = false)
}
}

/// <summary>
/// Queries the backend with various timeouts.
/// </summary>
/// <param name="statementWithExceptions"></param>
[SkippableTheory]
[ClassData(typeof(StatementTimeoutTestData))]
internal void StatementTimeoutTest(StatementWithExceptions statementWithExceptions)
Expand Down Expand Up @@ -188,6 +191,9 @@ public async Task CanInteractUsingSetOptions()
}
}

/// <summary>
/// Data type used for metadata timeout tests.
/// </summary>
internal class StatementWithExceptions
{
public StatementWithExceptions(int? queryTimeoutSeconds, string? query, Type? exceptionType)
Expand All @@ -208,11 +214,14 @@ public StatementWithExceptions(int? queryTimeoutSeconds, string? query, Type? ex
public Type? ExceptionType { get; }

/// <summary>
/// If null, uses the default TestConfiguration
/// If null, uses the default TestConfiguration.
/// </summary>
public string? Query { get; }
}

/// <summary>
/// Collection of <see cref="StatementWithExceptions"/> for testing statement timeouts."/>
/// </summary>
internal class StatementTimeoutTestData : TheoryData<StatementWithExceptions>
{
public StatementTimeoutTestData()
Expand Down

0 comments on commit 6aef1b2

Please sign in to comment.