-func (s *LoggingTestSuite) testWriteLogsWithRateLimit(c *C, throttleParam string, throttleValue int, throttleDefault int, expected string) {
- discoveryMap[throttleParam] = float64(throttleValue)
- defer func() {
- discoveryMap[throttleParam] = float64(throttleDefault)
- }()
-
- api := &ArvTestClient{}
- kc := &KeepTestClient{}
- defer kc.Close()
- cr, err := NewContainerRunner(s.client, api, kc, nil, "zzzzz-zzzzzzzzzzzzzzz")
- c.Assert(err, IsNil)
- 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.MarshalManifest(".")
- 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")
- 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)