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 2026/04/26 03:25:40 UTC
(skywalking-banyandb) 04/07: chore: fix lint issues
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch schema-consistency-tbd
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 493851bc93fd095f1221806839b830ae56698d52
Author: Hongtao Gao <ha...@gmail.com>
AuthorDate: Sat Apr 25 02:03:19 2026 +0000
chore: fix lint issues
Field alignment, exhaustive switches (KindMask), godot, misspell, goconst,
unused-helper, unparam — auto-fixes plus targeted touch-ups surfaced by
make lint after the Phase 1 commit.
via [HAPI](https://hapi.run)
---
banyand/liaison/grpc/barrier_test.go | 18 +++++-----
banyand/liaison/grpc/clamp_test.go | 6 ++--
banyand/liaison/grpc/discovery_test.go | 22 ++++++------
banyand/liaison/grpc/measure_write_test.go | 12 +++----
banyand/liaison/grpc/stream_write_test.go | 12 +++----
banyand/liaison/grpc/trace_write_test.go | 4 +--
banyand/liaison/grpc/write_helpers_test.go | 29 ++++++++++------
banyand/metadata/schema/property/converter.go | 8 ++---
pkg/schema/cache.go | 10 ++++--
pkg/schema/cache_test.go | 30 ++++++++--------
pkg/test/helpers/constant.go | 7 ++--
pkg/test/setup/watch_control.go | 2 +-
test/cases/schema/apply_rollback.go | 17 +++++----
test/cases/schema/clamp.go | 1 -
test/cases/schema/clients.go | 22 ++++++------
test/cases/schema/query_gate.go | 13 ++++---
test/cases/schema/write_gate.go | 50 ---------------------------
17 files changed, 116 insertions(+), 147 deletions(-)
diff --git a/banyand/liaison/grpc/barrier_test.go b/banyand/liaison/grpc/barrier_test.go
index 0cbe361ff..a6214db33 100644
--- a/banyand/liaison/grpc/barrier_test.go
+++ b/banyand/liaison/grpc/barrier_test.go
@@ -33,12 +33,12 @@ import (
schemav1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/schema/v1"
)
-// --- mock cache helpers ---
+// Mock cache helpers follow.
// staticBarrierCache implements barrierCacheReader with fixed data — no advancing.
type staticBarrierCache struct {
+ keys map[string]int64
maxModRevision int64
- keys map[string]int64 // propID → modRevision; key absent means "not in cache"
}
func (c *staticBarrierCache) GetMaxModRevision() int64 { return c.maxModRevision }
@@ -50,9 +50,9 @@ func (c *staticBarrierCache) GetKeyModRevision(propID string) (int64, bool) {
// advancingBarrierCache implements barrierCacheReader where individual fields can
// be updated concurrently (used to simulate cache catch-up).
type advancingBarrierCache struct {
- mu sync.RWMutex
- maxRev int64
keys map[string]int64
+ maxRev int64
+ mu sync.RWMutex
}
func newAdvancingCache(maxRev int64, keys map[string]int64) *advancingBarrierCache {
@@ -97,7 +97,7 @@ func schemaKey(kind, group, name string) *schemav1.SchemaKey {
return &schemav1.SchemaKey{Kind: kind, Group: group, Name: name}
}
-// --- AwaitRevisionApplied tests ---
+// AwaitRevisionApplied tests follow.
// TestBarrier_AwaitRevisionApplied_AlreadyAtRevision verifies that when the
// cache is already at or above the requested min_revision, Applied=true is
@@ -144,7 +144,7 @@ func TestBarrier_AwaitRevisionApplied_CacheAdvances_ReturnsTrue(t *testing.T) {
}
// TestBarrier_AwaitRevisionApplied_ContextCancelled_ReturnsFalse verifies that
-// when the caller's context is cancelled before the revision is reached, the RPC
+// when the caller's context is canceled before the revision is reached, the RPC
// returns Applied=false without error.
func TestBarrier_AwaitRevisionApplied_ContextCancelled_ReturnsFalse(t *testing.T) {
svc := newBarrierService(func() barrierCacheReader { return &staticBarrierCache{maxModRevision: 1} })
@@ -161,7 +161,7 @@ func TestBarrier_AwaitRevisionApplied_ContextCancelled_ReturnsFalse(t *testing.T
assert.False(t, resp.GetApplied())
}
-// --- AwaitSchemaApplied tests ---
+// AwaitSchemaApplied tests follow.
// TestBarrier_AwaitSchemaApplied_AllKeysPresent_ReturnsTrue verifies that when
// all requested schema keys are already in the cache, Applied=true is returned immediately.
@@ -225,7 +225,7 @@ func TestBarrier_AwaitSchemaApplied_KeyAppearsInTime_ReturnsTrue(t *testing.T) {
assert.True(t, resp.GetApplied())
}
-// --- AwaitSchemaDeleted tests ---
+// AwaitSchemaDeleted tests follow.
// TestBarrier_AwaitSchemaDeleted_AllKeysAbsent_ReturnsTrue verifies that when all
// requested keys are already absent from the cache, Applied=true is returned immediately.
@@ -289,7 +289,7 @@ func TestBarrier_AwaitSchemaDeleted_KeyRemovedInTime_ReturnsTrue(t *testing.T) {
assert.True(t, resp.GetApplied())
}
-// --- Pure function tests ---
+// Pure function tests follow.
// TestBarrierBackoff_GrowsByFactor verifies the backoff grows by barrierGrowthFactor each step.
func TestBarrierBackoff_GrowsByFactor(t *testing.T) {
diff --git a/banyand/liaison/grpc/clamp_test.go b/banyand/liaison/grpc/clamp_test.go
index 6c36c3cea..613b4341f 100644
--- a/banyand/liaison/grpc/clamp_test.go
+++ b/banyand/liaison/grpc/clamp_test.go
@@ -86,7 +86,7 @@ func TestClampTimeRangeBegin_BeginEqualsMaxCreatedAt_ReturnsBeginUnchanged(t *te
func TestClampTimeRangeBegin_ClampedBeginAfterEnd_ReturnsEmpty(t *testing.T) {
// End is far in the past; createdAt is recent → clamped begin > end.
createdAt := base.Add(time.Hour)
- begin := base.Add(-time.Hour) // before createdAt
+ begin := base.Add(-time.Hour) // before createdAt
end := base.Add(-30 * time.Minute) // between begin and createdAt
gotBegin, empty := clampTimeRangeBegin(begin, end, []time.Time{createdAt})
assert.Equal(t, createdAt, gotBegin)
@@ -98,8 +98,8 @@ func TestClampTimeRangeBegin_ClampedBeginAfterEnd_ReturnsEmpty(t *testing.T) {
// and empty is false (the caller should proceed with the query).
func TestClampTimeRangeBegin_ClampedBeginEqualsEnd_NotEmpty(t *testing.T) {
createdAt := base.Add(30 * time.Minute)
- begin := base // before createdAt
- end := createdAt // exactly equal to createdAt after clamping
+ begin := base // before createdAt
+ end := createdAt // exactly equal to createdAt after clamping
gotBegin, empty := clampTimeRangeBegin(begin, end, []time.Time{createdAt})
assert.Equal(t, createdAt, gotBegin)
assert.False(t, empty, "clamped begin == end is a valid single-point range, not empty")
diff --git a/banyand/liaison/grpc/discovery_test.go b/banyand/liaison/grpc/discovery_test.go
index 0ce755609..9842748de 100644
--- a/banyand/liaison/grpc/discovery_test.go
+++ b/banyand/liaison/grpc/discovery_test.go
@@ -30,12 +30,14 @@ import (
"github.com/apache/skywalking-banyandb/pkg/logger"
)
-// --- entityRepo tombstone GC helpers ---
+// entityRepo tombstone GC helpers follow.
// minimalStream returns a Stream proto suitable for entityRepo event tests.
-func minimalStream(group, name string, modRevision int64) *databasev1.Stream {
+// Group and name are fixed because every caller uses the same values; introducing
+// variation would only add noise without changing what's being asserted.
+func minimalStream(modRevision int64) *databasev1.Stream {
return &databasev1.Stream{
- Metadata: &commonv1.Metadata{Group: group, Name: name, ModRevision: modRevision},
+ Metadata: &commonv1.Metadata{Group: "g", Name: "s", ModRevision: modRevision},
Entity: &databasev1.Entity{TagNames: []string{"svc"}},
TagFamilies: []*databasev1.TagFamilySpec{{
Name: "default",
@@ -82,13 +84,13 @@ func traceAddEvent(tr *databasev1.Trace) schema.Metadata {
return schema.Metadata{TypeMeta: schema.TypeMeta{Kind: schema.KindTrace}, Spec: tr}
}
-// --- entityRepo tombstone GC unit tests ---
+// entityRepo tombstone GC unit tests follow.
// TestEntityRepo_OnAddOrUpdate_Stream verifies that OnAddOrUpdate for a stream
// populates entitiesMap with the correct ModRevision and streamMap with the spec.
func TestEntityRepo_OnAddOrUpdate_Stream(t *testing.T) {
er := newEmptyEntityRepo()
- s := minimalStream("g", "s", 42)
+ s := minimalStream(42)
er.OnAddOrUpdate(streamAddEvent(s))
id := identity{group: "g", name: "s"}
@@ -152,7 +154,7 @@ func TestEntityRepo_OnAddOrUpdate_Trace_MissingTraceID(t *testing.T) {
// the locator from entitiesMap and the entry from streamMap (tombstone GC).
func TestEntityRepo_OnDelete_Stream(t *testing.T) {
er := newEmptyEntityRepo()
- s := minimalStream("g", "s", 42)
+ s := minimalStream(42)
er.OnAddOrUpdate(streamAddEvent(s))
er.OnDelete(streamAddEvent(s))
@@ -203,7 +205,7 @@ func TestEntityRepo_OnDelete_Trace(t *testing.T) {
// add → present; delete → absent; add again with new revision → present with new revision.
func TestEntityRepo_AddDeleteAdd_Sequence(t *testing.T) {
er := newEmptyEntityRepo()
- s := minimalStream("g", "s", 10)
+ s := minimalStream(10)
id := identity{group: "g", name: "s"}
er.OnAddOrUpdate(streamAddEvent(s))
@@ -214,7 +216,7 @@ func TestEntityRepo_AddDeleteAdd_Sequence(t *testing.T) {
_, ok = er.getLocator(id)
require.False(t, ok, "entity must be absent after OnDelete (tombstone)")
- s2 := minimalStream("g", "s", 20)
+ s2 := minimalStream(20)
er.OnAddOrUpdate(streamAddEvent(s2))
loc, ok := er.getLocator(id)
require.True(t, ok, "entity must be present after second OnAddOrUpdate")
@@ -222,10 +224,10 @@ func TestEntityRepo_AddDeleteAdd_Sequence(t *testing.T) {
}
// TestEntityRepo_OnDelete_UnknownKind_IsNoop verifies that OnDelete for an
-// unrecognised kind does not panic and leaves existing entries intact.
+// unrecognized kind does not panic and leaves existing entries intact.
func TestEntityRepo_OnDelete_UnknownKind_IsNoop(t *testing.T) {
er := newEmptyEntityRepo()
- s := minimalStream("g", "s", 1)
+ s := minimalStream(1)
er.OnAddOrUpdate(streamAddEvent(s))
assert.NotPanics(t, func() {
diff --git a/banyand/liaison/grpc/measure_write_test.go b/banyand/liaison/grpc/measure_write_test.go
index 3d621cdb0..e866e89cf 100644
--- a/banyand/liaison/grpc/measure_write_test.go
+++ b/banyand/liaison/grpc/measure_write_test.go
@@ -35,8 +35,8 @@ func newTestMeasureService(er *entityRepo, maxWait time.Duration) *measureServic
return &measureService{
discoveryService: &discoveryService{entityRepo: er},
maxWaitDuration: maxWait,
- l: logger.GetLogger("test"),
- metrics: newBypassMetrics(),
+ l: logger.GetLogger("test"),
+ metrics: newBypassMetrics(),
}
}
@@ -53,7 +53,7 @@ func validMeasureWriteRequest() *measurev1.WriteRequest {
// with STATUS_EXPIRED_SCHEMA.
func TestValidateWriteRequest_Measure_ClientLower_ReturnsExpiredSchema(t *testing.T) {
id := identity{group: "g", name: "m"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestMeasureService(er, 50*time.Millisecond)
mock := &mockBidiServer[measurev1.WriteRequest, measurev1.WriteResponse]{}
@@ -70,7 +70,7 @@ func TestValidateWriteRequest_Measure_ClientLower_ReturnsExpiredSchema(t *testin
// maxWaitDuration and then returns STATUS_SCHEMA_NOT_APPLIED when the cache stays stale.
func TestValidateWriteRequest_Measure_ClientHigher_WaitsAndReturnsNotApplied_OnTimeout(t *testing.T) {
id := identity{group: "g", name: "m"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestMeasureService(er, 50*time.Millisecond)
mock := &mockBidiServer[measurev1.WriteRequest, measurev1.WriteResponse]{}
@@ -87,7 +87,7 @@ func TestValidateWriteRequest_Measure_ClientHigher_WaitsAndReturnsNotApplied_OnT
// once the cache advances to the required revision within maxWaitDuration.
func TestValidateWriteRequest_Measure_ClientHigher_SucceedsWhenCacheCatchesUp(t *testing.T) {
id := identity{group: "g", name: "m"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestMeasureService(er, 500*time.Millisecond)
mock := &mockBidiServer[measurev1.WriteRequest, measurev1.WriteResponse]{}
@@ -104,7 +104,7 @@ func TestValidateWriteRequest_Measure_ClientHigher_SucceedsWhenCacheCatchesUp(t
// client ModRevision equal to the cached revision is accepted immediately.
func TestValidateWriteRequest_Measure_Equal_ReturnsSucceed(t *testing.T) {
id := identity{group: "g", name: "m"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestMeasureService(er, 50*time.Millisecond)
mock := &mockBidiServer[measurev1.WriteRequest, measurev1.WriteResponse]{}
diff --git a/banyand/liaison/grpc/stream_write_test.go b/banyand/liaison/grpc/stream_write_test.go
index c015dbf05..31af53b73 100644
--- a/banyand/liaison/grpc/stream_write_test.go
+++ b/banyand/liaison/grpc/stream_write_test.go
@@ -35,8 +35,8 @@ func newTestStreamService(er *entityRepo, maxWait time.Duration) *streamService
return &streamService{
discoveryService: &discoveryService{entityRepo: er},
maxWaitDuration: maxWait,
- l: logger.GetLogger("test"),
- metrics: newBypassMetrics(),
+ l: logger.GetLogger("test"),
+ metrics: newBypassMetrics(),
}
}
@@ -53,7 +53,7 @@ func validStreamWriteRequest() *streamv1.WriteRequest {
// with STATUS_EXPIRED_SCHEMA.
func TestValidateWriteRequest_Stream_ClientLower_ReturnsExpiredSchema(t *testing.T) {
id := identity{group: "g", name: "s"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestStreamService(er, 50*time.Millisecond)
mock := &mockBidiServer[streamv1.WriteRequest, streamv1.WriteResponse]{}
@@ -70,7 +70,7 @@ func TestValidateWriteRequest_Stream_ClientLower_ReturnsExpiredSchema(t *testing
// maxWaitDuration and then returns STATUS_SCHEMA_NOT_APPLIED when the cache stays stale.
func TestValidateWriteRequest_Stream_ClientHigher_WaitsAndReturnsNotApplied_OnTimeout(t *testing.T) {
id := identity{group: "g", name: "s"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestStreamService(er, 50*time.Millisecond)
mock := &mockBidiServer[streamv1.WriteRequest, streamv1.WriteResponse]{}
@@ -87,7 +87,7 @@ func TestValidateWriteRequest_Stream_ClientHigher_WaitsAndReturnsNotApplied_OnTi
// once the cache advances to the required revision within maxWaitDuration.
func TestValidateWriteRequest_Stream_ClientHigher_SucceedsWhenCacheCatchesUp(t *testing.T) {
id := identity{group: "g", name: "s"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestStreamService(er, 500*time.Millisecond)
mock := &mockBidiServer[streamv1.WriteRequest, streamv1.WriteResponse]{}
@@ -104,7 +104,7 @@ func TestValidateWriteRequest_Stream_ClientHigher_SucceedsWhenCacheCatchesUp(t *
// client ModRevision equal to the cached revision is accepted immediately.
func TestValidateWriteRequest_Stream_Equal_ReturnsSucceed(t *testing.T) {
id := identity{group: "g", name: "s"}
- er := seededLocatorRepo(id, 100)
+ er := seededLocatorRepo(id)
svc := newTestStreamService(er, 50*time.Millisecond)
mock := &mockBidiServer[streamv1.WriteRequest, streamv1.WriteResponse]{}
diff --git a/banyand/liaison/grpc/trace_write_test.go b/banyand/liaison/grpc/trace_write_test.go
index 9c90ef446..989ea298c 100644
--- a/banyand/liaison/grpc/trace_write_test.go
+++ b/banyand/liaison/grpc/trace_write_test.go
@@ -35,8 +35,8 @@ func newTestTraceService(er *entityRepo, maxWait time.Duration) *traceService {
return &traceService{
discoveryService: &discoveryService{entityRepo: er},
maxWaitDuration: maxWait,
- l: logger.GetLogger("test"),
- metrics: newBypassMetrics(),
+ l: logger.GetLogger("test"),
+ metrics: newBypassMetrics(),
}
}
diff --git a/banyand/liaison/grpc/write_helpers_test.go b/banyand/liaison/grpc/write_helpers_test.go
index 0166709ac..bc789a507 100644
--- a/banyand/liaison/grpc/write_helpers_test.go
+++ b/banyand/liaison/grpc/write_helpers_test.go
@@ -35,8 +35,8 @@ import (
// mockBidiServer captures Send calls emitted by service handlers under test.
// It satisfies grpc.BidiStreamingServer[Req, Res] (= grpc.ServerStream + Recv + Send).
type mockBidiServer[Req any, Res any] struct {
- mu sync.Mutex
replies []*Res
+ mu sync.Mutex
}
func (s *mockBidiServer[Req, Res]) Send(resp *Res) error {
@@ -46,13 +46,13 @@ func (s *mockBidiServer[Req, Res]) Send(resp *Res) error {
return nil
}
-func (s *mockBidiServer[Req, Res]) Recv() (*Req, error) { return nil, io.EOF }
-func (s *mockBidiServer[Req, Res]) Context() context.Context { return context.Background() }
-func (s *mockBidiServer[Req, Res]) SetHeader(grpcmd.MD) error { return nil }
-func (s *mockBidiServer[Req, Res]) SendHeader(grpcmd.MD) error { return nil }
-func (s *mockBidiServer[Req, Res]) SetTrailer(grpcmd.MD) {}
-func (s *mockBidiServer[Req, Res]) SendMsg(any) error { return nil }
-func (s *mockBidiServer[Req, Res]) RecvMsg(any) error { return nil }
+func (s *mockBidiServer[Req, Res]) Recv() (*Req, error) { return nil, io.EOF }
+func (s *mockBidiServer[Req, Res]) Context() context.Context { return context.Background() }
+func (s *mockBidiServer[Req, Res]) SetHeader(grpcmd.MD) error { return nil }
+func (s *mockBidiServer[Req, Res]) SendHeader(grpcmd.MD) error { return nil }
+func (s *mockBidiServer[Req, Res]) SetTrailer(grpcmd.MD) {}
+func (s *mockBidiServer[Req, Res]) SendMsg(any) error { return nil }
+func (s *mockBidiServer[Req, Res]) RecvMsg(any) error { return nil }
// newBypassMetrics returns a metrics instance backed by a no-op registry.
func newBypassMetrics() *metrics {
@@ -72,10 +72,17 @@ func newEmptyEntityRepo() *entityRepo {
}
}
-// seededLocatorRepo returns an entityRepo with a single locator entry at rev.
-func seededLocatorRepo(id identity, rev int64) *entityRepo {
+// seededLocatorRepoRev is the baseline ModRevision every test uses for the seeded
+// locator. Picking 100 leaves headroom for tests that simulate stale (<100) and
+// future (>100) client revisions against this baseline.
+const seededLocatorRepoRev int64 = 100
+
+// seededLocatorRepo returns an entityRepo with a single locator entry at the
+// fixed seededLocatorRepoRev baseline. Tests that need a different revision
+// should mutate er.entitiesMap directly.
+func seededLocatorRepo(id identity) *entityRepo {
er := newEmptyEntityRepo()
- er.entitiesMap[id] = partition.Locator{ModRevision: rev}
+ er.entitiesMap[id] = partition.Locator{ModRevision: seededLocatorRepoRev}
return er
}
diff --git a/banyand/metadata/schema/property/converter.go b/banyand/metadata/schema/property/converter.go
index b1d1819f0..66326987c 100644
--- a/banyand/metadata/schema/property/converter.go
+++ b/banyand/metadata/schema/property/converter.go
@@ -389,8 +389,8 @@ func getCreatedAtFromSpec(kind schema.Kind, spec proto.Message) *timestamppb.Tim
if p, ok := spec.(*databasev1.Property); ok {
return p.GetCreatedAt()
}
- case schema.KindNode:
- // Node does not have a CreatedAt field.
+ case schema.KindNode, schema.KindMask:
+ // Node and Mask do not have a CreatedAt field.
}
return nil
}
@@ -430,8 +430,8 @@ func setCreatedAtOnSpec(kind schema.Kind, spec proto.Message, ts *timestamppb.Ti
if p, ok := spec.(*databasev1.Property); ok {
p.CreatedAt = ts
}
- case schema.KindNode:
- // Node does not have a CreatedAt field.
+ case schema.KindNode, schema.KindMask:
+ // Node and Mask do not have a CreatedAt field.
}
}
diff --git a/pkg/schema/cache.go b/pkg/schema/cache.go
index 522a021f0..8671b8c75 100644
--- a/pkg/schema/cache.go
+++ b/pkg/schema/cache.go
@@ -39,8 +39,10 @@ import (
"github.com/apache/skywalking-banyandb/pkg/run"
)
-var _ Resource = (*resourceSpec)(nil)
-var _ RevisionRepository = (*schemaRepo)(nil)
+var (
+ _ Resource = (*resourceSpec)(nil)
+ _ RevisionRepository = (*schemaRepo)(nil)
+)
type resourceSpec struct {
schema ResourceSchema
@@ -554,6 +556,10 @@ func (sr *schemaRepo) ResourceRevision(kind schema.Kind, groupName, name string)
return gs.GetMetadata().GetModRevision(), true
}
}
+ case schema.KindIndexRuleBinding, schema.KindTopNAggregation,
+ schema.KindNode, schema.KindProperty, schema.KindMask:
+ // schemaRepo only caches resources, index rules, and groups; other kinds
+ // (bindings, top-n aggregations, nodes, properties, masks) have no entry here.
}
return 0, false
}
diff --git a/pkg/schema/cache_test.go b/pkg/schema/cache_test.go
index f96b9c5d2..d524e238b 100644
--- a/pkg/schema/cache_test.go
+++ b/pkg/schema/cache_test.go
@@ -51,10 +51,12 @@ func newTestSchemaRepo() *schemaRepo {
return &schemaRepo{resourceSchemaSupplier: stubSupplier{}}
}
-// buildMeasure returns a *databasev1.Measure with the specified group, name, and mod_revision.
-func buildMeasure(group, name string, modRevision int64) *databasev1.Measure {
+// buildMeasure returns a *databasev1.Measure with the specified name and mod_revision.
+// Group is fixed to "g" because every test in this file uses the same group; varying
+// it would only add noise without changing what's being asserted.
+func buildMeasure(name string, modRevision int64) *databasev1.Measure {
return &databasev1.Measure{
- Metadata: &commonv1.Metadata{Group: group, Name: name, ModRevision: modRevision},
+ Metadata: &commonv1.Metadata{Group: "g", Name: name, ModRevision: modRevision},
}
}
@@ -63,10 +65,10 @@ func buildMeasure(group, name string, modRevision int64) *databasev1.Measure {
// leaving the cache entry intact (A7).
func TestDeleteResource_RevisionGuard_RejectsStaleDelete(t *testing.T) {
sr := newTestSchemaRepo()
- require.NoError(t, sr.storeResource(buildMeasure("g", "m", 100)))
+ require.NoError(t, sr.storeResource(buildMeasure("m", 100)))
sr.deleteResource(MetadataEvent{
- Metadata: buildMeasure("g", "m", 100),
+ Metadata: buildMeasure("m", 100),
DeleteRevision: 50,
Typ: EventDelete,
Kind: EventKindResource,
@@ -81,10 +83,10 @@ func TestDeleteResource_RevisionGuard_RejectsStaleDelete(t *testing.T) {
// the cache entry (A7).
func TestDeleteResource_RevisionGuard_AcceptsFreshDelete(t *testing.T) {
sr := newTestSchemaRepo()
- require.NoError(t, sr.storeResource(buildMeasure("g", "m", 100)))
+ require.NoError(t, sr.storeResource(buildMeasure("m", 100)))
sr.deleteResource(MetadataEvent{
- Metadata: buildMeasure("g", "m", 100),
+ Metadata: buildMeasure("m", 100),
DeleteRevision: 150,
Typ: EventDelete,
Kind: EventKindResource,
@@ -100,14 +102,14 @@ func TestLatestModRevision_Monotonic(t *testing.T) {
sr := newTestSchemaRepo()
assert.Equal(t, int64(0), sr.LatestModRevision(), "watermark must start at zero")
- require.NoError(t, sr.storeResource(buildMeasure("g", "m1", 10)))
+ require.NoError(t, sr.storeResource(buildMeasure("m1", 10)))
assert.Equal(t, int64(10), sr.LatestModRevision())
- require.NoError(t, sr.storeResource(buildMeasure("g", "m2", 30)))
+ require.NoError(t, sr.storeResource(buildMeasure("m2", 30)))
assert.Equal(t, int64(30), sr.LatestModRevision())
// A new key at a lower revision must not regress the watermark.
- require.NoError(t, sr.storeResource(buildMeasure("g", "m3", 20)))
+ require.NoError(t, sr.storeResource(buildMeasure("m3", 20)))
assert.Equal(t, int64(30), sr.LatestModRevision(), "stale store (rev=20) must not lower the watermark from 30")
}
@@ -116,7 +118,7 @@ func TestLatestModRevision_Monotonic(t *testing.T) {
func TestLatestModRevision_AcrossKinds(t *testing.T) {
sr := newTestSchemaRepo()
- require.NoError(t, sr.storeResource(buildMeasure("g", "m1", 10)))
+ require.NoError(t, sr.storeResource(buildMeasure("m1", 10)))
assert.Equal(t, int64(10), sr.LatestModRevision())
sr.storeIndexRule(&databasev1.IndexRule{
@@ -138,7 +140,7 @@ func TestLatestModRevision_AcrossKinds(t *testing.T) {
// stored mod_revision and ok=true for a present resource, and (0, false) for an absent one (A8).
func TestResourceRevision_PresentAndAbsent(t *testing.T) {
sr := newTestSchemaRepo()
- require.NoError(t, sr.storeResource(buildMeasure("g", "m", 77)))
+ require.NoError(t, sr.storeResource(buildMeasure("m", 77)))
rev, ok := sr.ResourceRevision(schema.KindMeasure, "g", "m")
assert.True(t, ok)
@@ -153,12 +155,12 @@ func TestResourceRevision_PresentAndAbsent(t *testing.T) {
// is cached and true after a valid delete removes it from the cache (A7, A8).
func TestIsAbsent_AfterDelete(t *testing.T) {
sr := newTestSchemaRepo()
- require.NoError(t, sr.storeResource(buildMeasure("g", "m", 100)))
+ require.NoError(t, sr.storeResource(buildMeasure("m", 100)))
assert.False(t, sr.IsAbsent(schema.KindMeasure, "g", "m"), "resource must not be absent immediately after store")
sr.deleteResource(MetadataEvent{
- Metadata: buildMeasure("g", "m", 100),
+ Metadata: buildMeasure("m", 100),
DeleteRevision: 100,
Typ: EventDelete,
Kind: EventKindResource,
diff --git a/pkg/test/helpers/constant.go b/pkg/test/helpers/constant.go
index b694e1c64..14d1b60c0 100644
--- a/pkg/test/helpers/constant.go
+++ b/pkg/test/helpers/constant.go
@@ -33,12 +33,9 @@ import (
// SharedContext is the context shared between test cases in the integration testing.
type SharedContext struct {
+ BaseTime time.Time
Connection *grpclib.ClientConn
- // Mode identifies the deployment shape of the running suite. Valid values are
- // "standalone" and "distributed". The empty string is accepted for callers that
- // do not need to discriminate between modes.
- Mode string
- BaseTime time.Time
+ Mode string
}
// Args is a wrapper seals all necessary info for table specs.
diff --git a/pkg/test/setup/watch_control.go b/pkg/test/setup/watch_control.go
index 021b89303..69e2b60f8 100644
--- a/pkg/test/setup/watch_control.go
+++ b/pkg/test/setup/watch_control.go
@@ -26,7 +26,7 @@ import "errors"
var ErrWatchControlNotImplemented = errors.New("watch control not implemented: landed in Phase 2")
// PauseDataNodeWatch suspends the named data node's schema watch loop so a
-// test can observe behaviour while the node is missing schema events. It is a
+// test can observe behavior while the node is missing schema events. It is a
// distributed-only hook; the standalone harness has no separate watch path.
// Phase 2 will provide a real implementation; until then it returns
// ErrWatchControlNotImplemented and callers should skip.
diff --git a/test/cases/schema/apply_rollback.go b/test/cases/schema/apply_rollback.go
index 0388227ac..a2a200101 100644
--- a/test/cases/schema/apply_rollback.go
+++ b/test/cases/schema/apply_rollback.go
@@ -66,6 +66,9 @@ func arMeasureSpec(group, name string) *databasev1.Measure {
}
}
+// applyRollbackMeasureName is the fixture measure name reused across the §6.1–§6.7 specs.
+const applyRollbackMeasureName = "cpu_total"
+
// Schema apply-rollback tests — §6.1 through §6.7.
var _ = g.Describe("Schema apply rollback", func() {
var (
@@ -81,7 +84,7 @@ var _ = g.Describe("Schema apply rollback", func() {
// §6.1 — creates a measure visible end-to-end.
g.It("creates a measure visible end-to-end (§6.1)", func() {
groupName := fmt.Sprintf("ar-vm-%d", time.Now().UnixNano())
- measureName := "cpu_total"
+ measureName := applyRollbackMeasureName
g.By("Creating measure group and awaiting revision")
createGroupResp, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -222,7 +225,7 @@ var _ = g.Describe("Schema apply rollback", func() {
// §6.3 — lists groups and measures after create.
g.It("lists groups and measures after create (§6.3)", func() {
groupName := fmt.Sprintf("ar-list-%d", time.Now().UnixNano())
- measureName := "cpu_total"
+ measureName := applyRollbackMeasureName
g.By("Creating measure group and measure")
_, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -297,7 +300,7 @@ var _ = g.Describe("Schema apply rollback", func() {
g.By("Creating first measure cpu_total → R1")
createResp1, createErr1 := clients.MeasureRegClient.Create(ctx, &databasev1.MeasureRegistryServiceCreateRequest{
- Measure: arMeasureSpec(groupName, "cpu_total"),
+ Measure: arMeasureSpec(groupName, applyRollbackMeasureName),
})
gm.Expect(createErr1).ShouldNot(gm.HaveOccurred())
r1 := createResp1.GetModRevision()
@@ -319,7 +322,7 @@ var _ = g.Describe("Schema apply rollback", func() {
g.By("Verifying GetMeasure for cpu_total returns R1")
getCPUResp, getCPUErr := clients.MeasureRegClient.Get(ctx, &databasev1.MeasureRegistryServiceGetRequest{
- Metadata: &commonv1.Metadata{Name: "cpu_total", Group: groupName},
+ Metadata: &commonv1.Metadata{Name: applyRollbackMeasureName, Group: groupName},
})
gm.Expect(getCPUErr).ShouldNot(gm.HaveOccurred())
gm.Expect(getCPUResp.GetMeasure().GetMetadata().GetModRevision()).Should(gm.Equal(r1),
@@ -341,7 +344,7 @@ var _ = g.Describe("Schema apply rollback", func() {
for _, m := range listResp.GetMeasure() {
names = append(names, m.GetMetadata().GetName())
}
- gm.Expect(names).Should(gm.ConsistOf("cpu_total", "mem_total"))
+ gm.Expect(names).Should(gm.ConsistOf(applyRollbackMeasureName, "mem_total"))
_, _ = clients.GroupClient.Delete(ctx, &databasev1.GroupRegistryServiceDeleteRequest{Group: groupName})
})
@@ -349,7 +352,7 @@ var _ = g.Describe("Schema apply rollback", func() {
// §6.5 — drops measure from BanyanDB on delete.
g.It("drops measure from BanyanDB on delete (§6.5)", func() {
groupName := fmt.Sprintf("ar-del-%d", time.Now().UnixNano())
- measureName := "cpu_total"
+ measureName := applyRollbackMeasureName
g.By("Creating measure group and measure")
_, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -405,7 +408,7 @@ var _ = g.Describe("Schema apply rollback", func() {
// §6.6 — delete-then-recreate is idempotent for identical shape.
g.It("delete-then-recreate is idempotent for identical shape (§6.6)", func() {
groupName := fmt.Sprintf("ar-recreate-%d", time.Now().UnixNano())
- measureName := "cpu_total"
+ measureName := applyRollbackMeasureName
g.By("Creating measure group and measure → R1")
_, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
diff --git a/test/cases/schema/clamp.go b/test/cases/schema/clamp.go
index 0eaceff8d..13d070499 100644
--- a/test/cases/schema/clamp.go
+++ b/test/cases/schema/clamp.go
@@ -291,4 +291,3 @@ var _ = g.Describe("Schema time-range clamp", func() {
}
})
})
-
diff --git a/test/cases/schema/clients.go b/test/cases/schema/clients.go
index 7c2b23248..e81fa8641 100644
--- a/test/cases/schema/clients.go
+++ b/test/cases/schema/clients.go
@@ -35,17 +35,17 @@ import (
// Clients holds all gRPC clients required by the schema integration test helpers.
type Clients struct {
- GroupClient databasev1.GroupRegistryServiceClient
- MeasureRegClient databasev1.MeasureRegistryServiceClient
- StreamRegClient databasev1.StreamRegistryServiceClient
- TraceRegClient databasev1.TraceRegistryServiceClient
- IndexRuleClient databasev1.IndexRuleRegistryServiceClient
- IndexRuleBindingClient databasev1.IndexRuleBindingRegistryServiceClient
- TopNAggregationRegClient databasev1.TopNAggregationRegistryServiceClient
- MeasureWriteClient measurev1.MeasureServiceClient
- StreamWriteClient streamv1.StreamServiceClient
- TraceWriteClient tracev1.TraceServiceClient
- BarrierClient schemav1.SchemaBarrierServiceClient
+ GroupClient databasev1.GroupRegistryServiceClient
+ MeasureRegClient databasev1.MeasureRegistryServiceClient
+ StreamRegClient databasev1.StreamRegistryServiceClient
+ TraceRegClient databasev1.TraceRegistryServiceClient
+ IndexRuleClient databasev1.IndexRuleRegistryServiceClient
+ IndexRuleBindingClient databasev1.IndexRuleBindingRegistryServiceClient
+ TopNAggregationRegClient databasev1.TopNAggregationRegistryServiceClient
+ MeasureWriteClient measurev1.MeasureServiceClient
+ StreamWriteClient streamv1.StreamServiceClient
+ TraceWriteClient tracev1.TraceServiceClient
+ BarrierClient schemav1.SchemaBarrierServiceClient
}
// NewClients constructs the registry/service client bundle used by the schema integration tests.
diff --git a/test/cases/schema/query_gate.go b/test/cases/schema/query_gate.go
index 35ddcb32b..3b52cbc07 100644
--- a/test/cases/schema/query_gate.go
+++ b/test/cases/schema/query_gate.go
@@ -67,6 +67,9 @@ func sendStreamQuery(
return st, nil
}
+// queryGateStreamName is the fixture stream name reused across §4.5 specs.
+const queryGateStreamName = "qg_stream"
+
// Schema query gate smoke tests — §4.5.1 / §4.5.2 / §4.5.3.
// Each spec exercises a distinct branch of the per-group ModRevision gate on the
// query path.
@@ -85,7 +88,7 @@ var _ = g.Describe("Schema query gate", func() {
// is short-circuited and returns STATUS_EXPIRED_SCHEMA for that group.
g.It("returns STATUS_EXPIRED_SCHEMA for stale group ModRevision (§4.5.1)", func() {
groupName := fmt.Sprintf("qg-stale-%d", time.Now().UnixNano())
- streamName := "qg_stream"
+ streamName := queryGateStreamName
g.By("Creating stream group and schema to obtain baseline ModRevision (R1)")
_, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -132,7 +135,7 @@ var _ = g.Describe("Schema query gate", func() {
// until the configured wait duration and then returned with STATUS_SCHEMA_NOT_APPLIED.
g.It("returns STATUS_SCHEMA_NOT_APPLIED for ahead group ModRevision that never applies (§4.5.2)", func() {
groupName := fmt.Sprintf("qg-ahead-%d", time.Now().UnixNano())
- streamName := "qg_stream"
+ streamName := queryGateStreamName
g.By("Creating stream group and schema")
_, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -164,7 +167,7 @@ var _ = g.Describe("Schema query gate", func() {
// and returns STATUS_SUCCEED for that group.
g.It("passes the gate and returns STATUS_SUCCEED when ModRevision matches cache (§4.5.3)", func() {
groupName := fmt.Sprintf("qg-match-%d", time.Now().UnixNano())
- streamName := "qg_stream"
+ streamName := queryGateStreamName
g.By("Creating stream group and schema")
_, createGroupErr := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -196,7 +199,7 @@ var _ = g.Describe("Schema query gate", func() {
g.It("returns mixed group_statuses and empty elements when one group is stale (§4.5.4)", func() {
group1 := fmt.Sprintf("qg-mixed1-%d", time.Now().UnixNano())
group2 := fmt.Sprintf("qg-mixed2-%d", time.Now().UnixNano())
- streamName := "qg_stream"
+ streamName := queryGateStreamName
g.By("Creating group1 + stream → R1a; updating stream → R1b")
_, createGroup1Err := clients.GroupClient.Create(ctx, &databasev1.GroupRegistryServiceCreateRequest{
@@ -290,7 +293,7 @@ var _ = g.Describe("Schema query gate", func() {
g.It("executes query when one group is ungated (not in GroupModRevisions) (§4.5.5)", func() {
group1 := fmt.Sprintf("qg-partial1-%d", time.Now().UnixNano())
group2 := fmt.Sprintf("qg-partial2-%d", time.Now().UnixNano())
- streamName := "qg_stream"
+ streamName := queryGateStreamName
g.By("Creating group1 and group2 with streams")
var maxGroupRev int64
diff --git a/test/cases/schema/write_gate.go b/test/cases/schema/write_gate.go
index bc10997dc..7b59b4d85 100644
--- a/test/cases/schema/write_gate.go
+++ b/test/cases/schema/write_gate.go
@@ -260,56 +260,6 @@ func sendMeasureWriteAtTime(
return firstStatus, nil
}
-// sendStreamElementAtTime opens a bidi stream write, sends one element at the given
-// timestamp with the svc entity tag, and returns the status string from the first response.
-func sendStreamElementAtTime(
- ctx context.Context,
- client streamv1.StreamServiceClient,
- groupName, streamName string,
- ts time.Time,
-) (string, error) {
- writeCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
- defer cancel()
- writeClient, dialErr := client.Write(writeCtx)
- if dialErr != nil {
- return "", fmt.Errorf("open stream write: %w", dialErr)
- }
- tsMilli := ts.Truncate(time.Millisecond)
- sendErr := writeClient.Send(&streamv1.WriteRequest{
- Metadata: &commonv1.Metadata{Name: streamName, Group: groupName},
- Element: &streamv1.ElementValue{
- ElementId: fmt.Sprintf("elt-%d", tsMilli.UnixNano()),
- Timestamp: timestamppb.New(tsMilli),
- TagFamilies: []*modelv1.TagFamilyForWrite{{
- Tags: []*modelv1.TagValue{{
- Value: &modelv1.TagValue_Str{Str: &modelv1.Str{Value: "svc-a"}},
- }},
- }},
- },
- MessageId: uint64(time.Now().UnixNano()),
- })
- if sendErr != nil {
- return "", fmt.Errorf("send stream element: %w", sendErr)
- }
- if closeErr := writeClient.CloseSend(); closeErr != nil {
- return "", fmt.Errorf("close stream send: %w", closeErr)
- }
- var firstStatus string
- for {
- resp, recvErr := writeClient.Recv()
- if errors.Is(recvErr, io.EOF) {
- break
- }
- if recvErr != nil {
- return "", fmt.Errorf("recv stream response: %w", recvErr)
- }
- if resp != nil && firstStatus == "" {
- firstStatus = resp.Status
- }
- }
- return firstStatus, nil
-}
-
// Schema write gate smoke tests — §4.4.1 / §4.4.2 / §4.4.3.
// Each spec exercises a distinct branch of the three-way ModRevision split.
var _ = g.Describe("Schema write gate", func() {