MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / test_generate_partial_access

Function test_generate_partial_access

tests/test_server.py:174–228  ·  view source on GitHub ↗
(hq_env: HqEnv)

Source from the content-addressed store, hash-verified

172
173
174def test_generate_partial_access(hq_env: HqEnv):
175 client_port = 18000 + random.randint(0, 1000)
176 worker_port = 14000 + random.randint(0, 1000)
177 hq_env.command(
178 [
179 "server",
180 "generate-access",
181 "myaccess.json",
182 f"--worker-port={worker_port}",
183 f"--client-port={client_port}",
184 "--client-file=client.json",
185 "--worker-file=worker.json",
186 ],
187 use_server_dir=False,
188 )
189
190 with open("client.json", "r") as f:
191 access = json.load(f)
192
193 schema = Schema(
194 {
195 "version": str,
196 "client": {"host": str, "port": client_port, "secret_key": str},
197 },
198 )
199 schema.validate(access)
200
201 with open("worker.json", "r") as f:
202 access = json.load(f)
203
204 schema = Schema(
205 {
206 "version": str,
207 "worker": {"host": str, "port": worker_port, "secret_key": str},
208 },
209 )
210 schema.validate(access)
211
212 hq_env.start_server(args=["--access-file=myaccess.json"])
213
214 WORKER_SD = "acc/worker"
215 os.makedirs(os.path.join(WORKER_SD, "hq-current"))
216 os.rename("worker.json", os.path.join(WORKER_SD, "hq-current", "access.json"))
217 hq_env.start_worker(server_dir=WORKER_SD)
218
219 CLIENT_SD = "acc/client"
220 os.makedirs(os.path.join(CLIENT_SD, "hq-current"))
221 os.rename("client.json", os.path.join(CLIENT_SD, "hq-current", "access.json"))
222
223 result = hq_env.command(
224 [f"--server-dir={CLIENT_SD}", "worker", "list"],
225 use_server_dir=False,
226 as_table=True,
227 )
228 assert result.get_row_value("1") == "RUNNING"
229
230
231def test_generate_partial_access_hosts(hq_env: HqEnv):

Callers

nothing calls this directly

Calls 6

commandMethod · 0.80
loadMethod · 0.80
get_row_valueMethod · 0.80
validateMethod · 0.45
start_serverMethod · 0.45
start_workerMethod · 0.45

Tested by

no test coverage detected