From 75524e1adc5a75abb317e93a63c2d4ac50a31614 Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Tue, 27 Aug 2019 10:38:47 -0700 Subject: [PATCH 1/9] deprecated check Signed-off-by: Jyoti Mahapatra --- test/tools/router_check/router.cc | 9 ++++++++- test/tools/router_check/router.h | 10 +++++++++- test/tools/router_check/router_check.cc | 5 +++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index 6922d26cea2f..63a7fcb5fa52 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -63,7 +63,8 @@ ToolConfig::ToolConfig(std::unique_ptr headers, int ran : headers_(std::move(headers)), random_value_(random_value) {} // static -RouterCheckTool RouterCheckTool::create(const std::string& router_config_file) { +RouterCheckTool RouterCheckTool::create(const std::string& router_config_file, + const bool disableDeprecationCheck) { // TODO(hennna): Allow users to load a full config and extract the route configuration from it. envoy::api::v2::RouteConfiguration route_config; auto stats = std::make_unique(); @@ -72,6 +73,9 @@ RouterCheckTool RouterCheckTool::create(const std::string& router_config_file) { auto factory_context = std::make_unique>(); auto config = std::make_unique(route_config, *factory_context, false); + if (!disableDeprecationCheck) { + MessageUtil::checkForDeprecation(route_config, &factory_context->runtime_loader_); + } return RouterCheckTool(std::move(factory_context), std::move(config), std::move(stats), std::move(api), Coverage(route_config)); @@ -439,6 +443,8 @@ Options::Options(int argc, char** argv) { TCLAP::CmdLine cmd("router_check_tool", ' ', "none", true); TCLAP::SwitchArg is_proto("p", "useproto", "Use Proto test file schema", cmd, false); TCLAP::SwitchArg is_detailed("d", "details", "Show detailed test execution results", cmd, false); + TCLAP::SwitchArg disable_deprecation_check("", "disable-deprecation-check", + "Disable deprecated fields check", cmd, true); TCLAP::ValueArg fail_under("f", "fail-under", "Fail if test coverage is under a specified amount", false, 0.0, "float", cmd); @@ -461,6 +467,7 @@ Options::Options(int argc, char** argv) { is_detailed_ = is_detailed.getValue(); fail_under_ = fail_under.getValue(); comprehensive_coverage_ = comprehensive_coverage.getValue(); + disable_deprecation_check_ = disable_deprecation_check.getValue(); if (is_proto_) { config_path_ = config_path.getValue(); diff --git a/test/tools/router_check/router.h b/test/tools/router_check/router.h index 7c81835da7ae..13f0eaf5e311 100644 --- a/test/tools/router_check/router.h +++ b/test/tools/router_check/router.h @@ -65,10 +65,12 @@ class RouterCheckTool : Logger::Loggable { public: /** * @param router_config_file v2 router config file. + * @param disableDeprecationCheck flag to disable the RouteConfig deprecated field check * @return RouterCheckTool a RouterCheckTool instance with member variables set by the router * config file. * */ - static RouterCheckTool create(const std::string& router_config_file); + static RouterCheckTool create(const std::string& router_config_file, + const bool disableDeprecationCheck); /** * TODO(tonya11en): Use a YAML format for the expected routes. This will require a proto. @@ -198,6 +200,11 @@ class Options { */ bool isDetailed() const { return is_detailed_; } + /** + * @return true if the deprecated field check is disabled. + */ + bool disableDeprecationCheck() const { return disable_deprecation_check_; } + private: std::string test_path_; std::string config_path_; @@ -207,5 +214,6 @@ class Options { bool comprehensive_coverage_; bool is_proto_; bool is_detailed_; + bool disable_deprecation_check_; }; } // namespace Envoy diff --git a/test/tools/router_check/router_check.cc b/test/tools/router_check/router_check.cc index e17f3eecc827..8d3c5b6fc72c 100644 --- a/test/tools/router_check/router_check.cc +++ b/test/tools/router_check/router_check.cc @@ -10,8 +10,9 @@ int main(int argc, char* argv[]) { const bool enforce_coverage = options.failUnder() != 0.0; try { Envoy::RouterCheckTool checktool = - options.isProto() ? Envoy::RouterCheckTool::create(options.configPath()) - : Envoy::RouterCheckTool::create(options.unlabelledConfigPath()); + options.isProto() ? Envoy::RouterCheckTool::create(options.configPath(), true) + : Envoy::RouterCheckTool::create(options.unlabelledConfigPath(), + options.disableDeprecationCheck()); if (options.isDetailed()) { checktool.setShowDetails(); From 22178384e5b3f1fd494655a81f210d17a7c2e075 Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Tue, 27 Aug 2019 11:07:09 -0700 Subject: [PATCH 2/9] docs Signed-off-by: Jyoti Mahapatra --- docs/root/install/tools/route_table_check_tool.rst | 10 ++++++++++ test/tools/router_check/router.cc | 2 +- test/tools/router_check/router.h | 2 +- test/tools/router_check/router_check.cc | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/root/install/tools/route_table_check_tool.rst b/docs/root/install/tools/route_table_check_tool.rst index ac0b523eec09..8acb2ac34a9d 100644 --- a/docs/root/install/tools/route_table_check_tool.rst +++ b/docs/root/install/tools/route_table_check_tool.rst @@ -40,6 +40,16 @@ Usage -p, --useproto Use Proto test file schema + -f, --fail-under + Represents a percent value for route test coverage under which the run should fail. + + --covall + Enables comprehensive code coverage percent calculation taking into account all the possible + asserts. + + --disable-deprecation-check + Disables the deprecation check for RouteConfiguration proto. + -h, --help Displays usage information and exits. diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index 63a7fcb5fa52..5eeadc7a1bb1 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -444,7 +444,7 @@ Options::Options(int argc, char** argv) { TCLAP::SwitchArg is_proto("p", "useproto", "Use Proto test file schema", cmd, false); TCLAP::SwitchArg is_detailed("d", "details", "Show detailed test execution results", cmd, false); TCLAP::SwitchArg disable_deprecation_check("", "disable-deprecation-check", - "Disable deprecated fields check", cmd, true); + "Disable deprecated fields check", cmd, false); TCLAP::ValueArg fail_under("f", "fail-under", "Fail if test coverage is under a specified amount", false, 0.0, "float", cmd); diff --git a/test/tools/router_check/router.h b/test/tools/router_check/router.h index 13f0eaf5e311..e2156afa1072 100644 --- a/test/tools/router_check/router.h +++ b/test/tools/router_check/router.h @@ -201,7 +201,7 @@ class Options { bool isDetailed() const { return is_detailed_; } /** - * @return true if the deprecated field check is disabled. + * @return true if the deprecated field check for RouteConfiguration is disabled. */ bool disableDeprecationCheck() const { return disable_deprecation_check_; } diff --git a/test/tools/router_check/router_check.cc b/test/tools/router_check/router_check.cc index 8d3c5b6fc72c..f3856e285d8c 100644 --- a/test/tools/router_check/router_check.cc +++ b/test/tools/router_check/router_check.cc @@ -10,9 +10,9 @@ int main(int argc, char* argv[]) { const bool enforce_coverage = options.failUnder() != 0.0; try { Envoy::RouterCheckTool checktool = - options.isProto() ? Envoy::RouterCheckTool::create(options.configPath(), true) - : Envoy::RouterCheckTool::create(options.unlabelledConfigPath(), - options.disableDeprecationCheck()); + options.isProto() ? Envoy::RouterCheckTool::create(options.configPath(), + options.disableDeprecationCheck()) + : Envoy::RouterCheckTool::create(options.unlabelledConfigPath(), true); if (options.isDetailed()) { checktool.setShowDetails(); From abd24d9827ba40dfde1adaa5f98d941634dc5058 Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Tue, 27 Aug 2019 11:12:05 -0700 Subject: [PATCH 3/9] docs Signed-off-by: Jyoti Mahapatra --- docs/root/intro/version_history.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index 63fb953c060a..f92c66a41ecc 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -43,6 +43,7 @@ Version history * router: added :ref:`rq_retry_skipped_request_not_complete ` counter stat to router stats. * router check tool: add coverage reporting & enforcement. * router check tool: add comprehensive coverage reporting. +* router check tool: add deprecated field check. * tls: added verification of IP address SAN fields in certificates against configured SANs in the certificate validation context. * upstream: added network filter chains to upstream connections, see :ref:`filters`. From b8f5dd4b0c3f1a36af7fd2ef44f0c329599b1b5e Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Thu, 29 Aug 2019 01:02:57 -0700 Subject: [PATCH 4/9] fixtests Signed-off-by: Jyoti Mahapatra --- .../test/config/HeaderMatchedRouting.yaml | 4 +- .../router_check/test/config/TestRoutes.yaml | 63 ++++++++++++++----- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/test/tools/router_check/test/config/HeaderMatchedRouting.yaml b/test/tools/router_check/test/config/HeaderMatchedRouting.yaml index f28c96a50a03..5f891bea08d5 100644 --- a/test/tools/router_check/test/config/HeaderMatchedRouting.yaml +++ b/test/tools/router_check/test/config/HeaderMatchedRouting.yaml @@ -30,7 +30,9 @@ virtual_hosts: prefix: / headers: - name: test_header_pattern - regex_match: ^user=test-\d+$ + safe_regex_match: + google_re2: {} + regex: ^user=test-\d+$ route: cluster: local_service_with_header_pattern_set_regex - match: diff --git a/test/tools/router_check/test/config/TestRoutes.yaml b/test/tools/router_check/test/config/TestRoutes.yaml index 34b665fb9fd5..862b6a4da8d5 100644 --- a/test/tools/router_check/test/config/TestRoutes.yaml +++ b/test/tools/router_check/test/config/TestRoutes.yaml @@ -104,26 +104,61 @@ virtual_hosts: timeout: seconds: 30 virtual_clusters: - - pattern: ^/rides$ - method: POST + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/rides$ + - name: :method + exact_match: POST name: ride_request - - pattern: ^/rides/\d+$ - method: PUT + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/rides/\d+$ + - name: :method + exact_match: PUT name: update_ride - - pattern: ^/users/\d+/chargeaccounts$ - method: POST + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/users/\d+/chargeaccounts$ + - name: :method + exact_match: POST name: cc_add - - pattern: ^/users/\d+/chargeaccounts/(?!validate)\w+$ - method: PUT + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/users/\d+/chargeaccounts/[^validate]\w+$ + - name: :method + exact_match: PUT name: cc_add - - pattern: ^/users$ - method: POST + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/users$ + - name: :method + exact_match: POST name: create_user_login - - pattern: ^/users/\d+$ - method: PUT + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/users/\d+$ + - name: :method + exact_match: PUT name: update_user - - pattern: ^/users/\d+/location$ - method: POST + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/users/\d+/location$ + - name: :method + exact_match: POST name: ulu internal_only_headers: - x-lyft-user-id From 51b9d27eb5e112de338da96f877a6351dfb79c35 Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Thu, 29 Aug 2019 18:14:22 -0700 Subject: [PATCH 5/9] tests Signed-off-by: Jyoti Mahapatra --- test/tools/router_check/router.cc | 36 +++++------ .../config/ComprehensiveRoutes.golden.json | 56 ----------------- .../ComprehensiveRoutes.golden.proto.json | 63 +++++++++++++++++++ .../test/config/ComprehensiveRoutes.yaml | 9 ++- .../test/config/Weighted.golden.proto.pb_text | 4 +- test/tools/router_check/test/route_tests.sh | 5 +- test/tools/router_check/validation.proto | 13 ++-- 7 files changed, 100 insertions(+), 86 deletions(-) delete mode 100644 test/tools/router_check/test/config/ComprehensiveRoutes.golden.json create mode 100644 test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index 5eeadc7a1bb1..fbd9eaed7031 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -224,13 +224,13 @@ bool RouterCheckTool::compareCluster(ToolConfig& tool_config, const std::string& bool RouterCheckTool::compareCluster( ToolConfig& tool_config, const envoy::RouterCheckToolSchema::ValidationAssert& expected) { - if (expected.cluster_name().empty()) { + if (!expected.has_cluster_name()) { return true; } if (tool_config.route_ == nullptr) { - return compareResults("", expected.cluster_name(), "cluster_name"); + return compareResults("", expected.cluster_name().value(), "cluster_name"); } - return compareCluster(tool_config, expected.cluster_name()); + return compareCluster(tool_config, expected.cluster_name().value()); } bool RouterCheckTool::compareVirtualCluster(ToolConfig& tool_config, const std::string& expected) { @@ -251,13 +251,13 @@ bool RouterCheckTool::compareVirtualCluster(ToolConfig& tool_config, const std:: bool RouterCheckTool::compareVirtualCluster( ToolConfig& tool_config, const envoy::RouterCheckToolSchema::ValidationAssert& expected) { - if (expected.virtual_cluster_name().empty()) { + if (!expected.has_virtual_cluster_name()) { return true; } if (tool_config.route_ == nullptr) { - return compareResults("", expected.virtual_cluster_name(), "virtual_cluster_name"); + return compareResults("", expected.virtual_cluster_name().value(), "virtual_cluster_name"); } - return compareVirtualCluster(tool_config, expected.virtual_cluster_name()); + return compareVirtualCluster(tool_config, expected.virtual_cluster_name().value()); } bool RouterCheckTool::compareVirtualHost(ToolConfig& tool_config, const std::string& expected) { @@ -275,13 +275,13 @@ bool RouterCheckTool::compareVirtualHost(ToolConfig& tool_config, const std::str bool RouterCheckTool::compareVirtualHost( ToolConfig& tool_config, const envoy::RouterCheckToolSchema::ValidationAssert& expected) { - if (expected.virtual_host_name().empty()) { + if (!expected.has_virtual_host_name()) { return true; } if (tool_config.route_ == nullptr) { - return compareResults("", expected.virtual_host_name(), "virtual_host_name"); + return compareResults("", expected.virtual_host_name().value(), "virtual_host_name"); } - return compareVirtualHost(tool_config, expected.virtual_host_name()); + return compareVirtualHost(tool_config, expected.virtual_host_name().value()); } bool RouterCheckTool::compareRewritePath(ToolConfig& tool_config, const std::string& expected) { @@ -306,13 +306,13 @@ bool RouterCheckTool::compareRewritePath(ToolConfig& tool_config, const std::str bool RouterCheckTool::compareRewritePath( ToolConfig& tool_config, const envoy::RouterCheckToolSchema::ValidationAssert& expected) { - if (expected.path_rewrite().empty()) { + if (!expected.has_path_rewrite()) { return true; } if (tool_config.route_ == nullptr) { - return compareResults("", expected.path_rewrite(), "path_rewrite"); + return compareResults("", expected.path_rewrite().value(), "path_rewrite"); } - return compareRewritePath(tool_config, expected.path_rewrite()); + return compareRewritePath(tool_config, expected.path_rewrite().value()); } bool RouterCheckTool::compareRewriteHost(ToolConfig& tool_config, const std::string& expected) { @@ -337,13 +337,13 @@ bool RouterCheckTool::compareRewriteHost(ToolConfig& tool_config, const std::str bool RouterCheckTool::compareRewriteHost( ToolConfig& tool_config, const envoy::RouterCheckToolSchema::ValidationAssert& expected) { - if (expected.host_rewrite().empty()) { + if (!expected.has_host_rewrite()) { return true; } if (tool_config.route_ == nullptr) { - return compareResults("", expected.host_rewrite(), "host_rewrite"); + return compareResults("", expected.host_rewrite().value(), "host_rewrite"); } - return compareRewriteHost(tool_config, expected.host_rewrite()); + return compareRewriteHost(tool_config, expected.host_rewrite().value()); } bool RouterCheckTool::compareRedirectPath(ToolConfig& tool_config, const std::string& expected) { @@ -361,13 +361,13 @@ bool RouterCheckTool::compareRedirectPath(ToolConfig& tool_config, const std::st bool RouterCheckTool::compareRedirectPath( ToolConfig& tool_config, const envoy::RouterCheckToolSchema::ValidationAssert& expected) { - if (expected.path_redirect().empty()) { + if (!expected.has_path_redirect()) { return true; } if (tool_config.route_ == nullptr) { - return compareResults("", expected.path_redirect(), "path_redirect"); + return compareResults("", expected.path_redirect().value(), "path_redirect"); } - return compareRedirectPath(tool_config, expected.path_redirect()); + return compareRedirectPath(tool_config, expected.path_redirect().value()); } bool RouterCheckTool::compareHeaderField( diff --git a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json deleted file mode 100644 index 5a0e4d8725e4..000000000000 --- a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "test_name": "Test 1", - "input": { - ":authority": "www.lyft.com", - ":path": "/new_endpoint" - }, - "validate": { - "cluster_name": "www2", - "virtual_cluster_name": "other", - "virtual_host_name": "www2_host", - "path_rewrite": "/api/new_endpoint", - "host_rewrite": "www.lyft.com", - "path_redirect": "" - } - }, - { - "test_name": "Test 2", - "input": { - ":authority": "www.lyft.com", - ":path": "/" - }, - "validate": { - "cluster_name": "root_www2", - "virtual_cluster_name": "other", - "virtual_host_name": "www2_host", - "path_rewrite": "/", - "host_rewrite": "www.lyft.com", - "path_redirect": "" - } - }, - { - "test_name": "Test 3", - "input": { - ":authority": "www.lyft.com", - ":path": "/foobar" - }, - "validate": { - "cluster_name": "www2", - "virtual_cluster_name": "other", - "virtual_host_name": "www2_host", - "path_rewrite": "/foobar", - "host_rewrite": "www.lyft.com", - "path_redirect": "" - } - }, - { - "test_name": "Test 4", - "input": { - ":authority": "www.lyft.com", - ":path": "/users/123", - ":method": "PUT" - }, - "validate": {"virtual_cluster_name": "update_user"} - } -] diff --git a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json new file mode 100644 index 000000000000..12b53b7a6c61 --- /dev/null +++ b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json @@ -0,0 +1,63 @@ +{ + "tests": [ + { + "test_name": "Test 1", + "input": { + "authority": "www.lyft.com", + "path": "/new_endpoint", + "method": "GET" + }, + "validate": { + "cluster_name": "www2", + "virtual_cluster_name": "other", + "virtual_host_name": "www2_host", + "path_rewrite": "/api/new_endpoint", + "host_rewrite": "www.lyft.com", + "path_redirect": "" + } + }, + { + "test_name": "Test 2", + "input": { + "authority": "www.lyft.com", + "path": "/", + "method": "GET" + }, + "validate": { + "cluster_name": "root_www2", + "virtual_cluster_name": "other", + "virtual_host_name": "www2_host", + "path_rewrite": "/", + "host_rewrite": "www.lyft.com", + "path_redirect": "" + } + }, + { + "test_name": "Test 3", + "input": { + "authority": "www.lyft.com", + "path": "/foobar", + "method": "GET" + }, + "validate": { + "cluster_name": "www2", + "virtual_cluster_name": "other", + "virtual_host_name": "www2_host", + "path_rewrite": "/foobar", + "host_rewrite": "www.lyft.com", + "path_redirect": "" + } + }, + { + "test_name": "Test 4", + "input": { + "authority": "www.lyft.com", + "path": "/users/123", + "method": "PUT" + }, + "validate": { + "virtual_cluster_name": "update_user" + } + } + ] +} \ No newline at end of file diff --git a/test/tools/router_check/test/config/ComprehensiveRoutes.yaml b/test/tools/router_check/test/config/ComprehensiveRoutes.yaml index 0613410256ca..6efad99a099e 100644 --- a/test/tools/router_check/test/config/ComprehensiveRoutes.yaml +++ b/test/tools/router_check/test/config/ComprehensiveRoutes.yaml @@ -17,6 +17,11 @@ virtual_hosts: route: cluster: www2 virtual_clusters: - - pattern: ^/users/\d+$ - method: PUT + - headers: + - name: :path + safe_regex_match: + google_re2: {} + regex: ^/users/\d+$ + - name: :method + exact_match: PUT name: update_user diff --git a/test/tools/router_check/test/config/Weighted.golden.proto.pb_text b/test/tools/router_check/test/config/Weighted.golden.proto.pb_text index c2ab5d18c377..fa7dedcb27c5 100644 --- a/test/tools/router_check/test/config/Weighted.golden.proto.pb_text +++ b/test/tools/router_check/test/config/Weighted.golden.proto.pb_text @@ -8,7 +8,7 @@ tests { method: "GET" } validate: { - path_redirect: "" + path_redirect: { value: "" } } } @@ -21,6 +21,6 @@ tests { random_value: 115 } validate: { - cluster_name: "cluster1" + cluster_name: { value: "cluster1" } } } \ No newline at end of file diff --git a/test/tools/router_check/test/route_tests.sh b/test/tools/router_check/test/route_tests.sh index 0b06cb7425bf..870063b34cb7 100755 --- a/test/tools/router_check/test/route_tests.sh +++ b/test/tools/router_check/test/route_tests.sh @@ -24,8 +24,9 @@ if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: "* ]] ; then exit 1 fi -COMP_COVERAGE_CMD="${PATH_BIN} ${PATH_CONFIG}/ComprehensiveRoutes.yaml ${PATH_CONFIG}/ComprehensiveRoutes.golden.json --details -f " -COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "100" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" +COMP_COVERAGE_CMD="${PATH_BIN} -c ${PATH_CONFIG}/ComprehensiveRoutes.yaml -t ${PATH_CONFIG}/ComprehensiveRoutes.golden.proto.json --details --useproto -f " +echo $COMP_COVERAGE_CMD "100" "--covall" +COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "94.4444" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: 100%"* ]] ; then exit 1 fi diff --git a/test/tools/router_check/validation.proto b/test/tools/router_check/validation.proto index 9c86153cd3e9..4ff3ab35f434 100644 --- a/test/tools/router_check/validation.proto +++ b/test/tools/router_check/validation.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package envoy.RouterCheckToolSchema; import "envoy/api/v2/core/base.proto"; +import "google/protobuf/wrappers.proto"; import "validate/validate.proto"; // [#protodoc-title: RouterCheckTool Validation] @@ -78,22 +79,22 @@ message ValidationInput { // For example, to test that no cluster match is expected use {“cluster_name”: “”}. message ValidationAssert { // Match the cluster name. - string cluster_name = 1; + google.protobuf.StringValue cluster_name = 1; // Match the virtual cluster name. - string virtual_cluster_name = 2; + google.protobuf.StringValue virtual_cluster_name = 2; // Match the virtual host name. - string virtual_host_name = 3; + google.protobuf.StringValue virtual_host_name = 3; // Match the host header field after rewrite. - string host_rewrite = 4; + google.protobuf.StringValue host_rewrite = 4; // Match the path header field after rewrite. - string path_rewrite = 5; + google.protobuf.StringValue path_rewrite = 5; // Match the returned redirect path. - string path_redirect = 6; + google.protobuf.StringValue path_redirect = 6; // Match the listed header fields. // Examples header fields include the “:path”, “cookie”, and “date” fields. From 856751c91a977a00c5471790d2c7a5ce0785c5de Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Thu, 29 Aug 2019 18:18:45 -0700 Subject: [PATCH 6/9] tests Signed-off-by: Jyoti Mahapatra --- .../config/ComprehensiveRoutes.golden.json | 56 +++++++++++++++++++ test/tools/router_check/test/route_tests.sh | 7 ++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/tools/router_check/test/config/ComprehensiveRoutes.golden.json diff --git a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json new file mode 100644 index 000000000000..be84b10242a4 --- /dev/null +++ b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json @@ -0,0 +1,56 @@ +[ + { + "test_name": "Test 1", + "input": { + ":authority": "www.lyft.com", + ":path": "/new_endpoint" + }, + "validate": { + "cluster_name": "www2", + "virtual_cluster_name": "other", + "virtual_host_name": "www2_host", + "path_rewrite": "/api/new_endpoint", + "host_rewrite": "www.lyft.com", + "path_redirect": "" + } + }, + { + "test_name": "Test 2", + "input": { + ":authority": "www.lyft.com", + ":path": "/" + }, + "validate": { + "cluster_name": "root_www2", + "virtual_cluster_name": "other", + "virtual_host_name": "www2_host", + "path_rewrite": "/", + "host_rewrite": "www.lyft.com", + "path_redirect": "" + } + }, + { + "test_name": "Test 3", + "input": { + ":authority": "www.lyft.com", + ":path": "/foobar" + }, + "validate": { + "cluster_name": "www2", + "virtual_cluster_name": "other", + "virtual_host_name": "www2_host", + "path_rewrite": "/foobar", + "host_rewrite": "www.lyft.com", + "path_redirect": "" + } + }, + { + "test_name": "Test 4", + "input": { + ":authority": "www.lyft.com", + ":path": "/users/123", + ":method": "PUT" + }, + "validate": {"virtual_cluster_name": "update_user"} + } +] \ No newline at end of file diff --git a/test/tools/router_check/test/route_tests.sh b/test/tools/router_check/test/route_tests.sh index 870063b34cb7..5a1440722cfe 100755 --- a/test/tools/router_check/test/route_tests.sh +++ b/test/tools/router_check/test/route_tests.sh @@ -25,7 +25,12 @@ if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: "* ]] ; then fi COMP_COVERAGE_CMD="${PATH_BIN} -c ${PATH_CONFIG}/ComprehensiveRoutes.yaml -t ${PATH_CONFIG}/ComprehensiveRoutes.golden.proto.json --details --useproto -f " -echo $COMP_COVERAGE_CMD "100" "--covall" +COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "94.4444" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" +if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: 100%"* ]] ; then + exit 1 +fi + +COMP_COVERAGE_CMD="${PATH_BIN} ${PATH_CONFIG}/ComprehensiveRoutes.yaml ${PATH_CONFIG}/ComprehensiveRoutes.golden.json --details -f " COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "94.4444" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: 100%"* ]] ; then exit 1 From e8decd5c2f42939f2a57cf3279ccace6ad086946 Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Thu, 29 Aug 2019 18:26:13 -0700 Subject: [PATCH 7/9] eof Signed-off-by: Jyoti Mahapatra --- .../router_check/test/config/ComprehensiveRoutes.golden.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json index be84b10242a4..5a0e4d8725e4 100644 --- a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json +++ b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.json @@ -53,4 +53,4 @@ }, "validate": {"virtual_cluster_name": "update_user"} } -] \ No newline at end of file +] From ab5d18c47118ac1bae49b792b5b52118e5756cf1 Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Thu, 29 Aug 2019 18:26:49 -0700 Subject: [PATCH 8/9] eof Signed-off-by: Jyoti Mahapatra --- .../test/config/ComprehensiveRoutes.golden.proto.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json index 12b53b7a6c61..ebc21381c347 100644 --- a/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json +++ b/test/tools/router_check/test/config/ComprehensiveRoutes.golden.proto.json @@ -60,4 +60,4 @@ } } ] -} \ No newline at end of file +} From e139575f6f4b00cbb34d2b76dacf7131f5dbdd5f Mon Sep 17 00:00:00 2001 From: Jyoti Mahapatra Date: Thu, 29 Aug 2019 18:28:22 -0700 Subject: [PATCH 9/9] 100 Signed-off-by: Jyoti Mahapatra --- test/tools/router_check/test/route_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tools/router_check/test/route_tests.sh b/test/tools/router_check/test/route_tests.sh index 5a1440722cfe..1e85bea3f598 100755 --- a/test/tools/router_check/test/route_tests.sh +++ b/test/tools/router_check/test/route_tests.sh @@ -25,13 +25,13 @@ if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: "* ]] ; then fi COMP_COVERAGE_CMD="${PATH_BIN} -c ${PATH_CONFIG}/ComprehensiveRoutes.yaml -t ${PATH_CONFIG}/ComprehensiveRoutes.golden.proto.json --details --useproto -f " -COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "94.4444" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" +COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "100" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: 100%"* ]] ; then exit 1 fi COMP_COVERAGE_CMD="${PATH_BIN} ${PATH_CONFIG}/ComprehensiveRoutes.yaml ${PATH_CONFIG}/ComprehensiveRoutes.golden.json --details -f " -COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "94.4444" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" +COVERAGE_OUTPUT=$($COMP_COVERAGE_CMD "100" "--covall" 2>&1) || echo "${COVERAGE_OUTPUT:-no-output}" if [[ "${COVERAGE_OUTPUT}" != *"Current route coverage: 100%"* ]] ; then exit 1 fi