FrameworkBenchmarks icon indicating copy to clipboard operation
FrameworkBenchmarks copied to clipboard

Check frameworks for HTTP compliance

Open Kaliumhexacyanoferrat opened this issue 1 year ago • 9 comments

Currently there are a lot of frameworks marked as realistic that do not provide a proper HTTP webserver implementation but just respond to the test tools in the expected manner. As they skip a lot of scenarios a real-world web server has to handle, they are of course faster.

After the discussion in #9391 I've created a project intended to check a HTTP web server for compliance with the HTTP specification. This is a very rough draft because this is a functionality not very much projects would need - so I am willing to spend more time only, if you are interested in integrating such tool into your test framework. The executable will take an HTTP endpoint and return a status code whether the server is compliant or not.

You can find the project here: https://github.com/Kaliumhexacyanoferrat/http-conformity

The information provided by the tool could be used in various ways:

  • Add another filter to the results dashboard
  • Do not allow frameworks that are not compliant to be marked as realistic
  • Fail the build if a non-compliant framework is added
  • Exclude non-compliant frameworks

Please let me know what you think :)

Kaliumhexacyanoferrat avatar Dec 04 '24 14:12 Kaliumhexacyanoferrat

We created our own functional tests for Adapterman and Workerman. https://github.com/joanhey/AdapterMan/actions/runs/11104804508

All the tests: https://github.com/joanhey/AdapterMan/actions/runs/11104804508/job/30849613841#step:5:1

As only 1 test is specific to PHP, recently we have move it to it's own project to use with any server or app server. And we are working in selecting which tests to run, it's easy (WIP). https://github.com/joanhey/TestMan

Actually we have 103 tests and 511 assertions. image

But for run the tests we need a file in the server to return the values. That's not possible to add in all the frameworks from this bench.

So with the code that we have from this bench, the number of tests that we can run it's very small and never will be realistic. Only will detect the more radical implementations.

joanhey avatar Dec 04 '24 19:12 joanhey

Nice, thanks - yes, without the server fulfilling some contract we can test only a few assertions. Nevertheless detecting and disabling radical implementations on official rounds already would be a great improvement as they tend to be on top - so I would encourage such an usage of your suite with just a few of the tests.

Kaliumhexacyanoferrat avatar Dec 04 '24 20:12 Kaliumhexacyanoferrat

We can start a list of the tests, that we can use in this bench:

  • 404 Not Found
  • 400 Bad Request
  • POST method and return the same that with the GET
  • HEAD method and return the body
  • Accept-Encoding: gzip Request, server need to return a gzip response
  • ...

joanhey avatar Dec 04 '24 20:12 joanhey

I think it's fine for a server to return 200 OK for a non-existent URL so the tests need to be very defensive - but yes, based on the test spec we should be able to find some things to be tested.

Some frameworks have very simplified socket handling (e.g. they expect the full request to be already in the buffer), but this would require something different than a HTTP client - the approach above would probably be fine.

Kaliumhexacyanoferrat avatar Dec 04 '24 20:12 Kaliumhexacyanoferrat

A non-existent URL is always a 404 Not Found !!

joanhey avatar Dec 04 '24 22:12 joanhey

Another problem that we had some years ago, and still now, it's that some frameworks return a compressed response always. Technically a server only need to return a compressed response if the client send the Accept-Encoding: header. And this bench never send this header in the Request (I think so). If the bench send it, we need to change this behavior.

Added to the list, only with gzip to be defensive.

joanhey avatar Dec 05 '24 09:12 joanhey

@NateBrady23 what do you think about this test list ?

joanhey avatar Dec 05 '24 09:12 joanhey

@joanhey This is a good list! I also like the idea of failing the build if the test is marked as realistic but fails this list.

NateBrady23 avatar Dec 10 '24 00:12 NateBrady23

Existing testing tools:

https://github.com/mnot/redbot

Maybe some HTTP servers already have some built in tests

https://github.com/mongrel/mongrel/tree/master/test

Dmole avatar Sep 18 '25 01:09 Dmole