def METHOD_NAME(agent_target, initial_status, clean_environment):
    '''
    description: Check agent enrollment process and new group assignment works as expected in a cluster environment.
                 Check that when an agent pointing to a master/worker node is registered, and when
                 it's assigned to a new group using API the change is sync with the cluster.
    wazuh_min_version: 4.4.0
    parameters:
        - agent_target:
            type: String
            brief: Name of the host where the agent will register.
        - initial_status:
            type: String
            brief: Status of the agent when the assign the new group.
        - clean_enviroment:
            type: Fixture
            brief: Reset the wazuh log files at the start of the test. Remove all registered agents from master.
    assertions:
        - Verify that after registering the agent key file exists in all nodes.
        - Verify that after registering and before starting the agent, it has no groups assigned.
        - Verify that after registering the agent appears as active/disconnected in all nodes.
        - Verify that the response of API query is 200.
        - Verify that after registering and after starting the agent, it has the 'group_test' group assigned.
    expected_output:
        - The agent 'Agent_name' with ID 'Agent_id' belongs to groups: group_test."
    '''
    agent_ip, agent_id, agent_name, manager_ip = register_agent(test_infra_agents[0], agent_target, host_manager)
    # Check that agent has no group assigned
    check_agent_groups(agent_id, AGENT_NO_GROUPS, test_infra_managers, host_manager)
    # Check that agent has client key file
    assert check_keys_file(test_infra_agents[0], host_manager), ERR_MSG_CLIENT_KEYS_IN_MASTER_NOT_FOUND
    # Start the enrollment process by restarting cluster
    restart_cluster(test_infra_agents, host_manager)
    time.sleep(timeout)
    # Check that agent status is active in cluster
    check_agent_status(agent_id, agent_name, agent_ip, AGENT_STATUS_ACTIVE, host_manager, test_infra_managers)
    if (initial_status == AGENT_STATUS_DISCONNECTED):
        host_manager.control_service(host='wazuh-agent1', service='wazuh', state="stopped")
        time.sleep(timeout)
        check_agent_status(agent_id, agent_name, agent_ip, AGENT_STATUS_DISCONNECTED, host_manager, test_infra_managers)
    # Create Group
    create_new_agent_group(test_infra_managers[0], test_group, host_manager)
    token = host_manager.get_api_token(test_infra_managers[0])
    try:
        response = host_manager.make_api_call(test_infra_managers[0], method='PUT',
                                              endpoint=f'/agents/{agent_id}/group/group_test?pretty=true',
                                              token=token)
        assert response['status'] == 200, ERR_MSG_FAILED_TO_SET_AGENT_GROUP
        # Check that agent has group set to group_test on Managers
        check_agent_groups(agent_id, test_group, test_infra_managers, host_manager)
    # Delete group of agent
    finally:
        delete_agent_group(test_infra_managers[0], test_group, host_manager)