Skip to content

Updated PHPUnit to version 7 + gh-24 + gh-42 + gh-85 + gh-83 + gh-71 #134

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

Closed
wants to merge 10 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
64 changes: 28 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,40 @@ 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: OS=el DIST=6
# # - env: OS=el DIST=7
# - env: OS=fedora DIST=26
# - env: OS=fedora DIST=27
# # - env: OS=ubuntu DIST=trusty
# - env: OS=ubuntu DIST=xenial
# - env: OS=ubuntu DIST=artful
# # - env: OS=ubuntu DIST=bionic
# # - env: OS=debian DIST=wheezy
# # - env: OS=debian DIST=jessie
# - env: OS=debian DIST=stretch
# - { env: TARGET=test, php: 7.0 }
- { env: TARGET=test, php: 7.1 }
- { env: TARGET=test, php: nightly }
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
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ _**Description**_: Available Tarantool Constants

``` php
Tarantool {
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
public Tarantool::__construct ( [ string $uri = 'tcp://guest@localhost:3301' [, string $persistent_id = NULL ] ] )
Copy link
Member

Choose a reason for hiding this comment

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

Default port is 3303 as I see in src/tarantool_url.c.

public bool Tarantool::connect ( void )
public bool Tarantool::disconnect ( void )
public bool Tarantool::flushSchema ( void )
Expand All @@ -133,17 +133,16 @@ Tarantool {
#### Tarantool::__construct

```
public Tarantool::__construct ( [ string $uri = 'tcp://guest@localhost:3301' [, string $persistent_id = NULL ] ] )
/* Old API, eventually it'll be deleted */
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
```

_**Description**_: Creates a Tarantool client
_**Description**_: Creates a Tarantool client (TCP/UNIX sockets are supported)

_**Parameters**_

* `host`: string, default is `'localhost'`
* `port`: number, default is `3301`
* `user`: string, default is `'guest'`
* `password`: string
* `uri`: string, default is `'tcp://guest@localhost:3301'`
* `persistent_id`: string (set it, and connection will be persistent, if
`persistent` in config isn't set)

Expand All @@ -155,8 +154,10 @@ Tarantool class instance

``` php
$tnt = new Tarantool(); // -> new Tarantool('localhost', 3301);
$tnt = new Tarantool('tarantool.org'); // -> new Tarantool('tarantool.org', 3301);
$tnt = new Tarantool('localhost', 16847);
$tnt = new Tarantool('tcp://test:test@localhost');
$tnt = new Tarantool('tcp://test:test@localhost:3301');
$tnt = new Tarantool('test:test@unix/:/var/tmp/tarantool.sock');
$tnt = new Tarantool('unix:///var/tmp/tarantool.sock'); /* if no login is needed */
```

## Manipulation connection
Expand Down
2 changes: 2 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ if test "$PHP_TARANTOOL" != "no"; then
src/tarantool_schema.c \
src/tarantool_proto.c \
src/tarantool_tp.c \
src/tarantool_url.c \
src/tarantool_exception.c \
src/utils.c \
src/third_party/msgpuck.c \
src/third_party/sha1.c \
src/third_party/uri.c \
src/third_party/PMurHash.c \
, $ext_shared)
PHP_ADD_BUILD_DIR([$ext_builddir/src/])
Expand Down
44 changes: 29 additions & 15 deletions lib/tarantool_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,35 @@ 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)

class TarantoolServer(object):
default_tarantool = {
"bin": "tarantool",
"logfile": "tarantool.log",
"init": "init.lua"}
"bin": "tarantool",
"logfile": "tarantool.log",
"init": "init.lua",
"unix": "tarantool.sock"
}

default_cfg = {
"custom_proc_title": "\"tarantool-python testing\"",
"slab_alloc_arena": 0.5,
"pid_file": "\"box.pid\"",
"rows_per_wal": 200}
"custom_proc_title": "\"tarantool-python testing\"",
"slab_alloc_arena": 0.5,
"pid_file": "\"box.pid\"",
"rows_per_wal": 200
}

@property
def logfile_path(self):
Expand All @@ -134,6 +137,10 @@ def cfgfile_path(self):
def script_path(self):
return os.path.join(self.vardir, self.default_tarantool['init'])

@property
def unix_path(self):
return os.path.join(self.vardir, self.default_tarantool['unix'])

@property
def script_dst(self):
return os.path.join(self.vardir, os.path.basename(self.script))
Expand Down Expand Up @@ -187,9 +194,9 @@ def log_des(self):
def __init__(self):
os.popen('ulimit -c unlimited')
self.args = {}
self.args['primary'] = find_port()
self.args['admin'] = find_port(self.args['primary'] + 1)
self._admin = self.args['admin']

self.use_unix = False

self.vardir = tempfile.mkdtemp(prefix='var_', dir=os.getcwd())
self.find_exe()

Expand Down Expand Up @@ -242,10 +249,18 @@ def start(self):
# start Tarantool\Box --DONE(prepare_args)
# * Wait unitl Tarantool\Box
# started --DONE(wait_until_started)
if self.use_unix:
self.args['primary'] = self.unix_path
self.args['admin'] = find_port()
else:
self.args['primary'] = find_port()
self.args['admin'] = find_port(self.args['primary'] + 1)
self._admin = self.args['admin']

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)
args = self.prepare_args()
self.process = subprocess.Popen(args,
cwd = self.vardir,
Expand All @@ -269,4 +284,3 @@ def clean(self):
def __del__(self):
self.stop()
self.clean()

12 changes: 7 additions & 5 deletions src/php_tarantool.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,20 @@ ZEND_EXTERN_MODULE_GLOBALS(tarantool);

typedef struct tarantool_object {
struct tarantool_connection {
char *host;
int port;
char *login;
char *passwd;
/* physical url, that's used for connection in raw PHP obtained
* from parsed url by `tarantool_url_write_php_format` */
char *url;
Copy link
Member

Choose a reason for hiding this comment

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

I think it wroth to comment purpose of url field, because it is not obvious considering presence of url_parsed. First poor variant of the description:

The url to perform 'physical' connection using php stream; it does not contain authentification information and uses the schema that php streams understands; see tarantool_url_write_php_format for more info.

/* parsed url, after have user/password/...
* obtained from user string by `tarantool_url_parse` */
struct tarantool_url *url_parsed;
php_stream *stream;
struct tarantool_schema *schema;
smart_string *value;
struct tp *tps;
char *greeting;
char *salt;
/* Only for persistent connections */
char *orig_login;
char *orig_user;
char *suffix;
int suffix_len;
zend_string *persistent_id;
Expand Down
Loading