* TestConcurrentGenericReadAndWrite verifies: 1. Repeatable read: a read transaction should always see the same data view during its lifecycle. 2. Any data written by a writing transaction should be visible to any following reading transactions (with txid >= previous writing txid). 3. The
(t *testing.T)
| 68 | 3. The txid should never decrease. |
| 69 | */ |
| 70 | func TestConcurrentGenericReadAndWrite(t *testing.T) { |
| 71 | if testing.Short() { |
| 72 | t.Skip("skipping test in short mode.") |
| 73 | } |
| 74 | |
| 75 | testDuration := concurrentTestDuration(t) |
| 76 | conf := concurrentConfig{ |
| 77 | bucketCount: 5, |
| 78 | keyCount: 10000, |
| 79 | workInterval: duration{}, |
| 80 | operationRatio: []operationChance{ |
| 81 | {operation: Read, chance: 60}, |
| 82 | {operation: Write, chance: 20}, |
| 83 | {operation: Delete, chance: 20}, |
| 84 | }, |
| 85 | readInterval: duration{ |
| 86 | min: 50 * time.Millisecond, |
| 87 | max: 100 * time.Millisecond, |
| 88 | }, |
| 89 | noopWriteRatio: 20, |
| 90 | writeBytes: bytesRange{ |
| 91 | min: 200, |
| 92 | max: 16000, |
| 93 | }, |
| 94 | } |
| 95 | |
| 96 | testCases := []struct { |
| 97 | name string |
| 98 | workerCount int |
| 99 | conf concurrentConfig |
| 100 | testDuration time.Duration |
| 101 | }{ |
| 102 | { |
| 103 | name: "1 worker", |
| 104 | workerCount: 1, |
| 105 | conf: conf, |
| 106 | testDuration: testDuration, |
| 107 | }, |
| 108 | { |
| 109 | name: "10 workers", |
| 110 | workerCount: 10, |
| 111 | conf: conf, |
| 112 | testDuration: testDuration, |
| 113 | }, |
| 114 | { |
| 115 | name: "50 workers", |
| 116 | workerCount: 50, |
| 117 | conf: conf, |
| 118 | testDuration: testDuration, |
| 119 | }, |
| 120 | { |
| 121 | name: "100 workers", |
| 122 | workerCount: 100, |
| 123 | conf: conf, |
| 124 | testDuration: testDuration, |
| 125 | }, |
| 126 | { |
| 127 | name: "200 workers", |
nothing calls this directly
no test coverage detected