From c0085532a593657f7ae588e4120bcb0b8a31dddc Mon Sep 17 00:00:00 2001 From: zhilingc Date: Mon, 21 Jan 2019 11:25:15 +0800 Subject: [PATCH 1/2] Fix timezone printing to be UTC --- cli/feast/pkg/printer/printer_test.go | 12 ++++++------ cli/feast/pkg/util/utils.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/feast/pkg/printer/printer_test.go b/cli/feast/pkg/printer/printer_test.go index c89751262d..27100d8a70 100644 --- a/cli/feast/pkg/printer/printer_test.go +++ b/cli/feast/pkg/printer/printer_test.go @@ -51,8 +51,8 @@ Uri: https://github.com/bob/example DataStores: Serving: REDIS Warehouse: BIGQUERY -Created: 1970-01-01T07:30:01+07:30 -LastUpdated: 1970-01-01T07:30:01+07:30 +Created: 1970-01-01T00:00:01Z +LastUpdated: 1970-01-01T00:00:01Z Related Jobs: - job1 - job2`, @@ -80,8 +80,8 @@ Owner: bob@example.com Description: testing feature ValueType: INT64 Uri: https://github.com/bob/example -Created: 1970-01-01T07:30:01+07:30 -LastUpdated: 1970-01-01T07:30:01+07:30 +Created: 1970-01-01T00:00:01Z +LastUpdated: 1970-01-01T00:00:01Z Related Jobs: - job1 - job2`, @@ -112,7 +112,7 @@ func TestPrintEntity(t *testing.T) { expected := `Name: test Description: my test entity Tags: tag1,tag2 -LastUpdated: 1970-01-01T07:30:01+07:30 +LastUpdated: 1970-01-01T00:00:01Z Related Jobs: - job1 - job2` @@ -139,7 +139,7 @@ Type: redis Options: option1: value1 option2: value2 -LastUpdated: 1970-01-01T07:30:01+07:30` +LastUpdated: 1970-01-01T00:00:01Z` if out != expected { t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out) } diff --git a/cli/feast/pkg/util/utils.go b/cli/feast/pkg/util/utils.go index a48ef6d741..b36c0ce092 100644 --- a/cli/feast/pkg/util/utils.go +++ b/cli/feast/pkg/util/utils.go @@ -35,6 +35,6 @@ func ParseAge(createdTimestamp timestamp.Timestamp) string { // ParseTimestamp parses a given timestamp to a human readable format. func ParseTimestamp(ts timestamp.Timestamp) string { - t := time.Unix(ts.GetSeconds(), int64(ts.GetNanos())) - return t.Format(time.RFC3339) + t := time.Unix(ts.GetSeconds(), int64(ts.GetNanos())).UTC() + return t.Format("2006-01-02T15:04:05Z") } From 40af0f3a9b5e5143acfc9229528fd9aac6972812 Mon Sep 17 00:00:00 2001 From: zhilingc Date: Mon, 21 Jan 2019 11:38:02 +0800 Subject: [PATCH 2/2] Revert timestamp printing to be timezone sensitive --- cli/feast/pkg/printer/printer_test.go | 31 +++++++++++++++++---------- cli/feast/pkg/util/utils.go | 4 ++-- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cli/feast/pkg/printer/printer_test.go b/cli/feast/pkg/printer/printer_test.go index 27100d8a70..a3ff2a263d 100644 --- a/cli/feast/pkg/printer/printer_test.go +++ b/cli/feast/pkg/printer/printer_test.go @@ -1,8 +1,11 @@ package printer import ( + "fmt" "testing" + "github.com/gojek/feast/cli/feast/pkg/util" + "github.com/golang/protobuf/ptypes/timestamp" "github.com/gojek/feast/protos/generated/go/feast/core" @@ -42,7 +45,7 @@ func TestPrintFeature(t *testing.T) { LastUpdated: ×tamp.Timestamp{Seconds: 1}, Created: ×tamp.Timestamp{Seconds: 1}, }, - expected: `Id: test.none.test_feature_two + expected: fmt.Sprintf(`Id: test.none.test_feature_two Entity: test Owner: bob@example.com Description: testing feature @@ -51,11 +54,13 @@ Uri: https://github.com/bob/example DataStores: Serving: REDIS Warehouse: BIGQUERY -Created: 1970-01-01T00:00:01Z -LastUpdated: 1970-01-01T00:00:01Z +Created: %s +LastUpdated: %s Related Jobs: - job1 - job2`, + util.ParseTimestamp(timestamp.Timestamp{Seconds: 1}), + util.ParseTimestamp(timestamp.Timestamp{Seconds: 1})), }, { name: "no storage", input: &core.UIServiceTypes_FeatureDetail{ @@ -74,17 +79,19 @@ Related Jobs: LastUpdated: ×tamp.Timestamp{Seconds: 1}, Created: ×tamp.Timestamp{Seconds: 1}, }, - expected: `Id: test.none.test_feature_two + expected: fmt.Sprintf(`Id: test.none.test_feature_two Entity: test Owner: bob@example.com Description: testing feature ValueType: INT64 Uri: https://github.com/bob/example -Created: 1970-01-01T00:00:01Z -LastUpdated: 1970-01-01T00:00:01Z +Created: %s +LastUpdated: %s Related Jobs: - job1 - job2`, + util.ParseTimestamp(timestamp.Timestamp{Seconds: 1}), + util.ParseTimestamp(timestamp.Timestamp{Seconds: 1})), }, } @@ -109,13 +116,14 @@ func TestPrintEntity(t *testing.T) { LastUpdated: ×tamp.Timestamp{Seconds: 1}, } out := PrintEntityDetail(entityDetail) - expected := `Name: test + expected := fmt.Sprintf(`Name: test Description: my test entity Tags: tag1,tag2 -LastUpdated: 1970-01-01T00:00:01Z +LastUpdated: %s Related Jobs: - job1 -- job2` +- job2`, + util.ParseTimestamp(timestamp.Timestamp{Seconds: 1})) if out != expected { t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out) } @@ -134,12 +142,13 @@ func TestPrintStorage(t *testing.T) { LastUpdated: ×tamp.Timestamp{Seconds: 1}, } out := PrintStorageDetail(storageDetail) - expected := `Id: REDIS1 + expected := fmt.Sprintf(`Id: REDIS1 Type: redis Options: option1: value1 option2: value2 -LastUpdated: 1970-01-01T00:00:01Z` +LastUpdated: %s`, + util.ParseTimestamp(timestamp.Timestamp{Seconds: 1})) if out != expected { t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out) } diff --git a/cli/feast/pkg/util/utils.go b/cli/feast/pkg/util/utils.go index b36c0ce092..a48ef6d741 100644 --- a/cli/feast/pkg/util/utils.go +++ b/cli/feast/pkg/util/utils.go @@ -35,6 +35,6 @@ func ParseAge(createdTimestamp timestamp.Timestamp) string { // ParseTimestamp parses a given timestamp to a human readable format. func ParseTimestamp(ts timestamp.Timestamp) string { - t := time.Unix(ts.GetSeconds(), int64(ts.GetNanos())).UTC() - return t.Format("2006-01-02T15:04:05Z") + t := time.Unix(ts.GetSeconds(), int64(ts.GetNanos())) + return t.Format(time.RFC3339) }