Ticket #76 (new enhancement)

Opened 2 months ago

Last modified 2 months ago

Take advantage of FastCGI

Reported by: arnaud.lb@… Owned by: tswicegood
Priority: major Milestone:
Component: PHPT_Core Version:
Keywords: Cc:
Blocking: Blocked By:

Description

It would be great to be able to run tests through FastCGI.

  • Tests can run twice times faster through FastCGI (avoids the overhead of spawning a new process for each test).
  • Can be used to test persistent stuffs (resources, etc).

Change History

follow-up: ↓ 2   Changed 2 months ago by tswicegood

Hey Arnaud - how you would go about implementing this? It's a good idea, but one of the key benefits of the .phpt format is that each test gets its own process to run tests in. Of course, that's one of its key downfalls too.

in reply to: ↑ 1 ; follow-up: ↓ 3   Changed 2 months ago by lbarnaud

Replying to tswicegood:
Instead of a process per test, this will be a "request" per test. Just like the current way of running tests, the tests can not affect each others (except for persistent resource), can be ran in parallel, etc.

The FastCGI server can be ran easily by creating a socket (unix or tcp), and by passing this socket as stdin to php-cgi using proc_open(). (e.g. $pipes = array(0 => $socket, 1 => array("pipe","w"),...))

Then each test can be ran by connecting to the socket.

in reply to: ↑ 2   Changed 2 months ago by tswicegood

Replying to lbarnaud:

This sounds excellent. I am already planning on doing full tests using pcntl to fork multiple runners which would then start working through tests in parallel via stream_socket_pair(), but this might be an even better way to handle it.

This could also open up some interesting implementations if you opened up the FastCGI server so tests could be triggered remotely as part of a grid of tests running on multiple platforms and such.

Would you be willing to help flesh this out? I would love to tackle it, but my time right now is spread pretty thin, so it'll be a month or so before I can dive into it.

  Changed 2 months ago by lbarnaud

I am already planning on doing full tests using pcntl to fork multiple runners which would then start working through tests in parallel via stream_socket_pair(), but this might be an even better way to handle it.

What about an event-driven design ? e.g. you do not fork the php script it self and make each driver non-blocking. Then block on stream_select() until one of the tests finishes. Each time a test finishes you run an other and block again on stream_select();

This could also open up some interesting implementations if you opened up the FastCGI server so tests could be triggered remotely as part of a grid of tests running on multiple platforms and such.

Yes, it allows that sort of things too :) (However the .php test files have to be local to the fast cgi process)

Would you be willing to help flesh this out? I would love to tackle it, but my time right now is spread pretty thin, so it'll be a month or so before I can dive into it.

Yes, I can at least provide a class to spawn a FastCGI server and speak to it.

Note: See TracTickets for help on using tickets.