4 "git.curoverse.com/arvados.git/sdk/go/blockdigest"
5 "git.curoverse.com/arvados.git/services/datamanager/keep"
10 // Gocheck boilerplate
11 func TestTrash(t *testing.T) {
15 type TrashSuite struct{}
17 var _ = Suite(&TrashSuite{})
19 func (s *TrashSuite) TestBuildTrashLists(c *C) {
20 var sv0 = keep.ServerAddress{Host: "keep0.example.com", Port: 80}
21 var sv1 = keep.ServerAddress{Host: "keep1.example.com", Port: 80}
23 var block0 = blockdigest.MakeTestDigestWithSize(0xdeadbeef)
24 var block1 = blockdigest.MakeTestDigestWithSize(0xfedbeef)
26 var keepServerInfo = keep.ReadServers{
27 KeepServerIndexToAddress: []keep.ServerAddress{sv0, sv1},
28 BlockToServers: map[blockdigest.DigestWithSize][]keep.BlockServerInfo{
29 block0: []keep.BlockServerInfo{
30 keep.BlockServerInfo{0, 99},
31 keep.BlockServerInfo{1, 101}},
32 block1: []keep.BlockServerInfo{
33 keep.BlockServerInfo{0, 99},
34 keep.BlockServerInfo{1, 101}}}}
36 // only block0 is in delete set
37 var bs = make(BlockSet)
38 bs[block0] = struct{}{}
40 // Test trash list where only sv0 is on writable list.
41 c.Check(buildTrashListsInternal(
43 sv0.URL(): struct{}{}},
48 map[string]keep.TrashList{
49 "http://keep0.example.com:80": keep.TrashList{keep.TrashRequest{"000000000000000000000000deadbeef", 99}}})
51 // Test trash list where both sv0 and sv1 are on writable list.
52 c.Check(buildTrashListsInternal(
54 sv0.URL(): struct{}{},
55 sv1.URL(): struct{}{}},
60 map[string]keep.TrashList{
61 "http://keep0.example.com:80": keep.TrashList{keep.TrashRequest{"000000000000000000000000deadbeef", 99}},
62 "http://keep1.example.com:80": keep.TrashList{keep.TrashRequest{"000000000000000000000000deadbeef", 101}}})
64 // Test trash list where only block on sv0 is expired
65 c.Check(buildTrashListsInternal(
67 sv0.URL(): struct{}{},
68 sv1.URL(): struct{}{}},
73 map[string]keep.TrashList{
74 "http://keep0.example.com:80": keep.TrashList{keep.TrashRequest{"000000000000000000000000deadbeef", 99}}})