Ejemplo n.º 1
0
def verify_context_broker_is_installed_successfully(context):
    """
    verify contextBroker is started successfully
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("Verifying if contextBroker is started successfully...")
    cb = CB(protocol=props_cb["CB_PROTOCOL"],
            host=props_cb["CB_HOST"],
            port=props_cb["CB_PORT"])
    c = 0
    while (not cb.is_cb_started()) and (int(props_cb["CB_RETRIES"]) > c):
        time.sleep(int(props_cb["CB_DELAY_TO_RETRY"]))
        c += 1
        __logger__.debug(
            "WARN - Retry in verification if context broker is started. No: (%s)"
            % str(c))
    assert (
        props_cb["CB_RETRIES"]
    ) > c, "ERROR - context Broker is not started after of %s verification retries" % str(
        c)
    if props_cb["CB_VERIFY_VERSION"].lower() == "true":
        context.execute_steps(u'Given send a version request')
        context.execute_steps(u'Given verify if version is the expected')
    else:
        __logger__.info("Current version is not verified...")
    __logger__.info("...Verified that contextBroker is started successfully")
Ejemplo n.º 2
0
def stop_Context_broker(context):
    """
    stop ContextBroker
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    if context.configuration["CB_RUNNING_MODE"].upper() == "RPM":
        __logger__.debug("Stopping contextBroker service...")
        context.my_fab.run("service contextBroker stop")
        __logger__.info("...Stopped contextBroker service")
    else:
        __logger__.debug("Stopping contextBroker per harakiri...")
        cb = CB(protocol=props_cb["CB_PROTOCOL"], host=props_cb["CB_HOST"], port=props_cb["CB_PORT"])
        cb.harakiri()
        __logger__.info("...Stopped contextBroker per harakiri")
Ejemplo n.º 3
0
def stop_Context_broker(context):
    """
    stop ContextBroker
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    if context.configuration["CB_RUNNING_MODE"].upper() == "RPM":
        __logger__.debug("Stopping contextBroker service...")
        context.my_fab.run("service contextBroker stop")
        __logger__.info("...Stopped contextBroker service")
    else:
        __logger__.debug("Stopping contextBroker per harakiri...")
        cb = CB(protocol=props_cb["CB_PROTOCOL"],
                host=props_cb["CB_HOST"],
                port=props_cb["CB_PORT"])
        cb.harakiri()
        __logger__.info("...Stopped contextBroker per harakiri")
Ejemplo n.º 4
0
def service_and_service_path(context):
    """
    configuration of service an service path in headers
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    props = properties_class.read_properties()[CONTEXT_BROKER_ENV]
    context.cb = CB(protocol=props["CB_PROTOCOL"],
                    host=props["CB_HOST"],
                    port=props["CB_PORT"])
    context.cb.definition_headers(context)
Ejemplo n.º 5
0
def verify_context_broker_is_installed_successfully(context):
    """
    verify contextBroker is started successfully
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("Verifying if contextBroker is started successfully...")
    cb = CB(protocol=props_cb["CB_PROTOCOL"], host=props_cb["CB_HOST"], port=props_cb["CB_PORT"])
    c = 0
    while (not cb.is_cb_started()) and (int(props_cb["CB_RETRIES"]) > c):
        time.sleep(int(props_cb["CB_DELAY_TO_RETRY"]))
        c += 1
        __logger__.debug("WARN - Retry in verification if context broker is started. No: (%s)" % str(c))
    assert (props_cb["CB_RETRIES"]) > c, "ERROR - context Broker is not started after of %s verification retries" % str(c)
    if props_cb["CB_VERIFY_VERSION"].lower() == "true":
        context.execute_steps(u'Given send a version request')
        context.execute_steps(u'Given verify if version is the expected')
    else:
        __logger__.info("Current version is not verified...")
    __logger__.info("...Verified that contextBroker is started successfully")
Ejemplo n.º 6
0
def send_a_base_request(context):
    """
    send a API entry point request
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("Sending a API entry point request: /v2 ...")
    props = properties_class.read_properties()[CONTEXT_BROKER_ENV]
    context.cb = CB(protocol=props["CB_PROTOCOL"],
                    host=props["CB_HOST"],
                    port=props["CB_PORT"])
    context.resp = context.cb.get_base_request()
    __logger__.info("...Sent a API entry point request: /v2 correctly")
Ejemplo n.º 7
0
def definition_of_headers(context):
    """
    configuration of  different header (service, service path, Content-Type, Accept, etc)
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.info("Reading CB properties from properties.json file...")
    props = properties_class.read_properties()[CONTEXT_BROKER_ENV]
    context.cb = CB(protocol=props["CB_PROTOCOL"],
                    host=props["CB_HOST"],
                    port=props["CB_PORT"])
    __logger__.info("Define header used in request...")
    context.cb.definition_headers(context)
Ejemplo n.º 8
0
def retrieve_the_log_level(context):
    """
    retrieve the log level in Context Broker
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.info("retrieving the log level in Context Broker")
    context.props_cb_env = properties_class.read_properties(
    )[CONTEXT_BROKER_ENV]
    context.cb = CB(protocol=context.props_cb_env["CB_PROTOCOL"],
                    host=context.props_cb_env["CB_HOST"],
                    port=context.props_cb_env["CB_PORT"])
    context.resp = context.cb.retrieve_the_log_level()
    __logger__.info("..retrieved the log level in Context Broker")
Ejemplo n.º 9
0
def send_a_cache_statistics_request(context):
    """
    send a cache statistics request
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("Sending a statistics request...")
    context.props_cb_env = properties_class.read_properties(
    )[CONTEXT_BROKER_ENV]
    context.cb = CB(protocol=context.props_cb_env["CB_PROTOCOL"],
                    host=context.props_cb_env["CB_HOST"],
                    port=context.props_cb_env["CB_PORT"])
    context.resp = context.cb.get_cache_statistics_request()
    __logger__.info("..Sent a statistics request correctly")
Ejemplo n.º 10
0
def change_the_log_level(context):
    """
    change the log level
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.info("changing the log level in Context Broker")
    query_param = {}
    if context.table is not None:
        for row in context.table:
            query_param[row["parameter"]] = row["value"]
            __logger__.info("query param: %s = %s" %
                            (row["parameter"], row["value"]))

    context.props_cb_env = properties_class.read_properties(
    )[CONTEXT_BROKER_ENV]
    context.cb = CB(protocol=context.props_cb_env["CB_PROTOCOL"],
                    host=context.props_cb_env["CB_HOST"],
                    port=context.props_cb_env["CB_PORT"])
    context.resp = context.cb.change_the_log_level(query_param)
    __logger__.info("..changed the log level in Context Broker")