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

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

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
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
47 changes: 31 additions & 16 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 All @@ -204,6 +211,7 @@ def find_exe(self):
raise RuntimeError("Can't find server executable in " + os.environ["PATH"])

def generate_configuration(self):
# print(self.args)
Copy link
Member

Choose a reason for hiding this comment

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

Forgotten debug print.

os.putenv("PRIMARY_PORT", str(self.args['primary']))
os.putenv("ADMIN_PORT", str(self.args['admin']))

Expand Down Expand Up @@ -242,10 +250,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, 511)
Copy link
Member

Choose a reason for hiding this comment

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

It is better to use 0o777, should work with python2 and python3 both.

args = self.prepare_args()
self.process = subprocess.Popen(args,
cwd = self.vardir,
Expand All @@ -268,5 +284,4 @@ def clean(self):

def __del__(self):
self.stop()
self.clean()

# self.clean()
Copy link
Member

Choose a reason for hiding this comment

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

Why do you comment clean here?

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

typedef struct tarantool_object {
struct tarantool_connection {
char *host;
int port;
char *login;
char *passwd;
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.

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