code: def test_missing_keyname(iam_client_stub, ec2_client_stub):
      config = helpers.load_aws_example_config_file("example-full.yaml")
      config["auth"]["ssh_private_key"] = "/path/to/private/key"
      head_node_config = config["available_node_types"][
          "ray.head.default"
      ]["node_config"]
      worker_node_config = config["available_node_types"][
          "ray.worker.default"
      ]["node_config"]
  
      # Setup stubs to mock out boto3. Should fail on assertion after
      # checking KeyName/UserData.
      stubs.configure_iam_role_default(iam_client_stub)
  
      missing_user_data_config = copy.deepcopy(config)
      with pytest.raises(AssertionError):
          # Config specified ssh_private_key, but missing KeyName/UserData in
          # node configs
          bootstrap_aws(missing_user_data_config)
  
      # Pass in SG for stub to work
      head_node_config["SecurityGroupIds"] = ["sg-1234abcd"]
      worker_node_config["SecurityGroupIds"] = ["sg-1234abcd"]
  
      # Set UserData for both node configs
      head_node_config["UserData"] = {"someKey": "someValue"}
      worker_node_config["UserData"] = {"someKey": "someValue"}
  
      # Stubs to mock out boto3. Should no longer fail on assertion
      # and go on to describe security groups + configure subnet
      stubs.configure_iam_role_default(iam_client_stub)
      stubs.describe_a_security_group(ec2_client_stub, DEFAULT_SG)
      stubs.configure_subnet_default(ec2_client_stub)
  
      # Should work without error now that UserData is set
      bootstrap_aws(config)
  
      iam_client_stub.assert_no_pending_responses()
      ec2_client_stub.assert_no_pending_responses()
  
imports: import copy
  from unittest.mock import Mock, patch
  import pytest
  from click.exceptions import ClickException
  import ray.tests.aws.utils.helpers
  import ray.tests.aws.utils.stubs
  from ray.autoscaler._private.aws.config import DEFAULT_AMI, _configure_subnet, _get_subnets_or_die, bootstrap_aws, log_to_cli
  from ray.autoscaler._private.aws.node_provider import AWSNodeProvider
  from ray.autoscaler._private.providers import _get_node_provider
  from ray.tests.aws.utils.constants import AUX_SG, AUX_SUBNET, CUSTOM_IN_BOUND_RULES, DEFAULT_CLUSTER_NAME, DEFAULT_INSTANCE_PROFILE, DEFAULT_KEY_PAIR, DEFAULT_LT, DEFAULT_SG, DEFAULT_SG_AUX_SUBNET, DEFAULT_SG_DUAL_GROUP_RULES, DEFAULT_SG_WITH_NAME, DEFAULT_SG_WITH_NAME_AND_RULES, DEFAULT_SG_WITH_RULES, DEFAULT_SG_WITH_RULES_AUX_SUBNET, DEFAULT_SUBNET
label_desc: Use image node_id 8 for calling a global function with example usage: test_missing_keyname(iam_client_stub, ec2_client_stub) without return types