def test_kill_kernel_success(self):  # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        assert_in(kernel_id, self.a._kernels)

        retval = self.a.kill_kernel(kernel_id)
        assert_is(retval, True)
        assert_not_in(kernel_id, self.a._kernels)
Esempio n. 2
0
    def test_kill_kernel_success(self):  # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        assert_in(kernel_id, self.a._kernels)

        retval = self.a.kill_kernel(kernel_id)
        assert_is(retval, True)
        assert_not_in(kernel_id, self.a._kernels)
Esempio n. 3
0
    def test_create_hb_stream(self): # depends on create_connected_stream
        kernel_id = "kern1"
        comp_id = "testcomp1"
        self.a._kernels[kernel_id] = {"comp_id": comp_id, "connection": {"ip": "127.0.0.1", "hb_port": 50101}}
        self.a._comps[comp_id] = {"host": "localhost"}

        ret = self.a.create_hb_stream(kernel_id)
        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.REQ)
    def test_create_hb_stream(self):  # depends on create_connected_stream
        kernel_id = "kern1"
        comp_id = "testcomp1"
        self.a._kernels[kernel_id] = {"comp_id": comp_id, "connection": {"ip": "127.0.0.1", "hb_port": 50101}}
        self.a._comps[comp_id] = {"host": "localhost"}

        ret = self.a.create_hb_stream(kernel_id)
        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.REQ)
Esempio n. 5
0
    def test_new_session_success(self): # depends on add_computer
        x = self.a.add_computer(self.default_comp_config)

        with capture_output() as (out, err):
            kern1 = self.a.new_session()
        out = out[0]

        assert_in(kern1, self.a._kernels)
        assert_in("comp_id", self.a._kernels[kern1])
        assert_uuid(self.a._kernels[kern1]["comp_id"])
        assert_in("connection", self.a._kernels[kern1])
        assert_in("executing", self.a._kernels[kern1])
        assert_is(self.a._kernels[kern1]["executing"], False)
        assert_in("timeout", self.a._kernels[kern1])
        assert_greater(time.time(), self.a._kernels[kern1]["timeout"])
        x = self.a._kernels[kern1]["comp_id"]
        assert_in(kern1, self.a._comps[x]["kernels"])
        assert_is_instance(self.a._sessions[kern1], Session)
    def test_new_session_success(self):  # depends on add_computer
        x = self.a.add_computer(self.default_comp_config)

        with capture_output() as (out, err):
            kern1 = self.a.new_session()
        out = out[0]

        assert_in(kern1, self.a._kernels)
        assert_in("comp_id", self.a._kernels[kern1])
        assert_uuid(self.a._kernels[kern1]["comp_id"])
        assert_in("connection", self.a._kernels[kern1])
        assert_in("executing", self.a._kernels[kern1])
        assert_is(self.a._kernels[kern1]["executing"], False)
        assert_in("timeout", self.a._kernels[kern1])
        assert_greater(time.time(), self.a._kernels[kern1]["timeout"])
        x = self.a._kernels[kern1]["comp_id"]
        assert_in(kern1, self.a._comps[x]["kernels"])
        assert_is_instance(self.a._sessions[kern1], Session)
Esempio n. 7
0
    def test_start_kernel_success(self):
        y = self.a.start_kernel()

        assert_is_instance(y, dict)
        assert_len(y, 2)
        assert_in("kernel_id", y)
        assert_uuid(y["kernel_id"])
        assert_in("connection", y)
        assert_len(y["connection"], 6)
        for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
            assert_in(s, y["connection"])
            assert_len(str(y["connection"][s]), 5)
        assert_in("ip", y["connection"])
        assert_equal(y["connection"]["ip"], "127.0.0.1")
        assert_in("key", y["connection"])
        assert_uuid(y["connection"]["key"])

        assert_in(y["kernel_id"], self.a.kernels.keys())
        assert_is_instance(self.a.kernels[y["kernel_id"]][0], Process)
        assert_is(self.a.kernels[y["kernel_id"]][0].is_alive(), True)
    def test_start_kernel_success(self):
        y = self.a.start_kernel()

        assert_is_instance(y, dict)
        assert_len(y, 2)
        assert_in("kernel_id", y)
        assert_uuid(y["kernel_id"])
        assert_in("connection", y)
        assert_len(y["connection"], 6)
        for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
            assert_in(s, y["connection"])
            assert_len(str(y["connection"][s]), 5)
        assert_in("ip", y["connection"])
        assert_equal(y["connection"]["ip"], "127.0.0.1")
        assert_in("key", y["connection"])
        assert_uuid(y["connection"]["key"])

        assert_in(y["kernel_id"], self.a.kernels.keys())
        assert_is_instance(self.a.kernels[y["kernel_id"]][0], Process)
        assert_is(self.a.kernels[y["kernel_id"]][0].is_alive(), True)
Esempio n. 9
0
    def test_create_connected_stream(self):
        host="localhost"
        port = 51337
        socket_type = zmq.SUB

        with capture_output() as (out, err):
            ret = self.a._create_connected_stream(host, port, socket_type)
        out = out[0]

        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.SUB)
        #assert_equal(out, "Connecting to: tcp://%s:%i\n" % (host, port))

        host="localhost"
        port = 51337
        socket_type = zmq.REQ

        ret = self.a._create_connected_stream(host, port, socket_type)

        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.REQ)

        host="localhost"
        port = 51337
        socket_type = zmq.DEALER

        ret = self.a._create_connected_stream(host, port, socket_type)

        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.DEALER)
    def test_create_connected_stream(self):
        host = "localhost"
        port = 51337
        socket_type = zmq.SUB

        with capture_output() as (out, err):
            ret = self.a._create_connected_stream(host, port, socket_type)
        out = out[0]

        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.SUB)
        # assert_equal(out, "Connecting to: tcp://%s:%i\n" % (host, port))

        host = "localhost"
        port = 51337
        socket_type = zmq.REQ

        ret = self.a._create_connected_stream(host, port, socket_type)

        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.REQ)

        host = "localhost"
        port = 51337
        socket_type = zmq.DEALER

        ret = self.a._create_connected_stream(host, port, socket_type)

        assert_is(ret.closed(), False)
        assert_equal(ret.socket.socket_type, zmq.DEALER)
Esempio n. 11
0
    def test_interrupt_kernel_success(self):  # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        proc = self.a.kernels[kernel_id][0]

        assert_is(proc.is_alive(), True)
        retval = self.a.interrupt_kernel(kernel_id)
        assert_is(retval, True)
        assert_is(proc.is_alive(), True)
    def test_interrupt_kernel_success(self): # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        proc = self.a.kernels[kernel_id][0]

        assert_is(proc.is_alive(), True)
        retval = self.a.interrupt_kernel(kernel_id)
        assert_is(retval, True)
        assert_is(proc.is_alive(), True)
Esempio n. 13
0
    def test_kill_kernel_success(self):  # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        proc = self.a.kernels[kernel_id][0]

        assert_is(proc.is_alive(), True)
        retval = self.a.kill_kernel(kernel_id)
        assert_is(retval, True)
        assert_not_in(kernel_id, self.a.kernels.keys())
        assert_is(proc.is_alive(), False)
    def test_kill_kernel_success(self): # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        proc = self.a.kernels[kernel_id][0]

        assert_is(proc.is_alive(), True)
        retval = self.a.kill_kernel(kernel_id)
        assert_is(retval, True)
        assert_not_in(kernel_id, self.a.kernels.keys())
        assert_is(proc.is_alive(), False)
    def test_restart_kernel_success(self): # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        proc = self.a.kernels[kernel_id][0]
        preports = self.a.kernels[kernel_id][1]

        assert_is(proc.is_alive(), True)
        retval = self.a.restart_kernel(kernel_id)
        assert_is(proc.is_alive(), False) # old kernel process is killed

        proc = self.a.kernels[kernel_id][0]
        assert_is(proc.is_alive(), True) # and a new kernel process with the same kernel_id exists
        postports = self.a.kernels[kernel_id][1]

        for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
            assert_equal(preports[s], postports[s]) # and that it has the same ports as before
Esempio n. 16
0
    def test_restart_kernel_success(self):  # depends on start_kernel
        y = self.a.start_kernel()
        kernel_id = y["kernel_id"]
        proc = self.a.kernels[kernel_id][0]
        preports = self.a.kernels[kernel_id][1]

        assert_is(proc.is_alive(), True)
        retval = self.a.restart_kernel(kernel_id)
        assert_is(proc.is_alive(), False)  # old kernel process is killed

        proc = self.a.kernels[kernel_id][0]
        assert_is(
            proc.is_alive(),
            True)  # and a new kernel process with the same kernel_id exists
        postports = self.a.kernels[kernel_id][1]

        for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
            assert_equal(
                preports[s],
                postports[s])  # and that it has the same ports as before
 def test_interrupt_kernel_invalid_kernel_id(self):
     kernel_id = 44
     retval = self.a.interrupt_kernel(kernel_id)
     assert_is(retval, False)
def test_init():
    tmkm = trusted_kernel_manager.TrustedMultiKernelManager()
    assert_len(tmkm._kernels.keys(), 0)
    assert_len(tmkm._comps.keys(), 0)
    assert_len(tmkm._clients.keys(), 0)
    assert_is(hasattr(tmkm, "context"), True)
Esempio n. 19
0
def test_init():
    tmkm = trusted_kernel_manager.TrustedMultiKernelManager()
    assert_len(tmkm._kernels.keys(), 0)
    assert_len(tmkm._comps.keys(), 0)
    assert_len(tmkm._clients.keys(), 0)
    assert_is(hasattr(tmkm, "context"), True)
Esempio n. 20
0
def test_init():
    umkm = untrusted_kernel_manager.UntrustedMultiKernelManager(
        "testing.log", '127.0.0.1', update_function=test_init)
    assert_len(umkm._kernels, 0)
    assert_equal(umkm.filename, "testing.log")
    assert_is(hasattr(umkm, "fkm"), True)
Esempio n. 21
0
 def test_kill_kernel_invalid_kernel_id(self):
     retval = self.a.kill_kernel(44)
     assert_is(retval, False)
def test_init():
    umkm = untrusted_kernel_manager.UntrustedMultiKernelManager("testing.log", "127.0.0.1", update_function=test_init)
    assert_len(umkm._kernels, 0)
    assert_equal(umkm.filename, "testing.log")
    assert_is(hasattr(umkm, "fkm"), True)
Esempio n. 23
0
 def test_interrupt_kernel_invalid_kernel_id(self):
     kernel_id = 44
     retval = self.a.interrupt_kernel(kernel_id)
     assert_is(retval, False)
 def test_kill_kernel_invalid_kernel_id(self):
     retval = self.a.kill_kernel(44)
     assert_is(retval, False)