Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return working tests on php7.0-php7.2 #140

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Makefile.in
/config.nice
/config.status
/config.sub
/configure.ac
/configure.in
/libtool
/ltmain.sh
Expand Down
14 changes: 14 additions & 0 deletions .travis.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: test

all: package

package:
git clone https://github.com/packpack/packpack.git packpack
packpack/packpack

test:
curl -s https://packagecloud.io/install/repositories/tarantool/1_10/script.deb.sh | sudo bash
sudo apt install tarantool
phpize && ./configure && make all && sudo make install
sudo pip install PyYAML
./test-run.py
52 changes: 16 additions & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ services:

language: php

php:
- 7.0
- 7.1
- nightly

python:
- 2.7

Expand All @@ -17,43 +12,28 @@ cache: false
env:
global:
- PRODUCT=php-tarantool
matrix:
- OS=el DIST=6 PACK=rpm
- OS=el DIST=7 PACK=rpm
- OS=fedora DIST=22 PACK=rpm
- OS=fedora DIST=23 PACK=rpm
- OS=fedora DIST=rawhide PACK=rpm
- OS=ubuntu DIST=trusty PACK=deb
- OS=ubuntu DIST=precise PACK=deb
- OS=ubuntu DIST=wily PACK=deb
# phpize is, currently, broken on xenial. can't test, still not stable
# - OS=ubuntu DIST=xenial PACK=deb
- OS=debian DIST=jessie PACK=deb
- OS=debian DIST=wheezy PACK=deb
- OS=debian DIST=stretch PACK=deb
- OS=debian DIST=sid PACK=deb
- PACK=none

# multiple php version exclusion matrix
matrix:
include:
- { env: TARGET=test, php: 7.1 }
- { env: TARGET=test, php: 7.2 }
fast_finish: true
allow_failures:
- env: OS=el DIST=6 PACK=rpm
- env: OS=el DIST=7 PACK=rpm
- env: OS=fedora DIST=22 PACK=rpm
- env: OS=fedora DIST=23 PACK=rpm
- env: OS=fedora DIST=rawhide PACK=rpm
- env: OS=ubuntu DIST=precise PACK=deb
- env: OS=ubuntu DIST=trusty PACK=deb
- env: OS=ubuntu DIST=wily PACK=deb
- env: OS=debian DIST=jessie PACK=deb
- env: OS=debian DIST=wheezy PACK=deb
- env: OS=debian DIST=stretch PACK=deb
- env: OS=debian DIST=sid PACK=deb
allowed_failures:
- OS=el DIST=6
- OS=el DIST=7
- OS=fedora DIST=26
- OS=fedora DIST=27
- OS=ubuntu DIST=trusty
- OS=ubuntu DIST=xenial
- OS=ubuntu DIST=artful
- OS=ubuntu DIST=bionic
- OS=debian DIST=wheezy
- OS=debian DIST=jessie
- OS=debian DIST=stretch

script:
- git clone https://github.com/tarantool/build.git
- bash build/pack/travis.sh
- make -f .travis.mk ${TARGET}

notifications:
email: true
Expand Down
8 changes: 4 additions & 4 deletions lib/tarantool_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ def execute_no_reconnect(self, command):
if not command:
return
cmd = command.replace('\n', ' ') + '\n'
self.socket.sendall(cmd)
self.socket.sendall(cmd.encode())

bufsiz = 4096
res = ""
res = b''

while True:
buf = self.socket.recv(bufsiz)
if not buf:
break
res = res + buf
if (res.rfind("\n...\n") >= 0 or res.rfind("\r\n...\r\n") >= 0):
if (res.rfind(b'\n...\n') >= 0 or res.rfind(b'\r\n...\r\n') >= 0):
break

return yaml.load(res)
Expand Down Expand Up @@ -245,7 +245,7 @@ def start(self):
self.generate_configuration()
if self.script:
shutil.copy(self.script, self.script_dst)
os.chmod(self.script_dst, 0777)
os.chmod(self.script_dst, 0o777)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You touched this line 2 times arcoss there commits. 0777 → 511 → 0o777. Please, use 0o777 right in the first commit.

args = self.prepare_args()
self.process = subprocess.Popen(args,
cwd = self.vardir,
Expand Down
1 change: 1 addition & 0 deletions src/tarantool.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ static zend_object *tarantool_create(zend_class_entry *entry) {
obj = (tarantool_object *)pecalloc(1, sizeof(tarantool_object) +
sizeof(zval) * (entry->default_properties_count - 1), 0);
zend_object_std_init(&obj->zo, entry);
object_properties_init(&obj->zo, entry);
obj->zo.handlers = &tarantool_obj_handlers;

return &obj->zo;
Expand Down
21 changes: 11 additions & 10 deletions test-run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

import os
import sys
Expand All @@ -12,6 +12,8 @@

from pprint import pprint

PHPUNIT_PHAR = 'phpunit.phar'

def read_popen(cmd):
path = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
path.wait()
Expand All @@ -22,7 +24,7 @@ def read_popen_config(cmd):
return read_popen(cmd)

def find_php_bin():
path = read_popen('which php').strip()
path = read_popen('which php').strip().decode()
if (path.find('phpenv') != -1):
version = read_popen('phpenv global')
if (version.find('system') != -1):
Expand All @@ -37,7 +39,7 @@ def prepare_env(php_ini):
os.mkdir('var')
shutil.copy('test/shared/phpunit.xml', 'var')
test_dir_path = os.path.abspath(os.path.join(os.getcwd(), 'test'))
test_lib_path = os.path.join(test_dir_path, 'phpunit.phar')
test_lib_path = os.path.join(test_dir_path, PHPUNIT_PHAR)
# shutil.copy('test/shared/tarantool.ini', 'var')
shutil.copy(php_ini, 'var')
shutil.copy('modules/tarantool.so', 'var')
Expand All @@ -60,18 +62,17 @@ def main():
try:
shutil.copy('test/shared/phpunit.xml', os.path.join(test_cwd, 'phpunit.xml'))
shutil.copy('modules/tarantool.so', test_cwd)
test_lib_path = os.path.join(test_dir_path, 'phpunit.phar')
test_lib_path = os.path.join(test_dir_path, PHPUNIT_PHAR)

version = read_popen_config('--version').strip(' \n\t') + '.'
version1 = read_popen_config('--extension-dir').strip(' \n\t')
version = read_popen_config('--version').decode().strip(' \n\t') + '.'
version1 = read_popen_config('--extension-dir').decode().strip(' \n\t')
version += '\n' + ('With' if version1.find('non-zts') == -1 else 'Without') + ' ZTS'
version += '\n' + ('With' if version1.find('no-debug') == -1 else 'Without') + ' Debug'
print('Running against ' + version)

for php_ini in [
'test/shared/tarantool-1.ini',
'test/shared/tarantool-2.ini',
'test/shared/tarantool-3.ini'
'test/shared/tarantool-2.ini'
]:
cmd = ''
shutil.copy(php_ini, os.path.join(test_cwd, 'tarantool.ini'))
Expand Down Expand Up @@ -100,9 +101,9 @@ def main():
cmd = cmd + 'sudo dtruss ' + find_php_bin()
cmd = cmd + ' -c tarantool.ini {0}'.format(test_lib_path)
else:
print find_php_bin()
print(find_php_bin())
cmd = '{0} -c tarantool.ini {1}'.format(find_php_bin(), test_lib_path)
print cmd
print(cmd)

print('Running "%s" with "%s"' % (cmd, php_ini))
proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)
Expand Down
19 changes: 0 additions & 19 deletions test.sh

This file was deleted.

8 changes: 7 additions & 1 deletion test/AssertTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
class AssertTest extends PHPUnit_Framework_TestCase

use PHPUnit\Framework\TestCase;

final class AssertTest extends TestCase
{
protected static $tarantool, $tm;

Expand Down Expand Up @@ -39,6 +42,9 @@ function assert_f()
self::$tarantool->select("test");
}

/**
* @doesNotPerformAssertions
*/
public function test_01_closed_connection() {
for ($i = 0; $i < 20000; $i++) {
try {
Expand Down
9 changes: 7 additions & 2 deletions test/CreateTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class CreateTest extends PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

final class CreateTest extends TestCase
{
protected static $port, $tm;

Expand Down Expand Up @@ -34,6 +36,9 @@ public function test_01_create_test_ping_and_close() {
$c->close();
}

/**
* @doesNotPerformAssertions
*/
public function test_01_01_double_disconnect() {
$a = new Tarantool('localhost', self::$port);
$a->disconnect();
Expand All @@ -42,7 +47,7 @@ public function test_01_01_double_disconnect() {

/**
* @expectedException TarantoolException
* @expectedExceptionMessageRegExp /Name or service not known|nodename nor servname provided/
* @expectedExceptionMessageRegExp /Name or service not known|nodename nor servname provided|getaddrinfo/
*/
public function test_02_create_error_host() {
(new Tarantool('very_bad_host'))->connect();
Expand Down
14 changes: 13 additions & 1 deletion test/DMLTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
class DMLTest extends PHPUnit_Framework_TestCase

use PHPUnit\Framework\TestCase;

final class DMLTest extends TestCase
{
protected static $tarantool;

Expand Down Expand Up @@ -158,6 +161,9 @@ public function test_06_update() {
$this->assertEquals($result_tuple, $tuple[0]);
}

/**
* @doesNotPerformAssertions
*/
public function test_07_update_no_error() {
self::$tarantool->update("test", 0, array());
}
Expand Down Expand Up @@ -439,6 +445,9 @@ public static function provideIteratorGood() {
];
}

/**
* @doesNotPerformAssertions
*/
public function test_18_01_delete_loop() {
for ($i = 0; $i <= 1000; $i++) {
self::$tarantool->replace("pstring", array("test2" . $i, $i));
Expand All @@ -451,6 +460,9 @@ public function test_18_01_delete_loop() {
gc_collect_cycles();
}

/**
* @doesNotPerformAssertions
*/
public function test_18_02_delete_loop() {
for ($i = 0; $i <= 1000; $i++) {
self::$tarantool->replace("pstring", array("test2" . $i, $i));
Expand Down
8 changes: 6 additions & 2 deletions test/MockTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php
class MockTest extends \PHPUnit_Framework_TestCase

use PHPUnit\Framework\TestCase;

final class MockTest extends TestCase
{
public function testFoo()
{
$tnt = $this->getMock('Tarantool');
// $tnt = $this->createMock(['Tarantool']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed?

$tnt = $this->createMock(\Tarantool::class);
$tnt->expects($this->once())->method('ping');
$tnt->ping();
}
Expand Down
23 changes: 15 additions & 8 deletions test/MsgPackTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
class MsgPackTest extends PHPUnit_Framework_TestCase

use PHPUnit\Framework\TestCase;

final class MsgPackTest extends TestCase
{
protected static $tarantool;

Expand Down Expand Up @@ -48,6 +51,9 @@ public function test_03_msgpack_array_of_float_as_key() {
self::$tarantool->select("msgpack", array(3));
}

/**
* @doesNotPerformAssertions
*/
public function test_04_msgpack_integer_keys_arrays() {
self::$tarantool->replace("msgpack", array(4,
"Integer keys causing server to error",
Expand All @@ -70,11 +76,12 @@ public function test_05_msgpack_string_keys() {
$this->assertTrue(True);
}

public function test_06_msgpack_array_reference() {
$data = [
'key1' => 'value1',
];
$link = &$data['key1'];
self::$tarantool->call('test_4', [$data]);
}
/**
* @doesNotPerformAssertions
*/
public function test_06_msgpack_array_reference() {
$data = [ 'key1' => 'value1', ];
$link = &$data['key1'];
self::$tarantool->call('test_4', [$data]);
}
}
8 changes: 7 additions & 1 deletion test/RandomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function generateRandomString($length = 10) {
return $randomString;
}

class RandomTest extends PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

final class RandomTest extends TestCase
{
protected static $tarantool;

Expand Down Expand Up @@ -39,6 +41,10 @@ public function test_03_another_big_response() {
$this->assertEquals($i, count($result));
}
}

/**
* @doesNotPerformAssertions
*/
public function test_04_get_strange_response() {
self::$tarantool->select("_schema", "12345");
}
Expand Down
1 change: 0 additions & 1 deletion test/phpunit

This file was deleted.

Loading