Merge branch 'master' into grpc-js-xds_federation

This commit is contained in:
Michael Lumish 2023-06-05 11:30:24 -07:00
commit 596d5f1192
7 changed files with 70 additions and 22 deletions

View File

@ -60,7 +60,7 @@ GRPC_NODE_TRACE=xds_client,xds_resolver,xds_cluster_manager,cds_balancer,xds_clu
--path_to_server_binary=/java_server/grpc-java/interop-testing/build/install/grpc-interop-testing/bin/xds-test-server \
--gcp_suffix=$(date '+%s') \
--verbose \
--qps=50 \
--qps=75 \
${XDS_V3_OPT-} \
--client_cmd="$(which node) --enable-source-maps --prof --logfile=${KOKORO_ARTIFACTS_DIR}/github/grpc/reports/prof.log grpc-node/packages/grpc-js-xds/build/interop/xds-interop-client \
--server=xds:///{server_uri} \

View File

@ -170,9 +170,6 @@ main() {
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
if (( failed_tests > 0 )); then
exit 1
fi
}
main "$@"

View File

@ -37,14 +37,19 @@ export interface ValueMatcher {
}
export class ExactValueMatcher implements ValueMatcher {
constructor(private targetValue: string) {}
constructor(private targetValue: string, private ignoreCase: boolean) {
}
apply(value: string) {
return value === this.targetValue;
if (this.ignoreCase) {
return value.toLowerCase() === this.targetValue.toLowerCase();
} else {
return value === this.targetValue;
}
}
toString() {
return 'Exact(' + this.targetValue + ')';
return 'Exact(' + this.targetValue + ', ignore_case=' + this.ignoreCase + ')';
}
}
@ -94,26 +99,51 @@ export class PresentValueMatcher implements ValueMatcher {
}
export class PrefixValueMatcher implements ValueMatcher {
constructor(private prefix: string) {}
constructor(private prefix: string, private ignoreCase: boolean) {
}
apply(value: string) {
return value.startsWith(this.prefix);
if (this.ignoreCase) {
return value.toLowerCase().startsWith(this.prefix.toLowerCase());
} else {
return value.startsWith(this.prefix);
}
}
toString() {
return 'Prefix(' + this.prefix + ')';
return 'Prefix(' + this.prefix + ', ignore_case=' + this.ignoreCase + ')';
}
}
export class SuffixValueMatcher implements ValueMatcher {
constructor(private suffix: string) {}
constructor(private suffix: string, private ignoreCase: boolean) {}
apply(value: string) {
return value.endsWith(this.suffix);
if (this.ignoreCase) {
return value.toLowerCase().endsWith(this.suffix.toLowerCase());
} else {
return value.endsWith(this.suffix);
}
}
toString() {
return 'Suffix(' + this.suffix + ')';
return 'Suffix(' + this.suffix + ', ignore_case=' + this.ignoreCase + ')';
}
}
export class ContainsValueMatcher implements ValueMatcher {
constructor(private contains: string, private ignoreCase: boolean) {}
apply(value: string) {
if (this.ignoreCase) {
return value.toLowerCase().includes(this.contains.toLowerCase());
} else {
return value.includes(this.contains);
}
}
toString() {
return 'Contains(' + this.contains + + ', ignore_case=' + this.ignoreCase + ')';
}
}

View File

@ -37,7 +37,7 @@ import { HeaderMatcher__Output } from './generated/envoy/config/route/v3/HeaderM
import ConfigSelector = experimental.ConfigSelector;
import LoadBalancingConfig = experimental.LoadBalancingConfig;
import { XdsClusterManagerLoadBalancingConfig } from './load-balancer-xds-cluster-manager';
import { ExactValueMatcher, FullMatcher, HeaderMatcher, Matcher, PathExactValueMatcher, PathPrefixValueMatcher, PathSafeRegexValueMatcher, PrefixValueMatcher, PresentValueMatcher, RangeValueMatcher, RejectValueMatcher, SafeRegexValueMatcher, SuffixValueMatcher, ValueMatcher } from './matcher';
import { ContainsValueMatcher, ExactValueMatcher, FullMatcher, HeaderMatcher, Matcher, PathExactValueMatcher, PathPrefixValueMatcher, PathSafeRegexValueMatcher, PrefixValueMatcher, PresentValueMatcher, RangeValueMatcher, RejectValueMatcher, SafeRegexValueMatcher, SuffixValueMatcher, ValueMatcher } from './matcher';
import { envoyFractionToFraction, Fraction } from "./fraction";
import { RouteAction, SingleClusterRouteAction, WeightedCluster, WeightedClusterRouteAction } from './route-action';
import { decodeSingleResource, HTTP_CONNECTION_MANGER_TYPE_URL } from './resources';
@ -136,7 +136,7 @@ function getPredicateForHeaderMatcher(headerMatch: HeaderMatcher__Output): Match
let valueChecker: ValueMatcher;
switch (headerMatch.header_match_specifier) {
case 'exact_match':
valueChecker = new ExactValueMatcher(headerMatch.exact_match!);
valueChecker = new ExactValueMatcher(headerMatch.exact_match!, false);
break;
case 'safe_regex_match':
valueChecker = new SafeRegexValueMatcher(headerMatch.safe_regex_match!.regex);
@ -150,10 +150,30 @@ function getPredicateForHeaderMatcher(headerMatch: HeaderMatcher__Output): Match
valueChecker = new PresentValueMatcher();
break;
case 'prefix_match':
valueChecker = new PrefixValueMatcher(headerMatch.prefix_match!);
valueChecker = new PrefixValueMatcher(headerMatch.prefix_match!, false);
break;
case 'suffix_match':
valueChecker = new SuffixValueMatcher(headerMatch.suffix_match!);
valueChecker = new SuffixValueMatcher(headerMatch.suffix_match!, false);
break;
case 'string_match':
const stringMatch = headerMatch.string_match!
switch (stringMatch.match_pattern) {
case 'exact':
valueChecker = new ExactValueMatcher(stringMatch.exact!, stringMatch.ignore_case);
break;
case 'safe_regex':
valueChecker = new SafeRegexValueMatcher(stringMatch.safe_regex!.regex);
break;
case 'prefix':
valueChecker = new PrefixValueMatcher(stringMatch.prefix!, stringMatch.ignore_case);
break;
case 'suffix':
valueChecker = new SuffixValueMatcher(stringMatch.suffix!, stringMatch.ignore_case);
break;
case 'contains':
valueChecker = new ContainsValueMatcher(stringMatch.contains!, stringMatch.ignore_case);
break;
}
break;
default:
valueChecker = new RejectValueMatcher();

View File

@ -29,7 +29,8 @@ const SUPPPORTED_HEADER_MATCH_SPECIFIERS = [
'range_match',
'present_match',
'prefix_match',
'suffix_match'];
'suffix_match',
'string_match'];
const SUPPORTED_CLUSTER_SPECIFIERS = ['cluster', 'weighted_clusters', 'cluster_header'];
const UINT32_MAX = 0xFFFFFFFF;

View File

@ -835,7 +835,7 @@ async function runScript() {
boolean: true,
default: false,
};
const argv = yargs
const argv = await yargs
.parserConfiguration({
'parse-positional-numbers': false
})

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/proto-loader",
"version": "0.7.6",
"version": "0.7.7",
"author": "Google Inc.",
"contributors": [
{
@ -49,14 +49,14 @@
"lodash.camelcase": "^4.3.0",
"long": "^4.0.0",
"protobufjs": "^7.0.0",
"yargs": "^16.2.0"
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/lodash.camelcase": "^4.3.4",
"@types/mkdirp": "^1.0.1",
"@types/mocha": "^5.2.7",
"@types/node": "^10.17.26",
"@types/yargs": "^16.0.4",
"@types/yargs": "^17.0.24",
"clang-format": "^1.2.2",
"gts": "^3.1.0",
"rimraf": "^3.0.2",