+// Ensure MountUUID in a pull list is correctly translated to a Volume
+// argument passed to writePulledBlock().
+func (s *PullWorkerTestSuite) TestSpecifyMountUUID(c *C) {
+ defer func(f func(*RRVolumeManager, Volume, []byte, string) error) {
+ writePulledBlock = f
+ }(writePulledBlock)
+ pullq := s.handler.Handler.(*router).pullq
+
+ for _, spec := range []struct {
+ sendUUID string
+ expectVolume Volume
+ }{
+ {
+ sendUUID: "",
+ expectVolume: nil,
+ },
+ {
+ sendUUID: s.handler.volmgr.Mounts()[0].UUID,
+ expectVolume: s.handler.volmgr.Mounts()[0].Volume,
+ },
+ } {
+ writePulledBlock = func(_ *RRVolumeManager, v Volume, _ []byte, _ string) error {
+ c.Check(v, Equals, spec.expectVolume)
+ return nil
+ }
+
+ resp := IssueRequest(s.handler, &RequestTester{
+ uri: "/pull",
+ apiToken: s.cluster.SystemRootToken,
+ method: "PUT",
+ requestBody: []byte(`[{
+ "locator":"acbd18db4cc2f85cedef654fccc4a4d8+3",
+ "servers":["server_1","server_2"],
+ "mount_uuid":"` + spec.sendUUID + `"}]`),
+ })
+ c.Assert(resp.Code, Equals, http.StatusOK)
+ expectEqualWithin(c, time.Second, 0, func() interface{} {
+ st := pullq.Status()
+ return st.InProgress + st.Queued
+ })
+ }
+}