[ARVADOS] updated: 2.1.0-58-g71733fbee
Git user
git at public.arvados.org
Thu Oct 15 15:22:02 UTC 2020
Summary of changes:
.licenseignore | 1 +
lib/controller/forecast/controller_test.go | 71 ++++++++++++++++------
.../forecast/test-fixtures/hasher1_data.golden | 1 +
.../forecast/test-fixtures/hasher2_data.golden | 1 +
.../forecast/test-fixtures/hasher3_data.golden | 1 +
sdk/go/arvados/forecast.go | 4 ++
sdk/go/arvadostest/fixtures.go | 9 +++
7 files changed, 68 insertions(+), 20 deletions(-)
create mode 100644 lib/controller/forecast/test-fixtures/hasher1_data.golden
create mode 100644 lib/controller/forecast/test-fixtures/hasher2_data.golden
create mode 100644 lib/controller/forecast/test-fixtures/hasher3_data.golden
via 71733fbeeed40ee6968d792bd668b4dd2060511b (commit)
via 74a8f47e08c7dc7b22388a6636adb3508bfe8d1d (commit)
from d81436f3d6bcb25811a14be4bd693c57100e414f (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 71733fbeeed40ee6968d792bd668b4dd2060511b
Author: Nico Cesar <nico at nicocesar.com>
Date: Thu Oct 15 11:15:17 2020 -0400
First batch of passing tests with golden files
refs #16462
Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>
diff --git a/lib/controller/forecast/controller_test.go b/lib/controller/forecast/controller_test.go
index 791094c94..7b45fe54c 100644
--- a/lib/controller/forecast/controller_test.go
+++ b/lib/controller/forecast/controller_test.go
@@ -6,6 +6,9 @@ package forecast
import (
"context"
+ "encoding/json"
+ "flag"
+ "io/ioutil"
"net/url"
"os"
"path/filepath"
@@ -55,18 +58,11 @@ func (s *ForecastSuite) SetUpTest(c *check.C) {
cluster := &arvados.Cluster{
ClusterID: "zzzzz",
PostgreSQL: integrationTestCluster().PostgreSQL,
- //ForceLegacyAPI14: forceLegacyAPI14,
}
cluster.API.RequestTimeout = arvados.Duration(5 * time.Minute)
cluster.TLS.Insecure = true
arvadostest.SetServiceURL(&cluster.Services.RailsAPI, "https://"+os.Getenv("ARVADOS_TEST_API_HOST"))
arvadostest.SetServiceURL(&cluster.Services.Controller, "http://localhost:/")
- //s.handler = newHandler(s.ctx, s.cluster, "", prometheus.NewRegistry())
-
- //cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load()
- //c.Assert(err, check.IsNil)
- //s.ctx, s.rollback = arvadostest.TransactionContext(c, arvadostest.DB(c, cluster))
- //s.stub = &arvadostest.APIStub{}
s.ctrl = New(cluster, rpc.NewConn(
cluster.ClusterID,
@@ -76,22 +72,57 @@ func (s *ForecastSuite) SetUpTest(c *check.C) {
}
func (s *ForecastSuite) TearDownTest(c *check.C) {
- //do we need a rollback if we're going to reset the database later?
- /*
- if s.rollback != nil {
- s.rollback()
- s.rollback = nil
- }
- */
- // reset the database..!
- // c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
+ if s.rollback != nil {
+ s.rollback()
+ s.rollback = nil
+ }
}
func (s *ForecastSuite) TestDatapoints(c *check.C) {
- // zzzzz-xvhdp-p1i7h1gy5z1ft4p is hasher_root from services/api/test/fixtures/container_requests.yml
- // if we have a better way to address fixture content in controller we should replace this hardcoded value
- resp, err := s.ctrl.ForecastDatapoints(s.ctx, arvados.GetOptions{UUID: "zzzzz-xvhdp-p1i7h1gy5z1ft4p"})
+ // Just as basic test to make sure the datapoints endpoint is there and giving out some data
+ // HasherRootUUID (zzzzz-xvhdp-p1i7h1gy5z1ft4p) is hasher_root from services/api/test/fixtures/container_requests.yml
+ // this container request start all the
+ resp, err := s.ctrl.ForecastDatapoints(s.ctx, arvados.GetOptions{UUID: arvadostest.HasherRootUUID})
c.Check(err, check.IsNil)
c.Check(len(resp.Datapoints), check.Equals, 3)
- //c.Check(s.stub.Calls(s.stub.UserList), check.HasLen, 1)
+}
+
+// A great way to update golden files if needed: go test -update
+var update = flag.Bool("update", false, "Update golden files")
+
+func (s *ForecastSuite) TestDatapointsValues(c *check.C) {
+ cases := []struct {
+ Name string
+ Checkpoint string
+ }{
+ {"hasher1_data", "hasher1"},
+ {"hasher2_data", "hasher2"},
+ {"hasher3_data", "hasher3"},
+ }
+ resp, err := s.ctrl.ForecastDatapoints(s.ctx, arvados.GetOptions{UUID: arvadostest.HasherRootUUID})
+ c.Check(err, check.IsNil)
+
+ for _, tc := range cases {
+ var actual arvados.Datapoint
+ for _, d := range resp.Datapoints {
+ if d.Checkpoint == tc.Checkpoint {
+ actual = d
+ }
+ }
+ c.Check(actual, check.NotNil)
+
+ actualBytes, err := json.Marshal(actual)
+ c.Check(err, check.IsNil)
+
+ golden := filepath.Join("test-fixtures", tc.Name+".golden")
+
+ if *update {
+ err = ioutil.WriteFile(golden, actualBytes, 0644)
+ c.Check(err, check.IsNil)
+ }
+
+ expected, err := ioutil.ReadFile(golden)
+ c.Check(err, check.IsNil)
+ c.Check(actualBytes, check.DeepEquals, expected)
+ }
}
diff --git a/lib/controller/forecast/test-fixtures/hasher1_data.golden b/lib/controller/forecast/test-fixtures/hasher1_data.golden
new file mode 100644
index 000000000..8dae64618
--- /dev/null
+++ b/lib/controller/forecast/test-fixtures/hasher1_data.golden
@@ -0,0 +1 @@
+{"checkpoint":"hasher1","start_1":"2020-09-28 15:04:38.079 +0000","end_1":"2020-09-28 15:04:40.708 +0000","start_2":"2020-09-28 15:04:40.364 +0000","end_2":"2020-09-28 15:04:40.708 +0000","reuse":false,"legend":"\u003cp\u003ehasher1\u003c/p\u003e\u003cp\u003eContainer Request: \u003ca href=\"https://workbench.x2bo2.arvadosapi.com/container_requests/zzzzz-xvhdp-et5v1vofm3109fn\"\u003ezzzzz-xvhdp-et5v1vofm3109fn\u003c/a\u003e\u003c/p\u003e\u003cp\u003eContainer duration: 343.564ms\n\u003c/p\u003e"}
\ No newline at end of file
diff --git a/lib/controller/forecast/test-fixtures/hasher2_data.golden b/lib/controller/forecast/test-fixtures/hasher2_data.golden
new file mode 100644
index 000000000..a2b1c62c2
--- /dev/null
+++ b/lib/controller/forecast/test-fixtures/hasher2_data.golden
@@ -0,0 +1 @@
+{"checkpoint":"hasher2","start_1":"2020-09-28 15:04:50.144 +0000","end_1":"2020-09-28 15:04:52.783 +0000","start_2":"2020-09-28 15:04:52.463 +0000","end_2":"2020-09-28 15:04:52.783 +0000","reuse":false,"legend":"\u003cp\u003ehasher2\u003c/p\u003e\u003cp\u003eContainer Request: \u003ca href=\"https://workbench.x2bo2.arvadosapi.com/container_requests/zzzzz-xvhdp-k2i0vu6n1ebsyvo\"\u003ezzzzz-xvhdp-k2i0vu6n1ebsyvo\u003c/a\u003e\u003c/p\u003e\u003cp\u003eContainer duration: 319.663ms\n\u003c/p\u003e"}
\ No newline at end of file
diff --git a/lib/controller/forecast/test-fixtures/hasher3_data.golden b/lib/controller/forecast/test-fixtures/hasher3_data.golden
new file mode 100644
index 000000000..42941eb4f
--- /dev/null
+++ b/lib/controller/forecast/test-fixtures/hasher3_data.golden
@@ -0,0 +1 @@
+{"checkpoint":"hasher3","start_1":"2020-09-28 15:05:02.111 +0000","end_1":"2020-09-28 15:05:04.783 +0000","start_2":"2020-09-28 15:05:04.490 +0000","end_2":"2020-09-28 15:05:04.783 +0000","reuse":false,"legend":"\u003cp\u003ehasher3\u003c/p\u003e\u003cp\u003eContainer Request: \u003ca href=\"https://workbench.x2bo2.arvadosapi.com/container_requests/zzzzz-xvhdp-37vzxz1l2k2ywvd\"\u003ezzzzz-xvhdp-37vzxz1l2k2ywvd\u003c/a\u003e\u003c/p\u003e\u003cp\u003eContainer duration: 293.211ms\n\u003c/p\u003e"}
\ No newline at end of file
diff --git a/sdk/go/arvados/forecast.go b/sdk/go/arvados/forecast.go
index 118f56ae4..fab91d4ef 100644
--- a/sdk/go/arvados/forecast.go
+++ b/sdk/go/arvados/forecast.go
@@ -7,6 +7,10 @@ package arvados
// Datapoint is the format that gets outputted to the user
type Datapoint struct {
//UUID string `json:"uuid"` // REVIEW: do we want each individual datapoint with a UUID
+
+ // This is a generic "Checkpoint" name, that is derived from the container name. For Example,
+ // bwamem_2902 will become checkpoint "bwamem", making this easy to agregate values
+
Checkpoint string `json:"checkpoint"`
Start1 string `json:"start_1"`
End1 string `json:"end_1"`
diff --git a/sdk/go/arvadostest/fixtures.go b/sdk/go/arvadostest/fixtures.go
index 5677f4dec..b339fffbe 100644
--- a/sdk/go/arvadostest/fixtures.go
+++ b/sdk/go/arvadostest/fixtures.go
@@ -73,6 +73,15 @@ const (
TestVMUUID = "zzzzz-2x53u-382brsig8rp3064"
CollectionWithUniqueWordsUUID = "zzzzz-4zz18-mnt690klmb51aud"
+
+ HasherRootUUID = "zzzzz-xvhdp-p1i7h1gy5z1ft4p"
+ HasherRootContainerUUID = "zzzzz-dz642-gxfj5yt5x6x6nr2"
+ HasherHasher1UUID = "zzzzz-xvhdp-et5v1vofm3109fn"
+ HasherHasher1ContainerUUID = "zzzzz-dz642-1wfe84lcxvojijy"
+ HasherHasher2UUID = "zzzzz-xvhdp-k2i0vu6n1ebsyvo"
+ HasherHasher2ContainerUUID = "zzzzz-dz642-80yksfp68lxz3gs"
+ HasherHasher3UUID = "zzzzz-xvhdp-37vzxz1l2k2ywvd"
+ HasherHasher3ContainerUUID = "zzzzz-dz642-gxfj5yt5x6x6nr2"
)
// PathologicalManifest : A valid manifest designed to test
commit 74a8f47e08c7dc7b22388a6636adb3508bfe8d1d
Author: Nico Cesar <nico at nicocesar.com>
Date: Thu Oct 15 11:20:41 2020 -0400
added *golden to .licenseignore
refs #16462
Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>
diff --git a/.licenseignore b/.licenseignore
index 490c8447c..ed1ffa9e1 100644
--- a/.licenseignore
+++ b/.licenseignore
@@ -85,3 +85,4 @@ go.sum
sdk/python/tests/fed-migrate/CWLFile
sdk/python/tests/fed-migrate/*.cwl
sdk/python/tests/fed-migrate/*.cwlex
+*.golden
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list