code: def test_profiler_endpoints(ray_start_with_dashboard, native):
      # Sanity check py-spy are installed.
      subprocess.check_call(["py-spy", "--version"])
  
      assert (
          wait_until_server_available(
              ray_start_with_dashboard["webui_url"]
          )
          is True
      )
      address_info = ray_start_with_dashboard
      webui_url = address_info["webui_url"]
      webui_url = format_web_url(webui_url)
  
      @ray.remote
      class Actor:
          def getpid(self):
              return os.getpid()
  
          def do_stuff_infinite(self):
              while True:
                  pass
  
      a = Actor.remote()
      pid = ray.get(a.getpid.remote())
      a.do_stuff_infinite.remote()
  
      def get_actor_stack():
          url = (
              f"{webui_url}/worker/traceback?pid={pid}&native={native}"
          )
          print("GET URL", url)
          response = requests.get(url)
          print("STATUS CODE", response.status_code)
          print("HEADERS", response.headers)
          content = response.content.decode("utf-8")
          print("CONTENT", content)
          response.raise_for_status()
          assert (
              "text/plain" in response.headers["Content-Type"]
          ), response.headers
          # Sanity check we got the stack trace text.
          assert "do_stuff_infinite" in content, content
          if native == "1":
              assert "ray::core::CoreWorker" in content, content
          else:
              assert "ray::core::CoreWorker" not in content, content
  
      assert wait_until_succeeded_without_exception(
          get_actor_stack,
          (requests.RequestException, AssertionError),
          timeout_ms=20000,
          retry_interval_ms=1000,
      )
  
      def get_actor_flamegraph():
          response = requests.get(
              f"{webui_url}/worker/cpu_profile?pid={pid}&native={native}"
          )
          response.raise_for_status()
          assert (
              response.headers["Content-Type"] == "image/svg+xml"
          ), response.headers
          content = response.content.decode("utf-8")
          print(content)
          # Sanity check we got the flame graph SVG.
          assert "<!DOCTYPE svg" in content, content
          assert "do_stuff_infinite" in content, content
          if native == "1":
              assert "ray::core" in content, content
          else:
              assert "ray::core" not in content, content
  
      assert wait_until_succeeded_without_exception(
          get_actor_flamegraph,
          (requests.RequestException, AssertionError),
          timeout_ms=20000,
          retry_interval_ms=1000,
      )
  
file_path: ray/python/ray/tests/test_dashboard_profiler.py
imports: import pytest
  import subprocess
  import os
  import requests
  import sys
  import ray
  from ray._private.test_utils import format_web_url, wait_until_server_available, wait_until_succeeded_without_exception
label_desc: Use image node_id 1 for calling a global function with example usage: test_profiler_endpoints(ray_start_with_dashboard, native) and returns: os