• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / test-run / 5727895731

pending completion
5727895731

push

github

ylobankov
Disable reproduce content printing

Now it is an irrelevant feature for us because we restart Tarantool
server before each test [1]. So the order of tests shouldn't affect
anything.

This patch just disables reproduce content printing. It is planned
to drop the related code later.

[1] https://github.com/tarantool/test-run/pull/309

759 of 1562 branches covered (48.59%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2933 of 4344 relevant lines covered (67.52%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/lib/admin_connection.py
1
__author__ = "Konstantin Osipov <kostja.osipov@gmail.com>"
1✔
2

3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1. Redistributions of source code must retain the above copyright
7
#    notice, this list of conditions and the following disclaimer.
8
# 2. Redistributions in binary form must reproduce the above copyright
9
#    notice, this list of conditions and the following disclaimer in the
10
#    documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
# ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
16
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
# SUCH DAMAGE.
23

24
import re
1✔
25
import sys
1✔
26

27
from lib.tarantool_connection import TarantoolConnection
1✔
28
from lib.tarantool_connection import TarantoolPool
1✔
29
from lib.tarantool_connection import TarantoolAsyncConnection
1✔
30

31
from lib.utils import bytes_to_str
1✔
32
from lib.utils import str_to_bytes
1✔
33

34
ADMIN_SEPARATOR = '\n'
1✔
35

36

37
def get_handshake(sock, length=128, max_try=100):
1✔
38
    """
39
    Correct way to get tarantool handshake
40
    """
41
    result = b""
1✔
42
    i = 0
1✔
43
    while len(result) != length and i < max_try:
1✔
44
        result = b"%s%s" % (result, sock.recv(length-len(result)))
1✔
45
        # max_try counter for tarantool/gh-1362
46
        i += 1
1✔
47
    return bytes_to_str(result)
1✔
48

49

50
class AdminPool(TarantoolPool):
1✔
51
    def _new_connection(self):
1✔
52
        s = super(AdminPool, self)._new_connection()
1✔
53
        handshake = get_handshake(s)
1✔
54
        if handshake and not re.search(r'^Tarantool.*console.*',
1!
55
                                       str(handshake)):
56
            # tarantool/gh-1163
57
            # 1. raise only if handshake is not full
58
            # 2. be silent on crashes or if it's server.stop() operation
59
            print('Handshake error {\n', handshake, '\n}')
×
60
            raise RuntimeError('Broken tarantool console handshake')
×
61
        return s
1✔
62

63

64
class ExecMixIn(object):
1✔
65
    def cmd(self, socket, cmd, silent):
1✔
66
        socket.sendall(str_to_bytes(cmd))
1✔
67

68
        bufsiz = 4096
1✔
69
        res = ""
1✔
70
        while True:
71
            buf = bytes_to_str(socket.recv(bufsiz))
1✔
72
            if not buf:
1!
73
                break
×
74
            res = res + buf
1✔
75
            if (res.rfind("\n...\n") >= 0 or res.rfind("\r\n...\r\n") >= 0):
1!
76
                break
×
77

78
        if not silent:
1✔
79
            sys.stdout.write(res.replace("\r\n", "\n"))
1✔
80
        return res
1✔
81

82

83
class BrokenConsoleHandshake(RuntimeError):
1✔
84
    pass
1✔
85

86

87
class AdminConnection(TarantoolConnection, ExecMixIn):
1✔
88
    def execute_no_reconnect(self, command, silent):
1✔
89
        if not command:
1!
90
            return
×
91
        if not silent:
1!
92
            sys.stdout.write(command + ADMIN_SEPARATOR)
×
93
        cmd = command.replace('\n', ' ') + ADMIN_SEPARATOR
1✔
94
        return self.cmd(self.socket, cmd, silent)
1✔
95

96
    def connect(self):
1✔
97
        super(AdminConnection, self).connect()
1✔
98
        handshake = get_handshake(self.socket)
1✔
99
        if not re.search(r'^Tarantool.*console.*', str(handshake)):
1!
100
            raise BrokenConsoleHandshake('Broken tarantool console handshake')
×
101

102

103
class AdminAsyncConnection(TarantoolAsyncConnection, ExecMixIn):
1✔
104
    pool = AdminPool
1✔
105

106
    def execute_no_reconnect(self, command, silent):
1✔
107
        if not command:
1!
108
            return
×
109
        if not silent:
1✔
110
            sys.stdout.write(command + ADMIN_SEPARATOR)
1✔
111
        cmd = command.replace('\n', ' ') + ADMIN_SEPARATOR
1✔
112

113
        result = None
1✔
114
        with self.connections.get() as sock:
1✔
115
            result = self.cmd(sock, cmd, silent)
1✔
116
        return result
1✔
117

118
    def execute(self, command, silent=True):
1✔
119
        if not self.is_connected:
1✔
120
            self.connect()
1✔
121
        try:
1✔
122
            return self.execute_no_reconnect(command, silent)
1✔
123
        except Exception:
×
124
            return None
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc