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

Conversation

bigbes
Copy link
Contributor

@bigbes bigbes commented Jul 20, 2018

No description provided.

….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'
@bigbes bigbes requested a review from alg1973 July 20, 2018 15:16
* 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)
@bigbes bigbes changed the title Updated PHPUnit to version 7 + gh-24 + gh-42 Updated PHPUnit to version 7 + gh-24 + gh-42 + gh-85 Aug 13, 2018
@bigbes bigbes changed the title Updated PHPUnit to version 7 + gh-24 + gh-42 + gh-85 Updated PHPUnit to version 7 + gh-24 + gh-42 + gh-85 + gh-83 + gh-71 Aug 14, 2018
Copy link
Member

@Totktonada Totktonada left a 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'.

@@ -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)
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.

{
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?

Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

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

Comments for 'Replace linear scan'.

Please, remove 'closes gh-24' mark, because the issue is not relevent. Moreover, it was already implemented ( 31cf8a8 ) and should be closed.

See one inline comment below.

return 0;
return !memcmp((*lval)->key.id, (*rval)->key.id, (*rval)->key.id_len);
}
#define MH_DEFINE_CMPFUNC(NAME, TYPE) \
Copy link
Member

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.

Copy link
Member

@Totktonada Totktonada left a 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)
Copy link
Member

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));
Copy link
Member

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)
Copy link
Member

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) {
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 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);
Copy link
Member

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 */
Copy link
Member

Choose a reason for hiding this comment

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

Typo: unmatched quote.

Copy link
Member

@Totktonada Totktonada left a 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.

@@ -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.

@@ -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?

test-run.py Outdated
'test/shared/tarantool-3.ini'
'test/shared/tarantool-1.ini'
# 'test/shared/tarantool-2.ini',
# 'test/shared/tarantool-3.ini'
Copy link
Member

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)

Copy link
Member

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');
Copy link
Member

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);
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 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;
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.

@@ -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;
Copy link
Member

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?


struct tarantool_url *
tarantool_url_parse(const char *url, int persistent) {
struct uri parsed; memset(&parsed, 0, sizeof(struct uri));
Copy link
Member

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.

src/tarantool_url.c Show resolved Hide resolved
@@ -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.

@@ -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;
Copy link
Member

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.

@Totktonada
Copy link
Member

The first review is done. @bigbes, the ball is on your court.

rybakit added a commit to tarantool-php/queue that referenced this pull request Oct 25, 2018
* 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
@bigbes bigbes force-pushed the php7-v2 branch 5 times, most recently from 75606c0 to 03bc225 Compare November 4, 2018 22:42
@bigbes
Copy link
Contributor Author

bigbes commented Dec 2, 2018

Superseded by #140 #141 #142 #143

@bigbes bigbes closed this Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants