Step 2: Move test folder to root
[integration/test.git] / csit / libraries / KarafKeywords.robot
1 *** Settings ***
2 Library           SSHLibrary
3 Library           OperatingSystem
4 Variables         ../variables/Variables.py
5
6 *** Variables ***
7 ${WORKSPACE}      /tmp
8 ${BUNDLEFOLDER}    distribution-karaf-0.3.0-SNAPSHOT
9
10 *** Keywords ***
11 Check Karaf Log File Does Not Have Messages
12     [Arguments]    ${ip}    ${message}    ${user}=${CONTROLLER_USER}    ${password}=${CONTROLLER_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
13     [Documentation]    Fails if the provided ${message} is found in the karaf.log file.  Uses grep to search.  The
14     ...    karaf.log file can be overridden with ${log_file} to be any file on the given system @ ${ip}
15     ${output}=    Run Command On Controller    ${ip}    grep ${message} ${log_file}    user=${user}    password=${password}    prompt=${prompt}
16     Should Not Contain    ${output}    ${message}
17
18 Verify Feature Is Installed
19     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
20     [Documentation]    Will Succeed if the given ${feature_name} is found in the output of "feature:list -i"
21     ${output}=    Issue Command On Karaf Console    feature:list -i | grep ${feature_name}    ${controller}    ${karaf_port}
22     Should Contain    ${output}    ${feature_name}
23     [Return]    ${output}
24
25 Verify Feature Is Not Installed
26     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
27     [Documentation]    Will Succeed if the given ${feature_name} is NOT found in the output of "feature:list -i"
28     ${output}=    Issue Command On Karaf Console    feature:list -i | grep ${feature_name}    ${controller}    ${karaf_port}
29     Should Not Contain    ${output}    ${feature_name}
30     [Return]    ${output}
31
32 Issue Command On Karaf Console
33     [Arguments]    ${cmd}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=5
34     [Documentation]    Will execute the given ${cmd} by ssh'ing to the karaf console running on ${CONTROLLER}
35     Open Connection    ${controller}    port=${karaf_port}    prompt=${KARAF_PROMPT}    timeout=${timeout}
36     Login    ${KARAF_USER}    ${KARAF_PASSWORD}
37     Write    ${cmd}
38     ${output}    Read Until    ${KARAF_PROMPT}
39     Close Connection
40     Log    ${output}
41     [Return]    ${output}
42
43 Verify Bundle Is Installed
44     [Arguments]    ${bundle_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
45     [Documentation]    Will succeed if the given ${bundle name} is present in the output of "bundle:list -s "
46     ${output}=    Issue Command On Karaf Console    bundle:list -s | grep ${bundle_name}    ${controller}    ${karaf_port}
47     Should Contain    ${output}    ${bundle_name}
48     [Return]    ${output}
49
50 Verify Bundle Is Not Installed
51     [Arguments]    ${bundle_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
52     [Documentation]    Will succeed if the given ${bundle_name} is NOT found in the output of "bundle:list -s"
53     ${output}=    Issue Command On Karaf Console    bundle:list -i | grep ${bundle_name}    ${controller}    ${karaf_port}
54     Should Not Contain    ${output}    ${bundle_name}
55     [Return]    ${output}
56
57 Check Karaf Log Has Messages
58     [Arguments]    ${filter_string}    @{message_list}
59     [Documentation]    Will succeed if the @{messages} are found in \ the output of "log:display"
60     ${output}=    Issue Command On Karaf Console    log:display | grep ${filter_string}
61     : FOR    ${message}    IN    @{message_list}
62     \    Should Contain    ${output}    ${message}
63     [Return]    ${output}
64
65 Install a Feature
66     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=15
67     [Documentation]    Will Install the given ${feature_name}
68     Log    ${timeout}
69     ${output}=    Issue Command On Karaf Console    feature:install ${feature_name}    ${controller}    ${karaf_port}    ${timeout}
70     Log    ${output}
71     [Return]    ${output}
72
73 Uninstall a Feature
74     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=15
75     [Documentation]    Will UnInstall the given ${feature_name}
76     ${output}=    Issue Command On Karaf Console    feature:uninstall ${feature_name}    ${controller}    ${karaf_port}    ${timeout}
77     Log    ${output}
78     [Return]    ${output}