[ARVADOS] updated: 9dabca0eedbc9f842d542fea3463a441140d590c
Git user
git at public.curoverse.com
Mon Apr 24 17:22:12 EDT 2017
Summary of changes:
services/crunch-run/logging.go | 5 +++--
services/crunch-run/logging_test.go | 40 ++++++++++---------------------------
2 files changed, 14 insertions(+), 31 deletions(-)
via 9dabca0eedbc9f842d542fea3463a441140d590c (commit)
from 6e577058389e70fd575580c3e11a122396140700 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 9dabca0eedbc9f842d542fea3463a441140d590c
Author: radhika <radhika at curoverse.com>
Date: Mon Apr 24 17:21:52 2017 -0400
8019: more testing
diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 00cc06a..da6a9ff 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -285,9 +285,8 @@ func (arvlog *ArvLogWriter) rateLimit(line []byte) (bool, []byte, error) {
lineSize := int64(len(line))
partialLine := false
skipCounts := false
- if arvlog.logThrottleIsOpen {
- matches := lineRegexp.FindStringSubmatch(string(line))
+ if arvlog.logThrottleIsOpen {
crunchLogPartialLineThrottlePeriod, err := arvlog.ArvClient.Discovery("crunchLogPartialLineThrottlePeriod")
crunchLimitLogBytesPerJob, err := arvlog.ArvClient.Discovery("crunchLimitLogBytesPerJob")
crunchLogThrottleBytes, err := arvlog.ArvClient.Discovery("crunchLogThrottleBytes")
@@ -297,6 +296,8 @@ func (arvlog *ArvLogWriter) rateLimit(line []byte) (bool, []byte, error) {
return false, []byte(""), err
}
+ matches := lineRegexp.FindStringSubmatch(string(line))
+
if len(matches) == 2 && strings.HasPrefix(matches[1], "[...]") && strings.HasSuffix(matches[1], "[...]") {
partialLine = true
diff --git a/services/crunch-run/logging_test.go b/services/crunch-run/logging_test.go
index 2ea9a31..477ed39 100644
--- a/services/crunch-run/logging_test.go
+++ b/services/crunch-run/logging_test.go
@@ -112,39 +112,21 @@ func (s *LoggingTestSuite) TestWriteMultipleLogs(c *C) {
}
func (s *LoggingTestSuite) TestWriteLogsWithRateLimitThrottleBytes(c *C) {
- discoveryMap["crunchLogThrottleBytes"] = float64(50)
- defer func() {
- discoveryMap["crunchLogThrottleBytes"] = float64(65536)
- }()
-
- 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")
+ testWriteLogsWithRateLimit(c, "crunchLogThrottleBytes", 50, 65536, "Exceeded rate 50 bytes per 60 seconds")
+}
- logtext := "2015-12-29T15:51:45.000000001Z Hello world!\n" +
- "2015-12-29T15:51:45.000000002Z Goodbye\n"
+func (s *LoggingTestSuite) TestWriteLogsWithRateLimitThrottleLines(c *C) {
+ testWriteLogsWithRateLimit(c, "crunchLogThrottleLines", 1, 1024, "Exceeded rate 1 lines per 60 seconds")
+}
- 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, "Exceeded rate 50 bytes per 60 seconds"))
- c.Check(string(kc.Content), Equals, logtext)
+func (s *LoggingTestSuite) TestWriteLogsWithRateLimitThrottleBytesPerEvent(c *C) {
+ testWriteLogsWithRateLimit(c, "crunchLimitLogBytesPerJob", 50, 67108864, "Exceeded log limit 50 bytes (crunch_limit_log_bytes_per_job)")
}
-func (s *LoggingTestSuite) TestWriteLogsWithRateLimitThrottleLines(c *C) {
- discoveryMap["crunchLogThrottleLines"] = float64(1)
+func testWriteLogsWithRateLimit(c *C, throttleParam string, throttleValue int, throttleDefault int, expected string) {
+ discoveryMap[throttleParam] = float64(throttleValue)
defer func() {
- discoveryMap["crunchLogThrottleLines"] = float64(1024)
+ discoveryMap[throttleParam] = float64(throttleDefault)
}()
api := &ArvTestClient{}
@@ -167,6 +149,6 @@ func (s *LoggingTestSuite) TestWriteLogsWithRateLimitThrottleLines(c *C) {
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, "Exceeded rate 1 lines per 60 seconds"))
+ c.Check(true, Equals, strings.Contains(stderrLog, expected))
c.Check(string(kc.Content), Equals, logtext)
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list