def METHOD_NAME(test, kwargs):
    timeout = time.time() + 900
    while True:
        cluster = test.cmd('az sf managed-cluster show -g {rg} -c {cluster_name}').get_output_in_json()
        if cluster['clusterState']:
            if cluster['clusterState'] == 'Ready':
                return
        if time.time() > timeout:
            state = "unknown"
            if cluster['clusterState']:
                state = cluster['clusterState']
            raise CLIError("Managed cluster deployment timed out. cluster state is not 'Ready'. State: {}".format(state))
        if test.in_recording or test.is_live:
            time.sleep(60)