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

router: support url matching regression testing #538

Closed
tschroed opened this issue Mar 5, 2017 · 24 comments
Closed

router: support url matching regression testing #538

tschroed opened this issue Mar 5, 2017 · 24 comments
Assignees
Labels
enhancement Feature requests. Not bugs or questions.
Milestone

Comments

@tschroed
Copy link
Contributor

tschroed commented Mar 5, 2017

It should be possible to load a router config and a set of URL -> cluster matches to ensure that rules match as expected.

@tschroed
Copy link
Contributor Author

tschroed commented Mar 5, 2017

Related: #499

@mattklein123 mattklein123 added the enhancement Feature requests. Not bugs or questions. label Mar 6, 2017
@mattklein123
Copy link
Member

+1, this would be great. This should be much easier than #499. The hard part will be figuring out the input and output format for the tests. We should discuss that here. We will definitely use this at Lyft.

@tschroed
Copy link
Contributor Author

tschroed commented Mar 6, 2017

One format I'm familiar with is simply three whitespace delimited fields: the URL; the cluster it maps to; and a tri-state indicating whether it should be http, https, or both. If we want flexibility for strict versus permissive, the latter could be expanded to two tri-states, each indicating yes, no, or don't care.

@hennna
Copy link
Contributor

hennna commented Mar 23, 2017

I'm starting to look into this.

@mattklein123
Copy link
Member

@hennna awesome, could you propose here at a high level what the test sequence will look like once you investigate? (Basically how the test file is written, what the output looks like, how the envoy route code will be compiled/used, etc.).

@mattklein123 mattklein123 added this to the 1.3.0 milestone Mar 23, 2017
@htuch
Copy link
Member

htuch commented Mar 23, 2017

@tschroed @mattklein123 Do we want to take as input a complete Envoy config as the basis for this? In addition, should RDS be supported?

If starting from a complete Envoy config, there will be a need to specify the listener (IP/port) as well as URL to get to the route config that applies.

@mattklein123
Copy link
Member

I would be fine just taking a route config as input, basically this: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/route_config.html

@mattklein123
Copy link
Member

I think ^ will be relatively easy to create a dedicated route testing binary (or just an option to envoy itself) with the ConfigImpl code.

@hennna
Copy link
Contributor

hennna commented Mar 24, 2017

Thoughts on the following proposal?

Build a route test tool binary in the directory test/tool (CMake or Blaze?)

Input:

  1. A .json router config file (multiple listener configs not supported)
  2. A .txt or directory of .txt files. A .txt file is composed of rows of two whitespace delimited fields: the URL and the cluster it maps to

Output:

  1. std output with the total number of matches and conflicts
  2. Optional log output with the contents of the input .txt file(s) with a third delimited field indicating a match of Y(es) or N(o). Can also include a fourth delimited field indicating the actual cluster match

@mattklein123
Copy link
Member

@hennna that looks good. The only thing I would like to see is some way of testing redirects also. Any proposal on how to add that to the possible inputs/outputs?

@hennna
Copy link
Contributor

hennna commented Mar 24, 2017

We can add a third optional delimiter field in the input.txt file. "R" for redirect testing and nothing for cluster name match testing.

@mattklein123
Copy link
Member

Right, something like that is fine, but for redirects we will need to have as input the expected redirect URL. As long as you are considering the redirect case, I would suggest just doing some prototyping and then coming back with a real example of inputs and outputs. I'm guessing tweaking the format will not be too big of a deal.

@hennna
Copy link
Contributor

hennna commented Mar 24, 2017

Yes. I'll cycle back when I get a working prototype.

@mattklein123
Copy link
Member

@hennna one other thing occurred to me: we support URL rewrite, and we would want to test that as well. So I think in both the redirect and forwarding case you want to allow the tester to specify the expected final URL. (Basically I would take a look at any of the mutating options we support and make sure we can test them).

@hennna
Copy link
Contributor

hennna commented Mar 24, 2017

I will keep that in mind. So far, I think it can be done as a third delimiter.
Options: "W" for rewrite and "R" for redirect.

@hennna
Copy link
Contributor

hennna commented Mar 28, 2017

@htuch @mattklein123
Sanity check on what I've written up so far: https://github.com/hennna/envoy/tree/url-cluster-match
The tool takes as input (1) a router config json input and (2) a whitespace delimited text file.
Example call: ./router-check ../router_check.json ../url_cluster.txt

url_cluster.txt
optional_flag expected_name host path
instant-server api.lyft.com /
ats api.lyft.com /api/leads/me
V www2 www.lyft.com /new_endpoint/foo
WP /Tart api.lyft.com /Tart
WH new_host api.lyft.com /newhost/rewrite/me

The optional flags
WH: match rewrite host
WP: match rewrite path
V: match virtual cluster
VPUT: match virtual cluster with put
VPOST: match virtual cluster with post
R: redirect

The output to std out
Y instant-server api.lyft.com/
...
Y www2 lyft.com/foo
N www lyft.com/foo
...
Total Y:8 N:1

@htuch
Copy link
Member

htuch commented Mar 28, 2017 via email

@mattklein123
Copy link
Member

@hennna I'm kind of wondering if the input for the test should be JSON (basically a list of objects that have the input and expected output). I think it would end up being a lot less complicated in the long run. There are other cases that we need to handle such as matching on particular header, etc. So I think we need the ability to optionally pass arbitrary headers as part of the "request". There may be other things I'm missing.

@htuch
Copy link
Member

htuch commented Mar 28, 2017

What about YAML? It might make the test files easier to read/write as humans and has the same expressive power as JSON... or do it with JSON and add a Python YAML-JSON translation on the front-end.

@mattklein123
Copy link
Member

YAML is fine with me for something like this, but there is existing JSON parsing code already in Envoy so I think it would be easier to use JSON.

@hennna
Copy link
Contributor

hennna commented Mar 28, 2017

Will there be an unlimited number of cases like matching on headers?

@mattklein123
Copy link
Member

Will there be an unlimited number of cases like matching on headers?

What do you mean? I think we have more complicated tests in the future and some type of structured test will be much easier to maintain/understand then the white space delimited file. If you add generic headers, you can get rid of VPUT, VPOST, etc. and I think boil it down to:

Input:

  • list of headers (:authority, :method, :path, etc. are special cases of headers)

Output (not all apply to all tests):

  • specific headers to check for (possibly to check for modified :path for example)
  • redirect status and redirect target.
  • target cluster

There might be some things I'm missing but that's roughly how I would approach it.

@hennna
Copy link
Contributor

hennna commented Mar 29, 2017

Ok. I'll write up a JSON schema but try to minimize the amount of typing necessary for simple tests.

@mattklein123
Copy link
Member

Added in #682. Thanks @hennna !

jplevyak added a commit to istio/envoy that referenced this issue Jul 9, 2020
…oyproxy#538)

* Add support for onForeignFunction and proxy-specific extensions.

Signed-off-by: John Plevyak <[email protected]>
jpsim pushed a commit that referenced this issue Nov 28, 2022
Signed-off-by: Michael Rebello <[email protected]>
Signed-off-by: JP Simard <[email protected]>
jpsim pushed a commit that referenced this issue Nov 29, 2022
Signed-off-by: Michael Rebello <[email protected]>
Signed-off-by: JP Simard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests. Not bugs or questions.
Projects
None yet
Development

No branches or pull requests

4 participants