14287: Test timestamp precision is maintained by response munging.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 7 May 2019 17:50:52 +0000 (13:50 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Mon, 17 Jun 2019 13:54:39 +0000 (09:54 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/controller/router/router_test.go
sdk/go/arvadostest/fixtures.go

index f43c69f465000a28969bb51dddf0d7952443d466..b20ffe590a12ab7e0a3638d6bea8d150c00d75e8 100644 (file)
@@ -12,6 +12,7 @@ import (
        "net/http/httptest"
        "os"
        "testing"
+       "time"
 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/arvadostest"
@@ -130,6 +131,27 @@ func (s *RouterSuite) TestContainerLock(c *check.C) {
        c.Check(jresp["uuid"], check.IsNil)
 }
 
+func (s *RouterSuite) TestFullTimestampsInResponse(c *check.C) {
+       uuid := arvadostest.CollectionReplicationDesired2Confirmed2UUID
+       token := arvadostest.ActiveTokenV2
+
+       _, rw, jresp := s.doRequest(c, token, "GET", `/arvados/v1/collections/`+uuid, nil, nil)
+       c.Check(rw.Code, check.Equals, http.StatusOK)
+       c.Check(jresp["uuid"], check.Equals, uuid)
+       expectNS := map[string]int{
+               "created_at":  596506000, // fixture says 596506247, but truncated by postgresql
+               "modified_at": 596338000, // fixture says 596338465, but truncated by postgresql
+       }
+       for key, ns := range expectNS {
+               mt, ok := jresp[key].(string)
+               c.Logf("jresp[%q] == %q", key, mt)
+               c.Assert(ok, check.Equals, true)
+               t, err := time.Parse(time.RFC3339Nano, mt)
+               c.Check(err, check.IsNil)
+               c.Check(t.Nanosecond(), check.Equals, ns)
+       }
+}
+
 func (s *RouterSuite) TestSelectParam(c *check.C) {
        uuid := arvadostest.QueuedContainerUUID
        token := arvadostest.ActiveTokenV2
index 95b83265a05a4835363975cf8720157c0e9171da..dd7f74756d5423bd36d59fe9a7f92e8ddff74219 100644 (file)
@@ -55,6 +55,8 @@ const (
        FooCollectionSharingToken     = "iknqgmunrhgsyfok8uzjlwun9iscwm3xacmzmg65fa1j1lpdss"
 
        WorkflowWithDefinitionYAMLUUID = "zzzzz-7fd4e-validworkfloyml"
+
+       CollectionReplicationDesired2Confirmed2UUID = "zzzzz-4zz18-434zv1tnnf2rygp"
 )
 
 // PathologicalManifest : A valid manifest designed to test