forked from TrueCloudLab/frostfs-node
[#1442] pilorama: Generate timestamp based on node position in the container
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
3caa982283
commit
4437cd7113
13 changed files with 333 additions and 169 deletions
38
pkg/local_object_storage/pilorama/util_test.go
Normal file
38
pkg/local_object_storage/pilorama/util_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package pilorama
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNextTimestamp(t *testing.T) {
|
||||
testCases := []struct {
|
||||
latest Timestamp
|
||||
pos, size uint64
|
||||
expected Timestamp
|
||||
}{
|
||||
{0, 0, 1, 1},
|
||||
{2, 0, 1, 3},
|
||||
{0, 0, 2, 2},
|
||||
{0, 1, 2, 1},
|
||||
{10, 0, 4, 12},
|
||||
{11, 0, 4, 12},
|
||||
{12, 0, 4, 16},
|
||||
{10, 1, 4, 13},
|
||||
{11, 1, 4, 13},
|
||||
{12, 1, 4, 13},
|
||||
{10, 2, 4, 14},
|
||||
{11, 2, 4, 14},
|
||||
{12, 2, 4, 14},
|
||||
{10, 3, 4, 11},
|
||||
{11, 3, 4, 15},
|
||||
{12, 3, 4, 15},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
actual := nextTimestamp(tc.latest, tc.pos, tc.size)
|
||||
require.Equal(t, tc.expected, actual,
|
||||
"latest %d, pos %d, size %d", tc.latest, tc.pos, tc.size)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue