Skip to content

Commit e27198a

Browse files
committed
try to use fpm for testing module
1 parent 6f76871 commit e27198a

File tree

7 files changed

+670
-0
lines changed

7 files changed

+670
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ script:
99
- uname -a
1010
- cat /etc/issue
1111
- rake compile test
12+
- rake integration
1213

1314
notifications:
1415
irc: "chat.freenode.net#php-protocolbuffers"

Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ task :test do
3232
sh "cat tests/*.diff; if [ $? -eq 0 ];then exit 1; fi"
3333
end
3434

35+
task :integration do
36+
if ENV["TRAVIS_PHP_VERSION"] > 5.3 then
37+
sh "phpenv config-add tests/integration/protocolbuffers.ini"
38+
sh "sudo make install"
39+
sh "sudo cp tests/integration/php-fpm.conf ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf"
40+
sh "~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm"
41+
sleep 1
42+
sh "tests/integration/fcgiget.php localhost:9000/home/vagrant/php-protocolbuffers/tests/integration/test.php"
43+
end
44+
end

tests/integration/fcgiget.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/php
2+
<?php
3+
/*
4+
* This file is part of PHP-FastCGI-Client.
5+
*
6+
* (c) Pierrick Charron <pierrick@adoy.net>
7+
* Remi Collet <remi@famillecollet.com>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
require 'src/Adoy/FastCGI/Client.php';
13+
14+
use Adoy\FastCGI\Client;
15+
16+
/**
17+
* Simple command line script to test communication with a FastCGI server
18+
*
19+
* @author Pierrick Charron <pierrick@adoy.net>
20+
* @author Remi Collet <remi@famillecollet.com>
21+
* @version 1.0
22+
*/
23+
if (!isset($_SERVER['argc'])) {
24+
die("Command line only\n");
25+
}
26+
if ($_SERVER['argc']<2) {
27+
die("Usage: ".$_SERVER['argv'][0]." URI\n\nEx: ".$_SERVER['argv'][0]." localhost:9000/status\n");
28+
}
29+
30+
$url = parse_url($_SERVER['argv'][1]);
31+
if (!$url || !isset($url['path'])) {
32+
die("Malformed URI");
33+
}
34+
35+
$req = '/'.basename($url['path']);
36+
if (isset($url['query'])) {
37+
$uri = $req .'?'.$url['query'];
38+
} else {
39+
$url['query'] = '';
40+
$uri = $req;
41+
}
42+
$client = new Client(
43+
(isset($url['host']) ? $url['host'] : 'localhost'),
44+
(isset($url['port']) ? $url['port'] : 9000));
45+
46+
$params = array(
47+
'GATEWAY_INTERFACE' => 'FastCGI/1.0',
48+
'REQUEST_METHOD' => 'GET',
49+
'SCRIPT_FILENAME' => $url['path'],
50+
'SCRIPT_NAME' => $req,
51+
'QUERY_STRING' => $url['query'],
52+
'REQUEST_URI' => $uri,
53+
'DOCUMENT_URI' => $req,
54+
'SERVER_SOFTWARE' => 'php/fcgiclient',
55+
'REMOTE_ADDR' => '127.0.0.1',
56+
'REMOTE_PORT' => '9985',
57+
'SERVER_ADDR' => '127.0.0.1',
58+
'SERVER_PORT' => '80',
59+
'SERVER_NAME' => php_uname('n'),
60+
'SERVER_PROTOCOL' => 'HTTP/1.1',
61+
'CONTENT_TYPE' => '',
62+
'CONTENT_LENGTH' => 0
63+
);
64+
echo $client->request($params, false)."\n";
65+

tests/integration/php-fpm.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[global]
2+
error_log = /home/vagrant/php-fpm.log
3+
log_level = debug
4+
5+
[www]
6+
user = vagrant
7+
group = vagrant
8+
listen = 127.0.0.1:9000
9+
10+
pm = dynamic
11+
pm.max_children = 5
12+
pm.start_servers = 2
13+
pm.min_spare_servers = 1
14+
pm.max_spare_servers = 3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extension=protocolbuffers.so

0 commit comments

Comments
 (0)