def METHOD_NAME(metadata, target_node):
    agent_ids = []
    for agent in test_infra_agents:
        agent_ip, agent_id, agent_name, manager_ip = register_agent(agent, test_infra_hosts[0], host_manager)
        agent_ids.append(agent_id)
    restart_cluster(test_infra_agents, host_manager)
    time.sleep(T_10)
    for group in groups:
        create_new_agent_group(target_node, group, host_manager)
    if metadata['agent_in_group'] == 'agent1':
        for group in groups:
            assign_agent_to_new_group(target_node, group, agent_ids[0], host_manager)
    elif metadata['agent_in_group'] == 'agent2':
        for group in groups:
            assign_agent_to_new_group(target_node, group, agent_ids[1], host_manager)
    else:
        for group in groups:
            for agent_id in agent_ids:
                assign_agent_to_new_group(target_node, group, agent_id, host_manager)
    yield
    for group in groups:
        delete_agent_group(test_infra_hosts[0], group, host_manager, 'api')