Skip to content

Commit 0b2281b

Browse files
committed
Revert version support change, run ring_hash tests conditionallly
1 parent 9e487e4 commit 0b2281b

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

packages/grpc-js-xds/gulpfile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ const compile = checkTask(() => execNpmCommand('compile'));
6363
const runTests = checkTask(() => {
6464
process.env.GRPC_EXPERIMENTAL_XDS_FEDERATION = 'true';
6565
process.env.GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG = 'true';
66-
process.env.GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH = 'true';
66+
if (Number(process.versions.node.split('.')[0]) > 14) {
67+
process.env.GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH = 'true';
68+
}
6769
return gulp.src(`${outDir}/test/**/*.js`)
6870
.pipe(mocha({reporter: 'mocha-jenkins-reporter',
6971
require: ['ts-node/register']}));

packages/grpc-js-xds/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@grpc/grpc-js": "~1.8.0"
5454
},
5555
"engines": {
56-
"node": ">=16.0.0"
56+
"node": ">=10.10.0"
5757
},
5858
"files": [
5959
"src/**/*.ts",

packages/grpc-js-xds/src/resolver-xds.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,16 @@ class XdsResolver implements Resolver {
587587
const onCommitted = () => {
588588
this.unrefCluster(clusterResult.name);
589589
}
590-
const hash = action.getHash(metadata, channelId);
590+
let hash: string;
591+
if (EXPERIMENTAL_RING_HASH) {
592+
hash = `${action.getHash(metadata, channelId)}`;
593+
} else {
594+
hash = '';
595+
}
591596
return {
592597
methodConfig: clusterResult.methodConfig,
593598
onCommitted: onCommitted,
594-
pickInformation: {cluster: clusterResult.name, hash: `${hash}`},
599+
pickInformation: {cluster: clusterResult.name, hash: hash},
595600
status: status.OK,
596601
dynamicFilterFactories: clusterResult.dynamicFilterFactories
597602
};

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { experimental, LoadBalancingConfig } from "@grpc/grpc-js";
1919
import { register } from "../src";
2020
import assert = require("assert");
2121
import parseLoadbalancingConfig = experimental.parseLoadBalancingConfig;
22+
import { EXPERIMENTAL_RING_HASH } from "../src/environment";
2223

2324
register();
2425

@@ -34,6 +35,7 @@ interface TestCase {
3435
input: object,
3536
output?: object;
3637
error?: RegExp;
38+
skipIf?: boolean;
3739
}
3840

3941
/* The main purpose of these tests is to verify that configs that are expected
@@ -319,28 +321,32 @@ const allTestCases: {[lbPolicyName: string]: TestCase[]} = {
319321
output: {
320322
min_ring_size: 1024,
321323
max_ring_size: 4096
322-
}
324+
},
325+
skipIf: !EXPERIMENTAL_RING_HASH
323326
},
324327
{
325328
name: 'populated config',
326329
input: {
327330
min_ring_size: 2048,
328331
max_ring_size: 8192
329-
}
332+
},
333+
skipIf: !EXPERIMENTAL_RING_HASH
330334
},
331335
{
332336
name: 'min_ring_size too large',
333337
input: {
334338
min_ring_size: 8_388_609
335339
},
336-
error: /min_ring_size/
340+
error: /min_ring_size/,
341+
skipIf: !EXPERIMENTAL_RING_HASH
337342
},
338343
{
339344
name: 'max_ring_size too large',
340345
input: {
341346
max_ring_size: 8_388_609
342347
},
343-
error: /max_ring_size/
348+
error: /max_ring_size/,
349+
skipIf: !EXPERIMENTAL_RING_HASH
344350
}
345351
]
346352
}
@@ -349,7 +355,10 @@ describe('Load balancing policy config parsing', () => {
349355
for (const [lbPolicyName, testCases] of Object.entries(allTestCases)) {
350356
describe(lbPolicyName, () => {
351357
for (const testCase of testCases) {
352-
it(testCase.name, () => {
358+
it(testCase.name, function() {
359+
if (testCase.skipIf) {
360+
this.skip();
361+
}
353362
const lbConfigInput = {[lbPolicyName]: testCase.input};
354363
if (testCase.error) {
355364
assert.throws(() => {

packages/grpc-js-xds/test/test-ring-hash.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import assert = require("assert");
2525
import { Any } from "../src/generated/google/protobuf/Any";
2626
import { AnyExtension } from "@grpc/proto-loader";
2727
import { RingHash } from "../src/generated/envoy/extensions/load_balancing_policies/ring_hash/v3/RingHash";
28+
import { EXPERIMENTAL_RING_HASH } from "../src/environment";
2829

2930
register();
3031

@@ -41,7 +42,10 @@ describe('Ring hash LB policy', () => {
4142
client?.close();
4243
xdsServer?.shutdownServer();
4344
});
44-
it('Should route requests to the single backend with the old lbPolicy field', done => {
45+
it('Should route requests to the single backend with the old lbPolicy field', function(done) {
46+
if (!EXPERIMENTAL_RING_HASH) {
47+
this.skip();
48+
}
4549
const cluster = new FakeEdsCluster('cluster1', 'endpoint1', [{backends: [new Backend()], locality:{region: 'region1'}}], 'RING_HASH');
4650
const routeGroup = new FakeRouteGroup('listener1', 'route1', [{cluster: cluster}]);
4751
routeGroup.startAllBackends().then(() => {
@@ -59,7 +63,10 @@ describe('Ring hash LB policy', () => {
5963
client.sendOneCall(done);
6064
}, reason => done(reason));
6165
});
62-
it('Should route requests to the single backend with the new load_balancing_policy field', done => {
66+
it('Should route requests to the single backend with the new load_balancing_policy field', function(done) {
67+
if (!EXPERIMENTAL_RING_HASH) {
68+
this.skip();
69+
}
6370
const lbPolicy: AnyExtension & RingHash = {
6471
'@type': 'type.googleapis.com/envoy.extensions.load_balancing_policies.ring_hash.v3.RingHash',
6572
hash_function: 'XX_HASH'
@@ -81,7 +88,10 @@ describe('Ring hash LB policy', () => {
8188
client.sendOneCall(done);
8289
}, reason => done(reason));
8390
});
84-
it('Should route all identical requests to the same backend', done => {
91+
it('Should route all identical requests to the same backend', function(done) {
92+
if (!EXPERIMENTAL_RING_HASH) {
93+
this.skip();
94+
}
8595
const backend1 = new Backend();
8696
const backend2 = new Backend()
8797
const cluster = new FakeEdsCluster('cluster1', 'endpoint1', [{backends: [backend1, backend2], locality:{region: 'region1'}}], 'RING_HASH');
@@ -105,4 +115,4 @@ describe('Ring hash LB policy', () => {
105115
})
106116
}, reason => done(reason));
107117
});
108-
})
118+
});

run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cd $ROOT
2828
git submodule update --init --recursive
2929

3030
if [ ! -n "$node_versions" ] ; then
31-
node_versions="16"
31+
node_versions="14 16"
3232
fi
3333

3434
set +ex

0 commit comments

Comments
 (0)