[ARVADOS] updated: be191fe42348d23708f0c4de8ace619644b18b2d
Git user
git at public.curoverse.com
Fri Mar 4 14:11:04 EST 2016
Summary of changes:
services/crunch-run/crunchrun_test.go | 61 +++++++++++++++++++----------------
services/crunch-run/logging_test.go | 12 +++----
2 files changed, 40 insertions(+), 33 deletions(-)
via be191fe42348d23708f0c4de8ace619644b18b2d (commit)
from e11ee6c48ee1ee0e02c48b739ca6989d9e9b2ae9 (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 be191fe42348d23708f0c4de8ace619644b18b2d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Fri Mar 4 14:10:59 2016 -0500
Fix crunch-run tests to pass reliably. refs #8015
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index 53cdbbc..659b3c0 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -36,7 +36,7 @@ var _ = Suite(&TestSuite{})
type ArvTestClient struct {
Total int64
Calls int
- Content arvadosclient.Dict
+ Content []arvadosclient.Dict
ContainerRecord
Logs map[string]*bytes.Buffer
WasSetRunning bool
@@ -131,7 +131,7 @@ func (this *ArvTestClient) Create(resourceType string,
output interface{}) error {
this.Calls += 1
- this.Content = parameters
+ this.Content = append(this.Content, parameters)
if resourceType == "logs" {
et := parameters["log"].(arvadosclient.Dict)["event_type"].(string)
@@ -168,8 +168,8 @@ func (this *ArvTestClient) Get(resourceType string, uuid string, parameters arva
}
func (this *ArvTestClient) Update(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) (err error) {
-
- this.Content = parameters
+ this.Calls += 1
+ this.Content = append(this.Content, parameters)
if resourceType == "containers" {
if parameters["container"].(arvadosclient.Dict)["state"] == "Running" {
this.WasSetRunning = true
@@ -399,8 +399,9 @@ func (s *TestSuite) TestCommitLogs(c *C) {
err := cr.CommitLogs()
c.Check(err, IsNil)
- c.Check(api.Content["collection"].(arvadosclient.Dict)["name"], Equals, "logs for zzzzz-zzzzz-zzzzzzzzzzzzzzz")
- c.Check(api.Content["collection"].(arvadosclient.Dict)["manifest_text"], Equals, ". 744b2e4553123b02fa7b452ec5c18993+123 0:123:crunch-run.txt\n")
+ c.Check(api.Calls, Equals, 2)
+ c.Check(api.Content[1]["collection"].(arvadosclient.Dict)["name"], Equals, "logs for zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+ c.Check(api.Content[1]["collection"].(arvadosclient.Dict)["manifest_text"], Equals, ". 744b2e4553123b02fa7b452ec5c18993+123 0:123:crunch-run.txt\n")
c.Check(*cr.LogsPDH, Equals, "63da7bdacf08c40f604daad80c261e9a+60")
}
@@ -412,7 +413,7 @@ func (s *TestSuite) TestUpdateContainerRecordRunning(c *C) {
err := cr.UpdateContainerRecordRunning()
c.Check(err, IsNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Running")
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["state"], Equals, "Running")
}
func (s *TestSuite) TestUpdateContainerRecordComplete(c *C) {
@@ -430,9 +431,9 @@ func (s *TestSuite) TestUpdateContainerRecordComplete(c *C) {
err := cr.UpdateContainerRecordComplete()
c.Check(err, IsNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["log"], Equals, *cr.LogsPDH)
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], Equals, *cr.ExitCode)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["log"], Equals, *cr.LogsPDH)
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["exit_code"], Equals, *cr.ExitCode)
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
}
func (s *TestSuite) TestUpdateContainerRecordCancelled(c *C) {
@@ -445,9 +446,9 @@ func (s *TestSuite) TestUpdateContainerRecordCancelled(c *C) {
err := cr.UpdateContainerRecordComplete()
c.Check(err, IsNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["log"], IsNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], IsNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Cancelled")
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["log"], IsNil)
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["exit_code"], IsNil)
+ c.Check(api.Content[0]["container"].(arvadosclient.Dict)["state"], Equals, "Cancelled")
}
// Used by the TestFullRun*() test below to DRY up boilerplate setup to do full
@@ -470,7 +471,7 @@ func FullRunHelper(c *C, record string, fn func(t *TestDockerClient)) (api *ArvT
c.Check(err, IsNil)
c.Check(api.WasSetRunning, Equals, true)
- c.Check(api.Content["container"].(arvadosclient.Dict)["log"], NotNil)
+ c.Check(api.Content[api.Calls-1]["container"].(arvadosclient.Dict)["log"], NotNil)
if err != nil {
for k, v := range api.Logs {
@@ -498,8 +499,9 @@ func (s *TestSuite) TestFullRunHello(c *C) {
t.finish <- dockerclient.WaitResult{}
})
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
+ c.Check(api.Calls, Equals, 7)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "hello world\n"), Equals, true)
@@ -522,9 +524,10 @@ func (s *TestSuite) TestFullRunStderr(c *C) {
t.finish <- dockerclient.WaitResult{ExitCode: 1}
})
- c.Check(api.Content["container"].(arvadosclient.Dict)["log"], NotNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], Equals, 1)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
+ c.Check(api.Calls, Equals, 8)
+ c.Check(api.Content[7]["container"].(arvadosclient.Dict)["log"], NotNil)
+ c.Check(api.Content[7]["container"].(arvadosclient.Dict)["exit_code"], Equals, 1)
+ c.Check(api.Content[7]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "hello\n"), Equals, true)
c.Check(strings.HasSuffix(api.Logs["stderr"].String(), "world\n"), Equals, true)
@@ -546,8 +549,9 @@ func (s *TestSuite) TestFullRunDefaultCwd(c *C) {
t.finish <- dockerclient.WaitResult{ExitCode: 0}
})
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
+ c.Check(api.Calls, Equals, 7)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
log.Print(api.Logs["stdout"].String())
@@ -570,8 +574,9 @@ func (s *TestSuite) TestFullRunSetCwd(c *C) {
t.finish <- dockerclient.WaitResult{ExitCode: 0}
})
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
+ c.Check(api.Calls, Equals, 7)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "/bin\n"), Equals, true)
}
@@ -617,7 +622,8 @@ func (s *TestSuite) TestCancel(c *C) {
c.Check(err, IsNil)
- c.Check(api.Content["container"].(arvadosclient.Dict)["log"], NotNil)
+ c.Check(api.Calls, Equals, 6)
+ c.Check(api.Content[5]["container"].(arvadosclient.Dict)["log"], NotNil)
if err != nil {
for k, v := range api.Logs {
@@ -626,7 +632,7 @@ func (s *TestSuite) TestCancel(c *C) {
}
}
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Cancelled")
+ c.Check(api.Content[5]["container"].(arvadosclient.Dict)["state"], Equals, "Cancelled")
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "foo\n"), Equals, true)
@@ -648,8 +654,9 @@ func (s *TestSuite) TestFullRunSetEnv(c *C) {
t.finish <- dockerclient.WaitResult{ExitCode: 0}
})
- c.Check(api.Content["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
- c.Check(api.Content["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
+ c.Check(api.Calls, Equals, 7)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
+ c.Check(api.Content[6]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "bilbo\n"), Equals, true)
}
diff --git a/services/crunch-run/logging_test.go b/services/crunch-run/logging_test.go
index bce324d..79214fc 100644
--- a/services/crunch-run/logging_test.go
+++ b/services/crunch-run/logging_test.go
@@ -40,8 +40,8 @@ func (s *LoggingTestSuite) TestWriteLogs(c *C) {
logtext := "2015-12-29T15:51:45.000000001Z Hello world!\n" +
"2015-12-29T15:51:45.000000002Z Goodbye\n"
- c.Check(api.Content["log"].(arvadosclient.Dict)["event_type"], Equals, "crunch-run")
- c.Check(api.Content["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"], Equals, logtext)
+ 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)
}
@@ -83,14 +83,14 @@ func (s *LoggingTestSuite) TestWriteMultipleLogs(c *C) {
cr.CrunchLog.Close()
logtext1 := "2015-12-29T15:51:45.000000001Z Hello world!\n" +
"2015-12-29T15:51:45.000000003Z Goodbye\n"
- c.Check(api.Content["log"].(arvadosclient.Dict)["event_type"], Equals, "crunch-run")
- c.Check(api.Content["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"], Equals, logtext1)
+ 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, logtext1)
stdout.Close()
logtext2 := "2015-12-29T15:51:45.000000002Z Doing stuff\n" +
"2015-12-29T15:51:45.000000004Z Blurb\n"
- c.Check(api.Content["log"].(arvadosclient.Dict)["event_type"], Equals, "stdout")
- c.Check(api.Content["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"], Equals, logtext2)
+ c.Check(api.Content[1]["log"].(arvadosclient.Dict)["event_type"], Equals, "stdout")
+ c.Check(api.Content[1]["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"], Equals, logtext2)
mt, err := cr.LogCollection.ManifestText()
c.Check(err, IsNil)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list