Skip to content

Commit dccf18f

Browse files
committed
test: move basic mesh test under './setup.py test'
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
1 parent fb23322 commit dccf18f

13 files changed

+36
-146
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "test-run"]
2-
path = test-run
3-
url = https://github.com/tarantool/test-run

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.PHONY: test
22
test:
33
python setup.py test
4-
cd test && ./test-run.py
54
coverage:
65
python -m coverage run -p --source=. setup.py test
76
cov-html:

test-run

-1
This file was deleted.

test/.tarantoolctl

-15
This file was deleted.

test/cluster-py/instance.lua

-16
This file was deleted.

test/cluster-py/instance1.lua

-1
This file was deleted.

test/cluster-py/instance2.lua

-1
This file was deleted.

test/cluster-py/master.lua

-9
This file was deleted.

test/cluster-py/multi.result

-22
This file was deleted.

test/cluster-py/multi.test.py

-71
This file was deleted.

test/cluster-py/suite.ini

-5
This file was deleted.

test/test-run.py

-1
This file was deleted.

unit/suites/test_mesh.py

+36
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
from time import sleep
99
import tarantool
1010
from tarantool.error import (
11+
NetworkError,
1112
ConfigurationError,
13+
NetworkWarning,
1214
ClusterDiscoveryWarning,
1315
)
1416
from .lib.tarantool_server import TarantoolServer
@@ -70,6 +72,40 @@ def setUp(self):
7072
self.define_cluster_function(self.get_all_nodes_func_name,
7173
self.servers)
7274

75+
def test_00_basic(self):
76+
def assert_srv_id(con, srv_id):
77+
with warnings.catch_warnings():
78+
warnings.simplefilter('ignore', category=NetworkWarning)
79+
resp = con.call('srv_id')
80+
self.assertEqual(resp.data and resp.data[0], srv_id)
81+
82+
con = tarantool.MeshConnection(addrs=[
83+
{'host': self.host_1, 'port': self.port_1},
84+
{'host': self.host_2, 'port': self.port_2},
85+
], user='test', password='test')
86+
87+
# Response from instance#1.
88+
assert_srv_id(con, 1)
89+
90+
# Stop instance#1 -- response from instance#2.
91+
self.srv.stop()
92+
assert_srv_id(con, 2)
93+
94+
# Start instance#1, stop instance#2 -- response from
95+
# instance#1 again.
96+
self.srv.start()
97+
self.srv.admin('function srv_id() return 1 end')
98+
self.srv2.stop()
99+
assert_srv_id(con, 1)
100+
101+
# Stop instance #2 -- NetworkError (because we have no
102+
# alive servers anymore).
103+
self.srv.stop()
104+
with self.assertRaises(NetworkError):
105+
with warnings.catch_warnings():
106+
warnings.simplefilter('ignore', category=NetworkWarning)
107+
con.ping()
108+
73109
def test_01_contructor(self):
74110
# Verify that an error is risen when no addresses are
75111
# configured (neither with host/port, nor with addrs).

0 commit comments

Comments
 (0)