Skip to content

Commit

Permalink
test: move basic mesh test under './setup.py test'
Browse files Browse the repository at this point in the history
In short: this commit moves the basic MeshConnection test cases to the
`./setup.py test` test suites (which are located in the unit/ now) and
removes the test-run submodule, which is not needed anymore.

A bit background: we have a testing framework called test-run, whose
primary goal is to give ability to manage tarantool instances from a
test. Historically tarantool-python does not use test-run for testing
(it uses several simple python helpers instead), but a test-run based
test was added in the scope of #106. The idea was to reuse test-run code
more and eventually port other tests to test-run.

The objective reality reveals several problems in the idea, which looked
nice in theory.

The main problem is the cyclic dependency between test-run and
tarantool-python submodules. It consumes an extra time at recursive git
clone and places old submodule revisions in a deeply nested level. The
latter may confuse linter tools, which search for files recursively (see
[1]).

Other problems look solvable, but I'll list them, because they give
considerable weight in my impression that we should get rid of the
test-run submodule within this repository:

1. test-run based tests were not run in CI and may break silently so
   (it already occurs once).
2. The first bullet looks easy to fix, but it is unclear whether it is
   right to depend on a submodule in the `./setup.py test` testing or we
   should keep only built-in and packaged testing tools in the
   dependencies.
3. Porting tests to test-run may require extra effort and nobody was
   eager to pay time for that.
4. Existing tooling for managing tarantool instances is enough for
   testing of the connector and, at the same time, it is quite simple.
   So if we'll meet a problem, it is easier to fix.
5. test-run supports only Python 2 at the moment (however it'll be fixed
   soon, see [2]).

To sum up, the experiment with the test-run submodule looks unsuccessful
and I think we should stop it for now. If we'll decide to try again, we
should consider all described problems and implement everything in a way
that does not hurt us.

[1]: tarantool/test-run#266 (comment)
[2]: tarantool/test-run#20

Fixes #111
  • Loading branch information
Totktonada committed Feb 16, 2021
1 parent 07aa6a3 commit 95c43d4
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 146 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "test-run"]
path = test-run
url = https://github.com/tarantool/test-run
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.PHONY: test
test:
python setup.py test
cd test && ./test-run.py
coverage:
python -m coverage run -p --source=. setup.py test
cov-html:
Expand Down
1 change: 0 additions & 1 deletion test-run
Submodule test-run deleted from 72f8b8
15 changes: 0 additions & 15 deletions test/.tarantoolctl

This file was deleted.

16 changes: 0 additions & 16 deletions test/cluster-py/instance.lua

This file was deleted.

1 change: 0 additions & 1 deletion test/cluster-py/instance1.lua

This file was deleted.

1 change: 0 additions & 1 deletion test/cluster-py/instance2.lua

This file was deleted.

9 changes: 0 additions & 9 deletions test/cluster-py/master.lua

This file was deleted.

22 changes: 0 additions & 22 deletions test/cluster-py/multi.result

This file was deleted.

71 changes: 0 additions & 71 deletions test/cluster-py/multi.test.py

This file was deleted.

5 changes: 0 additions & 5 deletions test/cluster-py/suite.ini

This file was deleted.

1 change: 0 additions & 1 deletion test/test-run.py

This file was deleted.

36 changes: 36 additions & 0 deletions unit/suites/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from time import sleep
import tarantool
from tarantool.error import (
NetworkError,
ConfigurationError,
NetworkWarning,
ClusterDiscoveryWarning,
)
from .lib.tarantool_server import TarantoolServer
Expand Down Expand Up @@ -70,6 +72,40 @@ def setUp(self):
self.define_cluster_function(self.get_all_nodes_func_name,
self.servers)

def test_00_basic(self):
def assert_srv_id(con, srv_id):
with warnings.catch_warnings():
warnings.simplefilter('ignore', category=NetworkWarning)
resp = con.call('srv_id')
self.assertEqual(resp.data and resp.data[0], srv_id)

con = tarantool.MeshConnection(addrs=[
{'host': self.host_1, 'port': self.port_1},
{'host': self.host_2, 'port': self.port_2},
], user='test', password='test')

# Response from instance#1.
assert_srv_id(con, 1)

# Stop instance#1 -- response from instance#2.
self.srv.stop()
assert_srv_id(con, 2)

# Start instance#1, stop instance#2 -- response from
# instance#1 again.
self.srv.start()
self.srv.admin('function srv_id() return 1 end')
self.srv2.stop()
assert_srv_id(con, 1)

# Stop instance #2 -- NetworkError (because we have no
# alive servers anymore).
self.srv.stop()
with self.assertRaises(NetworkError):
with warnings.catch_warnings():
warnings.simplefilter('ignore', category=NetworkWarning)
con.ping()

def test_01_contructor(self):
# Verify that an error is risen when no addresses are
# configured (neither with host/port, nor with addrs).
Expand Down

0 comments on commit 95c43d4

Please sign in to comment.