text: import sys
  
  import ray
  
  
  @ray.remote
  class Increase:
      def method(self, x):
          return x + 2
  
  
  @ray.remote
  def increase(x):
      return x + 1
  
  
  def test_gcs_server_restart(ray_start_regular):
      actor1 = Increase.remote()
      result = ray.get(actor1.method.remote(1))
      assert result == 3
  
      ray.worker._global_node.kill_gcs_server()
      ray.worker._global_node.start_gcs_server()
  
      result = ray.get(actor1.method.remote(7))
      assert result == 9
  
      actor2 = Increase.remote()
      result = ray.get(actor2.method.remote(2))
      assert result == 4
  
      result = ray.get(increase.remote(1))
      assert result == 2
  
  
  def test_gcs_server_restart_during_actor_creation(ray_start_regular):
      ids = []
      for i in range(0, 100):
          actor = Increase.remote()
          ids.append(actor.method.remote(1))
  
      ray.worker._global_node.kill_gcs_server()
      ray.worker._global_node.start_gcs_server()
  
      ready, unready = ray.wait(ids, 100, 240)
      print("Ready objects is {}.".format(ready))
      print("Unready objects is {}.".format(unready))
      assert len(unready) == 0
  
  
  if __name__ == "__main__":
      import pytest
      sys.exit(pytest.main(["-v", __file__]))
  