Merge branch '21766-disk-cache-size'
[arvados.git] / lib / crunchrun / logging_test.go
index fdd4f27b7f9af5463517e3658020795c75ceb8d5..ee3320c7c34b0ac0b2fa012ad8b8a5276ccdf176 100644 (file)
@@ -67,7 +67,7 @@ func (s *LoggingTestSuite) TestWriteLogs(c *C) {
 
        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)
+       s.checkWroteBlock(c, kc, "74561df9ae65ee9f35d5661d42454264+83", logtext)
 }
 
 func (s *LoggingTestSuite) TestWriteLogsLarge(c *C) {
@@ -191,6 +191,10 @@ func (s *LoggingTestSuite) TestWriteLogsWithRateLimitThrottleBytesPerEvent(c *C)
        s.testWriteLogsWithRateLimit(c, "crunchLimitLogBytesPerJob", 50, 67108864, "Exceeded log limit 50 bytes (crunch_limit_log_bytes_per_job)")
 }
 
+func (s *LoggingTestSuite) TestWriteLogsWithZeroBytesPerJob(c *C) {
+       s.testWriteLogsWithRateLimit(c, "crunchLimitLogBytesPerJob", 0, 67108864, "Exceeded log limit 0 bytes (crunch_limit_log_bytes_per_job)")
+}
+
 func (s *LoggingTestSuite) testWriteLogsWithRateLimit(c *C, throttleParam string, throttleValue int, throttleDefault int, expected string) {
        discoveryMap[throttleParam] = float64(throttleValue)
        defer func() {
@@ -220,7 +224,14 @@ func (s *LoggingTestSuite) testWriteLogsWithRateLimit(c *C, throttleParam string
        c.Check(api.Content[0]["log"].(arvadosclient.Dict)["event_type"], Equals, "crunch-run")
        stderrLog := api.Content[0]["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"]
        c.Check(true, Equals, strings.Contains(stderrLog, expected))
-       c.Check(string(kc.Content), Equals, logtext)
+       s.checkWroteBlock(c, kc, "74561df9ae65ee9f35d5661d42454264+83", logtext)
+}
+
+func (s *LoggingTestSuite) checkWroteBlock(c *C, kc *KeepTestClient, locator, expect string) {
+       buf := make([]byte, len([]byte(expect))+1)
+       n, err := kc.ReadAt(locator, buf, 0)
+       c.Check(err, IsNil)
+       c.Check(string(buf[:n]), Equals, expect)
 }
 
 type filterSuite struct{}