def test_create_delete_non_public(self, amq_client): resource_name = "my-rabbit-broker-non-public" replacements = REPLACEMENT_VALUES.copy() replacements["BROKER_NAME"] = resource_name resource_data = load_resource_file( SERVICE_NAME, "broker_rabbitmq_non_public", additional_replacements=replacements, ) logging.error(resource_data) # Create the k8s resource ref = k8s.CustomResourceReference( CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL, resource_name, namespace="default", ) k8s.create_custom_resource(ref, resource_data) cr = k8s.wait_resource_consumed_by_controller(ref) assert cr is not None assert k8s.get_resource_exists(ref) broker_id = cr['status']['brokerID'] # Let's check that the Broker appears in AmazonMQ aws_res = amq_client.describe_broker(BrokerId=broker_id) assert aws_res is not None now = datetime.datetime.now() timeout = now + datetime.timedelta(seconds=CREATE_TIMEOUT_SECONDS) # TODO(jaypipes): Move this into generic AWS-side waiter while aws_res['BrokerState'] != "RUNNING": if datetime.datetime.now() >= timeout: raise Exception("failed to find running Broker before timeout") time.sleep(CREATE_INTERVAL_SLEEP_SECONDS) aws_res = amq_client.describe_broker(BrokerId=broker_id) assert aws_res is not None # Delete the k8s resource on teardown of the module k8s.delete_custom_resource(ref) time.sleep(DELETE_WAIT_AFTER_SECONDS) # Broker should no longer appear in AmazonMQ res_found = False try: amq_client.describe_broker(BrokerId=broker_id) res_found = True except amq_client.exceptions.NotFoundException: pass assert res_found is False
def xgboost_hpojob(): hpo_job, data = _make_hpojob() resource = k8s.create_custom_resource(hpo_job, data) resource = k8s.wait_resource_consumed_by_controller(hpo_job) yield (hpo_job, resource) if k8s.get_resource_exists(hpo_job): k8s.delete_custom_resource(hpo_job)
def test_create_hpo(self, xgboost_hpojob): (reference, resource) = xgboost_hpojob assert k8s.get_resource_exists(reference) hpo_job_name = resource["spec"].get("hyperParameterTuningJobName", None) assert hpo_job_name is not None hpo_sm_desc = get_sagemaker_hpo_job(hpo_job_name) assert k8s.get_resource_arn( resource) == hpo_sm_desc["HyperParameterTuningJobArn"] assert hpo_sm_desc[ "HyperParameterTuningJobStatus"] in HPO_JOB_STATUS_CREATED # Delete the k8s resource. _, deleted = k8s.delete_custom_resource(reference) assert deleted is True hpo_sm_desc = get_sagemaker_hpo_job(hpo_job_name) assert hpo_sm_desc[ "HyperParameterTuningJobStatus"] in HPO_JOB_STATUS_STOPPED
def test_create_endpoint_config(self, single_variant_config): (reference, resource) = single_variant_config assert k8s.get_resource_exists(reference)
def test_create_endpoint(self, single_variant_xgboost_endpoint): assert k8s.get_resource_exists(single_variant_xgboost_endpoint[0])
def test_create_model(self, xgboost_model): (reference, resource) = xgboost_model assert k8s.get_resource_exists(reference)
def test_create_trainingjob(self, xgboost_trainingjob): (reference, resource) = xgboost_trainingjob assert k8s.get_resource_exists(reference)
def test_create_transformjob(self, xgboost_transformjob): (reference, _) = xgboost_transformjob assert k8s.get_resource_exists(reference)
def test_create_processing_job(self, kmeans_processing_job): (reference, resource) = kmeans_processing_job assert k8s.get_resource_exists(reference)
def test_create_delete_2az(self, rds_client): resource_name = "my-subnet-group" resource_desc = "my-subnet-group description" br_resources = get_bootstrap_resources() replacements = REPLACEMENT_VALUES.copy() replacements["DB_SUBNET_GROUP_NAME"] = resource_name replacements["DB_SUBNET_GROUP_DESC"] = resource_desc replacements["SUBNET_AZ1"] = br_resources.SubnetAZ1 replacements["SUBNET_AZ2"] = br_resources.SubnetAZ2 resource_data = load_resource_file( SERVICE_NAME, "db_subnet_group_2az", additional_replacements=replacements, ) logging.debug(resource_data) # Create the k8s resource ref = k8s.CustomResourceReference( CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL, resource_name, namespace="default", ) k8s.create_custom_resource(ref, resource_data) cr = k8s.wait_resource_consumed_by_controller(ref) assert cr is not None assert k8s.get_resource_exists(ref) # Let's check that the DB subnet group appears in RDS aws_res = rds_client.describe_db_subnet_groups( DBSubnetGroupName=resource_name) assert aws_res is not None assert len(aws_res['DBSubnetGroups']) == 1 now = datetime.datetime.now() timeout = now + datetime.timedelta(seconds=CREATE_TIMEOUT_SECONDS) # TODO(jaypipes): Move this into generic AWS-side waiter while aws_res['DBSubnetGroups'][0]['SubnetGroupStatus'] != "Complete": if datetime.datetime.now() >= timeout: raise Exception( "failed to find DB subnet group in Complete status before timeout" ) time.sleep(CREATE_INTERVAL_SLEEP_SECONDS) aws_res = rds_client.describe_db_subnet_groups( DBSubnetGroupName=resource_name) assert aws_res is not None assert len(aws_res['DBSubnetGroups']) == 1 # Delete the k8s resource on teardown of the module k8s.delete_custom_resource(ref) time.sleep(DELETE_WAIT_AFTER_SECONDS) # DB subnet group should no longer appear in RDS try: aws_res = rds_client.describe_db_subnet_groups( DBSubnetGroupName=resource_name) assert False except rds_client.exceptions.DBSubnetGroupNotFoundFault: pass