Skip to content

Commit

Permalink
Merge pull request #62 from hollodotme/development
Browse files Browse the repository at this point in the history
Release v3.1.3
  • Loading branch information
hollodotme authored Aug 13, 2020
2 parents d97647b + 8cb8a3b commit 8eb9d5c
Show file tree
Hide file tree
Showing 41 changed files with 497 additions and 296 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ shared-unit-tests: &shared-unit-tests

- run:
name: Run unit tests
command: php -d error_reporting=-1 -d auto_prepend_file=build/xdebug-filter.php vendor/bin/phpunit$PHPUNIT_VERSION.phar -c build --testsuite Unit --log-junit build/logs/junit/junit.xml --coverage-html build/logs/coverage --coverage-clover=coverage.xml
command: php -d error_reporting=-1 -d auto_prepend_file=build/xdebug-filter.php vendor/bin/phpunit$PHPUNIT_VERSION.phar -c build/phpunit$PHPUNIT_VERSION.xml --testsuite Unit --log-junit build/logs/junit/junit.xml --coverage-html build/logs/coverage --coverage-clover=coverage.xml

- run:
name: Upload code coverage to codecov.io
Expand Down Expand Up @@ -155,7 +155,7 @@ shared-integration-tests: &shared-integration-tests

- run:
name: Run integration tests
command: php -d error_reporting=-1 -d auto_prepend_file=build/xdebug-filter.php vendor/bin/phpunit$PHPUNIT_VERSION.phar -c build --testsuite Integration --log-junit build/logs/junit/junit.xml
command: php -d error_reporting=-1 -d auto_prepend_file=build/xdebug-filter.php vendor/bin/phpunit$PHPUNIT_VERSION.phar -c build/phpunit$PHPUNIT_VERSION.xml --testsuite Integration --log-junit build/logs/junit/junit.xml

- store_test_results:
path: build/logs/junit
Expand All @@ -174,7 +174,7 @@ shared-phpstan: &shared-phpstan

- run:
name: Run PHPStan
command: phpstan analyze --level max src/
command: phpstan analyze

# Define the actual jobs from the templates above
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .docker/php/7.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:7.1-fpm-alpine
ENV XDEBUG_VERSION='2.9.5'
ENV XDEBUG_VERSION='2.9.6'
ENV PHP_CONF_DIR=/usr/local/etc
RUN apk update && apk upgrade && apk add --no-cache ${PHPIZE_DEPS} \
&& pecl install xdebug-${XDEBUG_VERSION} \
Expand Down
2 changes: 1 addition & 1 deletion .docker/php/7.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:7.2-fpm-alpine
ENV XDEBUG_VERSION='2.9.5'
ENV XDEBUG_VERSION='2.9.6'
ENV PHP_CONF_DIR=/usr/local/etc
RUN apk update && apk upgrade && apk add --no-cache ${PHPIZE_DEPS} \
&& pecl install xdebug-${XDEBUG_VERSION} \
Expand Down
2 changes: 1 addition & 1 deletion .docker/php/7.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:7.3-fpm-alpine
ENV XDEBUG_VERSION='2.9.5'
ENV XDEBUG_VERSION='2.9.6'
ENV PHP_CONF_DIR=/usr/local/etc
RUN apk update && apk upgrade && apk add --no-cache ${PHPIZE_DEPS} \
&& pecl install xdebug-${XDEBUG_VERSION} \
Expand Down
2 changes: 1 addition & 1 deletion .docker/php/7.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:7.4-fpm-alpine
ENV XDEBUG_VERSION='2.9.5'
ENV XDEBUG_VERSION='2.9.6'
ENV PHP_CONF_DIR=/usr/local/etc
RUN apk update && apk upgrade && apk add --no-cache ${PHPIZE_DEPS} \
&& pecl install xdebug-${XDEBUG_VERSION} \
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ bin/ export-ignore
build/ export-ignore
tests/ export-ignore
CHANGELOG.md export-ignore
docker-compose.yml export-ignore
phpstan.neon export-ignore
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: docker run --rm -v $(pwd):/app composer update -o -v --ignore-platform-reqs

- name: Run PHPStan
run: docker run --rm -v $(pwd):/app phpstan/phpstan analyze --level=max /app/src
run: docker run --rm -v $(pwd):/app phpstan/phpstan analyze

unit-tests:
runs-on: ubuntu-latest
Expand All @@ -53,8 +53,9 @@ jobs:
run: >
docker-compose exec -T php71 php ${PHP_OPTIONS}
/repo/vendor/bin/phpunit7.phar
-c /repo/build
-c /repo/build/phpunit7.xml
--coverage-clover=/repo/coverage.xml
--testdox
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
PHP_OPTIONS: "-d error_reporting=-1 -d auto_prepend_file=/repo/build/xdebug-filter.php"
Expand All @@ -71,8 +72,9 @@ jobs:
run: >
docker-compose exec -T php72 php ${PHP_OPTIONS}
/repo/vendor/bin/phpunit8.phar
-c /repo/build
-c /repo/build/phpunit8.xml
--coverage-clover=/repo/coverage.xml
--testdox
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
PHP_OPTIONS: "-d error_reporting=-1 -d auto_prepend_file=/repo/build/xdebug-filter.php"
Expand All @@ -89,8 +91,9 @@ jobs:
run: >
docker-compose exec -T php73 php ${PHP_OPTIONS}
/repo/vendor/bin/phpunit9.phar
-c /repo/build
-c /repo/build/phpunit9.xml
--coverage-clover=/repo/coverage.xml
--testdox
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
PHP_OPTIONS: "-d error_reporting=-1 -d auto_prepend_file=/repo/build/xdebug-filter.php"
Expand All @@ -107,8 +110,9 @@ jobs:
run: >
docker-compose exec -T php74 php ${PHP_OPTIONS}
/repo/vendor/bin/phpunit9.phar
-c /repo/build
-c /repo/build/phpunit9.xml
--coverage-clover=/repo/coverage.xml
--testdox
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
PHP_OPTIONS: "-d error_reporting=-1 -d auto_prepend_file=/repo/build/xdebug-filter.php"
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com).

## [3.1.3] - 2020-08-13

### Fixed

* Remove broken sockets from socket collection if writing the request to stream fails - [#61]
* Do not export `docker-compose.yml` with composer archives via `.gitattributes`
* Stabilize unreliable tests with signaled pool processes

## [3.1.2] - 2020-05-19

### Added
Expand Down Expand Up @@ -338,6 +346,7 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http
* Getters/Setters for connect timeout, read/write timeout, keep alive, socket persistence from `Client` (now part of the socket connection)
* Method `Client->getValues()`

[3.1.3]: https://github.com/hollodotme/fast-cgi-client/compare/v3.1.2...v3.1.3
[3.1.2]: https://github.com/hollodotme/fast-cgi-client/compare/v3.1.1...v3.1.2
[3.1.1]: https://github.com/hollodotme/fast-cgi-client/compare/v3.1.0...v3.1.1
[3.1.0]: https://github.com/hollodotme/fast-cgi-client/compare/v3.0.1...v3.1.0
Expand Down Expand Up @@ -385,3 +394,4 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http
[#55]: https://github.com/hollodotme/fast-cgi-client/pull/55
[#56]: https://github.com/hollodotme/fast-cgi-client/issues/56
[#58]: https://github.com/hollodotme/fast-cgi-client/pull/58
[#61]: https://github.com/hollodotme/fast-cgi-client/issues/61
File renamed without changes.
31 changes: 31 additions & 0 deletions build/phpunit8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<phpunit
bootstrap="../vendor/autoload.php"
verbose="true"
beStrictAboutOutputDuringTests="true"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
<php>
<env name="network-socket-host" value="127.0.0.1"/>
<env name="network-socket-port" value="9001"/>
<env name="unix-domain-socket" value="/var/run/php-uds.sock"/>
<env name="restricted-unix-domain-socket" value="/var/run/php-ruds.sock"/>
<env name="non-existing-unix-domain-socket" value="/tmp/not/existing.sock"/>
<env name="invalid-unix-domain-socket" value="/Fixtures/test.sock"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">../tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">../tests/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../src</directory>
</whitelist>
</filter>
</phpunit>
29 changes: 29 additions & 0 deletions build/phpunit9.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="../vendor/autoload.php"
verbose="true"
beStrictAboutOutputDuringTests="true"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../src</directory>
</include>
</coverage>
<php>
<env name="network-socket-host" value="127.0.0.1"/>
<env name="network-socket-port" value="9001"/>
<env name="unix-domain-socket" value="/var/run/php-uds.sock"/>
<env name="restricted-unix-domain-socket" value="/var/run/php-ruds.sock"/>
<env name="non-existing-unix-domain-socket" value="/tmp/not/existing.sock"/>
<env name="invalid-unix-domain-socket" value="/Fixtures/test.sock"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>../tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>../tests/Integration</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ services:
container_name: fcc_phpstan
working_dir: /repo
restart: "no"
command: "analyze --level max src/"
command: "analyze"
networks:
- fcc_network
volumes:
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
paths:
- src
- tests
level: max
bootstrapFiles:
- ./vendor/bin/phpunit7.phar
19 changes: 8 additions & 11 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,21 @@ public function sendRequest(
*/
public function sendAsyncRequest( ConfiguresSocketConnection $connection, ProvidesRequestData $request ) : int
{
$socket = $this->sockets->getIdleSocket( $connection );
$socket = $this->sockets->getIdleSocket( $connection )
?? $this->sockets->new( $connection, $this->packetEncoder, $this->nameValuePairEncoder );

if ( null !== $socket )
try
{
$socket->sendRequest( $request );

return $socket->getId();
}
catch ( TimedoutException | WriteFailedException $e )
{
$this->sockets->remove( $socket->getId() );

$socket = $this->sockets->new(
$connection,
$this->packetEncoder,
$this->nameValuePairEncoder
);

$socket->sendRequest( $request );

return $socket->getId();
throw $e;
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Sockets/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ private function write( string $data ) : void
throw new WriteFailedException( 'Failed to write request to socket [broken pipe]' );
}

$writeResult = fwrite( $this->resource, $data );
$flushResult = fflush( $this->resource );
$writeResult = @fwrite( $this->resource, $data );
$flushResult = @fflush( $this->resource );

if ( $writeResult === false || !$flushResult )
{
Expand Down
24 changes: 11 additions & 13 deletions tests/Integration/AsyncRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ final class AsyncRequestsTest extends TestCase

/**
* @throws ExpectationFailedException
* @throws InvalidArgumentException
* @throws Throwable
* @throws ConnectException
* @throws ReadFailedException
Expand All @@ -40,7 +39,7 @@ public function testAsyncRequestsWillRespondToCallbackIfRequestsExceedPhpFpmMaxC
$maxChildren = $this->getMaxChildrenSettingFromNetworkSocket();
$limit = $maxChildren + 5;

$this->assertTrue( $limit > 5 );
self::assertTrue( $limit > 5 );

$client = new Client();
$results = [];
Expand All @@ -65,12 +64,12 @@ static function ( ProvidesResponseData $response ) use ( &$results )

sort( $results );

$this->assertSame( $expectedResults, $results );
self::assertSame( $expectedResults, $results );
}

private function getMaxChildrenSettingFromNetworkSocket() : int
{
$iniSettings = parse_ini_file(
$iniSettings = (array)parse_ini_file(
__DIR__ . '/../../.docker/php/network-socket.pool.conf',
true
);
Expand All @@ -89,7 +88,6 @@ private function getNetworkSocketConnection() : NetworkSocket
/**
* @throws ConnectException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
* @throws ReadFailedException
* @throws Throwable
* @throws TimedoutException
Expand All @@ -101,7 +99,7 @@ public function testAsyncRequestsWillRespondToCallbackIfRequestsExceedPhpFpmMaxC
$maxChildren = $this->getMaxChildrenSettingFromUnixDomainSocket();
$limit = $maxChildren + 5;

$this->assertTrue( $limit > 5 );
self::assertTrue( $limit > 5 );

$client = new Client();
$results = [];
Expand All @@ -126,12 +124,12 @@ static function ( ProvidesResponseData $response ) use ( &$results )

sort( $results );

$this->assertSame( $expectedResults, $results );
self::assertSame( $expectedResults, $results );
}

private function getMaxChildrenSettingFromUnixDomainSocket() : int
{
$iniSettings = parse_ini_file(
$iniSettings = (array)parse_ini_file(
__DIR__ . '/../../.docker/php/unix-domain-socket.pool.conf',
true
);
Expand All @@ -147,17 +145,17 @@ private function getUnixDomainSocketConnection() : UnixDomainSocket
/**
* @throws ConnectException
* @throws ExpectationFailedException
* @throws InvalidArgumentException
* @throws ReadFailedException
* @throws TimedoutException
* @throws WriteFailedException
* @throws InvalidArgumentException
*/
public function testCanReadResponsesOfAsyncRequestsIfRequestsExceedPhpFpmMaxChildrenSettingOnNetworkSocket() : void
{
$maxChildren = $this->getMaxChildrenSettingFromNetworkSocket();
$limit = $maxChildren + 5;

$this->assertTrue( $limit > 5 );
self::assertTrue( $limit > 5 );

$client = new Client();
$results = [];
Expand All @@ -182,7 +180,7 @@ public function testCanReadResponsesOfAsyncRequestsIfRequestsExceedPhpFpmMaxChil

sort( $results );

$this->assertSame( $expectedResults, $results );
self::assertSame( $expectedResults, $results );
}

/**
Expand All @@ -199,7 +197,7 @@ public function testCanReadResponsesOfAsyncRequestsIfRequestsExceedPhpFpmMaxChil
$maxChildren = $this->getMaxChildrenSettingFromUnixDomainSocket();
$limit = $maxChildren + 5;

$this->assertTrue( $limit > 5 );
self::assertTrue( $limit > 5 );

$client = new Client();
$results = [];
Expand Down Expand Up @@ -230,6 +228,6 @@ static function ( ProvidesResponseData $response ) use ( &$results )

sort( $results );

$this->assertSame( $expectedResults, $results );
self::assertSame( $expectedResults, $results );
}
}
6 changes: 3 additions & 3 deletions tests/Integration/FileUploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ protected function setUp() : void

protected function tearDown() : void
{
$this->connection = null;
$this->client = null;
$this->connection = new NetworkSocket( $this->getNetworkSocketHost(), $this->getNetworkSocketPort() );
$this->client = new Client();
}

/**
Expand Down Expand Up @@ -80,6 +80,6 @@ public function testCanUploadFile() : void
. "FILENAME: TestFile.txt\n"
. "SIZE: 24\n\n";

$this->assertSame( $expectedBody, $response->getBody() );
self::assertSame( $expectedBody, $response->getBody() );
}
}
Loading

0 comments on commit 8eb9d5c

Please sign in to comment.