(tx *bolt.Tx, bucket []byte, key []byte, readInterval duration)
| 435 | } |
| 436 | |
| 437 | func executeRead(tx *bolt.Tx, bucket []byte, key []byte, readInterval duration) (historyRecord, error) { |
| 438 | var rec historyRecord |
| 439 | |
| 440 | b := tx.Bucket(bucket) |
| 441 | |
| 442 | initialVal := b.Get(key) |
| 443 | time.Sleep(randomDurationInRange(readInterval.min, readInterval.max)) |
| 444 | val := b.Get(key) |
| 445 | |
| 446 | if !bytes.Equal(initialVal, val) { |
| 447 | return rec, fmt.Errorf("read different values for the same key (%q), value1: %q, value2: %q", |
| 448 | string(key), formatBytes(initialVal), formatBytes(val)) |
| 449 | } |
| 450 | |
| 451 | clonedVal := make([]byte, len(val)) |
| 452 | copy(clonedVal, val) |
| 453 | |
| 454 | rec = historyRecord{ |
| 455 | OperationType: Read, |
| 456 | Bucket: string(bucket), |
| 457 | Key: string(key), |
| 458 | Value: clonedVal, |
| 459 | Txid: tx.ID(), |
| 460 | } |
| 461 | |
| 462 | return rec, nil |
| 463 | } |
| 464 | |
| 465 | func executeWrite(tx *bolt.Tx, bucket []byte, key []byte, writeBytes bytesRange, noopWriteRatio int) (historyRecord, error) { |
| 466 | var rec historyRecord |
no test coverage detected