X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/32b402114038bc6761c04c370afad786dbbb3125..d6cccd7cd0c02742218b73b510d475c84e6bd5a3:/lib/diagnostics/cmd.go diff --git a/lib/diagnostics/cmd.go b/lib/diagnostics/cmd.go index b381a3c8c1..799abf9da4 100644 --- a/lib/diagnostics/cmd.go +++ b/lib/diagnostics/cmd.go @@ -59,7 +59,7 @@ func (Command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s // docker save hello-world > hello-world.tar //go:embed hello-world.tar -var helloWorldDockerImage []byte +var HelloWorldDockerImage []byte type diagnoser struct { stdout io.Writer @@ -378,7 +378,7 @@ func (diag *diagnoser) runtests() { // as "sha256:{...}.tar" var imageSHA2 string { - tr := tar.NewReader(bytes.NewReader(helloWorldDockerImage)) + tr := tar.NewReader(bytes.NewReader(HelloWorldDockerImage)) for { hdr, err := tr.Next() if err == io.EOF { @@ -397,6 +397,7 @@ func (diag *diagnoser) runtests() { return } } + tarfilename := "sha256:" + imageSHA2 + ".tar" diag.dotest(100, "uploading file via webdav", func() error { ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout)) @@ -404,7 +405,7 @@ func (diag *diagnoser) runtests() { if collection.UUID == "" { return fmt.Errorf("skipping, no test collection") } - req, err := http.NewRequestWithContext(ctx, "PUT", cluster.Services.WebDAVDownload.ExternalURL.String()+"c="+collection.UUID+"/sha256:"+imageSHA2+".tar", bytes.NewReader(helloWorldDockerImage)) + req, err := http.NewRequestWithContext(ctx, "PUT", cluster.Services.WebDAVDownload.ExternalURL.String()+"c="+collection.UUID+"/"+tarfilename, bytes.NewReader(HelloWorldDockerImage)) if err != nil { return fmt.Errorf("BUG? http.NewRequest: %s", err) } @@ -445,11 +446,11 @@ func (diag *diagnoser) runtests() { fileurl string }{ {false, false, http.StatusNotFound, strings.Replace(davurl.String(), "*", "d41d8cd98f00b204e9800998ecf8427e-0", 1) + "foo"}, - {false, false, http.StatusNotFound, strings.Replace(davurl.String(), "*", "d41d8cd98f00b204e9800998ecf8427e-0", 1) + "testfile"}, + {false, false, http.StatusNotFound, strings.Replace(davurl.String(), "*", "d41d8cd98f00b204e9800998ecf8427e-0", 1) + tarfilename}, {false, false, http.StatusNotFound, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=d41d8cd98f00b204e9800998ecf8427e+0/_/foo"}, - {false, false, http.StatusNotFound, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=d41d8cd98f00b204e9800998ecf8427e+0/_/testfile"}, - {true, true, http.StatusOK, strings.Replace(davurl.String(), "*", strings.Replace(collection.PortableDataHash, "+", "-", -1), 1) + "testfile"}, - {true, false, http.StatusOK, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=" + collection.UUID + "/_/sha256:" + imageSHA2 + ".tar"}, + {false, false, http.StatusNotFound, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=d41d8cd98f00b204e9800998ecf8427e+0/_/" + tarfilename}, + {true, true, http.StatusOK, strings.Replace(davurl.String(), "*", strings.Replace(collection.PortableDataHash, "+", "-", -1), 1) + tarfilename}, + {true, false, http.StatusOK, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=" + collection.UUID + "/_/" + tarfilename}, } { diag.dotest(120+i, fmt.Sprintf("downloading from webdav (%s)", trial.fileurl), func() error { if trial.needWildcard && !davWildcard { @@ -478,7 +479,7 @@ func (diag *diagnoser) runtests() { if resp.StatusCode != trial.status { return fmt.Errorf("unexpected response status: %s", resp.Status) } - if trial.status == http.StatusOK && !bytes.Equal(body, helloWorldDockerImage) { + if trial.status == http.StatusOK && !bytes.Equal(body, HelloWorldDockerImage) { excerpt := body if len(excerpt) > 128 { excerpt = append([]byte(nil), body[:128]...)