nucliadb-utils 6.2.1.post2835__py3-none-any.whl → 6.2.1.post2842__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of nucliadb-utils might be problematic. Click here for more details.

@@ -17,220 +17,16 @@
17
17
  # You should have received a copy of the GNU Affero General Public License
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- import http.client
21
- import os
22
- import platform
23
- import signal
24
20
  import socket
25
- import subprocess
26
- import tempfile
27
- import time
28
- from io import BytesIO
29
- from urllib.request import urlopen
30
- from zipfile import ZipFile
31
21
 
32
22
  import nats
33
23
  import pytest
34
24
  from pytest_docker_fixtures import images # type: ignore
35
25
  from pytest_docker_fixtures.containers._base import BaseImage # type: ignore
36
26
 
37
-
38
- class Gnatsd(object):
39
- def __init__(
40
- self,
41
- port=4222,
42
- user="",
43
- password="",
44
- token="",
45
- timeout=0,
46
- http_port=8222,
47
- debug=False,
48
- tls=False,
49
- cluster_listen=None,
50
- routes=None,
51
- config_file=None,
52
- ): # pragma: no cover
53
- self.port = port
54
- self.user = user
55
- self.password = password
56
- self.timeout = timeout
57
- self.http_port = http_port
58
- self.proc = None
59
- self.debug = debug
60
- self.tls = tls
61
- self.token = token
62
- self.cluster_listen = cluster_listen
63
- self.routes = routes or []
64
- self.bin_name = "gnatsd"
65
- self.config_file = config_file
66
- self.folder = None
67
-
68
- env_debug_flag = os.environ.get("DEBUG_NATS_TEST")
69
- if env_debug_flag == "true":
70
- self.debug = True
71
-
72
- def start(self):
73
- folder = tempfile.TemporaryDirectory()
74
- cmd = [
75
- f"{self.path}/{self.bin_name}",
76
- "-js",
77
- "-p",
78
- "%d" % self.port,
79
- "-m",
80
- "%d" % self.http_port,
81
- "-a",
82
- "0.0.0.0",
83
- "-sd",
84
- folder.name,
85
- "--log",
86
- f"{folder.name}/log.log",
87
- ]
88
- self.folder = folder
89
- if self.user != "":
90
- cmd.append("--user")
91
- cmd.append(self.user)
92
- if self.password != "":
93
- cmd.append("--pass")
94
- cmd.append(self.password)
95
-
96
- if self.token != "":
97
- cmd.append("--auth")
98
- cmd.append(self.token)
99
-
100
- if self.debug:
101
- cmd.append("-DV")
102
-
103
- if self.tls:
104
- cmd.append("--tls")
105
- cmd.append("--tlscert")
106
- cmd.append("tests/certs/server-cert.pem")
107
- cmd.append("--tlskey")
108
- cmd.append("tests/certs/server-key.pem")
109
- cmd.append("--tlsverify")
110
- cmd.append("--tlscacert")
111
- cmd.append("tests/certs/ca.pem")
112
-
113
- if self.cluster_listen is not None:
114
- cmd.append("--cluster_listen")
115
- cmd.append(self.cluster_listen)
116
-
117
- if len(self.routes) > 0:
118
- cmd.append("--routes")
119
- cmd.append(",".join(self.routes))
120
-
121
- if self.config_file is not None:
122
- cmd.append("--config")
123
- cmd.append(self.config_file)
124
-
125
- if self.debug:
126
- self.proc = subprocess.Popen(cmd)
127
- else:
128
- self.proc = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
129
-
130
- if self.debug:
131
- if self.proc is None:
132
- print(
133
- "[\031[0;33mDEBUG\033[0;0m] Failed to start server listening on port %d started."
134
- % self.port
135
- )
136
- else:
137
- print("[\033[0;33mDEBUG\033[0;0m] Server listening on port %d started." % self.port)
138
- return self.proc
139
-
140
- def stop(self):
141
- if self.folder is not None:
142
- self.folder.cleanup()
143
- if self.debug:
144
- print("[\033[0;33mDEBUG\033[0;0m] Server listening on %d will stop." % self.port)
145
-
146
- if self.debug:
147
- if self.proc is None:
148
- print(
149
- "[\033[0;31mDEBUG\033[0;0m] Failed terminating server listening on port %d"
150
- % self.port
151
- )
152
-
153
- if self.proc.returncode is not None:
154
- if self.debug:
155
- print(
156
- "[\033[0;31mDEBUG\033[0;0m] Server listening on port {port} finished running already with exit {ret}".format( # noqa: E501
157
- port=self.port, ret=self.proc.returncode
158
- )
159
- )
160
- else:
161
- os.kill(self.proc.pid, signal.SIGKILL)
162
- self.proc.wait()
163
- if self.debug:
164
- print("[\033[0;33mDEBUG\033[0;0m] Server listening on %d was stopped." % self.port)
165
-
166
-
167
- class NatsServer(Gnatsd): # pragma: no cover
168
- def __init__(self):
169
- super(Gnatsd, self)
170
- self.bin_name = "nats-server"
171
-
172
-
173
- def start_gnatsd(gnatsd: Gnatsd): # pragma: no cover
174
- gnatsd.start()
175
-
176
- endpoint = "127.0.0.1:{port}".format(port=gnatsd.http_port)
177
- retries = 0
178
- while True:
179
- if retries > 100:
180
- break
181
-
182
- try:
183
- httpclient = http.client.HTTPConnection(endpoint, timeout=5)
184
- httpclient.request("GET", "/varz")
185
- response = httpclient.getresponse()
186
- if response.status == 200:
187
- break
188
- except Exception:
189
- retries += 1
190
- time.sleep(0.1)
191
-
192
-
193
- @pytest.fixture(scope="session")
194
- def natsd_server(): # pragma: no cover
195
- # Create a persistent temporary directory
196
- tmpdir = tempfile.mkdtemp()
197
- nats_server_path = os.path.join(tmpdir, "nats-server")
198
-
199
- if not os.path.isfile(nats_server_path):
200
- version = "v2.10.12"
201
- arch = platform.machine()
202
- if arch == "x86_64":
203
- arch = "amd64"
204
- system = platform.system().lower()
205
-
206
- url = f"https://github.com/nats-io/nats-server/releases/download/{version}/nats-server-{version}-{system}-{arch}.zip"
207
-
208
- resp = urlopen(url)
209
- zipfile = ZipFile(BytesIO(resp.read()))
210
-
211
- file = zipfile.open(f"nats-server-{version}-{system}-{arch}/nats-server")
212
- content = file.read()
213
- with open(nats_server_path, "wb") as f:
214
- f.write(content)
215
- os.chmod(nats_server_path, 0o755)
216
-
217
- server = Gnatsd(port=4222)
218
- server.bin_name = "nats-server"
219
- server.path = tmpdir
220
- return server
221
-
222
-
223
- @pytest.fixture(scope="session")
224
- def natsd(natsd_server: Gnatsd): # pragma: no cover
225
- start_gnatsd(natsd_server)
226
- print("Started natsd")
227
- yield f"nats://localhost:{natsd_server.port}"
228
- natsd_server.stop()
229
-
230
-
231
27
  images.settings["nats"] = {
232
28
  "image": "nats",
233
- "version": "2.10.12",
29
+ "version": "2.10.21",
234
30
  "options": {"command": ["-js"], "ports": {"4222": None}},
235
31
  }
236
32
 
@@ -252,7 +48,7 @@ nats_image = NatsImage()
252
48
 
253
49
 
254
50
  @pytest.fixture(scope="session")
255
- def natsdocker(): # pragma: no cover
51
+ def natsd(): # pragma: no cover
256
52
  nats_host, nats_port = nats_image.run()
257
53
  print("Started natsd docker")
258
54
  yield f"nats://{nats_host}:{nats_port}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb_utils
3
- Version: 6.2.1.post2835
3
+ Version: 6.2.1.post2842
4
4
  Home-page: https://nuclia.com
5
5
  License: BSD
6
6
  Classifier: Development Status :: 4 - Beta
@@ -24,8 +24,8 @@ Requires-Dist: PyNaCl
24
24
  Requires-Dist: pyjwt>=2.4.0
25
25
  Requires-Dist: memorylru>=1.1.2
26
26
  Requires-Dist: mrflagly>=0.2.9
27
- Requires-Dist: nucliadb-protos>=6.2.1.post2835
28
- Requires-Dist: nucliadb-telemetry>=6.2.1.post2835
27
+ Requires-Dist: nucliadb-protos>=6.2.1.post2842
28
+ Requires-Dist: nucliadb-telemetry>=6.2.1.post2842
29
29
  Provides-Extra: cache
30
30
  Requires-Dist: redis>=4.3.4; extra == "cache"
31
31
  Requires-Dist: orjson>=3.6.7; extra == "cache"
@@ -57,10 +57,10 @@ nucliadb_utils/tests/fixtures.py,sha256=i0sqPqe5a5JlKGFdaIvOlHYkZ3pHZ2hTIgTsaIB3
57
57
  nucliadb_utils/tests/gcs.py,sha256=KW_DLet1WRlssSW55eI-IQ-0d94Jo2Oh7Di4xGv4JCc,4685
58
58
  nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQFxk,1513
59
59
  nucliadb_utils/tests/local.py,sha256=fXIBasrvdaFJM-sw2wk1_oiFzBcm9O10iCyC-OiXwY8,1914
60
- nucliadb_utils/tests/nats.py,sha256=nykEfwxPc3F3aO8n7g_V7IY3RQBXU3_R_ukwBKxYXa8,7893
60
+ nucliadb_utils/tests/nats.py,sha256=RWHjwqq5esuO7OFbP24yYX1cXnpPLcWJwDUdmwCpH28,1897
61
61
  nucliadb_utils/tests/s3.py,sha256=pl-RJFjA4MH6iXkqhsh5g8gDuEhrYu1nPZ-laxlrMlE,3704
62
- nucliadb_utils-6.2.1.post2835.dist-info/METADATA,sha256=KwZVJk5wY5SxTDZuETS_635KUdS_t26MDDckIUf_YcY,2204
63
- nucliadb_utils-6.2.1.post2835.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
64
- nucliadb_utils-6.2.1.post2835.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
65
- nucliadb_utils-6.2.1.post2835.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
66
- nucliadb_utils-6.2.1.post2835.dist-info/RECORD,,
62
+ nucliadb_utils-6.2.1.post2842.dist-info/METADATA,sha256=5qR7hlR1UIG34SJP1cSWz7-qRL0q7AEWp1fFs3mOtAU,2204
63
+ nucliadb_utils-6.2.1.post2842.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
64
+ nucliadb_utils-6.2.1.post2842.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
65
+ nucliadb_utils-6.2.1.post2842.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
66
+ nucliadb_utils-6.2.1.post2842.dist-info/RECORD,,