-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parameter encoding issue #930
Merged
pavolloffay
merged 8 commits into
open-telemetry:main
from
jaronoff97:925-fix-broken-allocator
Jun 23, 2022
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0dff10d
logging
jaronoff97 2776bb0
Fixed encoding issue of params
jaronoff97 737af76
Do string replacement
jaronoff97 7f10dc1
Another test
jaronoff97 ce22702
Removed dockerfile changes
jaronoff97 e90c89f
Fix broken test
jaronoff97 0ed6a6a
Newline
jaronoff97 5dddfae
Change placement of the log import
jaronoff97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package allocation | ||
|
||
import ( | ||
"github.com/prometheus/common/model" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestGetAllTargetsByCollectorAndJob(t *testing.T) { | ||
baseAllocator := NewAllocator(logger) | ||
baseAllocator.SetCollectors([]string{"test-collector"}) | ||
statefulAllocator := NewAllocator(logger) | ||
statefulAllocator.SetCollectors([]string{"test-collector-0"}) | ||
type args struct { | ||
collector string | ||
job string | ||
cMap map[string][]TargetItem | ||
allocator *Allocator | ||
} | ||
var tests = []struct { | ||
name string | ||
args args | ||
want []targetGroupJSON | ||
}{ | ||
{ | ||
name: "Empty target map", | ||
args: args{ | ||
collector: "test-collector", | ||
job: "test-job", | ||
cMap: map[string][]TargetItem{}, | ||
allocator: baseAllocator, | ||
}, | ||
want: nil, | ||
}, | ||
{ | ||
name: "Single entry target map", | ||
args: args{ | ||
collector: "test-collector", | ||
job: "test-job", | ||
cMap: map[string][]TargetItem{ | ||
"test-collectortest-job": { | ||
TargetItem{ | ||
JobName: "test-job", | ||
Label: model.LabelSet{ | ||
"test-label": "test-value", | ||
}, | ||
TargetURL: "test-url", | ||
Collector: &collector{ | ||
Name: "test-collector", | ||
NumTargets: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
allocator: baseAllocator, | ||
}, | ||
want: []targetGroupJSON{ | ||
{ | ||
Targets: []string{"test-url"}, | ||
Labels: map[model.LabelName]model.LabelValue{ | ||
"test-label": "test-value", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Multiple entry target map", | ||
args: args{ | ||
collector: "test-collector", | ||
job: "test-job", | ||
cMap: map[string][]TargetItem{ | ||
"test-collectortest-job": { | ||
TargetItem{ | ||
JobName: "test-job", | ||
Label: model.LabelSet{ | ||
"test-label": "test-value", | ||
}, | ||
TargetURL: "test-url", | ||
Collector: &collector{ | ||
Name: "test-collector", | ||
NumTargets: 1, | ||
}, | ||
}, | ||
}, | ||
"test-collectortest-job2": { | ||
TargetItem{ | ||
JobName: "test-job2", | ||
Label: model.LabelSet{ | ||
"test-label": "test-value", | ||
}, | ||
TargetURL: "test-url", | ||
Collector: &collector{ | ||
Name: "test-collector", | ||
NumTargets: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
allocator: baseAllocator, | ||
}, | ||
want: []targetGroupJSON{ | ||
{ | ||
Targets: []string{"test-url"}, | ||
Labels: map[model.LabelName]model.LabelValue{ | ||
"test-label": "test-value", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := GetAllTargetsByCollectorAndJob(tt.args.collector, tt.args.job, tt.args.cMap, tt.args.allocator); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("GetAllTargetsByCollectorAndJob() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
pkg/collector/testdata/http_sd_config_servicemonitor_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
processors: | ||
receivers: | ||
prometheus: | ||
config: | ||
scrape_configs: | ||
- job_name: serviceMonitor/test/test/0 | ||
|
||
static_configs: | ||
- targets: ["prom.domain:1001", "prom.domain:1002", "prom.domain:1003"] | ||
labels: | ||
my: label | ||
|
||
file_sd_configs: | ||
- files: | ||
- file2.json | ||
|
||
exporters: | ||
logging: | ||
|
||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [prometheus] | ||
processors: [] | ||
exporters: [logging] | ||
jaronoff97 marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be moved to the second group