You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/01/18 13:06:07 UTC
[skywalking-banyandb] branch main updated: Fix integration test's leaked goroutines (#237)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 7a69c0af Fix integration test's leaked goroutines (#237)
7a69c0af is described below
commit 7a69c0afdd5b20d38b9de26f7151248dee0966d9
Author: Mike <84...@qq.com>
AuthorDate: Wed Jan 18 21:06:00 2023 +0800
Fix integration test's leaked goroutines (#237)
* Fix integration test's leaked goroutines
Signed-off-by: mikechengwei <84...@qq.com>
---
test/integration/cold_query/query_suite_test.go | 4 ++++
test/integration/load/load_suite_test.go | 4 ++++
test/integration/other/measure_test.go | 4 ++++
test/integration/other/property_test.go | 4 ++++
test/integration/other/tls_test.go | 4 ++++
test/integration/query/query_suite_test.go | 4 ++++
6 files changed, 24 insertions(+)
diff --git a/test/integration/cold_query/query_suite_test.go b/test/integration/cold_query/query_suite_test.go
index 46f30c5d..580a3e18 100644
--- a/test/integration/cold_query/query_suite_test.go
+++ b/test/integration/cold_query/query_suite_test.go
@@ -23,6 +23,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -48,9 +49,11 @@ var (
connection *grpc.ClientConn
now time.Time
deferFunc func()
+ goods []gleak.Goroutine
)
var _ = SynchronizedBeforeSuite(func() []byte {
+ goods = gleak.Goroutines()
Expect(logger.Init(logger.Logging{
Env: "dev",
Level: flags.LogLevel,
@@ -99,4 +102,5 @@ var _ = SynchronizedAfterSuite(func() {
}
}, func() {
deferFunc()
+ Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
})
diff --git a/test/integration/load/load_suite_test.go b/test/integration/load/load_suite_test.go
index 1fb56391..eeff58ea 100644
--- a/test/integration/load/load_suite_test.go
+++ b/test/integration/load/load_suite_test.go
@@ -23,6 +23,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -44,9 +45,11 @@ var (
connection *grpc.ClientConn
now time.Time
deferFunc func()
+ goods []gleak.Goroutine
)
var _ = SynchronizedBeforeSuite(func() []byte {
+ goods = gleak.Goroutines()
Expect(logger.Init(logger.Logging{
Env: "dev",
Level: "warn",
@@ -97,4 +100,5 @@ var _ = SynchronizedAfterSuite(func() {
}
}, func() {
deferFunc()
+ Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
})
diff --git a/test/integration/other/measure_test.go b/test/integration/other/measure_test.go
index 830b5038..997f1ea2 100644
--- a/test/integration/other/measure_test.go
+++ b/test/integration/other/measure_test.go
@@ -22,6 +22,7 @@ import (
g "github.com/onsi/ginkgo/v2"
gm "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -38,6 +39,7 @@ var _ = g.Describe("Query service_cpm_minute", func() {
var baseTime time.Time
var interval time.Duration
var conn *grpc.ClientConn
+ var goods []gleak.Goroutine
g.BeforeEach(func() {
var addr string
@@ -50,10 +52,12 @@ var _ = g.Describe("Query service_cpm_minute", func() {
baseTime = timestamp.NowMilli()
interval = 500 * time.Millisecond
casesMeasureData.Write(conn, "service_cpm_minute", "sw_metric", "service_cpm_minute_data.json", baseTime, interval)
+ goods = gleak.Goroutines()
})
g.AfterEach(func() {
gm.Expect(conn.Close()).To(gm.Succeed())
deferFn()
+ gm.Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
})
g.It("queries service_cpm_minute by id after updating", func() {
casesMeasureData.Write(conn, "service_cpm_minute", "sw_metric", "service_cpm_minute_data1.json", baseTime, interval)
diff --git a/test/integration/other/property_test.go b/test/integration/other/property_test.go
index fcace892..2edef426 100644
--- a/test/integration/other/property_test.go
+++ b/test/integration/other/property_test.go
@@ -23,6 +23,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -39,6 +40,7 @@ var _ = Describe("Property application", func() {
var deferFn func()
var conn *grpc.ClientConn
var client propertyv1.PropertyServiceClient
+ var goods []gleak.Goroutine
BeforeEach(func() {
var addr string
@@ -49,10 +51,12 @@ var _ = Describe("Property application", func() {
conn, err = grpchelper.Conn(addr, 10*time.Second, grpc.WithTransportCredentials(insecure.NewCredentials()))
Expect(err).NotTo(HaveOccurred())
client = propertyv1.NewPropertyServiceClient(conn)
+ goods = gleak.Goroutines()
})
AfterEach(func() {
Expect(conn.Close()).To(Succeed())
deferFn()
+ Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
})
It("applies properties", func() {
md := &propertyv1.Metadata{
diff --git a/test/integration/other/tls_test.go b/test/integration/other/tls_test.go
index d0cc3d29..789ce3db 100644
--- a/test/integration/other/tls_test.go
+++ b/test/integration/other/tls_test.go
@@ -24,6 +24,7 @@ import (
g "github.com/onsi/ginkgo/v2"
gm "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gleak"
grpclib "google.golang.org/grpc"
"google.golang.org/grpc/credentials"
@@ -40,6 +41,7 @@ var _ = g.Describe("Query service_cpm_minute", func() {
var baseTime time.Time
var interval time.Duration
var conn *grpclib.ClientConn
+ var goods []gleak.Goroutine
g.BeforeEach(func() {
_, currentFile, _, _ := runtime.Caller(0)
@@ -57,10 +59,12 @@ var _ = g.Describe("Query service_cpm_minute", func() {
baseTime = timestamp.NowMilli()
interval = 500 * time.Millisecond
casesMeasureData.Write(conn, "service_cpm_minute", "sw_metric", "service_cpm_minute_data.json", baseTime, interval)
+ goods = gleak.Goroutines()
})
g.AfterEach(func() {
gm.Expect(conn.Close()).To(gm.Succeed())
deferFn()
+ gm.Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
})
g.It("queries a tls server", func() {
gm.Eventually(func(innerGm gm.Gomega) {
diff --git a/test/integration/query/query_suite_test.go b/test/integration/query/query_suite_test.go
index 4b820e7a..41f0b439 100644
--- a/test/integration/query/query_suite_test.go
+++ b/test/integration/query/query_suite_test.go
@@ -23,6 +23,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -48,9 +49,11 @@ var (
connection *grpc.ClientConn
now time.Time
deferFunc func()
+ goods []gleak.Goroutine
)
var _ = SynchronizedBeforeSuite(func() []byte {
+ goods = gleak.Goroutines()
Expect(logger.Init(logger.Logging{
Env: "dev",
Level: flags.LogLevel,
@@ -101,4 +104,5 @@ var _ = SynchronizedAfterSuite(func() {
}
}, func() {
deferFunc()
+ Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(goods))
})