This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch test/replication in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit bc3cc7e0da9ee72df0b9d6930926248b7ef43377 Author: Hongtao Gao <[email protected]> AuthorDate: Mon Mar 23 04:24:21 2026 +0000 fix(replication): use loopCloser context in executeSyncWithRetry --- banyand/measure/syncer.go | 2 +- banyand/stream/syncer.go | 2 +- banyand/trace/syncer.go | 2 +- pkg/test/measure/etcd.go | 28 +++++++ pkg/test/replicated/measure/etcd.go | 62 +++++--------- .../index_rule_bindings/endpoint_traffic.json | 16 ---- .../index_rule_bindings/service_cpm_day.json | 16 ---- .../index_rule_bindings/service_cpm_hour.json | 16 ---- .../index_rule_bindings/service_cpm_minute.json | 16 ---- .../service_cpm_minute_spec.json | 15 ---- .../service_cpm_minute_spec2.json | 15 ---- .../service_instance_cpm_day.json | 16 ---- .../service_instance_cpm_hour.json | 16 ---- .../service_instance_cpm_minute.json | 16 ---- .../service_instance_endpoint_cpm_minute.json | 16 ---- .../service_instance_latency_minute.json | 16 ---- .../service_instance_traffic.json | 17 ---- .../index_rule_bindings/service_traffic.json | 17 ---- .../testdata/index_rules/endpoint_name.json | 13 --- .../measure/testdata/index_rules/id.json | 12 --- .../measure/testdata/index_rules/id_spec.json | 10 --- .../measure/testdata/index_rules/id_spec2.json | 10 --- .../testdata/index_rules/im_service_id.json | 12 --- .../measure/testdata/index_rules/layer.json | 12 --- .../testdata/index_rules/searchable_name.json | 13 --- .../measure/testdata/index_rules/service_id.json | 12 --- .../measure/testdata/measures/duplicated.json | 42 ---------- .../measures/endpoint_resp_time_minute.json | 37 -------- .../testdata/measures/endpoint_traffic.json | 28 ------- .../testdata/measures/instance_clr_cpu_minute.json | 48 ----------- .../measure/testdata/measures/service_cpm_day.json | 42 ---------- .../testdata/measures/service_cpm_hour.json | 42 ---------- .../testdata/measures/service_cpm_minute.json | 42 ---------- .../testdata/measures/service_cpm_minute_spec.json | 40 --------- .../measures/service_cpm_minute_spec2.json | 40 --------- .../measures/service_cpm_minute_updated.json | 42 ---------- .../measures/service_instance_cpm_day.json | 47 ----------- .../measures/service_instance_cpm_hour.json | 47 ----------- .../measures/service_instance_cpm_minute.json | 52 ------------ .../service_instance_cpm_minute_updated.json | 52 ------------ .../service_instance_endpoint_cpm_minute.json | 56 ------------- .../measures/service_instance_latency_minute.json | 36 -------- .../measures/service_instance_traffic.json | 39 --------- .../testdata/measures/service_latency_minute.json | 47 ----------- .../measure/testdata/measures/service_traffic.json | 44 ---------- .../measures/service_traffic_replicated.json | 44 ---------- pkg/test/replicated/stream/etcd.go | 84 +------------------ .../index_rule_bindings/deduplication_test.json | 17 ---- .../testdata/index_rule_bindings/duplicated.json | 17 ---- .../stream/testdata/index_rule_bindings/sw.json | 26 ------ .../testdata/index_rule_bindings/sw_spec.json | 27 ------ .../testdata/index_rule_bindings/sw_spec2.json | 26 ------ .../testdata/index_rule_bindings/updated.json | 16 ---- .../stream/testdata/index_rules/db.instance.json | 13 --- .../stream/testdata/index_rules/db.type.json | 12 --- .../stream/testdata/index_rules/duration.json | 12 --- .../testdata/index_rules/duration_updated.json | 12 --- .../stream/testdata/index_rules/endpoint_id.json | 12 --- .../stream/testdata/index_rules/extended_tags.json | 12 --- .../stream/testdata/index_rules/http.method.json | 12 --- .../stream/testdata/index_rules/mq.broker.json | 12 --- .../stream/testdata/index_rules/mq.queue.json | 12 --- .../stream/testdata/index_rules/mq.topic.json | 12 --- .../stream/testdata/index_rules/status_code.json | 12 --- .../stream/testdata/index_rules/trace_id.json | 12 --- .../testdata/streams/deduplication_test.json | 50 ----------- .../stream/testdata/streams/duplicated.json | 50 ----------- .../replicated/stream/testdata/streams/sw.json | 98 ---------------------- .../stream/testdata/streams/sw_spec.json | 95 --------------------- .../stream/testdata/streams/sw_spec2.json | 94 --------------------- .../stream/testdata/streams/sw_updated.json | 90 -------------------- pkg/test/replicated/trace/etcd.go | 75 ++++------------- .../trace/testdata/index_rule_bindings/sw.json | 17 ---- .../testdata/index_rule_bindings/sw_spec.json | 14 ---- .../testdata/index_rule_bindings/sw_spec2.json | 14 ---- .../testdata/index_rule_bindings/sw_updated.json | 17 ---- .../trace/testdata/index_rule_bindings/zipkin.json | 16 ---- .../trace/testdata/index_rules/duration.json | 14 ---- .../trace/testdata/index_rules/duration_spec.json | 14 ---- .../trace/testdata/index_rules/duration_spec2.json | 9 -- .../testdata/index_rules/duration_updated.json | 14 ---- .../trace/testdata/index_rules/timestamp.json | 14 ---- .../trace/testdata/index_rules/timestamp_spec.json | 14 ---- .../testdata/index_rules/timestamp_spec2.json | 9 -- .../testdata/index_rules/timestamp_updated.json | 14 ---- .../testdata/index_rules/zipkin-timestamp.json | 14 ---- pkg/test/replicated/trace/testdata/traces/sw.json | 44 ---------- .../replicated/trace/testdata/traces/sw_spec.json | 45 ---------- .../replicated/trace/testdata/traces/sw_spec2.json | 44 ---------- .../trace/testdata/traces/sw_updated.json | 48 ----------- .../replicated/trace/testdata/traces/zipkin.json | 76 ----------------- pkg/test/stream/etcd.go | 6 ++ pkg/test/trace/etcd.go | 23 +++++ 93 files changed, 98 insertions(+), 2557 deletions(-) diff --git a/banyand/measure/syncer.go b/banyand/measure/syncer.go index 7b06e0c19..c94d18583 100644 --- a/banyand/measure/syncer.go +++ b/banyand/measure/syncer.go @@ -289,7 +289,7 @@ func (tst *tsTable) executeSyncWithRetry(partsToSync []*part, nodes []string) er failedPartsHandler := storage.NewFailedPartsHandler(tst.fileSystem, tst.root, tst.l, tst.option.failedPartsMaxTotalSizeBytes) partsInfo := tst.buildPartsInfoMap(partsToSync) - ctx := context.Background() + ctx := tst.loopCloser.Ctx() releaseFuncs := make([]func(), 0, len(partsToSync)) defer func() { for _, release := range releaseFuncs { diff --git a/banyand/stream/syncer.go b/banyand/stream/syncer.go index 37d3040c9..15d2b26f1 100644 --- a/banyand/stream/syncer.go +++ b/banyand/stream/syncer.go @@ -262,7 +262,7 @@ func (tst *tsTable) executeSyncWithRetry(partsToSync []*part, nodes []string) er failedPartsHandler := storage.NewFailedPartsHandler(tst.fileSystem, tst.root, tst.l, tst.option.failedPartsMaxTotalSizeBytes) partsInfo := tst.buildPartsInfoMap(partsToSync) - ctx := context.Background() + ctx := tst.loopCloser.Ctx() releaseFuncs := make([]func(), 0, len(partsToSync)) defer func() { for _, release := range releaseFuncs { diff --git a/banyand/trace/syncer.go b/banyand/trace/syncer.go index eb942b107..f92d43613 100644 --- a/banyand/trace/syncer.go +++ b/banyand/trace/syncer.go @@ -297,7 +297,7 @@ func (tst *tsTable) executeSyncOperation(partsToSync []*part, partIDsToSync map[ return partsToSync[i].partMetadata.ID < partsToSync[j].partMetadata.ID }) - ctx := context.Background() + ctx := tst.loopCloser.Ctx() releaseFuncs := make([]func(), 0, len(partsToSync)) defer func() { for _, release := range releaseFuncs { diff --git a/pkg/test/measure/etcd.go b/pkg/test/measure/etcd.go index 54910694c..cedd2e458 100644 --- a/pkg/test/measure/etcd.go +++ b/pkg/test/measure/etcd.go @@ -54,6 +54,34 @@ func LoadSchemaWithStages(ctx context.Context, e schema.Registry) error { return loadAllSchemas(ctx, e, groupStagesDir) } +// PreloadResourcesOnly loads measures, index rules, index rule bindings, and topN aggregations. +// It does NOT load groups. +func PreloadResourcesOnly(ctx context.Context, e schema.Registry) error { + return preloadSchemaWithFuncs(ctx, e, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(measureDir, &databasev1.Measure{}, func(measure *databasev1.Measure) error { + _, innerErr := e.CreateMeasure(ctx, measure) + return innerErr + }) + }, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(indexRuleDir, &databasev1.IndexRule{}, func(indexRule *databasev1.IndexRule) error { + return e.CreateIndexRule(ctx, indexRule) + }) + }, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(indexRuleBindingDir, &databasev1.IndexRuleBinding{}, func(indexRuleBinding *databasev1.IndexRuleBinding) error { + return e.CreateIndexRuleBinding(ctx, indexRuleBinding) + }) + }, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(topNAggregationDir, &databasev1.TopNAggregation{}, func(topN *databasev1.TopNAggregation) error { + return e.CreateTopNAggregation(ctx, topN) + }) + }, + ) +} + // loadAllSchemas is the common logic to load schemas from a given group directory. func loadAllSchemas(ctx context.Context, e schema.Registry, groupDirectory string) error { return preloadSchemaWithFuncs(ctx, e, diff --git a/pkg/test/replicated/measure/etcd.go b/pkg/test/replicated/measure/etcd.go index c50aca76b..506ae7bee 100644 --- a/pkg/test/replicated/measure/etcd.go +++ b/pkg/test/replicated/measure/etcd.go @@ -31,12 +31,11 @@ import ( commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1" databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1" "github.com/apache/skywalking-banyandb/banyand/metadata/schema" + testmeasure "github.com/apache/skywalking-banyandb/pkg/test/measure" ) const ( groupDir = "testdata/groups" - measureDir = "testdata/measures" - indexRuleDir = "testdata/index_rules" indexRuleBindingDir = "testdata/index_rule_bindings" ) @@ -45,38 +44,17 @@ var store embed.FS // PreloadSchema loads schemas from files in the booting process. func PreloadSchema(ctx context.Context, e schema.Registry) error { - return preloadSchemaWithFuncs(ctx, e, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(groupDir, &commonv1.Group{}, func(group *commonv1.Group) error { - return e.CreateGroup(ctx, group) - }) - }, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(measureDir, &databasev1.Measure{}, func(measure *databasev1.Measure) error { - _, innerErr := e.CreateMeasure(ctx, measure) - return innerErr - }) - }, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(indexRuleDir, &databasev1.IndexRule{}, func(indexRule *databasev1.IndexRule) error { - return e.CreateIndexRule(ctx, indexRule) - }) - }, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(indexRuleBindingDir, &databasev1.IndexRuleBinding{}, func(indexRuleBinding *databasev1.IndexRuleBinding) error { - return e.CreateIndexRuleBinding(ctx, indexRuleBinding) - }) - }, - ) -} - -func preloadSchemaWithFuncs(ctx context.Context, e schema.Registry, loaders ...func(context.Context, schema.Registry) error) error { - for _, loader := range loaders { - if err := loader(ctx, e); err != nil { - return errors.WithStack(err) - } + if err := loadSchema(groupDir, &commonv1.Group{}, func(group *commonv1.Group) error { + return e.CreateGroup(ctx, group) + }); err != nil { + return errors.WithStack(err) } - return nil + if loadErr := testmeasure.PreloadResourcesOnly(ctx, e); loadErr != nil { + return errors.WithStack(loadErr) + } + return loadSchema(indexRuleBindingDir, &databasev1.IndexRuleBinding{}, func(irb *databasev1.IndexRuleBinding) error { + return e.CreateIndexRuleBinding(ctx, irb) + }) } func loadSchema[T proto.Message](dir string, resource T, loadFn func(resource T) error) error { @@ -85,21 +63,19 @@ func loadSchema[T proto.Message](dir string, resource T, loadFn func(resource T) return err } for _, entry := range entries { - data, err := store.ReadFile(path.Join(dir, entry.Name())) - if err != nil { - return err + data, readErr := store.ReadFile(path.Join(dir, entry.Name())) + if readErr != nil { + return readErr } - // Create a new instance for each file to avoid race conditions - // when the callback holds a reference to the resource newResource := newProtoMessage(resource) - if err := protojson.Unmarshal(data, newResource); err != nil { - return err + if unmarshalErr := protojson.Unmarshal(data, newResource); unmarshalErr != nil { + return unmarshalErr } - if err := loadFn(newResource); err != nil { - if errors.Is(err, schema.ErrGRPCAlreadyExists) { + if loadErr := loadFn(newResource); loadErr != nil { + if errors.Is(loadErr, schema.ErrGRPCAlreadyExists) { continue } - return err + return loadErr } } return nil diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/endpoint_traffic.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/endpoint_traffic.json deleted file mode 100644 index 2633d4a54..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/endpoint_traffic.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "endpoint_traffic", - "group": "sw_metric" - }, - "rules": [ - "endpoint_name" - ], - "subject": { - "catalog": "CATALOG_MEASURE", - "name": "endpoint_traffic" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_day.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_day.json deleted file mode 100644 index 2115e3e13..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_day.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_day", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_cpm_day" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_hour.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_hour.json deleted file mode 100644 index 6c5ae3620..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_hour.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_hour", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_cpm_hour" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute.json deleted file mode 100644 index ad560c86e..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_cpm_minute" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute_spec.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute_spec.json deleted file mode 100644 index 3435c6451..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute_spec.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_spec" - }, - "rules": ["id"], - "subject": { - "catalog": "CATALOG_MEASURE", - "name": "service_cpm_minute" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} - diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute_spec2.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute_spec2.json deleted file mode 100644 index 24576d3f1..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_cpm_minute_spec2.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_spec2" - }, - "rules": ["id"], - "subject": { - "catalog": "CATALOG_MEASURE", - "name": "service_cpm_minute" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} - diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_day.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_day.json deleted file mode 100644 index 4fb9123e4..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_day.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_day", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_instance_cpm_day" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_hour.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_hour.json deleted file mode 100644 index b9b40c3f4..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_hour.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_hour", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_instance_cpm_hour" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_minute.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_minute.json deleted file mode 100644 index 8aa4f2377..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_cpm_minute.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_minute", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_instance_cpm_minute" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_endpoint_cpm_minute.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_endpoint_cpm_minute.json deleted file mode 100644 index 54ff83e52..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_endpoint_cpm_minute.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_instance_endpoint_cpm_minute", - "group": "sw_metric" - }, - "rules": [ - "id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_instance_endpoint_cpm_minute" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_latency_minute.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_latency_minute.json deleted file mode 100644 index dfc621d21..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_latency_minute.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "service_instance_latency_minute", - "group": "sw_metric" - }, - "rules": [ - "service_id" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_instance_latency_minute" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_traffic.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_traffic.json deleted file mode 100644 index 249c1f8f4..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_instance_traffic.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "metadata": { - "name": "service_instance_traffic_rule_binding", - "group": "sw_metric" - }, - "rules": [ - "service_id", - "searchable_name" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_instance_traffic" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_traffic.json b/pkg/test/replicated/measure/testdata/index_rule_bindings/service_traffic.json deleted file mode 100644 index 08b65e0d6..000000000 --- a/pkg/test/replicated/measure/testdata/index_rule_bindings/service_traffic.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "metadata": { - "name": "service_traffic_rule_binding", - "group": "index_mode" - }, - "rules": [ - "service_id", - "layer" - ], - "subject":{ - "catalog": "CATALOG_MEASURE", - "name": "service_traffic" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rules/endpoint_name.json b/pkg/test/replicated/measure/testdata/index_rules/endpoint_name.json deleted file mode 100644 index b75806a7e..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/endpoint_name.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "metadata": { - "id": 5, - "name": "endpoint_name", - "group": "sw_metric" - }, - "tags": [ - "endpoint_name" - ], - "type": "TYPE_INVERTED", - "analyzer": "url", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/index_rules/id.json b/pkg/test/replicated/measure/testdata/index_rules/id.json deleted file mode 100644 index c676824d6..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/id.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 4, - "name": "id", - "group": "sw_metric" - }, - "tags": [ - "id" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rules/id_spec.json b/pkg/test/replicated/measure/testdata/index_rules/id_spec.json deleted file mode 100644 index 74743d9e2..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/id_spec.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "metadata": { - "id": 4, - "name": "id", - "group": "sw_spec" - }, - "tags": ["id"], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rules/id_spec2.json b/pkg/test/replicated/measure/testdata/index_rules/id_spec2.json deleted file mode 100644 index 0a3211050..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/id_spec2.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "metadata": { - "id": 4, - "name": "id", - "group": "sw_spec2" - }, - "tags": ["id"], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rules/im_service_id.json b/pkg/test/replicated/measure/testdata/index_rules/im_service_id.json deleted file mode 100644 index 549a4037d..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/im_service_id.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 1, - "name": "service_id", - "group": "index_mode" - }, - "tags": [ - "service_id" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rules/layer.json b/pkg/test/replicated/measure/testdata/index_rules/layer.json deleted file mode 100644 index dbf70d7ab..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/layer.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 3, - "name": "layer", - "group": "index_mode" - }, - "tags": [ - "layer" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/index_rules/searchable_name.json b/pkg/test/replicated/measure/testdata/index_rules/searchable_name.json deleted file mode 100644 index 73c3a2f26..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/searchable_name.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "metadata": { - "id": 2, - "name": "searchable_name", - "group": "sw_metric" - }, - "tags": [ - "name" - ], - "type": "TYPE_INVERTED", - "analyzer": "url", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/index_rules/service_id.json b/pkg/test/replicated/measure/testdata/index_rules/service_id.json deleted file mode 100644 index c8088dd24..000000000 --- a/pkg/test/replicated/measure/testdata/index_rules/service_id.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 1, - "name": "service_id", - "group": "sw_metric" - }, - "tags": [ - "service_id" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/measures/duplicated.json b/pkg/test/replicated/measure/testdata/measures/duplicated.json deleted file mode 100644 index e25f0a372..000000000 --- a/pkg/test/replicated/measure/testdata/measures/duplicated.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "metadata": { - "name": "duplicated", - "group": "exception" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/endpoint_resp_time_minute.json b/pkg/test/replicated/measure/testdata/measures/endpoint_resp_time_minute.json deleted file mode 100644 index 1de19aaee..000000000 --- a/pkg/test/replicated/measure/testdata/measures/endpoint_resp_time_minute.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "metadata": { - "name": "endpoint_resp_time_minute", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "sharding_key": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/endpoint_traffic.json b/pkg/test/replicated/measure/testdata/measures/endpoint_traffic.json deleted file mode 100644 index 2c240557b..000000000 --- a/pkg/test/replicated/measure/testdata/measures/endpoint_traffic.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "metadata": { - "name": "endpoint_traffic", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_name", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "entity": { - "tag_names": [ - "service_id", - "endpoint_name" - ] - }, - "updated_at": "2024-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/instance_clr_cpu_minute.json b/pkg/test/replicated/measure/testdata/measures/instance_clr_cpu_minute.json deleted file mode 100644 index 24b3c5a6b..000000000 --- a/pkg/test/replicated/measure/testdata/measures/instance_clr_cpu_minute.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "entity": { - "tagNames": [ - "entity_id" - ] - }, - "fields": [ - { - "compressionMethod": "COMPRESSION_METHOD_ZSTD", - "encodingMethod": "ENCODING_METHOD_GORILLA", - "fieldType": "FIELD_TYPE_FLOAT", - "name": "summation" - }, - { - "compressionMethod": "COMPRESSION_METHOD_ZSTD", - "encodingMethod": "ENCODING_METHOD_GORILLA", - "fieldType": "FIELD_TYPE_INT", - "name": "count" - }, - { - "compressionMethod": "COMPRESSION_METHOD_ZSTD", - "encodingMethod": "ENCODING_METHOD_GORILLA", - "fieldType": "FIELD_TYPE_FLOAT", - "name": "value" - } - ], - "interval": "1m", - "metadata": { - "group": "sw_metric", - "name": "instance_clr_cpu_minute" - }, - "tagFamilies": [ - { - "name": "default", - "tags": [ - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_cpm_day.json b/pkg/test/replicated/measure/testdata/measures/service_cpm_day.json deleted file mode 100644 index 1f3f82093..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_cpm_day.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_day", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "24h", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_cpm_hour.json b/pkg/test/replicated/measure/testdata/measures/service_cpm_hour.json deleted file mode 100644 index 5e506ddf9..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_cpm_hour.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_hour", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1h", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute.json b/pkg/test/replicated/measure/testdata/measures/service_cpm_minute.json deleted file mode 100644 index 9ca254a1e..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_spec.json b/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_spec.json deleted file mode 100644 index 450990cf5..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_spec.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_spec" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": ["entity_id"] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_spec2.json b/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_spec2.json deleted file mode 100644 index d5a8b4037..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_spec2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_spec2" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": ["entity_id"] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_updated.json b/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_updated.json deleted file mode 100644 index 3d0d6cb95..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_cpm_minute_updated.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "metadata": { - "name": "service_cpm_minute", - "group": "sw_updated" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "entity_id", - "type": "TAG_TYPE_INT" - }, - { - "name": "extra_tag", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "extra_field", - "field_type": "FIELD_TYPE_STRING", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1m", - "updated_at": "2024-06-01T00:00:00Z" -} diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_day.json b/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_day.json deleted file mode 100644 index f93380a33..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_day.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_day", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "service_id", - "entity_id" - ] - }, - "interval": "24h", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_hour.json b/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_hour.json deleted file mode 100644 index 753d0a957..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_hour.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_hour", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "service_id", - "entity_id" - ] - }, - "interval": "1h", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_minute.json b/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_minute.json deleted file mode 100644 index 7c032704d..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_minute.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_minute", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "service_id", - "entity_id" - ] - }, - "sharding_key": { - "tag_names": [ - "service_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_minute_updated.json b/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_minute_updated.json deleted file mode 100644 index 1bc84febe..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_cpm_minute_updated.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "metadata": { - "name": "service_instance_cpm_minute", - "group": "sw_updated" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "service_id", - "entity_id" - ] - }, - "sharding_key": { - "tag_names": [ - "service_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_endpoint_cpm_minute.json b/pkg/test/replicated/measure/testdata/measures/service_instance_endpoint_cpm_minute.json deleted file mode 100644 index 47eadcee4..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_endpoint_cpm_minute.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "metadata": { - "name": "service_instance_endpoint_cpm_minute", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "http.uri", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "service_id", - "entity_id" - ] - }, - "sharding_key": { - "tag_names": [ - "service_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_latency_minute.json b/pkg/test/replicated/measure/testdata/measures/service_instance_latency_minute.json deleted file mode 100644 index 59ce77bc8..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_latency_minute.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "metadata": { - "name": "service_instance_latency_minute", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1m", - "updated_at": "2024-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_instance_traffic.json b/pkg/test/replicated/measure/testdata/measures/service_instance_traffic.json deleted file mode 100644 index 1b8961173..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_instance_traffic.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "metadata": { - "name": "service_instance_traffic", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "last_ping", - "type": "TAG_TYPE_INT" - }, - { - "name": "layer", - "type": "TAG_TYPE_INT" - } - ] - } - ], - "entity": { - "tag_names": [ - "id" - ] - }, - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_latency_minute.json b/pkg/test/replicated/measure/testdata/measures/service_latency_minute.json deleted file mode 100644 index 46ddf59cc..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_latency_minute.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "metadata": { - "name": "service_latency_minute", - "group": "sw_metric" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - } - ] - }, - { - "name": "storage_only", - "tags": [ - { - "name": "entity_id", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "fields": [ - { - "name": "total", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - }, - { - "name": "value", - "field_type": "FIELD_TYPE_INT", - "encoding_method": "ENCODING_METHOD_GORILLA", - "compression_method": "COMPRESSION_METHOD_ZSTD" - } - ], - "entity": { - "tag_names": [ - "entity_id" - ] - }, - "interval": "1m", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_traffic.json b/pkg/test/replicated/measure/testdata/measures/service_traffic.json deleted file mode 100644 index 1cf0608b3..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_traffic.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "metadata": { - "name": "service_traffic", - "group": "index_mode" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "short_name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_group", - "type": "TAG_TYPE_STRING" - }, - { - "name": "layer", - "type": "TAG_TYPE_INT" - } - ] - } - ], - "entity": { - "tag_names": [ - "id" - ] - }, - "index_mode": true, - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/measure/testdata/measures/service_traffic_replicated.json b/pkg/test/replicated/measure/testdata/measures/service_traffic_replicated.json deleted file mode 100644 index 73082adba..000000000 --- a/pkg/test/replicated/measure/testdata/measures/service_traffic_replicated.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "metadata": { - "name": "service_traffic", - "group": "replicated_group" - }, - "tag_families": [ - { - "name": "default", - "tags": [ - { - "name": "id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "short_name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_group", - "type": "TAG_TYPE_STRING" - }, - { - "name": "layer", - "type": "TAG_TYPE_INT" - } - ] - } - ], - "entity": { - "tag_names": [ - "id" - ] - }, - "index_mode": true, - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/etcd.go b/pkg/test/replicated/stream/etcd.go index 70e6edb18..8da2e4feb 100644 --- a/pkg/test/replicated/stream/etcd.go +++ b/pkg/test/replicated/stream/etcd.go @@ -20,100 +20,25 @@ package replicatedstream import ( "context" - "embed" + _ "embed" "encoding/json" "errors" - "path" "google.golang.org/protobuf/encoding/protojson" commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1" - databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1" "github.com/apache/skywalking-banyandb/banyand/metadata/schema" "github.com/apache/skywalking-banyandb/pkg/logger" -) - -const ( - streamDir = "testdata/streams" - indexRuleDir = "testdata/index_rules" - indexRuleBindingDir = "testdata/index_rule_bindings" + teststream "github.com/apache/skywalking-banyandb/pkg/test/stream" ) var ( - //go:embed testdata/index_rules/*.json - indexRuleStore embed.FS - //go:embed testdata/index_rule_bindings/*.json - indexRuleBindingStore embed.FS - //go:embed testdata/streams/*.json - streamStore embed.FS //go:embed testdata/group.json groupJSON string //go:embed testdata/group_with_stages.json groupWithStagesJSON string ) -// loadSchemas loads streams, index rules, and index rule bindings. -func loadSchemas(ctx context.Context, e schema.Registry) error { - streams, err := streamStore.ReadDir(streamDir) - if err != nil { - return err - } - var data []byte - for _, entry := range streams { - data, err = streamStore.ReadFile(path.Join(streamDir, entry.Name())) - if err != nil { - return err - } - var stream databasev1.Stream - err = protojson.Unmarshal(data, &stream) - if err != nil { - return err - } - if _, innerErr := e.CreateStream(ctx, &stream); innerErr != nil { - return innerErr - } - } - - entries, err := indexRuleStore.ReadDir(indexRuleDir) - if err != nil { - return err - } - for _, entry := range entries { - data, err = indexRuleStore.ReadFile(path.Join(indexRuleDir, entry.Name())) - if err != nil { - return err - } - var idxRule databasev1.IndexRule - err = protojson.Unmarshal(data, &idxRule) - if err != nil { - return err - } - if innerErr := e.CreateIndexRule(ctx, &idxRule); innerErr != nil { - return innerErr - } - } - indexRulesBindings, err := indexRuleBindingStore.ReadDir(indexRuleBindingDir) - if err != nil { - return err - } - for _, entry := range indexRulesBindings { - data, err = indexRuleBindingStore.ReadFile(path.Join(indexRuleBindingDir, entry.Name())) - if err != nil { - return err - } - var idxRuleBinding databasev1.IndexRuleBinding - err = protojson.Unmarshal(data, &idxRuleBinding) - if err != nil { - return err - } - if innerErr := e.CreateIndexRuleBinding(ctx, &idxRuleBinding); innerErr != nil { - return innerErr - } - } - - return nil -} - // LoadSchemaWithStages loads schemas from files, including group stages. func LoadSchemaWithStages(ctx context.Context, e schema.Registry) error { if e == nil { @@ -137,7 +62,7 @@ func LoadSchemaWithStages(ctx context.Context, e schema.Registry) error { return innerErr } } - return loadSchemas(ctx, e) + return teststream.PreloadResourcesOnly(ctx, e) } // PreloadSchema loads schemas from files in the booting process. @@ -164,6 +89,5 @@ func PreloadSchema(ctx context.Context, e schema.Registry) error { return innerErr } } - - return loadSchemas(ctx, e) + return teststream.PreloadResourcesOnly(ctx, e) } diff --git a/pkg/test/replicated/stream/testdata/index_rule_bindings/deduplication_test.json b/pkg/test/replicated/stream/testdata/index_rule_bindings/deduplication_test.json deleted file mode 100644 index 3953595c6..000000000 --- a/pkg/test/replicated/stream/testdata/index_rule_bindings/deduplication_test.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "metadata": { - "name": "deduplication_test-rule-binding", - "group": "default" - }, - "rules": [ - "trace_id", - "duration" - ], - "subject": { - "catalog": "CATALOG_STREAM", - "name": "deduplication_test" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/stream/testdata/index_rule_bindings/duplicated.json b/pkg/test/replicated/stream/testdata/index_rule_bindings/duplicated.json deleted file mode 100644 index bc741e5ae..000000000 --- a/pkg/test/replicated/stream/testdata/index_rule_bindings/duplicated.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "metadata": { - "name": "duplicated-rule-binding", - "group": "default" - }, - "rules": [ - "trace_id", - "duration" - ], - "subject":{ - "catalog": "CATALOG_STREAM", - "name": "duplicated" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rule_bindings/sw.json b/pkg/test/replicated/stream/testdata/index_rule_bindings/sw.json deleted file mode 100644 index e0d21b535..000000000 --- a/pkg/test/replicated/stream/testdata/index_rule_bindings/sw.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "metadata": { - "name": "sw-index-rule-binding", - "group": "default" - }, - "rules": [ - "trace_id", - "duration", - "endpoint_id", - "status_code", - "http.method", - "db.instance", - "db.type", - "mq.broker", - "mq.queue", - "mq.topic", - "extended_tags" - ], - "subject":{ - "catalog": "CATALOG_STREAM", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rule_bindings/sw_spec.json b/pkg/test/replicated/stream/testdata/index_rule_bindings/sw_spec.json deleted file mode 100644 index ba14f6933..000000000 --- a/pkg/test/replicated/stream/testdata/index_rule_bindings/sw_spec.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "metadata": { - "name": "sw-spec-index-rule-binding", - "group": "default-spec" - }, - "rules": [ - "trace_id", - "duration", - "endpoint_id", - "status_code", - "http.method", - "db.instance", - "db.type", - "mq.broker", - "mq.queue", - "mq.topic", - "extended_tags" - ], - "subject": { - "catalog": "CATALOG_STREAM", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} - diff --git a/pkg/test/replicated/stream/testdata/index_rule_bindings/sw_spec2.json b/pkg/test/replicated/stream/testdata/index_rule_bindings/sw_spec2.json deleted file mode 100644 index c645efc96..000000000 --- a/pkg/test/replicated/stream/testdata/index_rule_bindings/sw_spec2.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "metadata": { - "name": "sw-spec2-index-rule-binding", - "group": "default-spec2" - }, - "rules": [ - "trace_id", - "duration", - "endpoint_id", - "status_code", - "http.method", - "db.instance", - "db.type", - "mq.broker", - "mq.queue", - "mq.topic", - "extended_tags" - ], - "subject": { - "catalog": "CATALOG_STREAM", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rule_bindings/updated.json b/pkg/test/replicated/stream/testdata/index_rule_bindings/updated.json deleted file mode 100644 index 9eb12e762..000000000 --- a/pkg/test/replicated/stream/testdata/index_rule_bindings/updated.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "sw-index-rule-binding", - "group": "updated" - }, - "rules": [ - "duration" - ], - "subject":{ - "catalog": "CATALOG_STREAM", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/db.instance.json b/pkg/test/replicated/stream/testdata/index_rules/db.instance.json deleted file mode 100644 index 85c3c6ada..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/db.instance.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "metadata": { - "id": 1, - "name": "db.instance", - "group": "default" - }, - "tags": [ - "db.instance" - ], - "type": "TYPE_INVERTED", - "analyzer": "url", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/db.type.json b/pkg/test/replicated/stream/testdata/index_rules/db.type.json deleted file mode 100644 index 8e39ca3ba..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/db.type.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 2, - "name": "db.type", - "group": "default" - }, - "tags": [ - "db.type" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/duration.json b/pkg/test/replicated/stream/testdata/index_rules/duration.json deleted file mode 100644 index baae3592c..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/duration.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 3, - "name": "duration", - "group": "default" - }, - "tags": [ - "duration" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/duration_updated.json b/pkg/test/replicated/stream/testdata/index_rules/duration_updated.json deleted file mode 100644 index d9980a3ce..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/duration_updated.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 3, - "name": "duration", - "group": "updated" - }, - "tags": [ - "duration" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/endpoint_id.json b/pkg/test/replicated/stream/testdata/index_rules/endpoint_id.json deleted file mode 100644 index a82ec86a5..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/endpoint_id.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 4, - "name": "endpoint_id", - "group": "default" - }, - "tags": [ - "endpoint_id" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/extended_tags.json b/pkg/test/replicated/stream/testdata/index_rules/extended_tags.json deleted file mode 100644 index e0ee4f66e..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/extended_tags.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 11, - "name": "extended_tags", - "group": "default" - }, - "tags": [ - "extended_tags" - ], - "type": "TYPE_INVERTED", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/http.method.json b/pkg/test/replicated/stream/testdata/index_rules/http.method.json deleted file mode 100644 index 23bc230e9..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/http.method.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 6, - "name": "http.method", - "group": "default" - }, - "tags": [ - "http.method" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/mq.broker.json b/pkg/test/replicated/stream/testdata/index_rules/mq.broker.json deleted file mode 100644 index 1fd748d6b..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/mq.broker.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 7, - "name": "mq.broker", - "group": "default" - }, - "tags": [ - "mq.broker" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/mq.queue.json b/pkg/test/replicated/stream/testdata/index_rules/mq.queue.json deleted file mode 100644 index beb77bb49..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/mq.queue.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 8, - "name": "mq.queue", - "group": "default" - }, - "tags": [ - "mq.queue" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/mq.topic.json b/pkg/test/replicated/stream/testdata/index_rules/mq.topic.json deleted file mode 100644 index cc5544ddf..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/mq.topic.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 9, - "name": "mq.topic", - "group": "default" - }, - "tags": [ - "mq.topic" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/status_code.json b/pkg/test/replicated/stream/testdata/index_rules/status_code.json deleted file mode 100644 index ccaa9f8de..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/status_code.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 5, - "name": "status_code", - "group": "default" - }, - "tags": [ - "status_code" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/index_rules/trace_id.json b/pkg/test/replicated/stream/testdata/index_rules/trace_id.json deleted file mode 100644 index df92f0f94..000000000 --- a/pkg/test/replicated/stream/testdata/index_rules/trace_id.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "metadata": { - "id": 10, - "name": "trace_id", - "group": "default" - }, - "tags": [ - "trace_id" - ], - "type": "TYPE_SKIPPING", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/streams/deduplication_test.json b/pkg/test/replicated/stream/testdata/streams/deduplication_test.json deleted file mode 100644 index 81ff1fb04..000000000 --- a/pkg/test/replicated/stream/testdata/streams/deduplication_test.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "metadata": { - "name": "deduplication_test", - "group": "default" - }, - "tag_families": [ - { - "name": "data", - "tags": [ - { - "name": "data_binary", - "type": "TAG_TYPE_DATA_BINARY" - } - ] - }, - { - "name": "searchable", - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - } - ] - } - ], - "entity": { - "tag_names": [ - "service_id", - "service_instance_id", - "state" - ] - }, - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/streams/duplicated.json b/pkg/test/replicated/stream/testdata/streams/duplicated.json deleted file mode 100644 index 90ac019b5..000000000 --- a/pkg/test/replicated/stream/testdata/streams/duplicated.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "metadata": { - "name": "duplicated", - "group": "default" - }, - "tag_families": [ - { - "name": "data", - "tags": [ - { - "name": "data_binary", - "type": "TAG_TYPE_DATA_BINARY" - } - ] - }, - { - "name": "searchable", - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - } - ] - } - ], - "entity": { - "tag_names": [ - "service_id", - "service_instance_id", - "state" - ] - }, - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/stream/testdata/streams/sw.json b/pkg/test/replicated/stream/testdata/streams/sw.json deleted file mode 100644 index e590e7821..000000000 --- a/pkg/test/replicated/stream/testdata/streams/sw.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "default" - }, - "tag_families": [ - { - "name": "data", - "tags": [ - { - "name": "data_binary", - "type": "TAG_TYPE_DATA_BINARY" - } - ] - }, - { - "name": "searchable", - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "start_time", - "type": "TAG_TYPE_INT" - }, - { - "name": "http.method", - "type": "TAG_TYPE_STRING" - }, - { - "name": "status_code", - "type": "TAG_TYPE_INT" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.type", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.instance", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.queue", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.topic", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.broker", - "type": "TAG_TYPE_STRING" - }, - { - "name": "extended_tags", - "type": "TAG_TYPE_STRING_ARRAY" - }, - { - "name": "non_indexed_tags", - "type": "TAG_TYPE_STRING_ARRAY" - } - ] - } - ], - "entity": { - "tag_names": [ - "service_id", - "service_instance_id", - "state" - ] - }, - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/stream/testdata/streams/sw_spec.json b/pkg/test/replicated/stream/testdata/streams/sw_spec.json deleted file mode 100644 index 31b7b58f5..000000000 --- a/pkg/test/replicated/stream/testdata/streams/sw_spec.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "default-spec" - }, - "tag_families": [ - { - "name": "data", - "tags": [ - { - "name": "data_binary", - "type": "TAG_TYPE_DATA_BINARY" - } - ] - }, - { - "name": "searchable", - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "start_time", - "type": "TAG_TYPE_INT" - }, - { - "name": "http.method", - "type": "TAG_TYPE_STRING" - }, - { - "name": "status_code", - "type": "TAG_TYPE_STRING" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.type", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.instance", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.queue", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.topic", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.broker", - "type": "TAG_TYPE_STRING" - }, - { - "name": "extended_tags", - "type": "TAG_TYPE_STRING_ARRAY" - }, - { - "name": "non_indexed_tags", - "type": "TAG_TYPE_STRING_ARRAY" - } - ] - } - ], - "entity": { - "tag_names": ["service_id", "service_instance_id", "state"] - }, - "updated_at": "2021-04-15T01:30:15.01Z" -} - diff --git a/pkg/test/replicated/stream/testdata/streams/sw_spec2.json b/pkg/test/replicated/stream/testdata/streams/sw_spec2.json deleted file mode 100644 index 6f4fd30cd..000000000 --- a/pkg/test/replicated/stream/testdata/streams/sw_spec2.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "default-spec2" - }, - "tag_families": [ - { - "name": "data", - "tags": [ - { - "name": "data_binary", - "type": "TAG_TYPE_DATA_BINARY" - } - ] - }, - { - "name": "searchable", - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "start_time", - "type": "TAG_TYPE_INT" - }, - { - "name": "http.method", - "type": "TAG_TYPE_STRING" - }, - { - "name": "status_code", - "type": "TAG_TYPE_STRING" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.type", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.instance", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.queue", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.topic", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.broker", - "type": "TAG_TYPE_STRING" - }, - { - "name": "extended_tags", - "type": "TAG_TYPE_STRING_ARRAY" - }, - { - "name": "non_indexed_tags", - "type": "TAG_TYPE_STRING_ARRAY" - } - ] - } - ], - "entity": { - "tag_names": ["service_id", "service_instance_id", "state"] - }, - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/stream/testdata/streams/sw_updated.json b/pkg/test/replicated/stream/testdata/streams/sw_updated.json deleted file mode 100644 index 46731df94..000000000 --- a/pkg/test/replicated/stream/testdata/streams/sw_updated.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "updated" - }, - "tag_families": [ - { - "name": "data", - "tags": [ - { - "name": "data_binary", - "type": "TAG_TYPE_DATA_BINARY" - } - ] - }, - { - "name": "searchable", - "tags": [ - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "http.method", - "type": "TAG_TYPE_STRING" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.type", - "type": "TAG_TYPE_STRING" - }, - { - "name": "db.instance", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.topic", - "type": "TAG_TYPE_STRING" - }, - { - "name": "mq.broker", - "type": "TAG_TYPE_STRING" - }, - { - "name": "extended_tags", - "type": "TAG_TYPE_STRING_ARRAY" - }, - { - "name": "new_tag", - "type": "TAG_TYPE_STRING" - }, - { - "name": "status_code", - "type": "TAG_TYPE_STRING" - } - ] - } - ], - "entity": { - "tag_names": [ - "service_id", - "service_instance_id", - "state" - ] - }, - "updated_at": "2024-06-10T12:00:00Z" -} diff --git a/pkg/test/replicated/trace/etcd.go b/pkg/test/replicated/trace/etcd.go index adc4c2463..b528fe7dd 100644 --- a/pkg/test/replicated/trace/etcd.go +++ b/pkg/test/replicated/trace/etcd.go @@ -29,66 +29,23 @@ import ( "google.golang.org/protobuf/proto" commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1" - databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1" "github.com/apache/skywalking-banyandb/banyand/metadata/schema" + testtrace "github.com/apache/skywalking-banyandb/pkg/test/trace" ) -const ( - groupDir = "testdata/groups" - groupStagesDir = "testdata/groups_stages" - traceDir = "testdata/traces" - indexRuleDir = "testdata/index_rules" - indexRuleBindingDir = "testdata/index_rule_bindings" -) +const groupDir = "testdata/groups" //go:embed testdata/* var store embed.FS // PreloadSchema loads schemas from files in the booting process. func PreloadSchema(ctx context.Context, e schema.Registry) error { - return loadAllSchemas(ctx, e, groupDir) -} - -// PreloadSchemaWithStages loads group schemas with stages from files in the booting process. -func PreloadSchemaWithStages(ctx context.Context, e schema.Registry) error { - return loadAllSchemas(ctx, e, groupStagesDir) -} - -// loadAllSchemas loads all trace-related schemas from the testdata directory. -func loadAllSchemas(ctx context.Context, e schema.Registry, group string) error { - return preloadSchemaWithFuncs(ctx, e, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(group, &commonv1.Group{}, func(group *commonv1.Group) error { - return e.CreateGroup(ctx, group) - }) - }, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(traceDir, &databasev1.Trace{}, func(trace *databasev1.Trace) error { - _, innerErr := e.CreateTrace(ctx, trace) - return innerErr - }) - }, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(indexRuleDir, &databasev1.IndexRule{}, func(indexRule *databasev1.IndexRule) error { - return e.CreateIndexRule(ctx, indexRule) - }) - }, - func(ctx context.Context, e schema.Registry) error { - return loadSchema(indexRuleBindingDir, &databasev1.IndexRuleBinding{}, func(indexRuleBinding *databasev1.IndexRuleBinding) error { - return e.CreateIndexRuleBinding(ctx, indexRuleBinding) - }) - }, - ) -} - -// preloadSchemaWithFuncs extracts the common logic for loading schemas. -func preloadSchemaWithFuncs(ctx context.Context, e schema.Registry, loaders ...func(context.Context, schema.Registry) error) error { - for _, loader := range loaders { - if err := loader(ctx, e); err != nil { - return errors.WithStack(err) - } + if err := loadSchema(groupDir, &commonv1.Group{}, func(group *commonv1.Group) error { + return e.CreateGroup(ctx, group) + }); err != nil { + return errors.WithStack(err) } - return nil + return errors.WithStack(testtrace.PreloadResourcesOnly(ctx, e)) } func loadSchema[T proto.Message](dir string, resource T, loadFn func(resource T) error) error { @@ -97,21 +54,19 @@ func loadSchema[T proto.Message](dir string, resource T, loadFn func(resource T) return err } for _, entry := range entries { - data, err := store.ReadFile(path.Join(dir, entry.Name())) - if err != nil { - return err + data, readErr := store.ReadFile(path.Join(dir, entry.Name())) + if readErr != nil { + return readErr } - // Create a new instance for each file to avoid race conditions - // when the callback holds a reference to the resource newResource := newProtoMessage(resource) - if err := protojson.Unmarshal(data, newResource); err != nil { - return err + if unmarshalErr := protojson.Unmarshal(data, newResource); unmarshalErr != nil { + return unmarshalErr } - if err := loadFn(newResource); err != nil { - if errors.Is(err, schema.ErrGRPCAlreadyExists) { + if loadErr := loadFn(newResource); loadErr != nil { + if errors.Is(loadErr, schema.ErrGRPCAlreadyExists) { continue } - return err + return loadErr } } return nil diff --git a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw.json b/pkg/test/replicated/trace/testdata/index_rule_bindings/sw.json deleted file mode 100644 index 7955985b2..000000000 --- a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "metadata": { - "name": "sw-index-rule-binding", - "group": "test-trace-group" - }, - "rules": [ - "duration", - "timestamp" - ], - "subject": { - "catalog": "CATALOG_TRACE", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_spec.json b/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_spec.json deleted file mode 100644 index 810c1612e..000000000 --- a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "sw-spec-index-rule-binding", - "group": "test-trace-spec" - }, - "rules": ["duration", "timestamp"], - "subject": { - "catalog": "CATALOG_TRACE", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_spec2.json b/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_spec2.json deleted file mode 100644 index 4daee2a9f..000000000 --- a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_spec2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "sw-spec2-index-rule-binding", - "group": "test-trace-spec2" - }, - "rules": ["duration", "timestamp"], - "subject": { - "catalog": "CATALOG_TRACE", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_updated.json b/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_updated.json deleted file mode 100644 index c611a4903..000000000 --- a/pkg/test/replicated/trace/testdata/index_rule_bindings/sw_updated.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "metadata": { - "name": "sw-updated-index-rule-binding", - "group": "test-trace-updated" - }, - "rules": [ - "duration", - "timestamp" - ], - "subject": { - "catalog": "CATALOG_TRACE", - "name": "sw" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rule_bindings/zipkin.json b/pkg/test/replicated/trace/testdata/index_rule_bindings/zipkin.json deleted file mode 100644 index cf03fabbc..000000000 --- a/pkg/test/replicated/trace/testdata/index_rule_bindings/zipkin.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "metadata": { - "name": "zipkin-index-rule-binding", - "group": "zipkinTrace" - }, - "rules": [ - "zipkin-timestamp" - ], - "subject": { - "catalog": "CATALOG_TRACE", - "name": "zipkin" - }, - "begin_at": "2021-04-15T01:30:15.01Z", - "expire_at": "2121-04-15T01:30:15.01Z", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/duration.json b/pkg/test/replicated/trace/testdata/index_rules/duration.json deleted file mode 100644 index c9cb393ab..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/duration.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "duration", - "group": "test-trace-group" - }, - "tags": [ - "service_id", - "service_instance_id", - "state", - "duration" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/duration_spec.json b/pkg/test/replicated/trace/testdata/index_rules/duration_spec.json deleted file mode 100644 index a89781ee6..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/duration_spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "duration", - "group": "test-trace-spec" - }, - "tags": [ - "service_id", - "service_instance_id", - "state", - "duration" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/duration_spec2.json b/pkg/test/replicated/trace/testdata/index_rules/duration_spec2.json deleted file mode 100644 index 3d3240f35..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/duration_spec2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "metadata": { - "name": "duration", - "group": "test-trace-spec2" - }, - "tags": ["service_id", "service_instance_id", "state", "duration"], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/trace/testdata/index_rules/duration_updated.json b/pkg/test/replicated/trace/testdata/index_rules/duration_updated.json deleted file mode 100644 index d31796ad6..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/duration_updated.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "duration", - "group": "test-trace-updated" - }, - "tags": [ - "service_id", - "service_instance_id", - "state", - "duration" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/timestamp.json b/pkg/test/replicated/trace/testdata/index_rules/timestamp.json deleted file mode 100644 index be83e872e..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/timestamp.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "timestamp", - "group": "test-trace-group" - }, - "tags": [ - "service_id", - "service_instance_id", - "state", - "timestamp" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/timestamp_spec.json b/pkg/test/replicated/trace/testdata/index_rules/timestamp_spec.json deleted file mode 100644 index ba1a0e27d..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/timestamp_spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "timestamp", - "group": "test-trace-spec" - }, - "tags": [ - "service_id", - "service_instance_id", - "state", - "timestamp" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/timestamp_spec2.json b/pkg/test/replicated/trace/testdata/index_rules/timestamp_spec2.json deleted file mode 100644 index 45c896307..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/timestamp_spec2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "metadata": { - "name": "timestamp", - "group": "test-trace-spec2" - }, - "tags": ["service_id", "service_instance_id", "state", "timestamp"], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/trace/testdata/index_rules/timestamp_updated.json b/pkg/test/replicated/trace/testdata/index_rules/timestamp_updated.json deleted file mode 100644 index 2b947fa33..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/timestamp_updated.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "timestamp", - "group": "test-trace-updated" - }, - "tags": [ - "service_id", - "service_instance_id", - "state", - "timestamp" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/index_rules/zipkin-timestamp.json b/pkg/test/replicated/trace/testdata/index_rules/zipkin-timestamp.json deleted file mode 100644 index 98b483770..000000000 --- a/pkg/test/replicated/trace/testdata/index_rules/zipkin-timestamp.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "metadata": { - "name": "zipkin-timestamp", - "group": "zipkinTrace" - }, - "tags": [ - "local_endpoint_service_name", - "operation_name", - "kind", - "timestamp" - ], - "type": "TYPE_TREE", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/traces/sw.json b/pkg/test/replicated/trace/testdata/traces/sw.json deleted file mode 100644 index 4f501b9a5..000000000 --- a/pkg/test/replicated/trace/testdata/traces/sw.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "test-trace-group" - }, - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "timestamp", - "type": "TAG_TYPE_TIMESTAMP" - } - ], - "trace_id_tag_name": "trace_id", - "span_id_tag_name": "span_id", - "timestamp_tag_name": "timestamp", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/replicated/trace/testdata/traces/sw_spec.json b/pkg/test/replicated/trace/testdata/traces/sw_spec.json deleted file mode 100644 index 9b0841b72..000000000 --- a/pkg/test/replicated/trace/testdata/traces/sw_spec.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "test-trace-spec" - }, - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "timestamp", - "type": "TAG_TYPE_TIMESTAMP" - } - ], - "trace_id_tag_name": "trace_id", - "span_id_tag_name": "span_id", - "timestamp_tag_name": "timestamp", - "updated_at": "2021-04-15T01:30:15.01Z" -} - diff --git a/pkg/test/replicated/trace/testdata/traces/sw_spec2.json b/pkg/test/replicated/trace/testdata/traces/sw_spec2.json deleted file mode 100644 index c568dce6b..000000000 --- a/pkg/test/replicated/trace/testdata/traces/sw_spec2.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "test-trace-spec2" - }, - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_INT" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "timestamp", - "type": "TAG_TYPE_TIMESTAMP" - } - ], - "trace_id_tag_name": "trace_id", - "span_id_tag_name": "span_id", - "timestamp_tag_name": "timestamp", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/trace/testdata/traces/sw_updated.json b/pkg/test/replicated/trace/testdata/traces/sw_updated.json deleted file mode 100644 index 9d55e73b0..000000000 --- a/pkg/test/replicated/trace/testdata/traces/sw_updated.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "metadata": { - "name": "sw", - "group": "test-trace-updated" - }, - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "state", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "service_instance_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "endpoint_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "error_message", - "type": "TAG_TYPE_STRING" - }, - { - "name": "timestamp", - "type": "TAG_TYPE_TIMESTAMP" - } - ], - "trace_id_tag_name": "trace_id", - "span_id_tag_name": "span_id", - "timestamp_tag_name": "timestamp", - "updated_at": "2021-04-15T01:30:15.01Z" -} diff --git a/pkg/test/replicated/trace/testdata/traces/zipkin.json b/pkg/test/replicated/trace/testdata/traces/zipkin.json deleted file mode 100644 index bc832e0bb..000000000 --- a/pkg/test/replicated/trace/testdata/traces/zipkin.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "metadata": { - "name": "zipkin", - "group": "zipkinTrace" - }, - "tags": [ - { - "name": "trace_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "span_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "parent_id", - "type": "TAG_TYPE_STRING" - }, - { - "name": "operation_name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "kind", - "type": "TAG_TYPE_STRING" - }, - { - "name": "duration", - "type": "TAG_TYPE_INT" - }, - { - "name": "local_endpoint_service_name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "local_endpoint_ipv4", - "type": "TAG_TYPE_STRING" - }, - { - "name": "local_endpoint_port", - "type": "TAG_TYPE_INT" - }, - { - "name": "remote_endpoint_service_name", - "type": "TAG_TYPE_STRING" - }, - { - "name": "remote_endpoint_ipv4", - "type": "TAG_TYPE_STRING" - }, - { - "name": "remote_endpoint_port", - "type": "TAG_TYPE_INT" - }, - { - "name": "shared", - "type": "TAG_TYPE_INT" - }, - { - "name": "debug", - "type": "TAG_TYPE_INT" - }, - { - "name": "query", - "type": "TAG_TYPE_STRING_ARRAY" - }, - { - "name": "timestamp", - "type": "TAG_TYPE_TIMESTAMP" - } - ], - "trace_id_tag_name": "trace_id", - "span_id_tag_name": "span_id", - "timestamp_tag_name": "timestamp", - "updated_at": "2021-04-15T01:30:15.01Z" -} \ No newline at end of file diff --git a/pkg/test/stream/etcd.go b/pkg/test/stream/etcd.go index fca9c6c53..f70c5627a 100644 --- a/pkg/test/stream/etcd.go +++ b/pkg/test/stream/etcd.go @@ -52,6 +52,12 @@ var ( groupWithStagesJSON string ) +// PreloadResourcesOnly loads streams, index rules, and index rule bindings. +// It does NOT load groups. +func PreloadResourcesOnly(ctx context.Context, e schema.Registry) error { + return loadSchemas(ctx, e) +} + // loadSchemas loads streams, index rules, and index rule bindings. func loadSchemas(ctx context.Context, e schema.Registry) error { streams, err := streamStore.ReadDir(streamDir) diff --git a/pkg/test/trace/etcd.go b/pkg/test/trace/etcd.go index 414e8ef64..457272923 100644 --- a/pkg/test/trace/etcd.go +++ b/pkg/test/trace/etcd.go @@ -53,6 +53,29 @@ func PreloadSchemaWithStages(ctx context.Context, e schema.Registry) error { return loadAllSchemas(ctx, e, groupStagesDir) } +// PreloadResourcesOnly loads traces, index rules, and index rule bindings. +// It does NOT load groups. +func PreloadResourcesOnly(ctx context.Context, e schema.Registry) error { + return preloadSchemaWithFuncs(ctx, e, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(traceDir, &databasev1.Trace{}, func(trace *databasev1.Trace) error { + _, innerErr := e.CreateTrace(ctx, trace) + return innerErr + }) + }, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(indexRuleDir, &databasev1.IndexRule{}, func(indexRule *databasev1.IndexRule) error { + return e.CreateIndexRule(ctx, indexRule) + }) + }, + func(ctx context.Context, e schema.Registry) error { + return loadSchema(indexRuleBindingDir, &databasev1.IndexRuleBinding{}, func(indexRuleBinding *databasev1.IndexRuleBinding) error { + return e.CreateIndexRuleBinding(ctx, indexRuleBinding) + }) + }, + ) +} + // loadAllSchemas loads all trace-related schemas from the testdata directory. func loadAllSchemas(ctx context.Context, e schema.Registry, group string) error { return preloadSchemaWithFuncs(ctx, e,
