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
Add test for validating REST API routing & service order #3547
Comments
/bounty $200 |
💎 $200 bounty created by Qdrant 👉 Add a bounty • Share on socials
|
/attempt #3547
|
/attempt #3547 Options |
@timvisee So I have been trying this but it looks like there isn’t any way to write a test similar to the one you gave as proof of concept at the moment due to actix limitations. So maybe we could write a function to handle this responsibility of ordering our urls correctly and then we could write our tests for that function? Sudo Code:-
And then we could just test our Of course |
You're right. That's basically what the test was meant to validate. I do see value in configuring everything in a single array, which itself must be ordered correctly. That would at least give us a single place to configure things, in which we can describe specific ordering with comments. I see that you're suggesting a tuple of the URL and service handler above. I'm assuming we only include the URL here so we can do some testing. But I don't think I like this approach. It makes things more complex than they need to be, and we don't even verify whether the specified URL actually matches the service. So in my opinion, having a single array in which we specify the services in correct order is good enough. Without explicit testing, because we cannot easily do this. Thank you very much for thinking along! That's much appreciated. |
I agree that having tuples of URL and service handlers will make code a little bit complex. Yeah I was thinking of having a tuple of (URL, Handlers) so that we can test out whether the handlers are ordered correctly by looking at their routes. Defining an array with correct order of services should work for now but still we are leaving our code on assumptions in this way and have no actual tests to actually make sure the order. I think we could maybe have a defined mapping between our URLs and our Handlers at least maybe a |
This problem was resolved by the access-token based control in RBAC implementation |
Is your feature request related to a problem? Please describe.
The order of services we define for our REST API is important. If ordering is incorrect, there can be problems resolving a route due to pattern collisions.
Read more about this here: #3543.
The PR #3544 fixes this problem, but we want to make sure that ordering isn't accidentally broken afterwards.
Describe the solution you'd like
To prevent this, we would like to add a test that asserts routing and ordering of services is correct.
We imagine the following:
POST /collections/some/points/scroll
match_pattern
We imagine setting up a few dummy requests, such as to scroll, and asserting that the right route pattern is matched.
Most importantly, we want this new test to fail if ordering in #3544 would be reverted.
Describe alternatives you've considered
We could also add some integration test to call each read-only endpoint asserting the responses. But that would require quite a bit of work, and it would be less complete than testing actix routing and service ordering directly.
Additional context
I tried to implement a proof of concept for this test, but sadly that was not sufficient. In the snippet below we define the app having routes, and we define a request. But the
match_pattern
function to select what route pattern is matched does not know about ourapp
. There does not seem to be a way to connect the two together.Also, actix web has some testing facilities that may be helpful:
The text was updated successfully, but these errors were encountered: