8019: rateLimit crunch-run logging using API configuration parameters
[arvados.git] / services / crunch-run / logging_test.go
index ceb8ca87b00ba25a0a9dc1ac2f2f6ca591cdd0b8..91af16dc4970386b4c8f8301387b0b32943e5df7 100644 (file)
@@ -109,3 +109,27 @@ func (s *LoggingTestSuite) TestWriteMultipleLogs(c *C) {
                ". 408672f5b5325f7d20edfbf899faee42+83 0:83:crunch-run.txt\n"+
                ". c556a293010069fa79a6790a931531d5+80 0:80:stdout.txt\n")
 }
+
+func (s *LoggingTestSuite) TestWriteLogsWithRateLimit(c *C) {
+       api := &ArvTestClient{}
+       kc := &KeepTestClient{}
+       cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzzzzzzzzzzzz")
+       cr.CrunchLog.Timestamper = (&TestTimestamper{}).Timestamp
+
+       cr.CrunchLog.Print("Hello world!")
+       cr.CrunchLog.Print("Goodbye")
+       cr.CrunchLog.Close()
+
+       c.Check(api.Calls, Equals, 1)
+
+       mt, err := cr.LogCollection.ManifestText()
+       c.Check(err, IsNil)
+       c.Check(mt, Equals, ". 74561df9ae65ee9f35d5661d42454264+83 0:83:crunch-run.txt\n")
+
+       logtext := "2015-12-29T15:51:45.000000001Z Hello world!\n" +
+               "2015-12-29T15:51:45.000000002Z Goodbye\n"
+
+       c.Check(api.Content[0]["log"].(arvadosclient.Dict)["event_type"], Equals, "crunch-run")
+       c.Check(api.Content[0]["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"], Equals, logtext)
+       c.Check(string(kc.Content), Equals, logtext)
+}