docstr: Test node scheduling behavior correctly schedules with node affinity.
docstr_tok: ["Test","node","scheduling","behavior","correctly","schedules","with","node","affinity","."]
code: def testForceOnNodeScheduling(self):
      """Test node scheduling behavior correctly schedules with node affinity."""
      num_workers = 4
      num_cpu_per_node = 4
      self.cluster.update_config(
          {
              "provider": {
                  "head_resources": {"CPU": num_cpu_per_node, "GPU": 0}
              },
              "available_node_types": {
                  "ray.worker.cpu": {
                      "resources": {"CPU": num_cpu_per_node},
                      "min_workers": num_workers,
                      "max_workers": num_workers,
                  },
                  "ray.worker.gpu": {
                      "min_workers": 0,
                      "max_workers": 0,  # No GPU nodes
                  },
              },
          }
      )
      self.cluster.start()
      self.cluster.connect(client=True, timeout=120)
  
      total_num_cpu = (1 + num_workers) * num_cpu_per_node
      self.cluster.wait_for_resources({"CPU": total_num_cpu})
  
      @ray.remote
      def get_current_node_id():
          return ray.get_runtime_context().get_node_id()
  
      node_ids = [node["NodeID"] for node in ray.nodes()]
      assert len(node_ids) == 1 + num_workers
  
      remote_tasks = [
          _force_on_node(node_id, get_current_node_id).remote()
          for node_id in node_ids
      ]
      results = ray.get(remote_tasks)
      print(results)
      assert results == node_ids
  
file_path: ray/python/ray/tune/tests/test_multinode_sync.py
imports: import sys
  import time
  import unittest
  import ray
  from ray import train, tune
  from ray.air.util.node import _force_on_node
  from ray.autoscaler._private.fake_multi_node.test_utils import DockerCluster
  from ray.tune.callback import Callback
  from ray.tune.experiment import Trial
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 6 for calling the MultiNodeSyncTest obj's underlying member method code with example usage: obj.testForceOnNodeScheduling() and returns: ray