22053: fixed collection test
[arvados.git] / lib / crunchrun / crunchrun_test.go
index e51dfe629bc6b8922b31f6e28b46e00295e0f323..94826e9e346e05086ffb32b3d37de2bb74342df1 100644 (file)
@@ -36,7 +36,6 @@ import (
        "git.arvados.org/arvados.git/sdk/go/arvados"
        "git.arvados.org/arvados.git/sdk/go/arvadosclient"
        "git.arvados.org/arvados.git/sdk/go/arvadostest"
-       "git.arvados.org/arvados.git/sdk/go/manifest"
 
        . "gopkg.in/check.v1"
 )
@@ -414,26 +413,12 @@ func (fw FileWrapper) Splice(*arvados.Subtree) error {
        return errors.New("not implemented")
 }
 
-func (client *KeepTestClient) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) {
-       if filename == hwImageID+".tar" {
-               rdr := ioutil.NopCloser(&bytes.Buffer{})
-               client.Called = true
-               return FileWrapper{rdr, 1321984}, nil
-       } else if filename == "/file1_in_main.txt" {
-               rdr := ioutil.NopCloser(strings.NewReader("foo"))
-               client.Called = true
-               return FileWrapper{rdr, 3}, nil
-       }
-       return nil, nil
-}
-
 type apiStubServer struct {
        server    *httptest.Server
        proxy     *httputil.ReverseProxy
        intercept func(http.ResponseWriter, *http.Request) bool
 
        container arvados.Container
-       logs      map[string]string
 }
 
 func apiStub() (*arvados.Client, *apiStubServer) {
@@ -452,19 +437,6 @@ func (apistub *apiStubServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
        if apistub.intercept != nil && apistub.intercept(w, r) {
                return
        }
-       if r.Method == "POST" && r.URL.Path == "/arvados/v1/logs" {
-               var body struct {
-                       Log struct {
-                               EventType  string `json:"event_type"`
-                               Properties struct {
-                                       Text string
-                               }
-                       }
-               }
-               json.NewDecoder(r.Body).Decode(&body)
-               apistub.logs[body.Log.EventType] += body.Log.Properties.Text
-               return
-       }
        if r.Method == "GET" && r.URL.Path == "/arvados/v1/collections/"+hwPDH {
                json.NewEncoder(w).Encode(arvados.Collection{ManifestText: hwManifest})
                return
@@ -556,10 +528,6 @@ type KeepErrorTestClient struct {
        KeepTestClient
 }
 
-func (*KeepErrorTestClient) ManifestFileReader(manifest.Manifest, string) (arvados.File, error) {
-       return nil, errors.New("KeepError")
-}
-
 func (*KeepErrorTestClient) BlockWrite(context.Context, arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) {
        return arvados.BlockWriteResponse{}, errors.New("KeepError")
 }
@@ -576,22 +544,6 @@ func (*KeepReadErrorTestClient) ReadAt(string, []byte, int) (int, error) {
        return 0, errors.New("KeepError")
 }
 
-type ErrorReader struct {
-       FileWrapper
-}
-
-func (ErrorReader) Read(p []byte) (n int, err error) {
-       return 0, errors.New("ErrorReader")
-}
-
-func (ErrorReader) Seek(int64, int) (int64, error) {
-       return 0, errors.New("ErrorReader")
-}
-
-func (*KeepReadErrorTestClient) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) {
-       return ErrorReader{}, nil
-}
-
 func dockerLog(fd byte, msg string) []byte {
        by := []byte(msg)
        header := make([]byte, 8+len(by))
@@ -623,7 +575,7 @@ func (s *TestSuite) TestRunContainer(c *C) {
        err = s.runner.WaitFinish()
        c.Assert(err, IsNil)
 
-       c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, `Hello world\n`)
+       c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, `2\S+Z Hello world\n`)
        c.Check(logFileContent(c, s.runner, "stderr.txt"), Matches, ``)
 }
 
@@ -803,7 +755,7 @@ func (s *TestSuite) TestFullRunHello(c *C) {
 
        c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
        c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
-       c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, "hello world\n")
+       c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, `2\S+Z hello world\n`)
        c.Check(s.testDispatcherKeepClient.StorageClasses, DeepEquals, []string{"default"})
        c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"default"})
 }
@@ -999,10 +951,11 @@ func (s *TestSuite) TestCrunchstat(c *C) {
        c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
        c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
 
-       c.Check(logFileContent(c, s.runner, "crunchstat.txt"), Matches, `(?ms).*mem \d+ swap \d+ pgmajfault \d+ rss.*`)
+       c.Check(logFileContent(c, s.runner, "crunchstat.txt"), Matches, `(?ms).*`+reTimestamp+` mem \d+ swap \d+ pgmajfault \d+ rss.*`)
+       c.Check(logFileContent(c, s.runner, "hoststat.txt"), Matches, `(?ms).*`+reTimestamp+` mem \d+ swap \d+ pgmajfault \d+ rss.*`)
 
        // Check that we called (*crunchstat.Reporter)Stop().
-       c.Check(logFileContent(c, s.runner, "crunch-run.txt"), Matches, `(?ms).*Maximum crunch-run memory rss usage was \d+ bytes\n.*`)
+       c.Check(logFileContent(c, s.runner, "crunch-run.txt"), Matches, `(?ms).*`+reTimestamp+` Maximum crunch-run memory rss usage was \d+ bytes\n.*`)
 }
 
 func (s *TestSuite) TestNodeInfoLog(c *C) {
@@ -1814,7 +1767,7 @@ func (s *TestSuite) TestFullRunWithAPI(c *C) {
        })
        c.Check(s.api.CalledWith("container.exit_code", 3), NotNil)
        c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
-       c.Check(logFileContent(c, s.runner, "crunch-run.txt"), Matches, `(?ms).*status code 3\n.*`)
+       c.Check(logFileContent(c, s.runner, "crunch-run.txt"), Matches, `(?ms).*`+reTimestamp+` Container exited with status code 3\n.*`)
 }
 
 func (s *TestSuite) TestFullRunSetOutput(c *C) {
@@ -1869,7 +1822,8 @@ func (s *TestSuite) TestArvMountRuntimeStatusWarning(c *C) {
        c.Check(s.api.CalledWith("container.runtime_status.warning", "arv-mount: Keep write error"), NotNil)
        c.Check(s.api.CalledWith("container.runtime_status.warningDetail", "Test: Keep write error: I am a teapot"), NotNil)
        c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
-       c.Check(logFileContent(c, s.runner, "crunch-run.txt"), Matches, `(?ms).*Container exited with status code 137 \(signal 9, SIGKILL\).*`)
+       c.Check(logFileContent(c, s.runner, "crunch-run.txt"), Matches, `(?ms).*`+reTimestamp+` Container exited with status code 137 \(signal 9, SIGKILL\).*`)
+       c.Check(logFileContent(c, s.runner, "arv-mount.txt"), Matches, reTimestamp+` Test: Keep write error: I am a teapot\n`)
 }
 
 func (s *TestSuite) TestStdoutWithExcludeFromOutputMountPointUnderOutputDir(c *C) {