Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShay Rojansky <roji@roji.org>2022-08-29 12:36:14 +0300
committergithub-actions <github-actions@github.com>2022-08-29 14:25:25 +0300
commitd8b634a49a4b8e07944b986d5e4a2e85f12d2bdb (patch)
tree5d7e8d6e10bef397a24e08cbb2b0fb2f2441c205
parentfe99c441fd6169725366d61d0ba4b8a4d4a11ecf (diff)
Move distributed transaction test to OleTxTestsbackport/pr-74747-to-release/7.0
NonMsdtcPromoterTests.PSPENonMsdtcGetPromoterTypeMSDTC was triggering an MSDTC distributed transaction on Windows, but without the proper checks/resiliency. Moved to OleTxTests. Fixes #74170
-rw-r--r--src/libraries/System.Transactions.Local/tests/NonMsdtcPromoterTests.cs65
-rw-r--r--src/libraries/System.Transactions.Local/tests/OleTxNonWindowsUnsupportedTests.cs11
-rw-r--r--src/libraries/System.Transactions.Local/tests/OleTxTests.cs28
3 files changed, 37 insertions, 67 deletions
diff --git a/src/libraries/System.Transactions.Local/tests/NonMsdtcPromoterTests.cs b/src/libraries/System.Transactions.Local/tests/NonMsdtcPromoterTests.cs
index dc2ba01f63b..6313200e46a 100644
--- a/src/libraries/System.Transactions.Local/tests/NonMsdtcPromoterTests.cs
+++ b/src/libraries/System.Transactions.Local/tests/NonMsdtcPromoterTests.cs
@@ -21,7 +21,6 @@ namespace System.Transactions.Tests
private static MethodInfo s_setDistributedTransactionIdentifierMethodInfo;
private static MethodInfo s_getPromotedTokenMethodInfo;
private static PropertyInfo s_promoterTypePropertyInfo;
- private static FieldInfo s_promoterTypeDtcFieldInfo;
public NonMsdtcPromoterTests()
{
@@ -51,17 +50,12 @@ namespace System.Transactions.Tests
// And the PropertyInfo objects for PromoterType
s_promoterTypePropertyInfo = typeof(Transaction).GetTypeInfo().GetProperty("PromoterType", typeof(Guid));
-
- // And the FieldInfo for TransactionInterop.PromoterTypeDtc
- s_promoterTypeDtcFieldInfo = typeof(TransactionInterop).GetTypeInfo().GetField("PromoterTypeDtc", BindingFlags.Public | BindingFlags.Static);
}
bool allMethodsAreThere = ((s_enlistPromotableSinglePhaseMethodInfo != null) &&
(s_setDistributedTransactionIdentifierMethodInfo != null) &&
(s_getPromotedTokenMethodInfo != null) &&
- (s_promoterTypePropertyInfo != null) &&
- (s_promoterTypeDtcFieldInfo != null)
- );
+ (s_promoterTypePropertyInfo != null));
Assert.True(allMethodsAreThere, "At least one of the expected new methods or properties is not implemented by the available System.Transactions.");
}
@@ -339,14 +333,6 @@ namespace System.Transactions.Tests
return (byte[])s_getPromotedTokenMethodInfo.Invoke(txToGet, null);
}
- private static Guid PromoterTypeDtc
- {
- get
- {
- return (Guid)s_promoterTypeDtcFieldInfo.GetValue(null);
- }
- }
-
#endregion
#region NonMSDTCPromoterEnlistment
@@ -1706,45 +1692,6 @@ namespace System.Transactions.Tests
TestPassed();
}
- private static void TestCase_PromoterTypeMSDTC()
- {
- string testCaseDescription = "TestCase_PromoterTypeMSDTC";
-
- Trace("**** " + testCaseDescription + " ****");
-
- AutoResetEvent volCompleted = new AutoResetEvent(false);
- MyEnlistment vol = null;
-
- try
- {
- using (TransactionScope ts = new TransactionScope())
- {
- Assert.Equal(Guid.Empty, TxPromoterType(Transaction.Current));
-
- vol = CreateVolatileEnlistment(volCompleted);
-
- // Force MSDTC promotion.
- TransactionInterop.GetDtcTransaction(Transaction.Current);
-
- // TransactionInterop.PromoterTypeDtc
- Assert.Equal(PromoterTypeDtc, TxPromoterType(Transaction.Current));
-
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- Trace(string.Format("Caught unexpected exception {0}:{1}", ex.GetType().ToString(), ex.ToString()));
- return;
- }
-
- Assert.True(volCompleted.WaitOne(TimeSpan.FromSeconds(5)));
-
- Assert.True(vol.CommittedOutcome);
-
- TestPassed();
- }
-
private static void TestCase_FailPromotableSinglePhaseNotificationCalls()
{
string testCaseDescription = "TestCase_FailPromotableSinglePhaseNotificationCalls";
@@ -2134,16 +2081,6 @@ namespace System.Transactions.Tests
}
/// <summary>
- /// PSPE Non-MSDTC Get PromoterType.
- /// </summary>
- [Fact]
- public void PSPENonMsdtcGetPromoterTypeMSDTC()
- {
- // get_PromoterType
- TestCase_PromoterTypeMSDTC();
- }
-
- /// <summary>
/// PSPE Non-MSDTC Fail PromotableSinglePhaseNotification Calls.
/// </summary>
[Fact]
diff --git a/src/libraries/System.Transactions.Local/tests/OleTxNonWindowsUnsupportedTests.cs b/src/libraries/System.Transactions.Local/tests/OleTxNonWindowsUnsupportedTests.cs
index fc753cef0e2..bcf50d06c31 100644
--- a/src/libraries/System.Transactions.Local/tests/OleTxNonWindowsUnsupportedTests.cs
+++ b/src/libraries/System.Transactions.Local/tests/OleTxNonWindowsUnsupportedTests.cs
@@ -55,10 +55,15 @@ public class OleTxNonWindowsUnsupportedTests
[Fact]
public void GetWhereabouts()
- => Assert.Throws<PlatformNotSupportedException>(() => TransactionInterop.GetWhereabouts());
+ => Assert.Throws<PlatformNotSupportedException>(TransactionInterop.GetWhereabouts);
[Fact]
public void GetExportCookie()
- => Assert.Throws<PlatformNotSupportedException>(() => TransactionInterop.GetExportCookie(
- new CommittableTransaction(), new byte[200]));
+ => Assert.Throws<PlatformNotSupportedException>(() =>
+ TransactionInterop.GetExportCookie(new CommittableTransaction(), new byte[200]));
+
+ [Fact]
+ public void GetDtcTransaction()
+ => Assert.Throws<PlatformNotSupportedException>(() =>
+ TransactionInterop.GetDtcTransaction(new CommittableTransaction()));
}
diff --git a/src/libraries/System.Transactions.Local/tests/OleTxTests.cs b/src/libraries/System.Transactions.Local/tests/OleTxTests.cs
index 6a97aed542a..e646c09a593 100644
--- a/src/libraries/System.Transactions.Local/tests/OleTxTests.cs
+++ b/src/libraries/System.Transactions.Local/tests/OleTxTests.cs
@@ -433,6 +433,34 @@ public class OleTxTests : IClassFixture<OleTxTests.OleTxFixture>
Assert.Equal(tx.TransactionInformation.DistributedIdentifier, tx2.TransactionInformation.DistributedIdentifier);
});
+ // Test currently skipped, #74745
+ private void GetDtcTransaction()
+ => Test(() =>
+ {
+ using var tx = new CommittableTransaction();
+
+ var outcomeReceived = new AutoResetEvent(false);
+
+ var enlistment = new TestEnlistment(
+ Phase1Vote.Prepared, EnlistmentOutcome.Committed, outcomeReceived: outcomeReceived);
+
+ Assert.Equal(Guid.Empty, tx.PromoterType);
+
+ tx.EnlistVolatile(enlistment, EnlistmentOptions.None);
+
+ // Forces promotion to MSDTC, returns an ITransaction for use only with System.EnterpriseServices.
+ _ = TransactionInterop.GetDtcTransaction(tx);
+
+ Assert.Equal(TransactionStatus.Active, tx.TransactionInformation.Status);
+ Assert.Equal(TransactionInterop.PromoterTypeDtc, tx.PromoterType);
+
+ tx.Commit();
+
+ Assert.True(outcomeReceived.WaitOne(Timeout));
+ Assert.Equal(EnlistmentOutcome.Committed, enlistment.Outcome);
+ Retry(() => Assert.Equal(TransactionStatus.Committed, tx.TransactionInformation.Status));
+ });
+
private static void Test(Action action)
{
// Temporarily skip on 32-bit where we have an issue.