-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
….1+) * Update test-run.py and lib/tarantool_server.py to support python 3 * Update tests accordingly to new version of PHPUnit * Added initialization of standart class properties to 'Tarantool'
* Added uri library from tarantool * New arg-format for connect: `tcp://..` and `..@unix\:...` URIs * Spaces -> Tabs, 2xTabs -> Tabs in tests * Use ZVAL_UNDEF instead of three separate gotos * Rewrite connection algorithm for supporting unix/tcp connection URI * Changed internal tarantool_connection table (with new struct tarantool_url) * Added new flag for test-run (--unix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for 'Update PHPUnit'.
lib/tarantool_server.py
Outdated
@@ -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, 511) |
There was a problem hiding this comment.
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.
test/MockTest.php
Outdated
{ | ||
public function testFoo() | ||
{ | ||
$tnt = $this->getMock('Tarantool'); | ||
// $tnt = $this->createMock(['Tarantool']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/tarantool_schema.c
Outdated
return 0; | ||
return !memcmp((*lval)->key.id, (*rval)->key.id, (*rval)->key.id_len); | ||
} | ||
#define MH_DEFINE_CMPFUNC(NAME, TYPE) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I trying to retain myself from formatting nitpicking, but here the entire block formatted with exceeding 80 symbols limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for 'Selecting by space_no/index_name'.
src/tarantool.c
Outdated
size_t body_size = php_mp_unpack_package_size(pack_len); | ||
smart_string_ensure(obj->value, body_size); | ||
if (tarantool_stream_read(obj, obj->value->c, | ||
body_size) == FAILURE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Underindented.
src/tarantool.c
Outdated
body_size) == FAILURE) | ||
return FAILURE; | ||
|
||
struct tnt_response resp; memset(&resp, 0, sizeof(struct tnt_response)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: two operators on the same line.
obj->value->len = tp_used(obj->tps); | ||
tarantool_tp_flush(obj->tps); | ||
|
||
if (tarantool_stream_send(obj) == FAILURE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block (here and below) was mostly copy-pasted from get_spaceno_by_name
. It worth to wrap it into a function I think.
@@ -695,6 +744,11 @@ int get_indexno_by_name(tarantool_connection *obj, int space_no, | |||
THROW_EXC("Index ID must be String or Long"); | |||
return FAILURE; | |||
} | |||
|
|||
if (obtain_space_by_spaceno(obj, space_no) == FAILURE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this call should be a part of get_spaceno_by_name.
README.md
Outdated
$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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: unmatched quote.
README.md
Outdated
$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 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: unmatched quote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for 'Implement UNIX socket support'.
I propose to add uri.rl to track which version of the file is actually used.
See other comments below.
lib/tarantool_server.py
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgotten debug print.
lib/tarantool_server.py
Outdated
@@ -268,5 +284,4 @@ def clean(self): | |||
|
|||
def __del__(self): | |||
self.stop() | |||
self.clean() | |||
|
|||
# self.clean() |
There was a problem hiding this comment.
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?
test-run.py
Outdated
'test/shared/tarantool-3.ini' | ||
'test/shared/tarantool-1.ini' | ||
# 'test/shared/tarantool-2.ini', | ||
# 'test/shared/tarantool-3.ini' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is purpose of this change? Should be commented, I think.
srv.start() | ||
|
||
run_tests(srv.vardir) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be good to more or less follow PEP8 and use two empty lines to separate functions on the top level of a file.
static function connectTarantool() { | ||
$port = getenv('PRIMARY_PORT'); | ||
if ($port[0] == '/') { | ||
return new Tarantool('unix/:' . $port, 'prefix'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'prefix'
is persistent_id
value? It had no been passed before. Why do you change it?
tarantool_url_free(struct tarantool_url *url, int persistent); | ||
|
||
const char * | ||
tarantool_url_write_php_format(struct tarantool_url *url, int persistent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not obvious that here we return URL w/o user and password in the format that php streams support. Need to be commented.
int port; | ||
char *login; | ||
char *passwd; | ||
char *url; |
There was a problem hiding this comment.
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.
@@ -282,10 +282,11 @@ ptrdiff_t php_mp_unpack_map(zval *oval, char **str) { | |||
ZVAL_UNDEF(&key); | |||
ZVAL_UNDEF(&value); | |||
if (php_mp_unpack(&key, str) == FAILURE) { | |||
goto error_key; | |||
goto error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not ZVAL_UNDEF be used here too? We assume that php_mp_unpack
can write some garbage in case of a failure, yep?
src/tarantool_url.c
Outdated
|
||
struct tarantool_url * | ||
tarantool_url_parse(const char *url, int persistent) { | ||
struct uri parsed; memset(&parsed, 0, sizeof(struct uri)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would avoid two operators on the same line.
@@ -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 ] ] ) |
There was a problem hiding this comment.
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.
@@ -225,7 +225,7 @@ static int __tarantool_connect(tarantool_object *t_obj) { | |||
TSRMLS_FETCH(); | |||
tarantool_connection *obj = t_obj->obj; | |||
int status = SUCCESS; | |||
long count = TARANTOOL_G(retry_count); | |||
long count = TARANTOOL_G(retry_count) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in case of retry_count
> 0 the real retry count will be retry_count
+ 1? I think it should be handled in some other way.
The first review is done. @bigbes, the ball is on your court. |
* Bump php version to 7.1 * Temporary skip the test for the pecl connector until this PR is merged: tarantool/tarantool-php#134 * Use variadic args in Queue::call() * Use float type hint for timestamp and interval arguments * Declare strict types * Fix scrutinizer fails to parse a coverage file * Add .php_cs.dist * Update README.md
75606c0
to
03bc225
Compare
No description provided.