2798: Fixed inconsistencies with Python implementation of ShuffledServiceRoots.
[arvados.git] / sdk / go / src / arvados.org / keepclient / keepclient_test.go
1 package keepclient
2
3 import (
4         "fmt"
5         . "gopkg.in/check.v1"
6         "testing"
7 )
8
9 // Hook up gocheck into the "go test" runner.
10 func Test(t *testing.T) { TestingT(t) }
11
12 type MySuite struct{}
13
14 var _ = Suite(&MySuite{})
15
16 func (s *MySuite) TestGetKeepDisks(c *C) {
17         sr, err := KeepDisks()
18         c.Assert(err, Equals, nil)
19         c.Assert(len(sr), Equals, 2)
20         c.Assert(sr[0], Equals, "http://localhost:25107")
21         c.Assert(sr[1], Equals, "http://localhost:25108")
22
23         service_roots := []string{"http://localhost:25107", "http://localhost:25108", "http://localhost:25109", "http://localhost:25110", "http://localhost:25111", "http://localhost:25112", "http://localhost:25113", "http://localhost:25114", "http://localhost:25115", "http://localhost:25116", "http://localhost:25117", "http://localhost:25118", "http://localhost:25119", "http://localhost:25120", "http://localhost:25121", "http://localhost:25122", "http://localhost:25123"}
24
25         // "foo" acbd18db4cc2f85cedef654fccc4a4d8
26         foo_shuffle := []string{"http://localhost:25116", "http://localhost:25120", "http://localhost:25119", "http://localhost:25122", "http://localhost:25108", "http://localhost:25114", "http://localhost:25112", "http://localhost:25107", "http://localhost:25118", "http://localhost:25111", "http://localhost:25113", "http://localhost:25121", "http://localhost:25110", "http://localhost:25117", "http://localhost:25109", "http://localhost:25115", "http://localhost:25123"}
27         c.Check(ShuffledServiceRoots(service_roots, "acbd18db4cc2f85cedef654fccc4a4d8"), DeepEquals, foo_shuffle)
28
29         // "bar" 37b51d194a7513e45b56f6524f2d51f2
30         bar_shuffle := []string{"http://localhost:25108", "http://localhost:25112", "http://localhost:25119", "http://localhost:25107", "http://localhost:25110", "http://localhost:25116", "http://localhost:25122", "http://localhost:25120", "http://localhost:25121", "http://localhost:25117", "http://localhost:25111", "http://localhost:25123", "http://localhost:25118", "http://localhost:25113", "http://localhost:25114", "http://localhost:25115", "http://localhost:25109"}
31         c.Check(ShuffledServiceRoots(service_roots, "37b51d194a7513e45b56f6524f2d51f2"), DeepEquals, bar_shuffle)
32
33 }