X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f054bc3d7d3d26962e62c2ea7c27214b08e85bb6..6a544620c4d5acb0c42cd56346f74454637904cb:/services/crunch-run/crunchrun_test.go diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go index 1577215afa..935c61a110 100644 --- a/services/crunch-run/crunchrun_test.go +++ b/services/crunch-run/crunchrun_test.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -50,6 +54,7 @@ type ArvTestClient struct { Logs map[string]*bytes.Buffer sync.Mutex WasSetRunning bool + callraw bool } type KeepTestClient struct { @@ -216,17 +221,22 @@ func (client *ArvTestClient) Call(method, resourceType, uuid, action string, par func (client *ArvTestClient) CallRaw(method, resourceType, uuid, action string, parameters arvadosclient.Dict) (reader io.ReadCloser, err error) { - j := []byte(`{ - "command": ["sleep", "1"], - "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122", - "cwd": ".", - "environment": {}, - "mounts": {"/tmp": {"kind": "tmp"} }, - "output_path": "/tmp", - "priority": 1, - "runtime_constraints": {} - }`) - return ioutil.NopCloser(bytes.NewReader(j)), nil + var j []byte + if method == "GET" && resourceType == "containers" && action == "" && !client.callraw { + j, err = json.Marshal(client.Container) + } else { + j = []byte(`{ + "command": ["sleep", "1"], + "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122", + "cwd": ".", + "environment": {}, + "mounts": {"/tmp": {"kind": "tmp"}, "/json": {"kind": "json", "content": {"number": 123456789123456789}}}, + "output_path": "/tmp", + "priority": 1, + "runtime_constraints": {} + }`) + } + return ioutil.NopCloser(bytes.NewReader(j)), err } func (client *ArvTestClient) Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error { @@ -1097,7 +1107,7 @@ func (s *TestSuite) TestSetupMounts(c *C) { }{ {in: "foo", out: `"foo"`}, {in: nil, out: `null`}, - {in: map[string]int{"foo": 123}, out: `{"foo":123}`}, + {in: map[string]int64{"foo": 123456789123456789}, out: `{"foo":123456789123456789}`}, } { i = 0 cr.ArvMountPoint = "" @@ -1603,3 +1613,13 @@ func (s *TestSuite) TestStderrMount(c *C) { c.Check(api.CalledWith("collection.manifest_text", "./a b1946ac92492d2347c6235b4d2611184+6 0:6:out.txt\n./b 38af5c54926b620264ab1501150cf189+5 0:5:err.txt\n"), NotNil) } + +func (s *TestSuite) TestNumberRoundTrip(c *C) { + cr := NewContainerRunner(&ArvTestClient{callraw: true}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz") + cr.fetchContainerRecord() + + jsondata, err := json.Marshal(cr.Container.Mounts["/json"].Content) + + c.Check(err, IsNil) + c.Check(string(jsondata), Equals, `{"number":123456789123456789}`) +}