From b47c1a9a5a3caa3da77be2aad7520eb67e5e83bf Mon Sep 17 00:00:00 2001 From: sergeysviridenko Date: Mon, 25 Sep 2017 10:51:56 +0300 Subject: [PATCH] Added fix aerospike test --- .travis.yml | 6 +-- tests/_ci/install_aerospike.sh | 14 ++---- .../Annotations/Adapter/AerospikeTest.php | 49 ++++++++++--------- .../aerospike/Cache/Backend/AerospikeTest.php | 2 +- .../Session/Adapter/AerospikeTest.php | 6 +-- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14c9a501e..9ce45108b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ before_install: install: - travis_retry composer install --prefer-dist --no-interaction --quiet --no-ansi --no-progress --optimize-autoloader --dev --no-suggest --ignore-platform-reqs # See https://github.com/aerospike/aerospike-client-php/issues/127 - - '[[ "$PHP_MAJOR" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh' + - '[[ "$PHP_MAJOR" == "5" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aerospike.sh' - if [ ! -f $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so ]; then cd $HOME/cphalcon/$PHALCON_VERSION/build && bash ./install --phpize $(phpenv which phpize) --php-config $(phpenv which php-config) && mkdir -p $HOME/ext/$PHP_VERSION/$PHALCON_VERSION && cp $PHP_EXTENSION_DIR/phalcon.so $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so; fi; - if [ -f $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so ]; then cp $HOME/ext/$PHP_VERSION/$PHALCON_VERSION/phalcon.so $PHP_EXTENSION_DIR/phalcon.so; fi; - phpenv config-add $HOME/cphalcon/$PHALCON_VERSION/tests/_ci/phalcon.ini @@ -74,13 +74,13 @@ before_script: - echo "GRANT ALL PRIVILEGES ON incubator.* TO 'incubator'@'%' WITH GRANT OPTION" | mysql -u root - cat ${TRAVIS_BUILD_DIR}/tests/_data/dump.sql | mysql -u root incubator # See https://github.com/aerospike/aerospike-client-php/issues/127 - - '[[ "${PHP_MAJOR:0:1}" == "7" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aserver.sh' + - '[[ "${PHP_MAJOR:0:1}" == "5" ]] || bash ${TRAVIS_BUILD_DIR}/tests/_ci/install_aserver.sh' script: - vendor/bin/phpcs - vendor/bin/codecept build - vendor/bin/codecept run -v tests/unit - - '[[ "$PHP_MAJOR" == "7" ]] || vendor/bin/codecept run -v tests/aerospike' + - '[[ "$PHP_MAJOR" == "5" ]] || vendor/bin/codecept run -v tests/aerospike' - '[[ "$PHP_MAJOR" == "7" ]] || vendor/bin/codecept run -v tests/unit5x' notifications: diff --git a/tests/_ci/install_aerospike.sh b/tests/_ci/install_aerospike.sh index 263597bdc..b2d51b817 100755 --- a/tests/_ci/install_aerospike.sh +++ b/tests/_ci/install_aerospike.sh @@ -21,18 +21,14 @@ mkdir -p /tmp/aerospike-ext sudo mkdir -p /usr/local/aerospike/{lua,usr-lua} sudo chmod -R ugoa+rwx /usr/local/aerospike +git clone --depth=1 -q https://github.com/aerospike/aerospike-client-php /tmp/aerospike-ext +cd /tmp/aerospike-ext/src/ + sudo ln -sf /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/local/lib/libcrypto.so sudo ln -sf /usr/lib/x86_64-linux-gnu/libcrypto.a /usr/local/lib/libcrypto.a -cd /tmp/aerospike-ext -wget -O aerospike.zip https://github.com/aerospike/aerospike-client-php/archive/master.zip -unzip aerospike.zip -x "aerospike-client-php-master/doc/*" -x "aerospike-client-php-master/examples/*" -x "aerospike-client-php-master/src/aerospike/tests/*" - -mkdir -p aerospike-client-php-master/src/aerospike/tests/ -cd aerospike-client-php-master/src/aerospike - -./build.sh --loglevel OFF > /dev/null 2>&1 -make --silent install +bash ./build.sh +make install find . -type f -name aerospike.so | xargs sudo cp -t $(php-config --extension-dir) phpenv config-add ${TRAVIS_BUILD_DIR}/tests/_ci/aerospike.ini diff --git a/tests/aerospike/Annotations/Adapter/AerospikeTest.php b/tests/aerospike/Annotations/Adapter/AerospikeTest.php index f5dd2e38f..6e0b23fce 100644 --- a/tests/aerospike/Annotations/Adapter/AerospikeTest.php +++ b/tests/aerospike/Annotations/Adapter/AerospikeTest.php @@ -67,7 +67,7 @@ public function testHasSetProperty() */ public function testShouldReadAndWriteToAerospikeWithoutPrefix($key, $data) { - $object = new Aerospike(['hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]]]); + $object = new Aerospike(['hosts' => $this->getHostConfig()]); $object->write($key, $data); $this->assertEquals($data, $object->read($key)); @@ -80,7 +80,7 @@ public function testShouldReadAndWriteToAerospikeWithoutPrefix($key, $data) */ public function testShouldReadAndWriteToAerospikeWithPrefix($key, $data) { - $object = new Aerospike(['hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], 'prefix' => 'test_']); + $object = new Aerospike(['hosts' => $this->getHostConfig(), 'prefix' => 'test_']); $object->write($key, $data); $this->assertEquals($data, $object->read($key)); @@ -88,7 +88,7 @@ public function testShouldReadAndWriteToAerospikeWithPrefix($key, $data) public function testShouldGetCacheBackendThroughGetter() { - $object = new Aerospike(['hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]]]); + $object = new Aerospike(['hosts' => $this->getHostConfig()]); $reflectedMethod = new ReflectionMethod(get_class($object), 'getCacheBackend'); $reflectedMethod->setAccessible(true); @@ -97,7 +97,7 @@ public function testShouldGetCacheBackendThroughGetter() public function testShouldGetCacheBackendThroughReflectionSetter() { - $object = new Aerospike(['hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]]]); + $object = new Aerospike(['hosts' => $this->getHostConfig()]); $mock = $this->getMock(CacheBackend::class, [], [], '', false); $reflectedProperty = new ReflectionProperty(get_class($object), 'aerospike'); @@ -115,7 +115,7 @@ public function testShouldGetCacheBackendThroughReflectionSetter() */ public function testShouldPrepareKey($key) { - $object = new Aerospike(['hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]]]); + $object = new Aerospike(['hosts' => $this->getHostConfig()]); $reflectedMethod = new ReflectionMethod(get_class($object), 'prepareKey'); $reflectedMethod->setAccessible(true); @@ -192,14 +192,14 @@ public function providerInvalidConstructor() public function providerConstructor() { - return [ + return [ //$this->getConfig() [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 23 ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 23, 'prefix' => '', 'persistent' => false, @@ -208,7 +208,7 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 23, 'options' => [ 1 => 1250, @@ -216,7 +216,7 @@ public function providerConstructor() ] ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 23, 'prefix' => '', 'persistent' => false, @@ -228,12 +228,12 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 23, 'persistent' => true ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 23, 'prefix' => '', 'persistent' => true, @@ -242,11 +242,11 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'prefix' => 'test_' ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 8600, 'prefix' => 'test_', 'persistent' => false, @@ -255,11 +255,11 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'randomValue' => 'test_' ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'randomValue' => 'test_', 'lifetime' => 8600, 'prefix' => '', @@ -269,11 +269,11 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 123 => 'test_' ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 123 => 'test_', 'lifetime' => 8600, 'prefix' => '', @@ -283,12 +283,12 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 24, 'prefix' => 'test_', ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 24, 'prefix' => 'test_', 'persistent' => false, @@ -297,10 +297,10 @@ public function providerConstructor() ], [ [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), ], [ - 'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]], + 'hosts' => $this->getHostConfig(), 'lifetime' => 8600, 'prefix' => '', 'persistent' => false, @@ -310,4 +310,9 @@ public function providerConstructor() ]; } + + private function getHostConfig() + { + return [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => (int)env('TEST_AS_PORT', 3000)]]; + } } diff --git a/tests/aerospike/Cache/Backend/AerospikeTest.php b/tests/aerospike/Cache/Backend/AerospikeTest.php index 2536d9f81..853c5ede6 100644 --- a/tests/aerospike/Cache/Backend/AerospikeTest.php +++ b/tests/aerospike/Cache/Backend/AerospikeTest.php @@ -183,7 +183,7 @@ private function getConfig() { return [ 'hosts' => [ - ['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)] + ['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => (int)env('TEST_AS_PORT', 3000)] ], 'persistent' => false, // important 'namespace' => 'test', diff --git a/tests/aerospike/Session/Adapter/AerospikeTest.php b/tests/aerospike/Session/Adapter/AerospikeTest.php index 4aa9a3e88..af9ca686a 100644 --- a/tests/aerospike/Session/Adapter/AerospikeTest.php +++ b/tests/aerospike/Session/Adapter/AerospikeTest.php @@ -48,7 +48,7 @@ protected function _before() $this->getModule('Aerospike')->_reconfigure([ 'set' => $this->set, 'addr' => env('TEST_AS_HOST', '127.0.0.1'), - 'port' => env('TEST_AS_PORT', 3000) + 'port' => (int)env('TEST_AS_PORT', 3000) ]); } @@ -115,7 +115,7 @@ private function cleanup() $aerospike = new Aerospike( [ 'hosts' => [ - ['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)] + ['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => (int)env('TEST_AS_PORT', 3000)] ] ], false @@ -140,7 +140,7 @@ private function getConfig() { return [ 'hosts' => [ - ['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)] + ['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => (int)env('TEST_AS_PORT', 3000)] ], 'persistent' => false, 'namespace' => $this->ns,