Replies: 6 comments 1 reply
-
All this sounds very good and sensible to me. Thank you for working on it @MSP-Greg 💪 What do you think of this name change? |
Beta Was this translation helpful? Give feedback.
-
@dentarg, I added a 'Questions' section above, if you have any strong feelings about, please respond. One tricky thing with frameworks is deciding how many edge cases can be supported without making the code a lot more complex/messy. One example, which I think can be done easily, is sending a socket that is different from the server's protocol. An example currently used in one test is sending a TCP request to an SSL server. I'm sure there are more (and worse) examples... |
Beta Was this translation helpful? Give feedback.
-
Wow! An excellent proposal. We're very lucky to have you involved, Greg. I think especially this will help with new contributions. I have felt the pain point of number 3 even as a maintainer. Re:
Some sort of helper for this would be great. I think most contributors are not used to thinking of HTTP requests as strings but are quite used to the idea of a "request with headers and optional body". |
Beta Was this translation helpful? Give feedback.
-
Agreed. I think it can be a separate class, so it can be independent of the initial framework. I'll check how net/http assembles a request string... I haven't mentioned why I'd like to change 'integration' to 'spawn'. Currently, all integration tests use |
Beta Was this translation helpful? Give feedback.
-
I'm going to start work on the 'server' files, along with converting existing test files to use them. Once it's far enough along, one PR with the framework server files, then additional PR's with each test file conversion... |
Beta Was this translation helpful? Give feedback.
-
Update: Working on converting files to use PumaSocket for all client request processing. Doing so is also reminding me of all the needs for the new classes handling server creation. All of the server classes will have a keyword argument These will set variables that JFYI, in master, TestPumaServer take about 20 seconds on my ten core system. The update using PumaSocket takes about 3. That's an exception, most files show much smaller decreases... |
Beta Was this translation helpful? Give feedback.
-
PR #3179 adds two files to the test/helpers folder. These files are the first files from a new test framework. They may require non-breaking changes when the 'server side' code is added to the framework.
Below I've listed some goals of the new framework. Looking for feedback about the listed goals, and whether new goals should be added.
If people think this is a worthwhile task, I'll start by committing the framework files, then in subsequent PR's update individual test files to use it.
Goals
The framework should support the following socket types: tcp4, tcp6, ssl4, ssl6, unix, and aunix. These should be available for both bind and control. Centralized socket code should also make it easier to support QUIC and HTTP/3 if and when needed.
Since we are running CI tests parallel (with threads), any use of blocking operations should be minimized. I think many of the intermittent failures in current CI are caused by blocking test code.
The framework should make tests portable between files. Currently, a lot of files have their own code for client sockets and/or server creation, making it tedious to reorganize files. Note that some test files have just a handful of tests, others have dozens. I hope that reorganizing the test files will make it easier for contributors to find tests that are similar to tests they'd like to add.
Make test code agnostic as to the bind and/or control socket type. Or, make it trivial to change the socket type either in an individual test, a whole file, or possibly the whole test suite. One example would be changing all tests from tcp4 to tcp6 (IPv4 to IPv6). Changing all 'port' based tests from tcp4 to ssl6 might involve some careful code, but should be possible.
Discourage the use of native sockets (See 2 and 4). Native code that works locally may cause intermittent failures when run in parallel CI. Also, items like closing client sockets, removing UNIXSocket files, forcing server shutdown, etc are much better handled by a test framework.
Use Minitest's
before_shutdown
andafter_teardown
. This helps with test files usingsetup
andteardown
and not properly includingsuper
in those methods.Properly document all the helper files.
File Layout
File contents
test_puma.rb
-TestPuma
, module, main namespace, contains constants related to socketspuma_socket.rb
-PumaSocket
, module, contains client socket methodsserver_base.rb
-ServerBase
, subclass of::Minitest::Test
, contains common code for subclassesserver_in_process.rb
-ServerInProcess
, subclass ofServerBase
, createsPuma::Server
instancesserver_spawn.rb
-ServerSpawn
, subclass ofServerBase
, creates Puma instances usingspawn
server_cli.rb
-ServerCLI
, subclass ofServerBase
, creates Puma instances usingPuma::CLI.new(...).run
Questions
Beta Was this translation helpful? Give feedback.
All reactions