@@ -56,11 +56,11 @@ func TestAllocationPerNode(t *testing.T) {
56
56
thirdTarget := target .NewItem ("sample-name" , "0.0.0.0:8000" , thirdLabels , "" )
57
57
fourthTarget := target .NewItem ("sample-name" , "0.0.0.0:8000" , fourthLabels , "" )
58
58
59
- targetList := map [ string ]* target.Item {
60
- firstTarget . Hash (): firstTarget ,
61
- secondTarget . Hash (): secondTarget ,
62
- thirdTarget . Hash (): thirdTarget ,
63
- fourthTarget . Hash (): fourthTarget ,
59
+ targetList := [ ]* target.Item {
60
+ firstTarget ,
61
+ secondTarget ,
62
+ thirdTarget ,
63
+ fourthTarget ,
64
64
}
65
65
66
66
// test that targets and collectors are added properly
@@ -74,16 +74,16 @@ func TestAllocationPerNode(t *testing.T) {
74
74
assert .Len (t , actualItems , expectedTargetLen )
75
75
76
76
// verify allocation to nodes
77
- for targetHash , item := range targetList {
78
- actualItem , found := actualItems [targetHash ]
77
+ for _ , item := range targetList {
78
+ actualItem , found := actualItems [item . Hash () ]
79
79
// if third target, should be skipped
80
80
assert .True (t , found , "target with hash %s not found" , item .Hash ())
81
81
82
82
// only the first two targets should be allocated
83
83
itemsForCollector := s .GetTargetsForCollectorAndJob (actualItem .CollectorName , actualItem .JobName )
84
84
85
85
// first two should be assigned one to each collector; if third target, should not be assigned
86
- if targetHash == thirdTarget .Hash () {
86
+ if item . Hash () == thirdTarget .Hash () {
87
87
assert .Len (t , itemsForCollector , 0 )
88
88
continue
89
89
}
@@ -123,11 +123,11 @@ func TestAllocationPerNodeUsingFallback(t *testing.T) {
123
123
thirdTarget := target .NewItem ("sample-name" , "0.0.0.0:8000" , thirdLabels , "" )
124
124
fourthTarget := target .NewItem ("sample-name" , "0.0.0.0:8000" , fourthLabels , "" )
125
125
126
- targetList := map [ string ]* target.Item {
127
- firstTarget . Hash (): firstTarget ,
128
- secondTarget . Hash (): secondTarget ,
129
- thirdTarget . Hash (): thirdTarget ,
130
- fourthTarget . Hash (): fourthTarget ,
126
+ targetList := [ ]* target.Item {
127
+ firstTarget ,
128
+ secondTarget ,
129
+ thirdTarget ,
130
+ fourthTarget ,
131
131
}
132
132
133
133
// test that targets and collectors are added properly
@@ -141,8 +141,8 @@ func TestAllocationPerNodeUsingFallback(t *testing.T) {
141
141
assert .Len (t , actualItems , expectedTargetLen )
142
142
143
143
// verify allocation to nodes
144
- for targetHash , item := range targetList {
145
- actualItem , found := actualItems [targetHash ]
144
+ for _ , item := range targetList {
145
+ actualItem , found := actualItems [item . Hash () ]
146
146
147
147
assert .True (t , found , "target with hash %s not found" , item .Hash ())
148
148
@@ -151,7 +151,7 @@ func TestAllocationPerNodeUsingFallback(t *testing.T) {
151
151
// first two should be assigned one to each collector; if third target, it should be assigned
152
152
// according to the fallback strategy which may assign it to the otherwise empty collector or
153
153
// one of the others, depending on the strategy and collector loop order
154
- if targetHash == thirdTarget .Hash () {
154
+ if item . Hash () == thirdTarget .Hash () {
155
155
assert .Empty (t , item .GetNodeName ())
156
156
assert .NotZero (t , len (itemsForCollector ))
157
157
continue
0 commit comments