Skip to content

Commit

Permalink
feat: accept duplicated service definitions (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchezgavier authored Oct 16, 2020
1 parent 568957c commit 108d60f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/integration/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ func LoadSpecFiles(filesPath string) (Specs, error) {
continue
}
logrus.Debugf("spec file loaded for service:%s", sd.Service)
specs.SpecsByName[sd.Service] = sd
if spec, ok := specs.SpecsByName[sd.Service]; ok {
spec.Entities = append(spec.Entities, sd.Entities...)
specs.SpecsByName[sd.Service] = spec
//TODO how to manage defaultEntity for each spec?
} else {
specs.SpecsByName[sd.Service] = sd
}

}

return specs, nil
Expand Down
12 changes: 12 additions & 0 deletions internal/integration/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ func TestSpecs_getEntity(t *testing.T) {
Labels: []keyValue{}},
wantErr: false,
},
{
name: "redisBisMetric",
fields: fields{specs.SpecsByName},
args: args{
Metric{
name: "redis_metric_bis",
attributes: labels.Set{},
}},
wantProps: entityNameProps{Service: "redis", Name: "testbisredis", DisplayName: "Redis test bis", Type: "REDIS_TESTBISREDIS",
Labels: []keyValue{}},
wantErr: false,
},
{
name: "missingDimentions",
fields: fields{specs.SpecsByName},
Expand Down
10 changes: 10 additions & 0 deletions internal/integration/test/prometheus_redis_bis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
service: redis
display_name: Redis
entities:
- name: testbisredis
display_name: Redis test bis
metrics:
- provider_name: redis_metric_bis
description: Total amount of time in seconds spent per command
unit: Counter

0 comments on commit 108d60f

Please sign in to comment.