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

mrproliu 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 ea481add8 Fix unstable measure dump UT (#1148)
ea481add8 is described below

commit ea481add8a7ed41e8bb6e0b74650e8e306740e87
Author: mrproliu <[email protected]>
AuthorDate: Tue Jun 2 15:28:54 2026 +0800

    Fix unstable measure dump UT (#1148)
---
 banyand/internal/dump/measure/suite_test.go        | 12 +++++
 test/integration/standalone/other/property_test.go | 53 ++++++++++++----------
 2 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/banyand/internal/dump/measure/suite_test.go 
b/banyand/internal/dump/measure/suite_test.go
index c5f77a046..3c4de30ef 100644
--- a/banyand/internal/dump/measure/suite_test.go
+++ b/banyand/internal/dump/measure/suite_test.go
@@ -47,6 +47,7 @@ import (
        "github.com/apache/skywalking-banyandb/pkg/convert"
        localfs "github.com/apache/skywalking-banyandb/pkg/fs"
        "github.com/apache/skywalking-banyandb/pkg/index"
+       "github.com/apache/skywalking-banyandb/pkg/index/inverted"
        "github.com/apache/skywalking-banyandb/pkg/logger"
        pbv1 "github.com/apache/skywalking-banyandb/pkg/pb/v1"
        "github.com/apache/skywalking-banyandb/pkg/test"
@@ -358,6 +359,17 @@ func TestMeasureIndexedTagResolvedFromIndex(t *testing.T) {
 
        segmentPath := findSidxSegmentPath(t, rootPath)
 
+       // The series index persists asynchronously (unsafe batches + 
persister) and is
+       // flushed on stop; after a hard stop there is a brief window before 
all series
+       // are readable on disk. The fallback scan below sources EntityValues 
purely
+       // from this index, so wait until every written series is visible before
+       // asserting, otherwise the scan can race the flush and recover nothing.
+       sidxPath := filepath.Join(segmentPath, "sidx")
+       require.Eventually(t, func() bool {
+               count, _ := inverted.ReadOnlyDocCount(sidxPath)
+               return count >= int64(total)
+       }, 30*time.Second, 100*time.Millisecond, "series index not fully 
persisted after stop")
+
        ruleToTag := map[uint32]dump.IndexedTagSpec{
                strRuleID: {Family: "default", Name: "idxStr", Type: 
pbv1.ValueTypeStr},
                intRuleID: {Family: "default", Name: "idxInt", Type: 
pbv1.ValueTypeInt64},
diff --git a/test/integration/standalone/other/property_test.go 
b/test/integration/standalone/other/property_test.go
index ce226bc06..bb70fdf8f 100644
--- a/test/integration/standalone/other/property_test.go
+++ b/test/integration/standalone/other/property_test.go
@@ -38,6 +38,23 @@ import (
        "github.com/apache/skywalking-banyandb/pkg/test/setup"
 )
 
+// applyCreatedProperty issues req and retries until Apply succeeds, then 
asserts
+// the property was newly created with wantTags tags. A just-created group and
+// property reach the liaison's in-memory repositories asynchronously via the
+// schema watch, so the first Apply right after creating them can transiently
+// fail with "failed to get group copies". Eventually rides out that 
propagation
+// window without masking a persistent failure.
+func applyCreatedProperty(client propertyv1.PropertyServiceClient, req 
*propertyv1.ApplyRequest, wantTags uint32) {
+       var resp *propertyv1.ApplyResponse
+       gm.EventuallyWithOffset(1, func() error {
+               var err error
+               resp, err = client.Apply(context.Background(), req)
+               return err
+       }, flags.EventuallyTimeout).Should(gm.Succeed())
+       gm.ExpectWithOffset(1, resp.Created).To(gm.BeTrue())
+       gm.ExpectWithOffset(1, resp.TagsNum).To(gm.Equal(wantTags))
+}
+
 var _ = g.Describe("Property application", func() {
        var deferFn func()
        var conn *grpc.ClientConn
@@ -89,17 +106,14 @@ var _ = g.Describe("Property application", func() {
                        Name:  "p",
                        Group: "g",
                }
-               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               applyCreatedProperty(client, &propertyv1.ApplyRequest{Property: 
&propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
                                {Key: "t1", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v1"}}}},
                                {Key: "t2", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v2"}}}},
                        },
-               }})
-               gm.Expect(err).NotTo(gm.HaveOccurred())
-               gm.Expect(resp.Created).To(gm.BeTrue())
-               gm.Expect(resp.TagsNum).To(gm.Equal(uint32(2)))
+               }}, 2)
                got, err := client.Query(context.Background(), 
&propertyv1.QueryRequest{
                        Groups: []string{"g"},
                        Name:   "p",
@@ -112,7 +126,7 @@ var _ = g.Describe("Property application", func() {
                        {Key: "t1", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v1"}}}},
                        {Key: "t2", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v2"}}}},
                }))
-               resp, err = client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
@@ -140,17 +154,14 @@ var _ = g.Describe("Property application", func() {
                        Name:  "p",
                        Group: "g",
                }
-               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               applyCreatedProperty(client, &propertyv1.ApplyRequest{Property: 
&propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
                                {Key: "t1", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v1"}}}},
                        },
-               }})
-               gm.Expect(err).NotTo(gm.HaveOccurred())
-               gm.Expect(resp.Created).To(gm.BeTrue())
-               gm.Expect(resp.TagsNum).To(gm.Equal(uint32(1)))
-               resp, err = client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               }}, 1)
+               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
@@ -179,18 +190,15 @@ var _ = g.Describe("Property application", func() {
                        Name:  "p",
                        Group: "g",
                }
-               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               applyCreatedProperty(client, &propertyv1.ApplyRequest{Property: 
&propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
                                {Key: "t1", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v1"}}}},
                                {Key: "t2", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Null{}}},
                        },
-               }})
-               gm.Expect(err).NotTo(gm.HaveOccurred())
-               gm.Expect(resp.Created).To(gm.BeTrue())
-               gm.Expect(resp.TagsNum).To(gm.Equal(uint32(2)))
-               resp, err = client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               }}, 2)
+               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
@@ -258,18 +266,15 @@ var _ = g.Describe("Property application", func() {
                        Name:  "p",
                        Group: "g",
                }
-               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               applyCreatedProperty(client, &propertyv1.ApplyRequest{Property: 
&propertyv1.Property{
                        Metadata: md,
                        Id:       "1",
                        Tags: []*modelv1.Tag{
                                {Key: "t1", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v1"}}}},
                                {Key: "t2", Value: &modelv1.TagValue{Value: 
&modelv1.TagValue_Str{Str: &modelv1.Str{Value: "v2"}}}},
                        },
-               }})
-               gm.Expect(err).NotTo(gm.HaveOccurred())
-               gm.Expect(resp.Created).To(gm.BeTrue())
-               gm.Expect(resp.TagsNum).To(gm.Equal(uint32(2)))
-               resp, err = client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
+               }}, 2)
+               resp, err := client.Apply(context.Background(), 
&propertyv1.ApplyRequest{Property: &propertyv1.Property{
                        Metadata: &commonv1.Metadata{
                                Name:  "p",
                                Group: "g",

Reply via email to