Skip to content

Commit 7326035

Browse files
committed
Fix tests
1 parent c679726 commit 7326035

File tree

2 files changed

+50
-86
lines changed

2 files changed

+50
-86
lines changed

packages/grpc-js-xds/src/load-balancer-xds-cluster-impl.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ class XdsClusterImplLoadBalancingConfig implements TypedLoadBalancingConfig {
7070
cluster: this.cluster,
7171
drop_categories: this.dropCategories,
7272
child_policy: [this.childPolicy.toJsonObject()],
73-
max_concurrent_requests: this.maxConcurrentRequests
73+
max_concurrent_requests: this.maxConcurrentRequests,
74+
eds_service_name: this.edsServiceName,
75+
lrs_load_reporting_server: this.lrsLoadReportingServer,
7476
};
75-
if (this.edsServiceName !== undefined) {
76-
jsonObj.eds_service_name = this.edsServiceName;
77-
}
78-
if (this.lrsLoadReportingServer !== undefined) {
79-
jsonObj.lrs_load_reporting_server_name = this.lrsLoadReportingServer;
80-
}
8177
return {
8278
[TYPE_NAME]: jsonObj
8379
};

packages/grpc-js-xds/test/test-confg-parsing.ts

Lines changed: 47 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,22 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
6969
name: 'empty fields',
7070
input: {
7171
discovery_mechanisms: [],
72-
locality_picking_policy: [],
73-
endpoint_picking_policy: []
72+
xds_lb_policy: []
7473
}
7574
},
7675
{
7776
name: 'missing discovery_mechanisms',
7877
input: {
79-
locality_picking_policy: [],
80-
endpoint_picking_policy: []
78+
xds_lb_policy: []
8179
},
8280
error: /discovery_mechanisms/
8381
},
8482
{
85-
name: 'missing locality_picking_policy',
83+
name: 'missing xds_lb_policy',
8684
input: {
87-
discovery_mechanisms: [],
88-
endpoint_picking_policy: []
89-
},
90-
error: /locality_picking_policy/
91-
},
92-
{
93-
name: 'missing endpoint_picking_policy',
94-
input: {
95-
discovery_mechanisms: [],
96-
locality_picking_policy: []
85+
discovery_mechanisms: []
9786
},
98-
error: /endpoint_picking_policy/
87+
error: /xds_lb_policy/
9988
},
10089
{
10190
name: 'discovery_mechanism: EDS',
@@ -104,17 +93,15 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
10493
cluster: 'abc',
10594
type: 'EDS'
10695
}],
107-
locality_picking_policy: [],
108-
endpoint_picking_policy: []
96+
xds_lb_policy: []
10997
},
11098
output: {
11199
discovery_mechanisms: [{
112100
cluster: 'abc',
113101
type: 'EDS',
114102
lrs_load_reporting_server: undefined
115103
}],
116-
locality_picking_policy: [],
117-
endpoint_picking_policy: []
104+
xds_lb_policy: []
118105
}
119106
},
120107
{
@@ -124,17 +111,15 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
124111
cluster: 'abc',
125112
type: 'LOGICAL_DNS'
126113
}],
127-
locality_picking_policy: [],
128-
endpoint_picking_policy: []
114+
xds_lb_policy: []
129115
},
130116
output: {
131117
discovery_mechanisms: [{
132118
cluster: 'abc',
133119
type: 'LOGICAL_DNS',
134120
lrs_load_reporting_server: undefined
135121
}],
136-
locality_picking_policy: [],
137-
endpoint_picking_policy: []
122+
xds_lb_policy: []
138123
}
139124
},
140125
{
@@ -148,8 +133,7 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
148133
dns_hostname: undefined,
149134
lrs_load_reporting_server: undefined
150135
}],
151-
locality_picking_policy: [],
152-
endpoint_picking_policy: []
136+
xds_lb_policy: []
153137
}
154138
},
155139
{
@@ -170,8 +154,7 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
170154
server_features: ['test']
171155
}
172156
}],
173-
locality_picking_policy: [],
174-
endpoint_picking_policy: []
157+
xds_lb_policy: []
175158
}
176159
}
177160
],
@@ -180,12 +163,30 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
180163
name: 'only required fields',
181164
input: {
182165
cluster: 'abc',
166+
eds_service_name: 'def',
183167
drop_categories: [],
168+
lrs_load_reporting_server: {
169+
server_uri: 'localhost:12345',
170+
channel_creds: [{
171+
type: 'google_default',
172+
config: {}
173+
}],
174+
server_features: ['test']
175+
},
184176
child_policy: [{round_robin: {}}]
185177
},
186178
output: {
187179
cluster: 'abc',
180+
eds_service_name: 'def',
188181
drop_categories: [],
182+
lrs_load_reporting_server: {
183+
server_uri: 'localhost:12345',
184+
channel_creds: [{
185+
type: 'google_default',
186+
config: {}
187+
}],
188+
server_features: ['test']
189+
},
189190
child_policy: [{round_robin: {}}],
190191
max_concurrent_requests: 1024
191192
}
@@ -194,88 +195,55 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
194195
name: 'undefined optional fields',
195196
input: {
196197
cluster: 'abc',
197-
drop_categories: [],
198-
child_policy: [{round_robin: {}}],
199-
eds_service_name: undefined,
200-
max_concurrent_requests: undefined
201-
},
202-
output: {
203-
cluster: 'abc',
204-
drop_categories: [],
205-
child_policy: [{round_robin: {}}],
206-
max_concurrent_requests: 1024
207-
}
208-
},
209-
{
210-
name: 'populated optional fields',
211-
input: {
212-
cluster: 'abc',
213-
drop_categories: [{
214-
category: 'test',
215-
requests_per_million: 100
216-
}],
217-
child_policy: [{round_robin: {}}],
218-
eds_service_name: 'def',
219-
max_concurrent_requests: 123
220-
},
221-
}
222-
],
223-
lrs: [
224-
{
225-
name: 'only required fields',
226-
input: {
227-
cluster_name: 'abc',
228198
eds_service_name: 'def',
229-
locality: {},
230-
child_policy: [{round_robin: {}}],
199+
drop_categories: [],
231200
lrs_load_reporting_server: {
232201
server_uri: 'localhost:12345',
233202
channel_creds: [{
234203
type: 'google_default',
235204
config: {}
236205
}],
237206
server_features: ['test']
238-
}
207+
},
208+
child_policy: [{round_robin: {}}],
209+
max_concurrent_requests: undefined
239210
},
240211
output: {
241-
cluster_name: 'abc',
212+
cluster: 'abc',
242213
eds_service_name: 'def',
243-
locality: {
244-
region: '',
245-
zone: '',
246-
sub_zone: ''
247-
},
248-
child_policy: [{round_robin: {}}],
214+
drop_categories: [],
249215
lrs_load_reporting_server: {
250216
server_uri: 'localhost:12345',
251217
channel_creds: [{
252218
type: 'google_default',
253219
config: {}
254220
}],
255221
server_features: ['test']
256-
}
222+
},
223+
child_policy: [{round_robin: {}}],
224+
max_concurrent_requests: 1024
257225
}
258226
},
259227
{
260228
name: 'populated optional fields',
261229
input: {
262-
cluster_name: 'abc',
230+
cluster: 'abc',
263231
eds_service_name: 'def',
264-
locality: {
265-
region: 'a',
266-
zone: 'b',
267-
sub_zone: 'c'
268-
},
269-
child_policy: [{round_robin: {}}],
232+
drop_categories: [{
233+
category: 'test',
234+
requests_per_million: 100
235+
}],
270236
lrs_load_reporting_server: {
271237
server_uri: 'localhost:12345',
272238
channel_creds: [{
273239
type: 'google_default',
274240
config: {}
275241
}],
276242
server_features: ['test']
277-
}
278-
}
243+
},
244+
child_policy: [{round_robin: {}}],
245+
max_concurrent_requests: 123
246+
},
279247
}
280248
],
281249
priority: [

0 commit comments

Comments
 (0)