diff --git a/generated-source-files.mk b/generated-source-files.mk index b71eea6..7e809fb 100644 --- a/generated-source-files.mk +++ b/generated-source-files.mk @@ -40,7 +40,7 @@ genny-map-matcher-cache-elem: install-m3x-repo cd $(m3x_package_path) && make byteshashmap-gen \ pkg=cache \ value_type=elementPtr \ - out_dir=$(m3metrics_package_path)/matcher/cache \ + target_package=$(m3metrics_package)/matcher/cache \ rename_type_prefix=elem \ rename_constructor=newElemMap \ rename_constructor_options=elemMapOptions @@ -54,7 +54,7 @@ genny-map-matcher-namespace-results: install-m3x-repo cd $(m3x_package_path) && make byteshashmap-gen \ pkg=cache \ value_type=results \ - out_dir=$(m3metrics_package_path)/matcher/cache \ + target_package=$(m3metrics_package)/matcher/cache \ rename_type_prefix=namespaceResults \ rename_constructor=newNamespaceResultsMap \ rename_constructor_options=namespaceResultsMapOptions @@ -68,7 +68,7 @@ genny-map-matcher-namespace-rule-sets: install-m3x-repo cd $(m3x_package_path) && make byteshashmap-gen \ pkg=matcher \ value_type=RuleSet \ - out_dir=$(m3metrics_package_path)/matcher \ + target_package=$(m3metrics_package)/matcher \ rename_type_prefix=namespaceRuleSets \ rename_constructor=newNamespaceRuleSetsMap \ rename_constructor_options=namespaceRuleSetsMapOptions @@ -82,7 +82,7 @@ genny-map-matcher-rule-namespaces: install-m3x-repo cd $(m3x_package_path) && make byteshashmap-gen \ pkg=matcher \ value_type=rulesNamespace \ - out_dir=$(m3metrics_package_path)/matcher \ + target_package=$(m3metrics_package)/matcher \ rename_type_prefix=ruleNamespaces \ rename_constructor=newRuleNamespacesMap \ rename_constructor_options=ruleNamespacesMapOptions diff --git a/matcher/match_test.go b/matcher/match_test.go index d19fbd4..897060a 100644 --- a/matcher/match_test.go +++ b/matcher/match_test.go @@ -28,7 +28,7 @@ import ( "github.com/golang/mock/gomock" "github.com/m3db/m3cluster/kv" "github.com/m3db/m3cluster/kv/mem" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/matcher/cache" "github.com/m3db/m3metrics/rules" "github.com/m3db/m3x/clock" @@ -114,12 +114,12 @@ func testMatcher(t *testing.T, cache cache.Cache) Matcher { SetRuleSetKeyFn(defaultRuleSetKeyFn). SetRuleSetOptions(rules.NewOptions()). SetMatchRangePast(0) - proto = &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + proto = &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "fooNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: true, }, diff --git a/matcher/namespaces.go b/matcher/namespaces.go index 9c83ff4..b4bcdfa 100644 --- a/matcher/namespaces.go +++ b/matcher/namespaces.go @@ -28,7 +28,7 @@ import ( "github.com/m3db/m3cluster/kv" "github.com/m3db/m3cluster/kv/util/runtime" "github.com/m3db/m3metrics/aggregation" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/metric" "github.com/m3db/m3metrics/rules" "github.com/m3db/m3x/clock" @@ -105,7 +105,7 @@ type namespaces struct { onNamespaceAddedFn OnNamespaceAddedFn onNamespaceRemovedFn OnNamespaceRemovedFn - proto *schema.Namespaces + proto *rulepb.Namespaces rules *namespaceRuleSetsMap metrics namespacesMetrics } @@ -123,7 +123,7 @@ func NewNamespaces(key string, opts Options) Namespaces { matchRangePast: opts.MatchRangePast(), onNamespaceAddedFn: opts.OnNamespaceAddedFn(), onNamespaceRemovedFn: opts.OnNamespaceRemovedFn(), - proto: &schema.Namespaces{}, + proto: &rulepb.Namespaces{}, rules: newNamespaceRuleSetsMap(namespaceRuleSetsMapOptions{}), metrics: newNamespacesMetrics(instrumentOpts.MetricsScope()), } diff --git a/matcher/namespaces_test.go b/matcher/namespaces_test.go index fa83e67..0c002ed 100644 --- a/matcher/namespaces_test.go +++ b/matcher/namespaces_test.go @@ -30,7 +30,7 @@ import ( "github.com/m3db/m3cluster/kv" "github.com/m3db/m3cluster/kv/mem" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/matcher/cache" "github.com/m3db/m3metrics/rules" @@ -44,12 +44,12 @@ const ( func TestNamespacesWatchAndClose(t *testing.T) { store, _, nss, _ := testNamespaces() - proto := &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + proto := &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "fooNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: true, }, @@ -78,12 +78,12 @@ func TestToNamespacesUnmarshalError(t *testing.T) { func TestToNamespacesSuccess(t *testing.T) { store, _, nss, _ := testNamespaces() - proto := &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + proto := &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "fooNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: true, }, @@ -126,57 +126,57 @@ func TestNamespacesProcess(t *testing.T) { c.namespaces[string(input.namespace)] = memResults{source: rs} } - update := &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + update := &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "fooNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: false, }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 2, Tombstoned: false, }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "barNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: false, }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 2, Tombstoned: true, }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "bazNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: false, }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 2, Tombstoned: false, }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "catNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 3, Tombstoned: true, }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "mehNs", Snapshots: nil, }, diff --git a/matcher/ruleset.go b/matcher/ruleset.go index 062ad45..ee17f01 100644 --- a/matcher/ruleset.go +++ b/matcher/ruleset.go @@ -27,7 +27,7 @@ import ( "github.com/m3db/m3cluster/kv" "github.com/m3db/m3cluster/kv/util/runtime" "github.com/m3db/m3metrics/aggregation" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/metric" "github.com/m3db/m3metrics/rules" "github.com/m3db/m3x/clock" @@ -83,7 +83,7 @@ type ruleSet struct { ruleSetOpts rules.Options onRuleSetUpdatedFn OnRuleSetUpdatedFn - proto *schema.RuleSet + proto *rulepb.RuleSet version int cutoverNanos int64 tombstoned bool @@ -106,7 +106,7 @@ func newRuleSet( matchRangePast: opts.MatchRangePast(), ruleSetOpts: opts.RuleSetOptions(), onRuleSetUpdatedFn: opts.OnRuleSetUpdatedFn(), - proto: &schema.RuleSet{}, + proto: &rulepb.RuleSet{}, version: kv.UninitializedVersion, metrics: newRuleSetMetrics(instrumentOpts.MetricsScope(), instrumentOpts.MetricsSamplingRate()), } diff --git a/matcher/ruleset_test.go b/matcher/ruleset_test.go index e310c3e..03d1198 100644 --- a/matcher/ruleset_test.go +++ b/matcher/ruleset_test.go @@ -28,7 +28,7 @@ import ( "github.com/m3db/m3cluster/kv" "github.com/m3db/m3cluster/kv/mem" "github.com/m3db/m3metrics/aggregation" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/matcher/cache" "github.com/m3db/m3metrics/metric" "github.com/m3db/m3metrics/rules" @@ -114,7 +114,7 @@ func TestToRuleSetUnmarshalError(t *testing.T) { func TestToRuleSetSuccess(t *testing.T) { store, _, rs := testRuleSet() - proto := &schema.RuleSet{ + proto := &rulepb.RuleSet{ Namespace: string(testNamespace), Tombstoned: false, CutoverNanos: 123456, diff --git a/policy/policy.go b/policy/policy.go index 799c21c..1aac65b 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -26,7 +26,7 @@ import ( "strings" "github.com/m3db/m3metrics/aggregation" - schema "github.com/m3db/m3metrics/generated/proto/policypb" + "github.com/m3db/m3metrics/generated/proto/policypb" ) const ( @@ -53,7 +53,7 @@ func NewPolicy(sp StoragePolicy, aggID aggregation.ID) Policy { } // NewPolicyFromSchema creates a new policy from a schema policy. -func NewPolicyFromSchema(p *schema.Policy) (Policy, error) { +func NewPolicyFromSchema(p *policypb.Policy) (Policy, error) { if p == nil { return DefaultPolicy, errNilPolicySchema } @@ -73,8 +73,8 @@ func NewPolicyFromSchema(p *schema.Policy) (Policy, error) { } // Schema returns the schema of the policy. -func (p Policy) Schema() (*schema.Policy, error) { - var storagePolicyProto schema.StoragePolicy +func (p Policy) Schema() (*policypb.Policy, error) { + var storagePolicyProto policypb.StoragePolicy err := p.StoragePolicy.ToProto(&storagePolicyProto) if err != nil { return nil, err @@ -90,7 +90,7 @@ func (p Policy) Schema() (*schema.Policy, error) { return nil, err } - return &schema.Policy{ + return &policypb.Policy{ StoragePolicy: &storagePolicyProto, AggregationTypes: schemaAggTypes, }, nil @@ -170,7 +170,7 @@ func ParsePolicy(str string) (Policy, error) { } // NewPoliciesFromSchema creates multiple new policies from given schema policies. -func NewPoliciesFromSchema(policies []*schema.Policy) ([]Policy, error) { +func NewPoliciesFromSchema(policies []*policypb.Policy) ([]Policy, error) { res := make([]Policy, 0, len(policies)) for _, p := range policies { policy, err := NewPolicyFromSchema(p) diff --git a/policy/resolution.go b/policy/resolution.go index 4e4e56e..0eed30a 100644 --- a/policy/resolution.go +++ b/policy/resolution.go @@ -26,7 +26,7 @@ import ( "strings" "time" - schema "github.com/m3db/m3metrics/generated/proto/policypb" + "github.com/m3db/m3metrics/generated/proto/policypb" xtime "github.com/m3db/m3x/time" ) @@ -49,7 +49,7 @@ type Resolution struct { } // ToProto converts the resolution to a protobuf message in place. -func (r Resolution) ToProto(pb *schema.Resolution) error { +func (r Resolution) ToProto(pb *policypb.Resolution) error { precision, err := r.Precision.Value() if err != nil { return err @@ -60,7 +60,7 @@ func (r Resolution) ToProto(pb *schema.Resolution) error { } // FromProto converts the protobuf message to a resolution in place. -func (r *Resolution) FromProto(pb *schema.Resolution) error { +func (r *Resolution) FromProto(pb *policypb.Resolution) error { if pb == nil { return errNilResolutionProto } diff --git a/policy/retention.go b/policy/retention.go index c09a552..f586856 100644 --- a/policy/retention.go +++ b/policy/retention.go @@ -25,7 +25,7 @@ import ( "fmt" "time" - schema "github.com/m3db/m3metrics/generated/proto/policypb" + "github.com/m3db/m3metrics/generated/proto/policypb" xtime "github.com/m3db/m3x/time" ) @@ -47,12 +47,12 @@ func (r Retention) Duration() time.Duration { } // ToProto converts the retention to a protobuf message in place. -func (r Retention) ToProto(pb *schema.Retention) { +func (r Retention) ToProto(pb *policypb.Retention) { pb.Period = r.Duration().Nanoseconds() } // FromProto converts the protobuf message to a retention in place. -func (r *Retention) FromProto(pb *schema.Retention) error { +func (r *Retention) FromProto(pb *policypb.Retention) error { if pb == nil { return errNilRetentionProto } diff --git a/policy/storage_policy.go b/policy/storage_policy.go index 6a24155..e54255d 100644 --- a/policy/storage_policy.go +++ b/policy/storage_policy.go @@ -26,7 +26,7 @@ import ( "strings" "time" - schema "github.com/m3db/m3metrics/generated/proto/policypb" + "github.com/m3db/m3metrics/generated/proto/policypb" xtime "github.com/m3db/m3x/time" ) @@ -61,7 +61,7 @@ func NewStoragePolicy(window time.Duration, precision xtime.Unit, retention time } // NewStoragePolicyFromProto creates a new storage policy from a storage policy protobuf message. -func NewStoragePolicyFromProto(p *schema.StoragePolicy) (StoragePolicy, error) { +func NewStoragePolicyFromProto(p *policypb.StoragePolicy) (StoragePolicy, error) { if p == nil { return EmptyStoragePolicy, errNilStoragePolicySchema } @@ -90,22 +90,22 @@ func (p StoragePolicy) Retention() Retention { } // ToProto converts the storage policy to a protobuf message in place. -func (p StoragePolicy) ToProto(pb *schema.StoragePolicy) error { +func (p StoragePolicy) ToProto(pb *policypb.StoragePolicy) error { if pb.Resolution == nil { - pb.Resolution = &schema.Resolution{} + pb.Resolution = &policypb.Resolution{} } if err := p.resolution.ToProto(pb.Resolution); err != nil { return err } if pb.Retention == nil { - pb.Retention = &schema.Retention{} + pb.Retention = &policypb.Retention{} } p.retention.ToProto(pb.Retention) return nil } // FromProto converts the protobuf message to a storage policy in place. -func (p *StoragePolicy) FromProto(pb schema.StoragePolicy) error { +func (p *StoragePolicy) FromProto(pb policypb.StoragePolicy) error { if err := p.resolution.FromProto(pb.Resolution); err != nil { return err } diff --git a/policy/storage_policy_test.go b/policy/storage_policy_test.go index de87eea..9f81521 100644 --- a/policy/storage_policy_test.go +++ b/policy/storage_policy_test.go @@ -25,7 +25,6 @@ import ( "time" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/policypb" xtime "github.com/m3db/m3x/time" "github.com/stretchr/testify/require" @@ -255,28 +254,28 @@ func TestStoragePolicyUnmarshalYAMLErrors(t *testing.T) { func TestNewStoragePolicyFromSchema(t *testing.T) { inputs := []struct { - s *schema.StoragePolicy + s *policypb.StoragePolicy p StoragePolicy }{ { - s: &schema.StoragePolicy{ - Resolution: &schema.Resolution{ + s: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ WindowSize: int64(10 * time.Second), Precision: int64(time.Second), }, - Retention: &schema.Retention{ + Retention: &policypb.Retention{ Period: int64(24 * time.Hour), }, }, p: NewStoragePolicy(10*time.Second, xtime.Second, 24*time.Hour), }, { - s: &schema.StoragePolicy{ - Resolution: &schema.Resolution{ + s: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ WindowSize: int64(time.Minute), Precision: int64(time.Minute), }, - Retention: &schema.Retention{ + Retention: &policypb.Retention{ Period: int64(240 * time.Hour), }, }, diff --git a/rules/mapping.go b/rules/mapping.go index 72ae8f8..5bb73d8 100644 --- a/rules/mapping.go +++ b/rules/mapping.go @@ -27,7 +27,7 @@ import ( merrors "github.com/m3db/m3metrics/errors" "github.com/m3db/m3metrics/filters" policypb "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/policy" "github.com/m3db/m3metrics/rules/models" @@ -54,7 +54,7 @@ type mappingRuleSnapshot struct { } func newMappingRuleSnapshot( - r *schema.MappingRuleSnapshot, + r *rulepb.MappingRuleSnapshot, opts filters.TagsFilterOptions, ) (*mappingRuleSnapshot, error) { if r == nil { @@ -153,8 +153,8 @@ func (mrs *mappingRuleSnapshot) clone() mappingRuleSnapshot { } // Schema returns the given MappingRuleSnapshot in protobuf form. -func (mrs *mappingRuleSnapshot) Schema() (*schema.MappingRuleSnapshot, error) { - res := &schema.MappingRuleSnapshot{ +func (mrs *mappingRuleSnapshot) Schema() (*rulepb.MappingRuleSnapshot, error) { + res := &rulepb.MappingRuleSnapshot{ Name: mrs.name, Tombstoned: mrs.tombstoned, CutoverNanos: mrs.cutoverNanos, @@ -201,7 +201,7 @@ type mappingRule struct { } func newMappingRule( - mc *schema.MappingRule, + mc *rulepb.MappingRule, opts filters.TagsFilterOptions, ) (*mappingRule, error) { if mc == nil { @@ -369,8 +369,8 @@ func (mc *mappingRule) history() ([]*models.MappingRuleView, error) { } // Schema returns the given MappingRule in protobuf form. -func (mc *mappingRule) Schema() (*schema.MappingRule, error) { - snapshots := make([]*schema.MappingRuleSnapshot, len(mc.snapshots)) +func (mc *mappingRule) Schema() (*rulepb.MappingRule, error) { + snapshots := make([]*rulepb.MappingRuleSnapshot, len(mc.snapshots)) for i, s := range mc.snapshots { snapshot, err := s.Schema() if err != nil { @@ -379,7 +379,7 @@ func (mc *mappingRule) Schema() (*schema.MappingRule, error) { snapshots[i] = snapshot } - return &schema.MappingRule{ + return &rulepb.MappingRule{ Uuid: mc.uuid, Snapshots: snapshots, }, nil diff --git a/rules/mapping_test.go b/rules/mapping_test.go index 6f90482..fff57f3 100644 --- a/rules/mapping_test.go +++ b/rules/mapping_test.go @@ -28,7 +28,7 @@ import ( "github.com/m3db/m3metrics/errors" "github.com/m3db/m3metrics/generated/proto/aggregationpb" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/policy" "github.com/m3db/m3metrics/rules/models" xtime "github.com/m3db/m3x/time" @@ -37,10 +37,10 @@ import ( ) var ( - testMappingRuleSchema = &schema.MappingRule{ + testMappingRuleSchema = &rulepb.MappingRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "foo", Tombstoned: false, CutoverNanos: 12345, @@ -64,7 +64,7 @@ var ( }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "bar", Tombstoned: true, CutoverNanos: 67890, @@ -343,8 +343,8 @@ func TestMappingTombstoned(t *testing.T) { } func TestMappingRuleMarkTombstoned(t *testing.T) { - schema := &schema.MappingRule{ - Snapshots: []*schema.MappingRuleSnapshot{testMappingRuleSchema.Snapshots[0]}, + schema := &rulepb.MappingRule{ + Snapshots: []*rulepb.MappingRuleSnapshot{testMappingRuleSchema.Snapshots[0]}, } mr, err := newMappingRule(schema, testTagsFilterOptions()) require.NoError(t, err) @@ -383,7 +383,7 @@ func TestMappingRuleMarkTombstoned(t *testing.T) { } func TestMappingRuleMarkTombstonedNoSnapshots(t *testing.T) { - schema := &schema.MappingRule{} + schema := &rulepb.MappingRule{} mr, err := newMappingRule(schema, testTagsFilterOptions()) require.NoError(t, err) require.Error(t, mr.markTombstoned(UpdateMetadata{})) diff --git a/rules/namespace.go b/rules/namespace.go index 065f1f1..1fed138 100644 --- a/rules/namespace.go +++ b/rules/namespace.go @@ -24,7 +24,7 @@ import ( "errors" "fmt" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/rules/models" xerrors "github.com/m3db/m3x/errors" ) @@ -56,7 +56,7 @@ type NamespaceSnapshot struct { lastUpdatedBy string } -func newNamespaceSnapshot(snapshot *schema.NamespaceSnapshot) (NamespaceSnapshot, error) { +func newNamespaceSnapshot(snapshot *rulepb.NamespaceSnapshot) (NamespaceSnapshot, error) { if snapshot == nil { return emptyNamespaceSnapshot, errNilNamespaceSnapshotSchema } @@ -81,8 +81,8 @@ func (s NamespaceSnapshot) LastUpdatedAtNanos() int64 { return s.lastUpdatedAtNa func (s NamespaceSnapshot) LastUpdatedBy() string { return s.lastUpdatedBy } // Schema returns the given Namespace in protobuf form -func (s NamespaceSnapshot) Schema() *schema.NamespaceSnapshot { - return &schema.NamespaceSnapshot{ +func (s NamespaceSnapshot) Schema() *rulepb.NamespaceSnapshot { + return &rulepb.NamespaceSnapshot{ ForRulesetVersion: int32(s.forRuleSetVersion), Tombstoned: s.tombstoned, LastUpdatedAtNanos: s.lastUpdatedAtNanos, @@ -97,7 +97,7 @@ type Namespace struct { } // newNamespace creates a new namespace. -func newNamespace(namespace *schema.Namespace) (Namespace, error) { +func newNamespace(namespace *rulepb.Namespace) (Namespace, error) { if namespace == nil { return emptyNamespace, errNilNamespaceSchema } @@ -148,16 +148,16 @@ func (n Namespace) Name() []byte { return n.name } func (n Namespace) Snapshots() []NamespaceSnapshot { return n.snapshots } // Schema returns the given Namespace in protobuf form -func (n Namespace) Schema() (*schema.Namespace, error) { +func (n Namespace) Schema() (*rulepb.Namespace, error) { if n.snapshots == nil { return nil, errNilNamespaceSnapshot } - res := &schema.Namespace{ + res := &rulepb.Namespace{ Name: string(n.name), } - snapshots := make([]*schema.NamespaceSnapshot, len(n.snapshots)) + snapshots := make([]*rulepb.NamespaceSnapshot, len(n.snapshots)) for i, s := range n.snapshots { snapshots[i] = s.Schema() } @@ -215,7 +215,7 @@ type Namespaces struct { } // NewNamespaces creates new namespaces. -func NewNamespaces(version int, namespaces *schema.Namespaces) (Namespaces, error) { +func NewNamespaces(version int, namespaces *rulepb.Namespaces) (Namespaces, error) { if namespaces == nil { return emptyNamespaces, errNilNamespacesSchema } @@ -268,10 +268,10 @@ func (nss Namespaces) Version() int { return nss.version } func (nss Namespaces) Namespaces() []Namespace { return nss.namespaces } // Schema returns the given Namespaces slice in protobuf form. -func (nss Namespaces) Schema() (*schema.Namespaces, error) { - res := &schema.Namespaces{} +func (nss Namespaces) Schema() (*rulepb.Namespaces, error) { + res := &rulepb.Namespaces{} - namespaces := make([]*schema.Namespace, len(nss.namespaces)) + namespaces := make([]*rulepb.Namespace, len(nss.namespaces)) for i, n := range nss.namespaces { namespace, err := n.Schema() if err != nil { diff --git a/rules/namespace_test.go b/rules/namespace_test.go index 0eb6164..b295bf2 100644 --- a/rules/namespace_test.go +++ b/rules/namespace_test.go @@ -23,7 +23,7 @@ package rules import ( "testing" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/rules/models" "github.com/stretchr/testify/require" @@ -35,7 +35,7 @@ func TestNewNamespaceSnapshotFromNilSchema(t *testing.T) { } func TestNewNamespaceSnapshotFromValidSchema(t *testing.T) { - snapshot, err := newNamespaceSnapshot(&schema.NamespaceSnapshot{ + snapshot, err := newNamespaceSnapshot(&rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: true, LastUpdatedAtNanos: 456, @@ -63,7 +63,7 @@ func TestNamespaceSnapshotToSchema(t *testing.T) { } func TestNamespaceSnapshotRoundTrip(t *testing.T) { - schema := &schema.NamespaceSnapshot{ + schema := &rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: true, LastUpdatedAtNanos: 456, @@ -168,16 +168,16 @@ func TestNewNamespaceFromNilSchema(t *testing.T) { } func TestNewNamespaceFromValidSchema(t *testing.T) { - ns, err := newNamespace(&schema.Namespace{ + ns, err := newNamespace(&rulepb.Namespace{ Name: "foo", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: false, LastUpdatedAtNanos: 456, LastUpdatedBy: "someone", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 456, Tombstoned: true, LastUpdatedAtNanos: 7890, @@ -225,16 +225,16 @@ func TestNamespaceToSchema(t *testing.T) { res, err := ns.Schema() require.NoError(t, err) - expected := &schema.Namespace{ + expected := &rulepb.Namespace{ Name: "foo", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: false, LastUpdatedAtNanos: 456, LastUpdatedBy: "someone", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 456, Tombstoned: true, LastUpdatedAtNanos: 7890, @@ -255,16 +255,16 @@ func TestNamespaceToSchemaNoSnapshots(t *testing.T) { } func TestNamespaceRoundTrip(t *testing.T) { - testNs := &schema.Namespace{ + testNs := &rulepb.Namespace{ Name: "foo", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: false, LastUpdatedAtNanos: 456, LastUpdatedBy: "someone", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 456, Tombstoned: true, LastUpdatedAtNanos: 7890, @@ -570,18 +570,18 @@ func TestNewNamespacesFromNilSchema(t *testing.T) { } func TestNewNamespacesFromValidSchema(t *testing.T) { - ns, err := NewNamespaces(1, &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + ns, err := NewNamespaces(1, &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "foo", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: false, LastUpdatedAtNanos: 456, LastUpdatedBy: "someone", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 456, Tombstoned: true, LastUpdatedAtNanos: 7890, @@ -589,16 +589,16 @@ func TestNewNamespacesFromValidSchema(t *testing.T) { }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "bar", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 789, Tombstoned: false, LastUpdatedAtNanos: 12345, LastUpdatedBy: "john", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1000, Tombstoned: true, LastUpdatedAtNanos: 67890, @@ -650,18 +650,18 @@ func TestNewNamespacesFromValidSchema(t *testing.T) { } func TestNamespacesRoundTrip(t *testing.T) { - testNss := &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + testNss := &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "foo", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 123, Tombstoned: false, LastUpdatedAtNanos: 456, LastUpdatedBy: "someone", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 456, Tombstoned: true, LastUpdatedAtNanos: 7890, @@ -669,16 +669,16 @@ func TestNamespacesRoundTrip(t *testing.T) { }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "foo2", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 789, Tombstoned: false, LastUpdatedAtNanos: 12345, LastUpdatedBy: "john", }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1000, Tombstoned: true, LastUpdatedAtNanos: 67890, diff --git a/rules/rollup.go b/rules/rollup.go index 4e16490..496388f 100644 --- a/rules/rollup.go +++ b/rules/rollup.go @@ -29,7 +29,7 @@ import ( merrors "github.com/m3db/m3metrics/errors" "github.com/m3db/m3metrics/filters" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/policy" "github.com/m3db/m3metrics/rules/models" @@ -54,7 +54,7 @@ type rollupTarget struct { Policies []policy.Policy } -func newRollupTarget(target *schema.RollupTarget) (rollupTarget, error) { +func newRollupTarget(target *rulepb.RollupTarget) (rollupTarget, error) { if target == nil { return emptyRollupTarget, errNilRollupTargetSchema } @@ -131,8 +131,8 @@ func (t *rollupTarget) clone() rollupTarget { } // Schema returns the schema representation of a rollup target. -func (t *rollupTarget) Schema() (*schema.RollupTarget, error) { - res := &schema.RollupTarget{ +func (t *rollupTarget) Schema() (*rulepb.RollupTarget, error) { + res := &rulepb.RollupTarget{ Name: string(t.Name), } @@ -164,7 +164,7 @@ type rollupRuleSnapshot struct { } func newRollupRuleSnapshot( - r *schema.RollupRuleSnapshot, + r *rulepb.RollupRuleSnapshot, opts filters.TagsFilterOptions, ) (*rollupRuleSnapshot, error) { if r == nil { @@ -269,8 +269,8 @@ func (rrs *rollupRuleSnapshot) clone() rollupRuleSnapshot { } // Schema returns the given MappingRuleSnapshot in protobuf form. -func (rrs *rollupRuleSnapshot) Schema() (*schema.RollupRuleSnapshot, error) { - res := &schema.RollupRuleSnapshot{ +func (rrs *rollupRuleSnapshot) Schema() (*rulepb.RollupRuleSnapshot, error) { + res := &rulepb.RollupRuleSnapshot{ Name: rrs.name, Tombstoned: rrs.tombstoned, CutoverNanos: rrs.cutoverNanos, @@ -279,7 +279,7 @@ func (rrs *rollupRuleSnapshot) Schema() (*schema.RollupRuleSnapshot, error) { LastUpdatedBy: rrs.lastUpdatedBy, } - targets := make([]*schema.RollupTarget, len(rrs.targets)) + targets := make([]*rulepb.RollupTarget, len(rrs.targets)) for i, t := range rrs.targets { target, err := t.Schema() if err != nil { @@ -322,7 +322,7 @@ type rollupRule struct { } func newRollupRule( - rc *schema.RollupRule, + rc *rulepb.RollupRule, opts filters.TagsFilterOptions, ) (*rollupRule, error) { if rc == nil { @@ -491,8 +491,8 @@ func (rc *rollupRule) history() ([]*models.RollupRuleView, error) { } // Schema returns the given RollupRule in protobuf form. -func (rc *rollupRule) Schema() (*schema.RollupRule, error) { - snapshots := make([]*schema.RollupRuleSnapshot, len(rc.snapshots)) +func (rc *rollupRule) Schema() (*rulepb.RollupRule, error) { + snapshots := make([]*rulepb.RollupRuleSnapshot, len(rc.snapshots)) for i, s := range rc.snapshots { snapshot, err := s.Schema() if err != nil { @@ -501,7 +501,7 @@ func (rc *rollupRule) Schema() (*schema.RollupRule, error) { snapshots[i] = snapshot } - return &schema.RollupRule{ + return &rulepb.RollupRule{ Uuid: rc.uuid, Snapshots: snapshots, }, nil diff --git a/rules/rollup_test.go b/rules/rollup_test.go index daf7fbe..b471d33 100644 --- a/rules/rollup_test.go +++ b/rules/rollup_test.go @@ -28,7 +28,7 @@ import ( "github.com/m3db/m3metrics/errors" "github.com/m3db/m3metrics/generated/proto/aggregationpb" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/policy" "github.com/m3db/m3metrics/rules/models" xtime "github.com/m3db/m3x/time" @@ -37,18 +37,18 @@ import ( ) var ( - testRollupRuleSchema = &schema.RollupRule{ + testRollupRuleSchema = &rulepb.RollupRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "foo", Tombstoned: false, CutoverNanos: 12345, LastUpdatedAtNanos: 12345, LastUpdatedBy: "someone-else", Filter: "tag1:value1 tag2:value2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -67,15 +67,15 @@ var ( }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "bar", Tombstoned: true, CutoverNanos: 67890, LastUpdatedAtNanos: 67890, LastUpdatedBy: "someone", Filter: "tag3:value3 tag4:value4", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -118,7 +118,7 @@ func TestNewRollupTargetNilTargetSchema(t *testing.T) { } func TestNewRollupTargetNilPolicySchema(t *testing.T) { - _, err := newRollupTarget(&schema.RollupTarget{ + _, err := newRollupTarget(&rulepb.RollupTarget{ Policies: []*policypb.Policy{nil}, }) require.Error(t, err) @@ -466,8 +466,8 @@ func TestRollupTombstoned(t *testing.T) { } func TestRollupRuleMarkTombstoned(t *testing.T) { - schema := &schema.RollupRule{ - Snapshots: []*schema.RollupRuleSnapshot{testRollupRuleSchema.Snapshots[0]}, + schema := &rulepb.RollupRule{ + Snapshots: []*rulepb.RollupRuleSnapshot{testRollupRuleSchema.Snapshots[0]}, } rr, err := newRollupRule(schema, testTagsFilterOptions()) require.NoError(t, err) @@ -512,7 +512,7 @@ func TestRollupRuleMarkTombstoned(t *testing.T) { } func TestRollupRuleMarkTombstonedNoSnapshots(t *testing.T) { - schema := &schema.RollupRule{} + schema := &rulepb.RollupRule{} rr, err := newRollupRule(schema, testTagsFilterOptions()) require.NoError(t, err) require.Error(t, rr.markTombstoned(UpdateMetadata{})) diff --git a/rules/ruleset.go b/rules/ruleset.go index e105631..fa57b52 100644 --- a/rules/ruleset.go +++ b/rules/ruleset.go @@ -32,7 +32,7 @@ import ( "github.com/m3db/m3metrics/aggregation" merrors "github.com/m3db/m3metrics/errors" "github.com/m3db/m3metrics/filters" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/metric" metricID "github.com/m3db/m3metrics/metric/id" "github.com/m3db/m3metrics/policy" @@ -497,8 +497,8 @@ type RuleSet interface { type MutableRuleSet interface { RuleSet - // Schema returns the schema.Ruleset representation of this ruleset. - Schema() (*schema.RuleSet, error) + // Schema returns the rulepb.Ruleset representation of this ruleset. + Schema() (*rulepb.RuleSet, error) // Clone returns a copy of this MutableRuleSet. Clone() MutableRuleSet @@ -551,7 +551,7 @@ type ruleSet struct { } // NewRuleSetFromSchema creates a new RuleSet from a schema object. -func NewRuleSetFromSchema(version int, rs *schema.RuleSet, opts Options) (RuleSet, error) { +func NewRuleSetFromSchema(version int, rs *rulepb.RuleSet, opts Options) (RuleSet, error) { if rs == nil { return nil, errNilRuleSetSchema } @@ -639,8 +639,8 @@ func (rs *ruleSet) ToMutableRuleSet() MutableRuleSet { } // Schema returns the protobuf representation of a ruleset. -func (rs *ruleSet) Schema() (*schema.RuleSet, error) { - res := &schema.RuleSet{ +func (rs *ruleSet) Schema() (*rulepb.RuleSet, error) { + res := &rulepb.RuleSet{ Uuid: rs.uuid, Namespace: string(rs.namespace), CreatedAtNanos: rs.createdAtNanos, @@ -650,7 +650,7 @@ func (rs *ruleSet) Schema() (*schema.RuleSet, error) { CutoverNanos: rs.cutoverNanos, } - mappingRules := make([]*schema.MappingRule, len(rs.mappingRules)) + mappingRules := make([]*rulepb.MappingRule, len(rs.mappingRules)) for i, m := range rs.mappingRules { mr, err := m.Schema() if err != nil { @@ -660,7 +660,7 @@ func (rs *ruleSet) Schema() (*schema.RuleSet, error) { } res.MappingRules = mappingRules - rollupRules := make([]*schema.RollupRule, len(rs.rollupRules)) + rollupRules := make([]*rulepb.RollupRule, len(rs.rollupRules)) for i, r := range rs.rollupRules { rr, err := r.Schema() if err != nil { diff --git a/rules/ruleset_test.go b/rules/ruleset_test.go index 2a7a89b..8644f88 100644 --- a/rules/ruleset_test.go +++ b/rules/ruleset_test.go @@ -32,7 +32,7 @@ import ( "github.com/m3db/m3metrics/filters" "github.com/m3db/m3metrics/generated/proto/aggregationpb" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/metric" "github.com/m3db/m3metrics/metric/id" "github.com/m3db/m3metrics/policy" @@ -802,7 +802,7 @@ func TestActiveRuleSetRollupResults(t *testing.T) { func TestRuleSetProperties(t *testing.T) { opts := testRuleSetOptions() version := 1 - rs := &schema.RuleSet{ + rs := &rulepb.RuleSet{ Uuid: "ruleset", Namespace: "namespace", CreatedAtNanos: 1234, @@ -824,7 +824,7 @@ func TestRuleSetProperties(t *testing.T) { func TestRuleSetSchema(t *testing.T) { version := 1 - expectedRs := &schema.RuleSet{ + expectedRs := &rulepb.RuleSet{ Uuid: "ruleset", Namespace: "namespace", CreatedAtNanos: 1234, @@ -846,7 +846,7 @@ func TestRuleSetSchema(t *testing.T) { func TestRuleSetActiveSet(t *testing.T) { opts := testRuleSetOptions() version := 1 - rs := &schema.RuleSet{ + rs := &rulepb.RuleSet{ MappingRules: testMappingRulesConfig(), RollupRules: testRollupRulesConfig(), } @@ -1218,7 +1218,7 @@ func TestRuleSetActiveSet(t *testing.T) { } func TestRuleSetLatest(t *testing.T) { - schema := &schema.RuleSet{ + schema := &rulepb.RuleSet{ Namespace: "testNamespace", CutoverNanos: 998234, MappingRules: testMappingRulesConfig(), @@ -1796,12 +1796,12 @@ func testRollupRules(t *testing.T) []*rollupRule { return []*rollupRule{rollupRule1, rollupRule2, rollupRule3, rollupRule4, rollupRule5, rollupRule6, rollupRule7} } -func testMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule1.snapshot1", Tombstoned: false, CutoverNanos: 10000, @@ -1820,7 +1820,7 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule1.snapshot2", Tombstoned: false, CutoverNanos: 20000, @@ -1861,7 +1861,7 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule1.snapshot3", Tombstoned: false, CutoverNanos: 30000, @@ -1882,10 +1882,10 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule2", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule2.snapshot1", Tombstoned: false, CutoverNanos: 15000, @@ -1904,7 +1904,7 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule2.snapshot2", Tombstoned: false, CutoverNanos: 22000, @@ -1937,7 +1937,7 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule2.snapshot3", Tombstoned: true, CutoverNanos: 35000, @@ -1972,10 +1972,10 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule3", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule3.snapshot1", Tombstoned: false, CutoverNanos: 22000, @@ -2019,7 +2019,7 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule3.snapshot2", Tombstoned: false, CutoverNanos: 34000, @@ -2051,10 +2051,10 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule4", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule4.snapshot1", Tombstoned: false, CutoverNanos: 24000, @@ -2078,10 +2078,10 @@ func testMappingRulesConfig() []*schema.MappingRule { }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule5", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "mappingRule5.snapshot1", Tombstoned: false, CutoverNanos: 100000, @@ -2107,18 +2107,18 @@ func testMappingRulesConfig() []*schema.MappingRule { } } -func testRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule1.snapshot1", Tombstoned: false, CutoverNanos: 10000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2137,13 +2137,13 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule1.snapshot2", Tombstoned: false, CutoverNanos: 20000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2184,13 +2184,13 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule1.snapshot3", Tombstoned: false, CutoverNanos: 30000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2211,16 +2211,16 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule2", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule2.snapshot1", Tombstoned: false, CutoverNanos: 15000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2239,13 +2239,13 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule2.snapshot2", Tombstoned: false, CutoverNanos: 22000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2275,13 +2275,13 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule2.snapshot3", Tombstoned: true, CutoverNanos: 35000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2313,16 +2313,16 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule3", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule3.snapshot1", Tombstoned: false, CutoverNanos: 22000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2361,7 +2361,7 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName2", Tags: []string{"rtagName1"}, Policies: []*policypb.Policy{ @@ -2380,13 +2380,13 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule3.snapshot2", Tombstoned: false, CutoverNanos: 34000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2418,16 +2418,16 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule4", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule4.snapshot1", Tombstoned: false, CutoverNanos: 24000, Filter: "rtagName1:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName3", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2448,16 +2448,16 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule5", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule5.snapshot1", Tombstoned: false, CutoverNanos: 24000, Filter: "rtagName1:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName4", Tags: []string{"rtagName1"}, Policies: []*policypb.Policy{ @@ -2478,16 +2478,16 @@ func testRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule6", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "rollupRule6.snapshot1", Tombstoned: false, CutoverNanos: 100000, Filter: "rtagName1:rtagValue1 rtagName2:rtagValue2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName3", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -2554,7 +2554,7 @@ func testTagsFilterOptions() filters.TagsFilterOptions { func initMutableTest() (MutableRuleSet, *ruleSet, RuleSetUpdateHelper, error) { version := 1 - expectedRs := &schema.RuleSet{ + expectedRs := &rulepb.RuleSet{ Uuid: "ruleset", Namespace: "namespace", CreatedAtNanos: 1234, @@ -2573,7 +2573,7 @@ func initMutableTest() (MutableRuleSet, *ruleSet, RuleSetUpdateHelper, error) { // nolint: unparam // newMutableRuleSetFromSchema creates a new MutableRuleSet from a schema object. -func newMutableRuleSetFromSchema(version int, rs *schema.RuleSet) (MutableRuleSet, error) { +func newMutableRuleSetFromSchema(version int, rs *rulepb.RuleSet) (MutableRuleSet, error) { // Takes a blank Options stuct because none of the mutation functions need the options. roRuleSet, err := NewRuleSetFromSchema(version, rs, NewOptions()) if err != nil { diff --git a/rules/store/kv/store.go b/rules/store/kv/store.go index a655df1..b09c1d3 100644 --- a/rules/store/kv/store.go +++ b/rules/store/kv/store.go @@ -26,7 +26,7 @@ import ( "github.com/m3db/m3cluster/kv" merrors "github.com/m3db/m3metrics/errors" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/rules" ) @@ -52,7 +52,7 @@ func (s *store) ReadNamespaces() (*rules.Namespaces, error) { } version := value.Version() - var namespaces schema.Namespaces + var namespaces rulepb.Namespaces if err := value.Unmarshal(&namespaces); err != nil { return nil, err } @@ -73,7 +73,7 @@ func (s *store) ReadRuleSet(nsName string) (rules.RuleSet, error) { } version := value.Version() - var ruleSet schema.RuleSet + var ruleSet rulepb.RuleSet if err := value.Unmarshal(&ruleSet); err != nil { return nil, fmt.Errorf("Could not fetch RuleSet %s: %v", nsName, err.Error()) } diff --git a/rules/store/kv/store_test.go b/rules/store/kv/store_test.go index c389a43..6194c6e 100644 --- a/rules/store/kv/store_test.go +++ b/rules/store/kv/store_test.go @@ -30,7 +30,7 @@ import ( merrors "github.com/m3db/m3metrics/errors" "github.com/m3db/m3metrics/generated/proto/aggregationpb" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/rules" "github.com/m3db/m3metrics/rules/models" @@ -44,29 +44,29 @@ const ( ) var ( - testNamespaces = &schema.Namespaces{ - Namespaces: []*schema.Namespace{ - &schema.Namespace{ + testNamespaces = &rulepb.Namespaces{ + Namespaces: []*rulepb.Namespace{ + &rulepb.Namespace{ Name: "fooNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: false, }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 2, Tombstoned: false, }, }, }, - &schema.Namespace{ + &rulepb.Namespace{ Name: "barNs", - Snapshots: []*schema.NamespaceSnapshot{ - &schema.NamespaceSnapshot{ + Snapshots: []*rulepb.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 1, Tombstoned: false, }, - &schema.NamespaceSnapshot{ + &rulepb.NamespaceSnapshot{ ForRulesetVersion: 2, Tombstoned: true, }, @@ -76,18 +76,18 @@ var ( } testRuleSetKey = fmt.Sprintf(testRuleSetKeyFmt, testNamespace) - testRuleSet = &schema.RuleSet{ + testRuleSet = &rulepb.RuleSet{ Uuid: "ruleset", Namespace: "fooNs", CreatedAtNanos: 1234, LastUpdatedAtNanos: 5678, Tombstoned: false, CutoverNanos: 34923, - MappingRules: []*schema.MappingRule{ - &schema.MappingRule{ + MappingRules: []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "foo", Tombstoned: false, CutoverNanos: 12345, @@ -109,7 +109,7 @@ var ( }, }, }, - &schema.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "foo", Tombstoned: false, CutoverNanos: 67890, @@ -141,10 +141,10 @@ var ( }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "dup", Tombstoned: false, CutoverNanos: 12345, @@ -169,17 +169,17 @@ var ( }, }, }, - RollupRules: []*schema.RollupRule{ - &schema.RollupRule{ + RollupRules: []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "foo2", Tombstoned: false, CutoverNanos: 12345, Filter: "tag1:value1 tag2:value2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -198,13 +198,13 @@ var ( }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "bar", Tombstoned: true, CutoverNanos: 67890, Filter: "tag3:value3 tag4:value4", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -239,16 +239,16 @@ var ( }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "foo", Tombstoned: false, CutoverNanos: 12345, Filter: "tag1:value1 tag2:value2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -267,13 +267,13 @@ var ( }, }, }, - &schema.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "baz", Tombstoned: false, CutoverNanos: 67890, Filter: "tag3:value3 tag4:value4", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -308,16 +308,16 @@ var ( }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "12669817-13ae-40e6-ba2f-33087b262c68", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "dup", Tombstoned: false, CutoverNanos: 12345, Filter: "tag1:value1 tag2:value2", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -375,7 +375,7 @@ func TestReadNamespacesError(t *testing.T) { s := testStore() defer s.Close() - _, e := s.(*store).kvStore.Set(testNamespaceKey, &schema.RollupRule{Uuid: "x"}) + _, e := s.(*store).kvStore.Set(testNamespaceKey, &rulepb.RollupRule{Uuid: "x"}) require.NoError(t, e) nss, err := s.ReadNamespaces() require.Error(t, err) @@ -397,7 +397,7 @@ func TestReadRuleSetError(t *testing.T) { s := testStore() defer s.Close() - _, e := s.(*store).kvStore.Set(testRuleSetKey, &schema.Namespace{Name: "x"}) + _, e := s.(*store).kvStore.Set(testRuleSetKey, &rulepb.Namespace{Name: "x"}) require.NoError(t, e) rs, err := s.ReadRuleSet("blah") require.Error(t, err) @@ -606,7 +606,7 @@ func testStoreWithValidator(validator rules.Validator) rules.Store { func newMutableRuleSetFromSchema( t *testing.T, version int, - rs *schema.RuleSet, + rs *rulepb.RuleSet, ) rules.MutableRuleSet { // Takes a blank Options stuct because none of the mutation functions need the options. roRuleSet, err := rules.NewRuleSetFromSchema(version, rs, rules.NewOptions()) diff --git a/rules/validator/validator_test.go b/rules/validator/validator_test.go index 8aa6c38..8895536 100644 --- a/rules/validator/validator_test.go +++ b/rules/validator/validator_test.go @@ -32,7 +32,7 @@ import ( "github.com/m3db/m3metrics/filters" "github.com/m3db/m3metrics/generated/proto/aggregationpb" "github.com/m3db/m3metrics/generated/proto/policypb" - schema "github.com/m3db/m3metrics/generated/proto/rulepb" + "github.com/m3db/m3metrics/generated/proto/rulepb" "github.com/m3db/m3metrics/metric" "github.com/m3db/m3metrics/policy" "github.com/m3db/m3metrics/rules" @@ -73,7 +73,7 @@ func TestValidatorInvalidNamespace(t *testing.T) { v := NewValidator(opts) defer v.Close() - rs, err := rules.NewRuleSetFromSchema(1, &schema.RuleSet{Namespace: "baz"}, rules.NewOptions()) + rs, err := rules.NewRuleSetFromSchema(1, &rulepb.RuleSet{Namespace: "baz"}, rules.NewOptions()) require.NoError(t, err) require.Error(t, v.Validate(rs)) } @@ -86,7 +86,7 @@ func TestValidatorValidNamespace(t *testing.T) { v := NewValidator(opts) defer v.Close() - rs, err := rules.NewRuleSetFromSchema(1, &schema.RuleSet{Namespace: "foo"}, rules.NewOptions()) + rs, err := rules.NewRuleSetFromSchema(1, &rulepb.RuleSet{Namespace: "foo"}, rules.NewOptions()) require.NoError(t, err) require.NoError(t, v.Validate(rs)) } @@ -391,22 +391,22 @@ func TestValidatorValidateRollupRuleConflictingTargets(t *testing.T) { require.True(t, ok) } -func testDuplicateMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testDuplicateMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Policies: testPolicies(), }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule2", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Policies: []*policypb.Policy{ @@ -428,22 +428,22 @@ func testDuplicateMappingRulesConfig() []*schema.MappingRule { } } -func testNoDuplicateMappingRulesConfigWithTombstone() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testNoDuplicateMappingRulesConfigWithTombstone() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: true, Policies: testPolicies(), }, }, }, - &schema.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule2", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Policies: testPolicies(), @@ -475,12 +475,12 @@ func testInvalidFilterTagNameMappingRuleSetSnapshot() *models.RuleSetSnapshotVie } } -func testInvalidMetricTypeMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testInvalidMetricTypeMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":nonexistent", @@ -490,12 +490,12 @@ func testInvalidMetricTypeMappingRulesConfig() []*schema.MappingRule { } } -func testPolicyResolutionMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testPolicyResolutionMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, @@ -518,12 +518,12 @@ func testPolicyResolutionMappingRulesConfig() []*schema.MappingRule { } } -func testNoPoliciesMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testNoPoliciesMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, @@ -534,12 +534,12 @@ func testNoPoliciesMappingRulesConfig() []*schema.MappingRule { } } -func testDuplicatePoliciesMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testDuplicatePoliciesMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, @@ -573,12 +573,12 @@ func testDuplicatePoliciesMappingRulesConfig() []*schema.MappingRule { } } -func testCustomAggregationTypeMappingRulesConfig() []*schema.MappingRule { - return []*schema.MappingRule{ - &schema.MappingRule{ +func testCustomAggregationTypeMappingRulesConfig() []*rulepb.MappingRule { + return []*rulepb.MappingRule{ + &rulepb.MappingRule{ Uuid: "mappingRule1", - Snapshots: []*schema.MappingRuleSnapshot{ - &schema.MappingRuleSnapshot{ + Snapshots: []*rulepb.MappingRuleSnapshot{ + &rulepb.MappingRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, @@ -605,16 +605,16 @@ func testCustomAggregationTypeMappingRulesConfig() []*schema.MappingRule { } } -func testDuplicateRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testDuplicateRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -623,14 +623,14 @@ func testDuplicateRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule2", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -642,16 +642,16 @@ func testDuplicateRollupRulesConfig() []*schema.RollupRule { } } -func testNoDuplicateRollupRulesConfigWithTombstone() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testNoDuplicateRollupRulesConfigWithTombstone() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: true, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -660,14 +660,14 @@ func testNoDuplicateRollupRulesConfigWithTombstone() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule2", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -701,17 +701,17 @@ func testInvalidFilterTagNameRollupRuleSetSnapshot() *models.RuleSetSnapshotView } } -func testInvalidMetricTypeRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testInvalidMetricTypeRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":nonexistent", - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -723,16 +723,16 @@ func testInvalidMetricTypeRollupRulesConfig() []*schema.RollupRule { } } -func testDuplicateTagRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testDuplicateTagRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2", "rtagName1"}, Policies: testPolicies(), @@ -744,16 +744,16 @@ func testDuplicateTagRollupRulesConfig() []*schema.RollupRule { } } -func testMissingRequiredTagRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testMissingRequiredTagRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -765,16 +765,16 @@ func testMissingRequiredTagRollupRulesConfig() []*schema.RollupRule { } } -func testTagNameRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testTagNameRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2$", "$"}, Policies: testPolicies(), @@ -786,16 +786,16 @@ func testTagNameRollupRulesConfig() []*schema.RollupRule { } } -func testMetricNameRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testMetricNameRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName$1", Tags: []string{"rtagName1", "rtagName2"}, Policies: testPolicies(), @@ -807,16 +807,16 @@ func testMetricNameRollupRulesConfig() []*schema.RollupRule { } } -func testEmptyMetricNameRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testEmptyMetricNameRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "", Tags: []string{"rtagName1", "rtagName2"}, }, @@ -827,17 +827,17 @@ func testEmptyMetricNameRollupRulesConfig() []*schema.RollupRule { } } -func testPolicyResolutionRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testPolicyResolutionRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -861,17 +861,17 @@ func testPolicyResolutionRollupRulesConfig() []*schema.RollupRule { } } -func testNoPoliciesRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testNoPoliciesRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{}, @@ -883,17 +883,17 @@ func testNoPoliciesRollupRulesConfig() []*schema.RollupRule { } } -func testDuplicatePoliciesRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testDuplicatePoliciesRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -928,17 +928,17 @@ func testDuplicatePoliciesRollupRulesConfig() []*schema.RollupRule { } } -func testCustomAggregationTypeRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testCustomAggregationTypeRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -966,17 +966,17 @@ func testCustomAggregationTypeRollupRulesConfig() []*schema.RollupRule { } } -func testConflictingTargetsRollupRulesConfig() []*schema.RollupRule { - return []*schema.RollupRule{ - &schema.RollupRule{ +func testConflictingTargetsRollupRulesConfig() []*rulepb.RollupRule { + return []*rulepb.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule1", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot1", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName1", "rtagName2"}, Policies: []*policypb.Policy{ @@ -997,15 +997,15 @@ func testConflictingTargetsRollupRulesConfig() []*schema.RollupRule { }, }, }, - &schema.RollupRule{ + &rulepb.RollupRule{ Uuid: "rollupRule2", - Snapshots: []*schema.RollupRuleSnapshot{ - &schema.RollupRuleSnapshot{ + Snapshots: []*rulepb.RollupRuleSnapshot{ + &rulepb.RollupRuleSnapshot{ Name: "snapshot2", Tombstoned: false, Filter: testTypeTag + ":" + testTimerType, - Targets: []*schema.RollupTarget{ - &schema.RollupTarget{ + Targets: []*rulepb.RollupTarget{ + &rulepb.RollupTarget{ Name: "rName1", Tags: []string{"rtagName2", "rtagName1"}, Policies: []*policypb.Policy{ @@ -1029,15 +1029,15 @@ func testConflictingTargetsRollupRulesConfig() []*schema.RollupRule { } } -func testRuleSetWithMappingRules(t *testing.T, mrs []*schema.MappingRule) rules.RuleSet { - rs := &schema.RuleSet{MappingRules: mrs} +func testRuleSetWithMappingRules(t *testing.T, mrs []*rulepb.MappingRule) rules.RuleSet { + rs := &rulepb.RuleSet{MappingRules: mrs} newRuleSet, err := rules.NewRuleSetFromSchema(1, rs, rules.NewOptions()) require.NoError(t, err) return newRuleSet } -func testRuleSetWithRollupRules(t *testing.T, rrs []*schema.RollupRule) rules.RuleSet { - rs := &schema.RuleSet{RollupRules: rrs} +func testRuleSetWithRollupRules(t *testing.T, rrs []*rulepb.RollupRule) rules.RuleSet { + rs := &rulepb.RuleSet{RollupRules: rrs} newRuleSet, err := rules.NewRuleSetFromSchema(1, rs, rules.NewOptions()) require.NoError(t, err) return newRuleSet