|
10 | 10 | using NUnit.Framework;
|
11 | 11 | using TestCommon.Model;
|
12 | 12 | using Xtensive.Orm.Reprocessing.Tests.ReprocessingContext;
|
| 13 | +using Xtensive.Orm.Tests; |
13 | 14 |
|
14 | 15 | namespace Xtensive.Orm.Reprocessing.Tests
|
15 | 16 | {
|
16 |
| - [TestFixture, Timeout(DefaultTestTimeout * 4)] |
| 17 | + [TestFixture] |
17 | 18 | public class DeadlockReprocessing : ReprocessingBaseTest
|
18 | 19 | {
|
| 20 | + protected override void CheckRequirements() |
| 21 | + { |
| 22 | + base.CheckRequirements(); |
| 23 | + Require.ProviderIsNot(StorageProvider.Firebird, "Throws timeout operation instead of deadlock, which is not reprocessible."); |
| 24 | + } |
| 25 | + |
19 | 26 | [Test, Timeout(DefaultTestTimeout)]
|
20 | 27 | public void SimpleDeadlockTest()
|
21 | 28 | {
|
22 |
| - Console.WriteLine("Test started"); |
23 |
| - |
24 |
| - var context = new Context(Domain); |
25 |
| - context.Run(IsolationLevel.Serializable, null, context.Deadlock); |
26 |
| - Assert.That(context.Count, Is.EqualTo(3)); |
27 |
| - Assert.That(Bar2Count(), Is.EqualTo(2)); |
| 29 | + using (var context = new Context(Domain)) { |
| 30 | + context.Run(IsolationLevel.Serializable, null, context.Deadlock); |
| 31 | + Assert.That(context.Count, Is.EqualTo(3)); |
| 32 | + Assert.That(Bar2Count(), Is.EqualTo(2)); |
| 33 | + } |
28 | 34 | }
|
29 | 35 |
|
30 | 36 | [Test, Timeout(DefaultTestTimeout)]
|
31 | 37 | public void NestedSerializableDeadlockTest()
|
32 | 38 | {
|
33 |
| - Console.WriteLine("Test started"); |
34 |
| - |
35 |
| - var context = new Context(Domain); |
36 |
| - context.Run( |
37 |
| - IsolationLevel.Serializable, |
38 |
| - null, |
39 |
| - (b, level, open) => context.Parent(b, level, open, ExecuteActionStrategy.HandleReprocessableException, context.Deadlock)); |
40 |
| - Assert.That(context.Count, Is.EqualTo(3)); |
41 |
| - Assert.That(Bar2Count(), Is.EqualTo(4)); |
| 39 | + using (var context = new Context(Domain)) { |
| 40 | + context.Run( |
| 41 | + IsolationLevel.Serializable, |
| 42 | + null, |
| 43 | + (b, level, open) => context.Parent(b, level, open, ExecuteActionStrategy.HandleReprocessableException, context.Deadlock)); |
| 44 | + Assert.That(context.Count, Is.EqualTo(3)); |
| 45 | + Assert.That(Bar2Count(), Is.EqualTo(4)); |
| 46 | + } |
42 | 47 | }
|
43 | 48 |
|
44 | 49 | [Test, Timeout(DefaultTestTimeout)]
|
45 | 50 | public void NestedSnapshotDeadlockTest()
|
46 | 51 | {
|
47 |
| - Console.WriteLine("Test started"); |
48 |
| - |
49 |
| - var context = new Context(Domain); |
50 |
| - context.Run( |
51 |
| - IsolationLevel.Snapshot, |
52 |
| - null, |
53 |
| - (b, level, open) => context.Parent(b, level, open, ExecuteActionStrategy.HandleReprocessableException, context.Deadlock)); |
54 |
| - Assert.That(context.Count, Is.EqualTo(3)); |
55 |
| - Assert.That(Bar2Count(), Is.EqualTo(4)); |
| 52 | + using (var context = new Context(Domain)) { |
| 53 | + context.Run( |
| 54 | + IsolationLevel.Snapshot, |
| 55 | + null, |
| 56 | + (b, level, open) => context.Parent(b, level, open, ExecuteActionStrategy.HandleReprocessableException, context.Deadlock)); |
| 57 | + Assert.That(context.Count, Is.EqualTo(3)); |
| 58 | + Assert.That(Bar2Count(), Is.EqualTo(4)); |
| 59 | + } |
56 | 60 | }
|
57 | 61 |
|
58 | 62 | [Test, Timeout(DefaultTestTimeout)]
|
59 | 63 | public void NestedNestedSerializableSerializableTest()
|
60 | 64 | {
|
61 |
| - Console.WriteLine("Test started"); |
62 |
| - |
63 | 65 | //nested nested serializable deadlock
|
64 |
| - var context = new Context(Domain); |
65 |
| - context.Run( |
66 |
| - IsolationLevel.Serializable, |
67 |
| - null, |
68 |
| - (b, level, open) => |
69 |
| - context.Parent( |
70 |
| - b, |
71 |
| - level, |
72 |
| - open, |
73 |
| - ExecuteActionStrategy.HandleReprocessableException, |
74 |
| - (b1, level1, open1) => |
75 |
| - context.Parent(b1, level1, open1, ExecuteActionStrategy.HandleReprocessableException, context.Deadlock))); |
76 |
| - Assert.That(context.Count, Is.EqualTo(3)); |
77 |
| - Assert.That(Bar2Count(), Is.EqualTo(6)); |
| 66 | + using (var context = new Context(Domain)) { |
| 67 | + context.Run( |
| 68 | + IsolationLevel.Serializable, |
| 69 | + null, |
| 70 | + (b, level, open) => |
| 71 | + context.Parent( |
| 72 | + b, |
| 73 | + level, |
| 74 | + open, |
| 75 | + ExecuteActionStrategy.HandleReprocessableException, |
| 76 | + (b1, level1, open1) => |
| 77 | + context.Parent(b1, level1, open1, ExecuteActionStrategy.HandleReprocessableException, context.Deadlock))); |
| 78 | + Assert.That(context.Count, Is.EqualTo(3)); |
| 79 | + Assert.That(Bar2Count(), Is.EqualTo(6)); |
| 80 | + } |
78 | 81 | }
|
79 | 82 |
|
80 |
| - private int Bar2Count() |
81 |
| - { |
82 |
| - return Domain.Execute(session => session.Query.All<Bar2>().Count()); |
83 |
| - } |
| 83 | + private int Bar2Count() => Domain.Execute(session => session.Query.All<Bar2>().Count()); |
84 | 84 | }
|
85 | 85 | }
|
86 | 86 |
|
|
0 commit comments