tools: Add protoxform tests#9241
Conversation
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
htuch
left a comment
There was a problem hiding this comment.
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
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
htuch
left a comment
There was a problem hiding this comment.
Cool, thanks for following up on the comments. A few more.
/wait
| # 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) |
There was a problem hiding this comment.
You can just do capture_output=True.
There was a problem hiding this comment.
@htuch we can't use capture_output because envoy_ci internal python runtime version is less than 3.7
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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....
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
@htuch hmm...can't pass formatting check because of confusing exception...
https://dev.azure.com/cncf/envoy/_build/results?buildId=23684&view=logs&jobId=9fd74226-df5b-5f29-39da-76fc341cc763&j=9fd74226-df5b-5f29-39da-76fc341cc763&t=068b98b1-acf0-52d0-fc6e-f6d1a5b1d5ef
There was a problem hiding this comment.
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/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} No newline at end of file |
There was a problem hiding this comment.
I wonder if @lizan has any Bazel Fu to make the tests work as Bazel aspects.
There was a problem hiding this comment.
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 <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
|
@Shikugawa LGTM, can you |
| messages += Run(path, filename, 'v3alpha') | ||
|
|
||
| if len(messages) == 0: | ||
| logging.warning("PASS") |
There was a problem hiding this comment.
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 <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
tools/protoxform_test_helper.py
Outdated
| """ | ||
| base = "./bazel-bin/" | ||
| delimited_path = path.split('/') | ||
| base += os.path.join(*delimited_path, "protos", *delimited_path) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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 <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: shikugawa <rei@tetrate.io>
Signed-off-by: Harvey Tuch <htuch@google.com>
* 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) ...
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 <rei@tetrate.io> Signed-off-by: Prakhar <prakhar_au@yahoo.com>
…nvoyproxy#9427) Signed-off-by: Harvey Tuch <htuch@google.com> Signed-off-by: Prakhar <prakhar_au@yahoo.com>
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:]