public void StartCommitTest() { Transaction context = new Transaction(); ResourceManagerList rms = new ResourceManagerList(MyRMTest.MockRM()); rms.Add(MyRMTest.MockRM()); CommitedTransaction_Accessor target = new CommitedTransaction_Accessor(context, rms); CommitedTransaction_Accessor.stepTimeout = 1000; target.StartCommit(); Assert.IsTrue(target.DoneEvent.WaitOne(1000)); }
public void StartCommitTest() { Transaction context = new Transaction(); ResourceManagerList rms = new ResourceManagerList(MyRMTest.MockRM()); rms.Add(MyRMTest.MockRM()); CommitedTransaction_Accessor target = new CommitedTransaction_Accessor(context, rms); CommitedTransaction_Accessor.stepTimeout = 1000; target.StartCommit(); Assert.IsTrue(target.DoneEvent.WaitOne(1000)); }
public void StartCommitTestWithOneFailPrepare() { Transaction context = new Transaction(); MockRM failRm = new MockRM(); failRm.PrepareResponse = TP.XaResponse.XAER_RMERR; ResourceManagerList rms = new ResourceManagerList(failRm); rms.Add(MyRMTest.MockRM()); CommitedTransaction_Accessor.expBackoff = 1; CommitedTransaction_Accessor target = new CommitedTransaction_Accessor(context, rms); CommitedTransaction_Accessor.stepTimeout = 100; target.State = CommitState.Committed; target.StartCommit(); Assert.AreEqual(string.Format("2PC:Prepare {0}:MockRM\r2PC:Prepare {0}:test\r2PC:Rollback {0}:MockRM\r2PC:Rollback {0}:test\r", context.Id), target.Message); }
public void StartCommitWithOneFailCommitTest() { Transaction context = new Transaction(); MockRM failRm = new MockRM(); failRm.CommitResponse = TP.XaResponse.XAER_RMERR; ResourceManagerList rms = new ResourceManagerList(failRm); rms.Add(MyRMTest.MockRM()); CommitedTransaction_Accessor.expBackoff = 1; CommitedTransaction_Accessor target = new CommitedTransaction_Accessor(context, rms); CommitedTransaction_Accessor.stepTimeout = 10; target.State = CommitState.Committed; target.StartCommit(); Assert.AreEqual(string.Format("2PC:Prepare {0}:MockRM\r2PC:Prepare {0}:test\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\rSleep and retry 1\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\rSleep and retry 2\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\rSleep and retry 3\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\r2PC:Retry Commit {0}\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\rSleep and retry 1\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\rSleep and retry 2\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\rSleep and retry 3\r2PC:Commit {0}:MockRM\r2PC:Commit {0}:test\r", context.Id), target.Message); }