Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: Add protoxform tests #9241

Merged
merged 23 commits into from
Dec 19, 2019
Merged

Conversation

Shikugawa
Copy link
Member

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Description: Add testing for protoxform scripts. We apply golden testing method for this.
Risk Level: Low
Testing: none
Docs Changes: none
Release Notes:
[Optional Fixes #Issue] #8428
[Optional Deprecated:]

@Shikugawa Shikugawa changed the title Add protoxform tests tools: Add protoxform tests Dec 5, 2019
@lizan lizan requested a review from htuch December 5, 2019 21:01
Signed-off-by: shikugawa <[email protected]>
Signed-off-by: shikugawa <[email protected]>
@Shikugawa Shikugawa marked this pull request as ready for review December 6, 2019 09:55
tools/api_proto_plugin/utils.py Outdated Show resolved Hide resolved
tools/protoxform/options.py Outdated Show resolved Hide resolved
tools/protoxform_test_helper.py Outdated Show resolved Hide resolved
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

This is super cool @Shikugawa, big thanks for putting this together. I think the PR is largely correctly structured, just working through some Python style stuff.
/wait

tools/run_command.py Show resolved Hide resolved
tools/type_whisperer/typedb_gen.py Outdated Show resolved Hide resolved
tools/protoxform_test_helper.py Show resolved Hide resolved
tools/protoxform_test_helper.py Outdated Show resolved Hide resolved
tools/protoxform_test.sh Outdated Show resolved Hide resolved
Signed-off-by: shikugawa <[email protected]>
Signed-off-by: shikugawa <[email protected]>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Cool, thanks for following up on the comments. A few more.
/wait

tools/spelling_dictionary.txt Show resolved Hide resolved
tools/type_whisperer/type_database.bzl Show resolved Hide resolved
tools/type_whisperer/typedb_gen.py Outdated Show resolved Hide resolved
# stdout and stderr as a string array.
def runCommand(command):
logging.info("%s" % command)
proc = subprocess.run([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Copy link
Member

Choose a reason for hiding this comment

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

You can just do capture_output=True.

Copy link
Member Author

Choose a reason for hiding this comment

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

@htuch we can't use capture_output because envoy_ci internal python runtime version is less than 3.7

Copy link
Member

Choose a reason for hiding this comment

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

I was able to use it in https://github.com/envoyproxy/envoy/pull/9258/files#diff-bba1df52a76edae166f0c52c4fed21dbR38, I'm wondering what version issues we're hitting here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@htuch it seems that api_boost.py is not defined to run on envoy_ci internal docker runtime because the execution definition isn't written in do_ci.sh so test should be passed. But if we add this python script execution definition to that shell script, it may be failed... so unless update docker internal python version, this argument should not work....

Copy link
Member Author

Choose a reason for hiding this comment

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

anyway, add issue #9339

Copy link
Member

Choose a reason for hiding this comment

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

@Shikugawa is this blocking? I think I will have a similar issue with a test I'm working on, so I can take a look. Is there anything else here that we need to sort out?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

so is capture_output=True is the reason for python >= 3.7? I think using subprocess.PIPE can workaround it.

@Shikugawa the exception seems from yapf so it's failing on Python formatter somewhere, were you able to run ci/run_envoy_docker.sh 'ci/check_and_fix_format.sh' locally?

tools/run_command.py Outdated Show resolved Hide resolved
tools/run_command.py Outdated Show resolved Hide resolved
tools/protoxform_test_helper.py Outdated Show resolved Hide resolved
//tools/testdata/protoxform:protos --aspects //tools/protoxform:protoxform.bzl%protoxform_aspect --output_groups=proto \
--action_env=CPROFILE_ENABLED=1 --host_force_python=PY3

./tools/protoxform_test_helper.py ${PROTO_TARGETS}
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if @lizan has any Bazel Fu to make the tests work as Bazel aspects.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, you can write a rule that depends on aspect (like what type_database rule does depend on type_whisperer aspect), then define a test target on that. but we're good to go with this for now.

Signed-off-by: shikugawa <[email protected]>
Signed-off-by: shikugawa <[email protected]>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo the one question I have for @lizan on aspect magic. Thanks!

tools/protoxform_test_helper.py Outdated Show resolved Hide resolved
@htuch
Copy link
Member

htuch commented Dec 13, 2019

@Shikugawa LGTM, can you fix_format so that CI passes and we can merge? Thanks again for this work, this is really nice and will be a huge velocity improvement for work in protoxform (we can now make changes with confidence).

@htuch htuch added the waiting label Dec 16, 2019
messages += Run(path, filename, 'v3alpha')

if len(messages) == 0:
logging.warning("PASS")
Copy link
Member

Choose a reason for hiding this comment

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

I think you are going to want to sys.exit() with different success/failure values here (was just looking again at this PR as I'm writing some simple golden source test as well right now). Thanks.

Signed-off-by: shikugawa <[email protected]>
"""
base = "./bazel-bin/"
delimited_path = path.split('/')
base += os.path.join(*delimited_path, "protos", *delimited_path)
Copy link
Member

Choose a reason for hiding this comment

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

I think this might be where the pyformat failure is happening; how come you want to squash the path twice here and join it twice? Why not just use path instead of delimited_path?

Copy link
Member Author

Choose a reason for hiding this comment

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

@htuch automatically generated proto file is located on ./bazel-bin/tools/testdata/protoxform/envoy/v2/protos/tools/testdata/protoxform/envoy/v2/.
So, this instruction could not avoid. But, It seems for me to use path instead of delimited_path.

Signed-off-by: shikugawa <[email protected]>
Signed-off-by: shikugawa <[email protected]>
Signed-off-by: shikugawa <[email protected]>
Signed-off-by: shikugawa <[email protected]>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@htuch htuch merged commit 6992b00 into envoyproxy:master Dec 19, 2019
htuch added a commit to htuch/envoy that referenced this pull request Dec 19, 2019
htuch added a commit that referenced this pull request Dec 19, 2019
@wrowe wrowe mentioned this pull request Dec 20, 2019
spenceral added a commit to spenceral/envoy that referenced this pull request Dec 20, 2019
* master: (167 commits)
  stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, using the new MemBlock wrapper for memcpy (envoyproxy#8779)
  Make %UPSTREAM_LOCAL_ADDRESS% access-log format work for HTTP requests. (envoyproxy#9362)
  tools: API boosting support for using decls and enum constants. (envoyproxy#9418)
  Fix incorrect cluster InitializePhase type (envoyproxy#9379)
  build: fix merge race between envoyproxy#9241 and envoyproxy#9413. (envoyproxy#9427)
  fuzz: fix incorrect evaluator test (envoyproxy#9402)
  server: fix bogus startup log message (envoyproxy#9404)
  tools: Add protoxform tests (envoyproxy#9241)
  api: options after import (envoyproxy#9413)
  misc: use std::move instead of constructing a copy (envoyproxy#9415)
  tools: API boosting support for rewriting elaborated types. (envoyproxy#9375)
  docs: fix invalid transport_socket value (envoyproxy#9403)
  fix typo in docs (envoyproxy#9394)
  srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict. (envoyproxy#9366)
  api: generate whole directory and sync (envoyproxy#9382)
  bazel: Add load statements for proto_library (envoyproxy#9367)
  Fix typo (envoyproxy#9388)
  Correct test of OptionsImpl argc type (Was: Correct type for std::array size() result) (envoyproxy#9290)
  http1 encode trailers in chunk encoding (envoyproxy#8667)
  Add mode to PipeInstance (envoyproxy#8423)
  ...
prakhag1 pushed a commit to prakhag1/envoy that referenced this pull request Jan 3, 2020
Add testing for protoxform scripts. We apply golden testing method for this.

Risk Level: Low
Testing: none
Docs Changes: none
Release Notes:

Fixes envoyproxy#8428

Signed-off-by: shikugawa <[email protected]>
Signed-off-by: Prakhar <[email protected]>
prakhag1 pushed a commit to prakhag1/envoy that referenced this pull request Jan 3, 2020
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.

3 participants