From 5752349c4d1a36da693b4a57c46f9dc694010bf6 Mon Sep 17 00:00:00 2001 From: Rodric Rabbah Date: Wed, 26 Jun 2019 10:31:07 -0400 Subject: [PATCH 1/4] Allow log stripping to tolerate a missing stream identifier. --- commands/util.go | 10 +++++++--- commands/util_test.go | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/commands/util.go b/commands/util.go index ddabb34ab..01ecce0f3 100644 --- a/commands/util.go +++ b/commands/util.go @@ -273,11 +273,15 @@ func makeDefaultHeader(collection interface{}) string { } func stripTimestamp(log string) (strippedLog string) { - regex := regexp.MustCompile("[a-zA-Z0-9\\s]*(stdout|stderr):\\s(.*)") + // parses out the timestamp if it exists first + // the timestamp expected format is YYYY-MM-DDTHH:MM:SS.[0-9]+Z + // an optional " stdout" or " stderr" stream identifier + // and the rest as the log line + regex := regexp.MustCompile("\\d{4}-[01]{1}\\d{1}-[0-3]{1}\\d{1}T[0-2]{1}\\d{1}:[0-6]{1}\\d{1}:[0-6]{1}\\d{1}.\\d+Z( (stdout|stderr):)?\\s(.*)") match := regex.FindStringSubmatch(log) - if len(match) > 2 && len(match[2]) > 0 { - strippedLog = match[2] + if len(match) > 3 && len(match[3]) > 0 { + strippedLog = match[3] } else { strippedLog = log } diff --git a/commands/util_test.go b/commands/util_test.go index 4e5341ad6..b0c389486 100644 --- a/commands/util_test.go +++ b/commands/util_test.go @@ -29,7 +29,8 @@ func TestStripTimestamp(t *testing.T) { "2018-05-02T19:33:32.829992819Z stdout: this is stdout stderr: this is still stdout": "this is stdout stderr: this is still stdout", "2018-05-02T19:33:32.829992819Z stderr: this is stderr stdout: this is still stderr": "this is stderr stdout: this is still stderr", "2018-05-02T19:33:32.89Z stdout: this is stdout": "this is stdout", - "2018-05-02T19:33:32.89Z stderr: this is stderr": "this is stderr", + "2018-05-02T19:33:32.89Z this is a msg": "this is a msg", + "2018-05-02T19:33:32.89Z this is a msg": " this is a msg", "anything stdout: this is stdout": "this is stdout", "anything stderr: this is stderr": "this is stderr", "stdout: this is stdout": "this is stdout", From 62e772fbc91b9b6b3d3680ddff72db0b0e55a976 Mon Sep 17 00:00:00 2001 From: Rodric Rabbah Date: Wed, 26 Jun 2019 12:08:13 -0400 Subject: [PATCH 2/4] Fix tests. --- commands/util_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/util_test.go b/commands/util_test.go index b0c389486..1350d8ab4 100644 --- a/commands/util_test.go +++ b/commands/util_test.go @@ -31,10 +31,10 @@ func TestStripTimestamp(t *testing.T) { "2018-05-02T19:33:32.89Z stdout: this is stdout": "this is stdout", "2018-05-02T19:33:32.89Z this is a msg": "this is a msg", "2018-05-02T19:33:32.89Z this is a msg": " this is a msg", - "anything stdout: this is stdout": "this is stdout", - "anything stderr: this is stderr": "this is stderr", - "stdout: this is stdout": "this is stdout", - "stderr: this is stderr": "this is stderr", + "anything stdout: this is stdout": "anything stdout: this is stdout", + "anything stderr: this is stderr": "anything stderr: this is stderr", + "stdout: this is stdout": "stdout: this is stdout", + "stderr: this is stderr": "stderr: this is stderr", "this is stdout": "this is stdout", "this is stderr": "this is stderr", "something": "something", From baf50b44e1c94d1b5112477ada4d1d6250962894 Mon Sep 17 00:00:00 2001 From: Rodric Rabbah Date: Wed, 26 Jun 2019 12:08:25 -0400 Subject: [PATCH 3/4] Add unit tests to travis. --- tools/travis/test_openwhisk.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/travis/test_openwhisk.sh b/tools/travis/test_openwhisk.sh index 698fdd239..bf515a613 100755 --- a/tools/travis/test_openwhisk.sh +++ b/tools/travis/test_openwhisk.sh @@ -109,4 +109,5 @@ sleep 30 # # Finally, run the integration test for the CLI # +./gradlew --console=plain --info goTest -PgoTags=unit ./gradlew --console=plain --info goTest -PgoTags=integration From bb3f5c55d42459d51de3235c0fc171bf434b58ce Mon Sep 17 00:00:00 2001 From: Rodric Rabbah Date: Wed, 26 Jun 2019 17:47:29 -0400 Subject: [PATCH 4/4] gofmt --- commands/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/util.go b/commands/util.go index 01ecce0f3..49dee6215 100644 --- a/commands/util.go +++ b/commands/util.go @@ -277,7 +277,7 @@ func stripTimestamp(log string) (strippedLog string) { // the timestamp expected format is YYYY-MM-DDTHH:MM:SS.[0-9]+Z // an optional " stdout" or " stderr" stream identifier // and the rest as the log line - regex := regexp.MustCompile("\\d{4}-[01]{1}\\d{1}-[0-3]{1}\\d{1}T[0-2]{1}\\d{1}:[0-6]{1}\\d{1}:[0-6]{1}\\d{1}.\\d+Z( (stdout|stderr):)?\\s(.*)") + regex := regexp.MustCompile("\\d{4}-[01]{1}\\d{1}-[0-3]{1}\\d{1}T[0-2]{1}\\d{1}:[0-6]{1}\\d{1}:[0-6]{1}\\d{1}.\\d+Z( (stdout|stderr):)?\\s(.*)") match := regex.FindStringSubmatch(log) if len(match) > 3 && len(match[3]) > 0 {