Skip to content

Commit

Permalink
Merge pull request #820 from sergeysviridenko/3.2.aerospike_fix
Browse files Browse the repository at this point in the history
Fix aerospike tests
  • Loading branch information
sergeyklay authored Sep 25, 2017
2 parents a17fd7b + b47c1a9 commit 08fc3ef
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
14 changes: 5 additions & 9 deletions tests/_ci/install_aerospike.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 27 additions & 22 deletions tests/aerospike/Annotations/Adapter/AerospikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -80,15 +80,15 @@ 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));
}

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);
Expand All @@ -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');
Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -208,15 +208,15 @@ 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,
3 => 1500
]
],
[
'hosts' => [['addr' => env('TEST_AS_HOST', '127.0.0.1'), 'port' => env('TEST_AS_PORT', 3000)]],
'hosts' => $this->getHostConfig(),
'lifetime' => 23,
'prefix' => '',
'persistent' => false,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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' => '',
Expand All @@ -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' => '',
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)]];
}
}
2 changes: 1 addition & 1 deletion tests/aerospike/Cache/Backend/AerospikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions tests/aerospike/Session/Adapter/AerospikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]);
}

Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 08fc3ef

Please sign in to comment.