Skip to content

Commit

Permalink
Add UTC time formatting and rewrite comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscovalentecastro committed Feb 22, 2022
1 parent be0e2e6 commit d41a13c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions integration_test/ops_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ func TestCustomLogFormat(t *testing.T) {
ctx, logger, vm := agents.CommonSetup(t, platform)

logPath := logPathForPlatform(vm.Platform)
// TODO(b/219518200) : Update time_format to use correct format.
config := fmt.Sprintf(`logging:
receivers:
mylog_source:
Expand Down Expand Up @@ -283,7 +282,9 @@ func TestCustomLogFormat(t *testing.T) {
t.Fatal(err)
}

line := fmt.Sprintf("<13>1 %s %s my_app_id - - - qqqqrrrr\n", time.Now().Format(time.RFC3339Nano), vm.Name)
// When not using UTC timestamps, the parsing with "%Y-%m-%dT%H:%M:%S.%L%z" doesn't work
// correctly in windows (b/218888265).
line := fmt.Sprintf("<13>1 %s %s my_app_id - - - qqqqrrrr\n", time.Now().UTC().Format(time.RFC3339Nano), vm.Name)
if err := gce.UploadContent(ctx, logger, vm, strings.NewReader(line), logPath); err != nil {
t.Fatalf("error writing dummy log line: %v", err)
}
Expand Down Expand Up @@ -365,9 +366,7 @@ func TestProcessorOrder(t *testing.T) {
}

// When not using UTC timestamps, the parsing with "%Y-%m-%dT%H:%M:%S.%L%z" doesn't work
// correctly in windows (b/218888265). The similar test TestCustomLogFormat uses the time
// format "%Y-%m-%dT%H:%M:%S.%L%Z" which is invalid to parse time.RFC3339Nano format.
// TestCustomLogFormat passes since it fallbacks to use a "now" timestamp when parsing fails.
// correctly in windows (b/218888265).
line := fmt.Sprintf(`{"log":"{\"level\":\"info\",\"message\":\"start\"}\n","time":"%s"}`, time.Now().UTC().Format(time.RFC3339Nano)) + "\n"
if err := gce.UploadContent(ctx, logger, vm, strings.NewReader(line), logPath); err != nil {
t.Fatalf("error writing dummy log line: %v", err)
Expand Down

0 comments on commit d41a13c

Please sign in to comment.