(t *testing.T, name string, db *bolt.DB, bucket []byte, key []byte, readInterval duration, stopCh chan struct{})
| 928 | } |
| 929 | |
| 930 | func executeLongRunningRead(t *testing.T, name string, db *bolt.DB, bucket []byte, key []byte, readInterval duration, stopCh chan struct{}) error { |
| 931 | err := db.View(func(tx *bolt.Tx) error { |
| 932 | b := tx.Bucket(bucket) |
| 933 | |
| 934 | initialVal := b.Get(key) |
| 935 | |
| 936 | for { |
| 937 | select { |
| 938 | case <-stopCh: |
| 939 | t.Logf("%q finished.", name) |
| 940 | return nil |
| 941 | default: |
| 942 | } |
| 943 | |
| 944 | time.Sleep(randomDurationInRange(readInterval.min, readInterval.max)) |
| 945 | val := b.Get(key) |
| 946 | |
| 947 | if !bytes.Equal(initialVal, val) { |
| 948 | dirtyReadErr := fmt.Errorf("read different values for the same key (%q), value1: %q, value2: %q", |
| 949 | string(key), formatBytes(initialVal), formatBytes(val)) |
| 950 | return dirtyReadErr |
| 951 | } |
| 952 | } |
| 953 | }) |
| 954 | |
| 955 | return err |
| 956 | } |
no test coverage detected