def test_local_tls(loop, temporary): if temporary: pytest.importorskip("cryptography") security = True else: security = tls_only_security() with LocalCluster( n_workers=0, scheduler_port=8786, silence_logs=False, security=security, dashboard_address=False, host="tls://0.0.0.0", loop=loop, ) as c: sync( loop, assert_can_connect_from_everywhere_4, c.scheduler.port, protocol="tls", timeout=3, **c.security.get_connection_args("client"), ) # If we connect to a TLS localculster without ssl information we should fail sync( loop, assert_cannot_connect, addr="tcp://127.0.0.1:%d" % c.scheduler.port, exception_class=RuntimeError, **c.security.get_connection_args("client"), )
def test_local_tls(loop): from distributed.utils_test import tls_only_security security = tls_only_security() with LocalCluster( scheduler_port=8786, silence_logs=False, security=security, dashboard_address=False, ip="tls://0.0.0.0", loop=loop, ) as c: sync( loop, assert_can_connect_from_everywhere_4, c.scheduler.port, connection_args=security.get_connection_args("client"), protocol="tls", timeout=3, ) # If we connect to a TLS localculster without ssl information we should fail sync( loop, assert_cannot_connect, addr="tcp://127.0.0.1:%d" % c.scheduler.port, connection_args=security.get_connection_args("client"), exception_class=RuntimeError, )
async def test_capture_security(cleanup): security = tls_only_security() async with LocalCluster( n_workers=0, silence_logs=False, security=security, asynchronous=True, dashboard_address=False, host="tls://0.0.0.0", ) as cluster: async with Client(cluster, asynchronous=True) as client: assert client.security == cluster.security
def test_local_tls_restart(loop): from distributed.utils_test import tls_only_security security = tls_only_security() with LocalCluster(n_workers=1, scheduler_port=8786, silence_logs=False, security=security, diagnostics_port=False, ip='tls://0.0.0.0', loop=loop) as c: with Client(c.scheduler.address, loop=loop, security=security) as client: print(c.workers, c.workers[0].address) workers_before = set(client.scheduler_info()['workers']) assert client.submit(inc, 1).result() == 2 client.restart() workers_after = set(client.scheduler_info()['workers']) assert client.submit(inc, 2).result() == 3 assert workers_before != workers_after
def test_local_tls_restart(loop): from distributed.utils_test import tls_only_security security = tls_only_security() with LocalCluster(n_workers=1, scheduler_port=8786, silence_logs=False, security=security, diagnostics_port=False, ip='tls://0.0.0.0', loop=loop) as c: with Client(c.scheduler.address, loop=loop, security=security) as client: print(c.workers, c.workers[0].address) workers_before = set(client.scheduler_info()['workers']) assert client.submit(inc, 1).result() == 2 client.restart() workers_after = set(client.scheduler_info()['workers']) assert client.submit(inc, 2).result() == 3 assert workers_before != workers_after
def test_local_tls(loop): from distributed.utils_test import tls_only_security security = tls_only_security() with LocalCluster(scheduler_port=8786, silence_logs=False, security=security, diagnostics_port=False, ip='tls://0.0.0.0', loop=loop) as c: sync(loop, assert_can_connect_from_everywhere_4, c.scheduler.port, connection_args=security.get_connection_args('client'), protocol='tls', timeout=3) # If we connect to a TLS localculster without ssl information we should fail sync(loop, assert_cannot_connect, addr='tcp://127.0.0.1:%d' % c.scheduler.port, connection_args=security.get_connection_args('client'), exception_class=RuntimeError, )
async def test_capture_security(cleanup, temporary): if temporary: pytest.importorskip("cryptography") security = True else: security = tls_only_security() async with LocalCluster( n_workers=0, silence_logs=False, security=security, asynchronous=True, dashboard_address=False, host="tls://0.0.0.0", ) as cluster: async with Client(cluster, asynchronous=True) as client: assert client.security == cluster.security
def test_local_tls_restart(loop): from distributed.utils_test import tls_only_security security = tls_only_security() with LocalCluster( n_workers=1, scheduler_port=8786, silence_logs=False, security=security, dashboard_address=False, host="tls://0.0.0.0", loop=loop, ) as c: with Client(c.scheduler.address, loop=loop, security=security) as client: workers_before = set(client.scheduler_info()["workers"]) assert client.submit(inc, 1).result() == 2 client.restart() workers_after = set(client.scheduler_info()["workers"]) assert client.submit(inc, 2).result() == 3 assert workers_before != workers_after
def gen_tls_cluster(**kwargs): kwargs.setdefault('ncores', [('tls://127.0.0.1', 1), ('tls://127.0.0.1', 2)]) return gen_cluster(scheduler='tls://127.0.0.1', security=tls_only_security(), **kwargs)
assert isinstance(s, Scheduler) for w in [a, b]: assert isinstance(w, Worker) assert s.nthreads == {w.address: w.nthreads for w in [a, b]} async with Client(s.address, asynchronous=True) as c: future = c.submit(lambda x: x + 1, 1) result = await future assert result == 2 @gen_cluster( client=True, scheduler="tls://127.0.0.1", nthreads=[("tls://127.0.0.1", 1), ("tls://127.0.0.1", 2)], security=tls_only_security(), ) async def test_gen_cluster_tls(e, s, a, b): assert isinstance(e, Client) assert isinstance(s, Scheduler) assert s.address.startswith("tls://") for w in [a, b]: assert isinstance(w, Worker) assert w.address.startswith("tls://") assert s.nthreads == {w.address: w.nthreads for w in [a, b]} @gen_test() async def test_gen_test(): await asyncio.sleep(0.01)
f() assert not dask.config.get('get', None) @gen_cluster(client=False) def test_gen_cluster_without_client(s, a, b): assert isinstance(s, Scheduler) for w in [a, b]: assert isinstance(w, Worker) assert s.ncores == {w.address: w.ncores for w in [a, b]} @gen_cluster(client=True, scheduler='tls://127.0.0.1', ncores=[('tls://127.0.0.1', 1), ('tls://127.0.0.1', 2)], security=tls_only_security()) def test_gen_cluster_tls(e, s, a, b): assert isinstance(e, Client) assert isinstance(s, Scheduler) assert s.address.startswith('tls://') for w in [a, b]: assert isinstance(w, Worker) assert w.address.startswith('tls://') assert s.ncores == {w.address: w.ncores for w in [a, b]} @gen_test() def test_gen_test(): yield gen.sleep(0.01)