Skip to content

test: fix bad route entry test cases on Windows#11830

Merged
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
nigriMSFT:badrouteconfig-test
Jul 20, 2020
Merged

test: fix bad route entry test cases on Windows#11830
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
nigriMSFT:badrouteconfig-test

Conversation

@nigriMSFT
Copy link
Copy Markdown
Contributor

Signed-off-by: Nick Grifka nigri@microsoft.com

Commit Message: test: fix bad route entry test cases on Windows
Additional Description:
Risk Level: Low
Testing: Ran test cases locally on Windows
Docs Changes: NA
Release Notes: NA

Signed-off-by: Nick Grifka <nigri@microsoft.com>
@nigriMSFT
Copy link
Copy Markdown
Contributor Author

@lizan it seems ef7d81d change regarding yaml->protobuf conversion changed the expected exception message slightly for BadRouteEntryConfigPrefixAndPath and a few other test cases. On Windows, these test cases still seem to be producing the old exception message. Is this at all expected? Is it important that the exception message check be as specific as it is today? BadRouteEntryConfigPrefixAndPathAndRegex is an example of a more relaxed check that passes on both platforms.

For completeness, here is the expected vs. actual exception messages on Windows:

BadHttpRouteConfigurationsTest.BadRouteEntryConfigPrefixAndPath
expected: "invalid value oneof field 'path_specifier' is already set. Cannot set '(prefix|path)' for type oneof"
actual:   "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for type oneof"
BadHttpRouteConfigurationsTest.BadRouteEntryConfigPrefixAndRegex
expected: "invalid value oneof field 'path_specifier' is already set. Cannot set '(prefix|regex)' for type oneof"
actual:   "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for type oneof"
BadHttpRouteConfigurationsTest.BadRouteEntryConfigPathAndRegex
expected: "invalid value oneof field 'path_specifier' is already set. Cannot set '(path|regex)' for type oneof"
actual:   "invalid value oneof field 'path_specifier' is already set. Cannot set 'path' for type oneof"
BadHttpRouteConfigurationsTest.BadRouteEntryConfigPrefixAndPathAndRegex
expected: "invalid value oneof field 'path_specifier' is already set."
actual:   "invalid value oneof field 'path_specifier' is already set." (matches)

@nigriMSFT
Copy link
Copy Markdown
Contributor Author

@dio
Copy link
Copy Markdown
Member

dio commented Jul 6, 2020

@nigriMSFT I think you need to merge master.

TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException,
"invalid value oneof field 'path_specifier' is already set. Cannot set '(prefix|path)' for "
"type oneof");
"invalid value oneof field 'path_specifier' is already set.");
Copy link
Copy Markdown
Member

@dio dio Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So part of the message is missing/different when running on windows?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. For this example specifically, we get "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for type oneof"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the (prefix|path) part a regex capture group for the EXPECT_THROW_WITH_REGEX? I looks like this failure is a symptom of googletest not supporting more advanced regex

Running this test locally I see:

[ RUN      ] BadHttpRouteConfigurationsTest.BadRouteEntryConfigPrefixAndPath
external/com_google_googletest/googletest/src/gtest-port.cc(860): error: Failed
Syntax error at index 71 in simple regular expression "invalid value oneof field 'path_specifier' is already set. Cannot set '(prefix|path)' for type oneof":
'(' is unsupported.
Stack trace:
...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunjayBhatia is right. I've updated the PR to use GTEST_USES_SIMPLE_RE as we have done in other parts of the codebase, so that this can be simplified if/when google test supports capture groups Windows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realistically the only solve is the adoption of RE2, why Google test doesn't support Google RE2 is a little puzzling :-)

We can in fact shift as a project to pcre if we don't believe this is going to happen any time soon.

@dio
Copy link
Copy Markdown
Member

dio commented Jul 6, 2020

@nigriMSFT Sorry, I know this is annoying, but you need to fix DCO https://github.com/envoyproxy/envoy/blob/master/CONTRIBUTING.md#fixing-dco 🙏🏽.

Signed-off-by: Nick Grifka <nigri@microsoft.com>
@dio
Copy link
Copy Markdown
Member

dio commented Jul 6, 2020

Looks good. Running tools/code_format/code_format.py test/common/router/config_impl_test.cc should fix the formatting issue.

Format check failed, try apply following patch to fix:

diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc
index 2eab7fc6e..a0796a9f6 100644
--- a/test/common/router/config_impl_test.cc
+++ b/test/common/router/config_impl_test.cc
@@ -5109,12 +5109,12 @@ virtual_hosts:
   EXPECT_THAT_THROWS_MESSAGE(
       TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException,
       ::testing::AnyOf(
-        ::testing::ContainsRegex(
-          "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for "
-          "type oneof"),
-        ::testing::ContainsRegex(
-          "invalid value oneof field 'path_specifier' is already set. Cannot set 'path' for "
-          "type oneof")));
+          ::testing::ContainsRegex(
+              "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for "
+              "type oneof"),
+          ::testing::ContainsRegex(
+              "invalid value oneof field 'path_specifier' is already set. Cannot set 'path' for "
+              "type oneof")));
 #endif
 }
 
@@ -5157,12 +5157,12 @@ virtual_hosts:
   EXPECT_THAT_THROWS_MESSAGE(
       TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException,
       ::testing::AnyOf(
-        ::testing::ContainsRegex(
-          "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for "
-          "type oneof"),
-        ::testing::ContainsRegex(
-          "invalid value oneof field 'path_specifier' is already set. Cannot set 'regex' for "
-          "type oneof")));
+          ::testing::ContainsRegex(
+              "invalid value oneof field 'path_specifier' is already set. Cannot set 'prefix' for "
+              "type oneof"),
+          ::testing::ContainsRegex(
+              "invalid value oneof field 'path_specifier' is already set. Cannot set 'regex' for "
+              "type oneof")));
 #endif
 }
 
@@ -5205,12 +5205,12 @@ virtual_hosts:
   EXPECT_THAT_THROWS_MESSAGE(
       TestConfigImpl(parseRouteConfigurationFromYaml(yaml), factory_context_, true), EnvoyException,
       ::testing::AnyOf(
-        ::testing::ContainsRegex(
-          "invalid value oneof field 'path_specifier' is already set. Cannot set 'path' for "
-          "type oneof"),
-        ::testing::ContainsRegex(
-          "invalid value oneof field 'path_specifier' is already set. Cannot set 'regex' for "
-          "type oneof")));
+          ::testing::ContainsRegex(
+              "invalid value oneof field 'path_specifier' is already set. Cannot set 'path' for "
+              "type oneof"),
+          ::testing::ContainsRegex(
+              "invalid value oneof field 'path_specifier' is already set. Cannot set 'regex' for "
+              "type oneof")));
 #endif
 }

Signed-off-by: Nick Grifka <nigri@microsoft.com>
@dio
Copy link
Copy Markdown
Member

dio commented Jul 10, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dio
Copy link
Copy Markdown
Member

dio commented Jul 13, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dio
Copy link
Copy Markdown
Member

dio commented Jul 14, 2020

@nigriMSFT sorry. Seems like you need to sync with head to pick some CI fixes.

Signed-off-by: Nick Grifka <nigri@microsoft.com>
@nigriMSFT
Copy link
Copy Markdown
Contributor Author

@dio Linux-x64 clang_tidy CI job seemed to have hung on "cCmakeMakeRule external/envoy/bazel/foreign_cc/event/include;" but none of the other jobs did. I'm not sure what else I can do here but retry? Is this a known issue?

@dio
Copy link
Copy Markdown
Member

dio commented Jul 18, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mattklein123 mattklein123 merged commit e7bdb1f into envoyproxy:master Jul 20, 2020
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
Signed-off-by: Nick Grifka <nigri@microsoft.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
Signed-off-by: Nick Grifka <nigri@microsoft.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants