You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/05/23 03:53:24 UTC

[incubator-openwhisk-runtime-go] branch master updated: Fix random failures (#38)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 04191b9  Fix random failures (#38)
04191b9 is described below

commit 04191b99d3c7fd611839b6bb69894786ee414df8
Author: Sciabarra.com ltd <30...@users.noreply.github.com>
AuthorDate: Wed May 23 05:53:22 2018 +0200

    Fix random failures (#38)
---
 openwhisk/executor_test.go | 11 +++++------
 openwhisk/util_test.go     | 11 +++++++++--
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/openwhisk/executor_test.go b/openwhisk/executor_test.go
index db8247b..5c78bea 100644
--- a/openwhisk/executor_test.go
+++ b/openwhisk/executor_test.go
@@ -19,7 +19,6 @@ package openwhisk
 import (
 	"fmt"
 	"io/ioutil"
-	"time"
 )
 
 func ExampleNewExecutor_failed() {
@@ -64,7 +63,7 @@ func ExampleNewExecutor_bc() {
 	case <-proc.exit:
 		fmt.Println("exit")
 	}
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	proc.Stop()
 	dump(log)
 	// Output:
@@ -83,9 +82,9 @@ func ExampleNewExecutor_hello() {
 	proc.io <- `{"name":"Mike"}`
 	fmt.Println(<-proc.io)
 	proc.log <- true
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	proc.Stop()
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	_, ok := <-proc.io
 	fmt.Printf("io %v\n", ok)
 	dump(log)
@@ -113,9 +112,9 @@ func ExampleNewExecutor_term() {
 	}
 	proc.log <- true
 	fmt.Printf("exit %v\n", exited)
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	proc.Stop()
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	_, ok := <-proc.io
 	fmt.Printf("io %v\n", ok)
 	dump(log)
diff --git a/openwhisk/util_test.go b/openwhisk/util_test.go
index 190e61d..6aeeeec 100644
--- a/openwhisk/util_test.go
+++ b/openwhisk/util_test.go
@@ -55,7 +55,8 @@ func startTestServer(compiler string) (*httptest.Server, string, *os.File) {
 
 func stopTestServer(ts *httptest.Server, cur string, buf *os.File) {
 	runtime.Gosched()
-	time.Sleep(1 * time.Second)
+	// wait 2 seconds before declaring a test done
+	time.Sleep(2 * time.Second)
 	os.Chdir(cur)
 	ts.Close()
 	dump(buf)
@@ -162,11 +163,17 @@ func detect(dir, filename string) string {
 	return kind.Extension
 }
 
+func waitabit() {
+	time.Sleep(1000 * time.Millisecond)
+}
+
 func TestMain(m *testing.M) {
 	sys("_test/build.sh")
 	sys("_test/zips.sh")
-	// increase timeouts
+	// increase timeouts for init
 	DefaultTimeoutInit = 1000 * time.Millisecond
+	// timeout for drain - shoud less (or you can get stuck on stdout without getting the stderr)
+	DefaultTimeoutDrain = 100 * time.Millisecond
 	code := m.Run()
 	os.Exit(code)
 }

-- 
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.