[ARVADOS] updated: 1.3.0-3264-gb39f7a614
Git user
git at public.arvados.org
Wed Nov 18 21:21:08 UTC 2020
Summary of changes:
lib/costanalyzer/cmd.go | 1 -
lib/costanalyzer/costanalyzer.go | 7 +++----
lib/costanalyzer/costanalyzer_test.go | 16 ++++++++--------
3 files changed, 11 insertions(+), 13 deletions(-)
via b39f7a6141ecd5c53531b7705c0496623b4df9e9 (commit)
from 6790e4990fa54d81decdd555beee337144d1fab1 (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 b39f7a6141ecd5c53531b7705c0496623b4df9e9
Author: Ward Vandewege <ward at curii.com>
Date: Wed Nov 18 16:20:40 2020 -0500
16950: switch to os.UserHomeDir(), and send all output to stderr.
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>
diff --git a/lib/costanalyzer/cmd.go b/lib/costanalyzer/cmd.go
index 800860ddf..9b0685225 100644
--- a/lib/costanalyzer/cmd.go
+++ b/lib/costanalyzer/cmd.go
@@ -33,7 +33,6 @@ func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s
}()
logger.SetFormatter(new(NoPrefixFormatter))
- logger.SetOutput(stdout)
loader := config.NewLoader(stdin, logger)
loader.SkipLegacy = true
diff --git a/lib/costanalyzer/costanalyzer.go b/lib/costanalyzer/costanalyzer.go
index ddd7abc63..4284542b8 100644
--- a/lib/costanalyzer/costanalyzer.go
+++ b/lib/costanalyzer/costanalyzer.go
@@ -17,7 +17,6 @@ import (
"io/ioutil"
"net/http"
"os"
- "os/user"
"strconv"
"strings"
"time"
@@ -227,12 +226,12 @@ func loadObject(logger *logrus.Logger, ac *arvados.Client, path string, uuid str
if !cache {
reload = true
} else {
- user, err := user.Current()
+ homeDir, err := os.UserHomeDir()
if err != nil {
reload = true
- logger.Info("Unable to determine current user, not using cache")
+ logger.Info("Unable to determine current user home directory, not using cache")
} else {
- cacheDir = user.HomeDir + "/.cache/arvados/costanalyzer/"
+ cacheDir = homeDir + "/.cache/arvados/costanalyzer/"
err = ensureDirectory(logger, cacheDir)
if err != nil {
reload = true
diff --git a/lib/costanalyzer/costanalyzer_test.go b/lib/costanalyzer/costanalyzer_test.go
index 862f5161c..4fab93bf4 100644
--- a/lib/costanalyzer/costanalyzer_test.go
+++ b/lib/costanalyzer/costanalyzer_test.go
@@ -163,13 +163,13 @@ func (*Suite) TestContainerRequestUUID(c *check.C) {
// Run costanalyzer with 1 container request uuid
exitcode := Command.RunCommand("costanalyzer.test", []string{"-uuid", arvadostest.CompletedContainerRequestUUID, "-output", "results"}, &bytes.Buffer{}, &stdout, &stderr)
c.Check(exitcode, check.Equals, 0)
- c.Assert(stdout.String(), check.Matches, "(?ms).*supplied uuids in .*")
+ c.Assert(stderr.String(), check.Matches, "(?ms).*supplied uuids in .*")
uuidReport, err := ioutil.ReadFile("results/" + arvadostest.CompletedContainerRequestUUID + ".csv")
c.Assert(err, check.IsNil)
c.Check(string(uuidReport), check.Matches, "(?ms).*TOTAL,,,,,,,,,7.01302889")
re := regexp.MustCompile(`(?ms).*supplied uuids in (.*?)\n`)
- matches := re.FindStringSubmatch(stdout.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
+ matches := re.FindStringSubmatch(stderr.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
aggregateCostReport, err := ioutil.ReadFile(matches[1])
c.Assert(err, check.IsNil)
@@ -182,7 +182,7 @@ func (*Suite) TestDoubleContainerRequestUUID(c *check.C) {
// Run costanalyzer with 2 container request uuids
exitcode := Command.RunCommand("costanalyzer.test", []string{"-uuid", arvadostest.CompletedContainerRequestUUID, "-uuid", arvadostest.CompletedContainerRequestUUID2, "-output", "results"}, &bytes.Buffer{}, &stdout, &stderr)
c.Check(exitcode, check.Equals, 0)
- c.Assert(stdout.String(), check.Matches, "(?ms).*supplied uuids in .*")
+ c.Assert(stderr.String(), check.Matches, "(?ms).*supplied uuids in .*")
uuidReport, err := ioutil.ReadFile("results/" + arvadostest.CompletedContainerRequestUUID + ".csv")
c.Assert(err, check.IsNil)
@@ -193,7 +193,7 @@ func (*Suite) TestDoubleContainerRequestUUID(c *check.C) {
c.Check(string(uuidReport2), check.Matches, "(?ms).*TOTAL,,,,,,,,,42.27031111")
re := regexp.MustCompile(`(?ms).*supplied uuids in (.*?)\n`)
- matches := re.FindStringSubmatch(stdout.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
+ matches := re.FindStringSubmatch(stderr.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
aggregateCostReport, err := ioutil.ReadFile(matches[1])
c.Assert(err, check.IsNil)
@@ -222,7 +222,7 @@ func (*Suite) TestDoubleContainerRequestUUID(c *check.C) {
// Run costanalyzer with the project uuid
exitcode = Command.RunCommand("costanalyzer.test", []string{"-uuid", arvadostest.AProjectUUID, "-cache=false", "-log-level", "debug", "-output", "results"}, &bytes.Buffer{}, &stdout, &stderr)
c.Check(exitcode, check.Equals, 0)
- c.Assert(stdout.String(), check.Matches, "(?ms).*supplied uuids in .*")
+ c.Assert(stderr.String(), check.Matches, "(?ms).*supplied uuids in .*")
uuidReport, err = ioutil.ReadFile("results/" + arvadostest.CompletedContainerRequestUUID + ".csv")
c.Assert(err, check.IsNil)
@@ -233,7 +233,7 @@ func (*Suite) TestDoubleContainerRequestUUID(c *check.C) {
c.Check(string(uuidReport2), check.Matches, "(?ms).*TOTAL,,,,,,,,,42.27031111")
re = regexp.MustCompile(`(?ms).*supplied uuids in (.*?)\n`)
- matches = re.FindStringSubmatch(stdout.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
+ matches = re.FindStringSubmatch(stderr.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
aggregateCostReport, err = ioutil.ReadFile(matches[1])
c.Assert(err, check.IsNil)
@@ -246,7 +246,7 @@ func (*Suite) TestMultipleContainerRequestUUIDWithReuse(c *check.C) {
// Run costanalyzer with 2 container request uuids
exitcode := Command.RunCommand("costanalyzer.test", []string{"-uuid", arvadostest.CompletedDiagnosticsContainerRequest1UUID, "-uuid", arvadostest.CompletedDiagnosticsContainerRequest2UUID, "-output", "results"}, &bytes.Buffer{}, &stdout, &stderr)
c.Check(exitcode, check.Equals, 0)
- c.Assert(stdout.String(), check.Matches, "(?ms).*supplied uuids in .*")
+ c.Assert(stderr.String(), check.Matches, "(?ms).*supplied uuids in .*")
uuidReport, err := ioutil.ReadFile("results/" + arvadostest.CompletedDiagnosticsContainerRequest1UUID + ".csv")
c.Assert(err, check.IsNil)
@@ -257,7 +257,7 @@ func (*Suite) TestMultipleContainerRequestUUIDWithReuse(c *check.C) {
c.Check(string(uuidReport2), check.Matches, "(?ms).*TOTAL,,,,,,,,,0.00588088")
re := regexp.MustCompile(`(?ms).*supplied uuids in (.*?)\n`)
- matches := re.FindStringSubmatch(stdout.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
+ matches := re.FindStringSubmatch(stderr.String()) // matches[1] contains a string like 'results/2020-11-02-18-57-45-aggregate-costaccounting.csv'
aggregateCostReport, err := ioutil.ReadFile(matches[1])
c.Assert(err, check.IsNil)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list