소스 검색

clientv3: use CheckAfterTest after terminating cluster

AfterTest() has a delay that waits for runtime goroutines to exit;
CheckLeakedGoroutine does not. Since the test runner manages the
test cluster for examples, there is no delay between terminating
the cluster and checking for leaked goroutines. Instead, apply
Aftertest checking before running CheckLeakedGoroutine to let runtime
http goroutines finish.
Anthony Romano 9 년 전
부모
커밋
593489d454
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      clientv3/main_test.go

+ 6 - 0
clientv3/main_test.go

@@ -15,10 +15,12 @@
 package clientv3_test
 package clientv3_test
 
 
 import (
 import (
+	"fmt"
 	"os"
 	"os"
 	"regexp"
 	"regexp"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
+	"time"
 
 
 	"github.com/coreos/etcd/auth"
 	"github.com/coreos/etcd/auth"
 	"github.com/coreos/etcd/integration"
 	"github.com/coreos/etcd/integration"
@@ -50,6 +52,10 @@ func TestMain(m *testing.M) {
 		}
 		}
 		v = m.Run()
 		v = m.Run()
 		clus.Terminate(nil)
 		clus.Terminate(nil)
+		if err := testutil.CheckAfterTest(time.Second); err != nil {
+			fmt.Fprintf(os.Stderr, "%v", err)
+			os.Exit(1)
+		}
 	} else {
 	} else {
 		v = m.Run()
 		v = m.Run()
 	}
 	}