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 2022/10/31 09:45:13 UTC

[skywalking-banyandb] branch test updated (9542c5d -> e304ff4)

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

hanahmily pushed a change to branch test
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


 discard 9542c5d  Fix flaky test cases
     new e304ff4  Fix flaky test cases

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (9542c5d)
            \
             N -- N -- N   refs/heads/test (e304ff4)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 test/integration/cold_query/query_suite_test.go | 3 ++-
 test/integration/query/query_suite_test.go      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)


[skywalking-banyandb] 01/01: Fix flaky test cases

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit e304ff4c63d730c658eac5ba113296bccc1bd61e
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Mon Oct 31 09:37:33 2022 +0000

    Fix flaky test cases
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 bydbctl/internal/cmd/index_rule_binding_test.go | 28 ++++++++++---------
 bydbctl/internal/cmd/index_rule_test.go         | 28 ++++++++++---------
 bydbctl/internal/cmd/measure_test.go            | 32 ++++++++++++----------
 bydbctl/internal/cmd/rest.go                    |  8 +++---
 bydbctl/internal/cmd/stream_test.go             | 36 ++++++++++++-------------
 test/integration/cold_query/query_suite_test.go |  3 ++-
 test/integration/query/query_suite_test.go      |  3 ++-
 7 files changed, 75 insertions(+), 63 deletions(-)

diff --git a/bydbctl/internal/cmd/index_rule_binding_test.go b/bydbctl/internal/cmd/index_rule_binding_test.go
index ac3e328..2a07803 100644
--- a/bydbctl/internal/cmd/index_rule_binding_test.go
+++ b/bydbctl/internal/cmd/index_rule_binding_test.go
@@ -44,7 +44,8 @@ var _ = Describe("IndexRuleBindingSchema Operation", func() {
 		rootCmd = &cobra.Command{Use: "root"}
 		cmd.RootCmdFlags(rootCmd)
 		rootCmd.SetArgs([]string{"group", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createGroup := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: group1
 catalog: CATALOG_STREAM
@@ -59,24 +60,27 @@ resource_opts:
   ttl:
     unit: UNIT_DAY
     num: 7`))
-		out := capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("group group1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createGroup).Should(ContainSubstring("group group1 is created"))
 		rootCmd.SetArgs([]string{"indexRuleBinding", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createIndexRuleBinding := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: name1
   group: group1
 subject:
   catalog: CATALOG_STREAM
   name: stream1`))
-		out = capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("indexRuleBinding group1.name1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createIndexRuleBinding).Should(ContainSubstring("indexRuleBinding group1.name1 is created"))
 	})
 
 	It("get indexRuleBinding schema", func() {
diff --git a/bydbctl/internal/cmd/index_rule_test.go b/bydbctl/internal/cmd/index_rule_test.go
index f09ff1e..c2049ba 100644
--- a/bydbctl/internal/cmd/index_rule_test.go
+++ b/bydbctl/internal/cmd/index_rule_test.go
@@ -44,7 +44,8 @@ var _ = Describe("IndexRuleSchema Operation", func() {
 		rootCmd = &cobra.Command{Use: "root"}
 		cmd.RootCmdFlags(rootCmd)
 		rootCmd.SetArgs([]string{"group", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createGroup := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: group1
 catalog: CATALOG_STREAM
@@ -59,21 +60,24 @@ resource_opts:
   ttl:
     unit: UNIT_DAY
     num: 7`))
-		out := capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("group group1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createGroup).Should(ContainSubstring("group group1 is created"))
 		rootCmd.SetArgs([]string{"indexRule", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createIndexRule := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: name1
   group: group1`))
-		out = capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("indexRule group1.name1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createIndexRule).Should(ContainSubstring("indexRule group1.name1 is created"))
 	})
 
 	It("get indexRule schema", func() {
diff --git a/bydbctl/internal/cmd/measure_test.go b/bydbctl/internal/cmd/measure_test.go
index 85ae3fb..3036062 100644
--- a/bydbctl/internal/cmd/measure_test.go
+++ b/bydbctl/internal/cmd/measure_test.go
@@ -50,7 +50,8 @@ var _ = Describe("Measure Schema Operation", func() {
 		rootCmd = &cobra.Command{Use: "root"}
 		cmd.RootCmdFlags(rootCmd)
 		rootCmd.SetArgs([]string{"group", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createGroup := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: group1
 catalog: CATALOG_MEASURE
@@ -65,21 +66,24 @@ resource_opts:
   ttl:
     unit: UNIT_DAY
     num: 7`))
-		out := capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("group group1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createGroup).Should(ContainSubstring("group group1 is created"))
 		rootCmd.SetArgs([]string{"measure", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createMeasure := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: name1
   group: group1`))
-		out = capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("measure group1.name1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createMeasure).Should(ContainSubstring("measure group1.name1 is created"))
 	})
 
 	It("get measure schema", func() {
@@ -170,9 +174,9 @@ var _ = Describe("Measure Data Query", func() {
 	var interval time.Duration
 	BeforeEach(func() {
 		now = timestamp.NowMilli()
-		startStr = now.Add(-20 * time.Minute).Format(RFC3339)
+		startStr = now.Add(-20 * time.Minute).Format(time.RFC3339)
 		interval = 1 * time.Millisecond
-		endStr = now.Add(5 * time.Minute).Format(RFC3339)
+		endStr = now.Add(5 * time.Minute).Format(time.RFC3339)
 		grpcAddr, addr, deferFunc = setup.SetUp()
 		Eventually(helpers.HTTPHealthCheck(addr), 10*time.Second).Should(Succeed())
 		addr = "http://" + addr
diff --git a/bydbctl/internal/cmd/rest.go b/bydbctl/internal/cmd/rest.go
index b42e50f..e161bdd 100644
--- a/bydbctl/internal/cmd/rest.go
+++ b/bydbctl/internal/cmd/rest.go
@@ -38,8 +38,6 @@ import (
 )
 
 const (
-	// RFC3339 refers to https://www.rfc-editor.org/rfc/rfc3339
-	RFC3339        = "2006-01-02T15:04:05Z07:00"
 	timeRange      = 30 * time.Minute
 	timeRangeUsage = `"start" and "end" specify a time range during which the query is preformed,
 		they can be absolute time like "2006-01-02T15:04:05Z07:00"(https://www.rfc-editor.org/rfc/rfc3339), 
@@ -183,8 +181,8 @@ func parseTimeRangeFromFlagAndYAML(reader io.Reader) (requests []reqBody, err er
 		}
 		startTS = endTS.Add(-timeRange)
 	}
-	s := startTS.Format(RFC3339)
-	e := endTS.Format(RFC3339)
+	s := startTS.Format(time.RFC3339)
+	e := endTS.Format(time.RFC3339)
 	var rawRequests []reqBody
 	if rawRequests, err = parseNameAndGroupFromYAML(reader); err != nil {
 		return nil, err
@@ -211,7 +209,7 @@ func parseTime(timestamp string) (time.Time, error) {
 	if len(timestamp) < 1 {
 		return time.Time{}, errors.New("time is empty")
 	}
-	t, errAbsoluteTime := time.Parse(timestamp, RFC3339)
+	t, errAbsoluteTime := time.Parse(timestamp, time.RFC3339)
 	if errAbsoluteTime == nil {
 		return t, nil
 	}
diff --git a/bydbctl/internal/cmd/stream_test.go b/bydbctl/internal/cmd/stream_test.go
index 187c8c2..0e1efd7 100644
--- a/bydbctl/internal/cmd/stream_test.go
+++ b/bydbctl/internal/cmd/stream_test.go
@@ -38,10 +38,6 @@ import (
 	cases_stream_data "github.com/apache/skywalking-banyandb/test/cases/stream/data"
 )
 
-const (
-	RFC3339 = "2006-01-02T15:04:05Z07:00"
-)
-
 var _ = Describe("Stream Schema Operation", func() {
 	var addr string
 	var deferFunc func()
@@ -54,7 +50,8 @@ var _ = Describe("Stream Schema Operation", func() {
 		rootCmd = &cobra.Command{Use: "root"}
 		cmd.RootCmdFlags(rootCmd)
 		rootCmd.SetArgs([]string{"group", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createGroup := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: group1
 catalog: CATALOG_STREAM
@@ -69,13 +66,15 @@ resource_opts:
   ttl:
     unit: UNIT_DAY
     num: 7`))
-		out := capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("group group1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createGroup).Should(ContainSubstring("group group1 is created"))
 		rootCmd.SetArgs([]string{"stream", "create", "-a", addr, "-f", "-"})
-		rootCmd.SetIn(strings.NewReader(`
+		createStream := func() string {
+			rootCmd.SetIn(strings.NewReader(`
 metadata:
   name: name1
   group: group1
@@ -84,11 +83,12 @@ tagFamilies:
     tags: 
       - name: trace_id
         type: TAG_TYPE_STRING`))
-		out = capturer.CaptureStdout(func() {
-			err := rootCmd.Execute()
-			Expect(err).NotTo(HaveOccurred())
-		})
-		Expect(out).To(ContainSubstring("stream group1.name1 is created"))
+			return capturer.CaptureStdout(func() {
+				err := rootCmd.Execute()
+				Expect(err).NotTo(HaveOccurred())
+			})
+		}
+		Eventually(createStream).Should(ContainSubstring("stream group1.name1 is created"))
 	})
 
 	It("get stream schema", func() {
@@ -180,9 +180,9 @@ var _ = Describe("Stream Data Query", func() {
 	var interval time.Duration
 	BeforeEach(func() {
 		now = timestamp.NowMilli()
-		nowStr = now.Format(RFC3339)
+		nowStr = now.Format(time.RFC3339)
 		interval = 500 * time.Millisecond
-		endStr = now.Add(1 * time.Hour).Format(RFC3339)
+		endStr = now.Add(1 * time.Hour).Format(time.RFC3339)
 		grpcAddr, addr, deferFunc = setup.SetUp()
 		Eventually(helpers.HTTPHealthCheck(addr), 10*time.Second).Should(Succeed())
 		addr = "http://" + addr
diff --git a/test/integration/cold_query/query_suite_test.go b/test/integration/cold_query/query_suite_test.go
index a12a3fb..1978eb7 100644
--- a/test/integration/cold_query/query_suite_test.go
+++ b/test/integration/cold_query/query_suite_test.go
@@ -60,7 +60,8 @@ var _ = SynchronizedBeforeSuite(func() []byte {
 		grpclib.WithTransportCredentials(insecure.NewCredentials()),
 	)
 	Expect(err).NotTo(HaveOccurred())
-	now = timestamp.NowMilli().Add(-time.Hour * 24)
+	ns := timestamp.NowMilli().UnixNano()
+	now = time.Unix(0, ns-ns%int64(time.Minute)).Add(-time.Hour * 24)
 	interval := 500 * time.Millisecond
 	casesStreamData.Write(conn, "data.json", now, interval)
 	interval = time.Minute
diff --git a/test/integration/query/query_suite_test.go b/test/integration/query/query_suite_test.go
index 22a7972..df56248 100644
--- a/test/integration/query/query_suite_test.go
+++ b/test/integration/query/query_suite_test.go
@@ -60,7 +60,8 @@ var _ = SynchronizedBeforeSuite(func() []byte {
 		grpclib.WithTransportCredentials(insecure.NewCredentials()),
 	)
 	Expect(err).NotTo(HaveOccurred())
-	now = timestamp.NowMilli()
+	ns := timestamp.NowMilli().UnixNano()
+	now = time.Unix(0, ns-ns%int64(time.Minute))
 	interval := 500 * time.Millisecond
 	// stream
 	cases_stream_data.Write(conn, "data.json", now, interval)