mirror of
https://github.com/vale981/ray
synced 2025-03-13 22:56:38 -04:00

* draft of local scheduler * API * update APIs * fix * update * Rename halo -> photon. * Add build directory. * Update common submodule. * More renaming. * Fix python ctypes. * Compile in travis. * Process generic messages and not just tasks. * Move free outside of switch. * Formatting and address comments. * Remove event loop from local scheduler state. * Use accept_client from common. * Use bind_ipc_sock from common. * Fix tests. * Update common submodule. * Fix formatting.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from __future__ import print_function
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import unittest
|
|
import random
|
|
import time
|
|
|
|
import photon
|
|
|
|
class TestPhotonClient(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
# Start Redis.
|
|
redis_executable = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../common/thirdparty/redis-3.2.3/src/redis-server")
|
|
self.p1 = subprocess.Popen([redis_executable, "--loglevel", "warning"])
|
|
time.sleep(0.1)
|
|
scheduler_executable = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../build/photon_scheduler")
|
|
scheduler_name = "/tmp/scheduler{}".format(random.randint(0, 10000))
|
|
self.p2 = subprocess.Popen([scheduler_executable, "-s", scheduler_name, "-r", "127.0.0.1:6379"])
|
|
time.sleep(0.1)
|
|
# Connect to the scheduler.
|
|
self.photon_client = photon.PhotonClient(scheduler_name)
|
|
|
|
def tearDown(self):
|
|
# Kill the Redis server.
|
|
self.p1.kill()
|
|
# Kill the local scheduler.
|
|
self.p2.kill()
|
|
|
|
def test_create(self):
|
|
l = [photon.make_id(20 * "a"), photon.make_id(20 * "b"), photon.make_id(20 * "c")]
|
|
self.photon_client.submit(20 * "a", l)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|