You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ch...@apache.org on 2019/07/22 10:18:15 UTC

[incubator-openwhisk-cli] branch master updated: Allow log stripping to tolerate a missing stream identifier. (#444)

This is an automated email from the ASF dual-hosted git repository.

chetanm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new d75e6d9  Allow log stripping to tolerate a missing stream identifier. (#444)
d75e6d9 is described below

commit d75e6d969a215d4bac19092378d076d24216cccb
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Mon Jul 22 06:18:09 2019 -0400

    Allow log stripping to tolerate a missing stream identifier. (#444)
    
    Allows log stripping to tolerate a missing stream identifier. This enables the log parsing to work cases  like with standalone OpenWhisk the emitted log entries do not contain the stream info.
    
    Also enables unit test on travis
---
 commands/util.go               | 10 +++++++---
 commands/util_test.go          | 11 ++++++-----
 tools/travis/test_openwhisk.sh |  1 +
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/commands/util.go b/commands/util.go
index ddabb34..49dee62 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 4e5341a..1350d8a 100644
--- a/commands/util_test.go
+++ b/commands/util_test.go
@@ -29,11 +29,12 @@ 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",
-		"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",
+		"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":                                                    "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",
diff --git a/tools/travis/test_openwhisk.sh b/tools/travis/test_openwhisk.sh
index a6840a7..c39a9e0 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