# Buggy code
def _check_connected(self):
    """Check that the object has been initialized before it is used.

    Raises:
        Exception: An exception is raised if ray.init() has not been called
            yet.
    """
    if self.redis_client is None:
        raise Exception(
            "The ray.global_state API cannot be used before ray.init has been called."
        )


# Traceback (Exception)
+ python /home/jenkins/workspace/Ray-PRB/test/jenkins_tests/multi_node_docker_test.py --docker-image=60125e3f54e6f8f0623b956c8cb04ddc6402819ed22ef5908c5b9ba8db38b46d --num-nodes=5 --num-redis-shards=10 --test-script=/ray/test/jenkins_tests/multi_node_tests/test_0.py
Starting head node with command:['docker', 'run', '-d', '--shm-size=1G', '60125e3f54e6f8f0623b956c8cb04ddc6402819ed22ef5908c5b9ba8db38b46d', 'ray', 'start', '--head', '--block', '--redis-port=6379', '--num-redis-shards=10', '--num-cpus=10', '--num-gpus=0']
Starting worker node with command:['docker', 'run', '-d', '--shm-size=1G', '--shm-size=1G', '60125e3f54e6f8f0623b956c8cb04ddc6402819ed22ef5908c5b9ba8db38b46d', 'ray', 'start', '--block', '--redis-address=172.17.0.12:6379', '--num-cpus=10', '--num-gpus=0']
Starting worker node with command:['docker', 'run', '-d', '--shm-size=1G', '--shm-size=1G', '60125e3f54e6f8f0623b956c8cb04ddc6402819ed22ef5908c5b9ba8db38b46d', 'ray', 'start', '--block', '--redis-address=172.17.0.12:6379', '--num-cpus=10', '--num-gpus=0']
Starting worker node with command:['docker', 'run', '-d', '--shm-size=1G', '--shm-size=1G', '60125e3f54e6f8f0623b956c8cb04ddc6402819ed22ef5908c5b9ba8db38b46d', 'ray', 'start', '--block', '--redis-address=172.17.0.12:6379', '--num-cpus=10', '--num-gpus=0']
Starting worker node with command:['docker', 'run', '-d', '--shm-size=1G', '--shm-size=1G', '60125e3f54e6f8f0623b956c8cb04ddc6402819ed22ef5908c5b9ba8db38b46d', 'ray', 'start', '--block', '--redis-address=172.17.0.12:6379', '--num-cpus=10', '--num-gpus=0']
Starting driver with command /ray/test/jenkins_tests/multi_node_tests/test_0.py.
STDOUT:
Driver 0 started at 1501449715.55.

STDERR:
Traceback (most recent call last):
File "/ray/test/jenkins_tests/multi_node_tests/test_0.py", line 22, in <module>
ray.init(redis_address=redis_address)
File "/opt/conda/lib/python2.7/site-packages/ray-0.1.2-py2.7-linux-x86_64.egg/ray/worker.py", line 1011, in init
num_gpus=num_gpus, num_redis_shards=num_redis_shards)
File "/opt/conda/lib/python2.7/site-packages/ray-0.1.2-py2.7-linux-x86_64.egg/ray/worker.py", line 962, in _init
mode=driver_mode, worker=global_worker, actor_id=NIL_ACTOR_ID)
File "/opt/conda/lib/python2.7/site-packages/ray-0.1.2-py2.7-linux-x86_64.egg/ray/worker.py", line 1338, in connect
global_state._initialize_global_state(redis_ip_address, int(redis_port))
File "/opt/conda/lib/python2.7/site-packages/ray-0.1.2-py2.7-linux-x86_64.egg/ray/experimental/state.py", line 96, in _initialize_global_state
len(ip_address_ports)))
Exception: Expected 10 Redis shard addresses, found 7

stop_node {'container_id': u'fea4409391126e14fca2459ce705051d644ec15163d5143708fc7820a2b7ba2a', 'is_head': True}
stop_node {'container_id': u'd9942971920d496cd39b65b4b9f95525a4479d455036ec2460fdbe8fe4b51c6e', 'is_head': False}
Traceback (most recent call last):
File "/home/jenkins/workspace/Ray-PRB/test/jenkins_tests/multi_node_docker_test.py", line 323, in <module>
d.stop_ray()
File "/home/jenkins/workspace/Ray-PRB/test/jenkins_tests/multi_node_docker_test.py", line 224, in stop_ray
self._stop_node(container_id)
File "/home/jenkins/workspace/Ray-PRB/test/jenkins_tests/multi_node_docker_test.py", line 207, in _stop_node
.format(container_id))
Exception: Failed to stop container 27327225b793cc721628b2fa4cf66b3c0a49eb5f0732273b66fa7ee505689655.
Build step 'Execute shell' marked build as failure
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/1453/
Test FAILed.
Finished: FAILURE

# Fixed code
def _check_connected(self):
    """Check that the object has been initialized before it is used.

    Raises:
        Exception: An exception is raised if ray.init() has not been called
            yet.
    """
    if self.redis_client is None:
        raise Exception(
            "The ray.global_state API cannot be used before ray.init has been called."
        )

    if self.redis_clients is None:
        raise Exception(
            "The ray.global_state API cannot be used before ray.init has been called."
        )