def test_services_parse_example():
    """
       Just simple check if  test .yaml file parsing properly
      :return:
      """
    expected_result_len = 4
    services: Services = parse_yaml_services(yaml_path, 'example.yaml')
    assert expected_result_len == len(services.services)
def test_start_estimated_order_example():
    """
        Just simple check if expected == actual for test .yaml file
    :return:
    """
    expected_result = [['mysql', 'zookeeper'], ['kibana'], ['fullhouse']]
    services: Services = parse_yaml_services(yaml_path, 'example.yaml')
    result = start_estimated_order(services)
    assert len(result) == len(expected_result)
    for i in range(len(result)):
        assert set(result[i]) == set(expected_result[i])
def test_services_parse_with_circular_dep():
    """
       Just simple check if  test .yaml file parsing properly - for case with  circular dependencies
      :return:
      """
    try:
        services: Services = parse_yaml_services(yaml_path,
                                                 'services_circular_dep.yaml')
    except Exception as error:
        assert True
    else:
        assert False
def test_stop_estimated_order_services():
    """
      Just simple check if expected == actual for test .yaml file
      :return:
    """
    expected_result = [['kibana', 'dashboard'], ['fullhouse'],
                       ['mysql', 'hbase-master', 'elasticsearch'],
                       ['hadoop-namenode'], ['zookeeper']]

    services: Services = parse_yaml_services(yaml_path, 'services.yaml')
    result = stop_estimated_order(services)
    assert len(result) == len(expected_result)
    for i in range(len(result)):
        assert set(result[i]) == set(expected_result[i])
Exemple #5
0
    # Parse command line args
    parser = argparse.ArgumentParser(description=f"{__doc__} \n ")

    parser.add_argument(
        'operation',
        type=Operation,
        choices=list(Operation),
        help=f"Supported operation values {Operation.ARG_COMMAND_START} or "
        f"{Operation.ARG_COMMAND_STOP}")
    # default  default=Operation.ARG_COMMAND_START,
    args = parser.parse_args()

    # parse / validate given yaml
    try:
        yaml_path = os.path.abspath(YAML_PATH)
        services: Services = parse_yaml_services(yaml_path, YAML_NAME)

        if not services:
            app_root_logger.error(
                "There is no any services or yaml has not been parsed properly "
            )
    except Exception as error:
        app_root_logger.error(
            f"The current services cant be processed because {error}")

    # if validation has been successful
    try:
        if services:
            app_root_logger.info(
                "YAML file has been parsed and services hierarchy has been created"
            )