9397: add normalized manifest test
authorradhika <radhika@curoverse.com>
Mon, 6 Feb 2017 03:40:00 +0000 (22:40 -0500)
committerradhika <radhika@curoverse.com>
Mon, 6 Feb 2017 03:40:00 +0000 (22:40 -0500)
sdk/go/manifest/manifest.go
sdk/go/manifest/manifest_test.go
services/crunch-run/crunchrun.go

index 5219a5871f867176601810cd740d2c54e2ae2c91..a9745ae7cd7fb650909516f5e36451214654d792 100644 (file)
@@ -313,6 +313,8 @@ func (m *Manifest) NormalizedManifestForPath(path string) string {
                        } else {
                                if currentSpan[1] == fss.SegPos {
                                        currentSpan[1] += fss.SegLen
+                               } else if currentSpan[0]+currentSpan[1] == fss.SegPos {
+                                       currentSpan[1] = fss.SegPos + fss.SegLen
                                } else {
                                        manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]+fss.SegLen) + ":" + fss.Name + " "
                                        currentSpan = []uint64{fss.SegPos, fss.SegPos + fss.SegLen}
index 2fe427224ec848ea448a172aaf9e991289b46dd3..0d58a9ec1116de52529b4b80ffaf1787d2ac71db 100644 (file)
@@ -251,3 +251,9 @@ func TestBlockIterWithBadManifest(t *testing.T) {
                }
        }
 }
+
+func TestNormalizeManifest(t *testing.T) {
+       m := Manifest{Text: ". acbd18db4cc2f85cedef654fccc4a4d8+40 0:10:one 10:10:one 20:10:two 30:10:two\n"}
+       normalized := m.NormalizedManifestForPath("")
+       expectEqual(t, normalized, ". acbd18db4cc2f85cedef654fccc4a4d8+40 0:20:one 20:40:two\n")
+}
index 8d292581e2b2dda2d1db824e0c284dd86932c2db..6d8ec9c84eade9ceb2a46fbd9605bf49b308ce41 100644 (file)
@@ -755,12 +755,18 @@ func (runner *ContainerRunner) getCollectionManifestForPath(mnt arvados.Mount, b
                manifestText = strings.Replace(collection.ManifestText, "./", "."+bindSuffix+"/", -1)
                manifestText = strings.Replace(manifestText, ". ", "."+bindSuffix+" ", -1)
                wanted := ""
-               for _, token := range strings.Split(manifestText, " ") {
-                       if strings.Index(token, ":") == -1 {
-                               wanted += " " + token
-                       } else if strings.Index(token, ":"+mntPath) >= 0 {
-                               wanted += " " + token + "\n"
-                               break
+               for _, stream := range strings.Split(manifestText, "\n") {
+                       if strings.Index(stream, mntPath) == -1 {
+                               continue
+                       }
+
+                       for _, token := range strings.Split(manifestText, " ") {
+                               if strings.Index(token, ":") == -1 {
+                                       wanted += " " + token
+                               } else if strings.Index(token, ":"+mntPath) >= 0 {
+                                       wanted += " " + token + "\n"
+                                       break
+                               }
                        }
                }
                return wanted, nil