Add an all-features template to the cluster deployer.
[integration/test.git] / test / 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}    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
13     ${output}=    Run Command On Remote System    ${ip}    grep ${message} ${log_file}
14     Should Not Contain    ${output}    ${message}
15
16 Verify Feature Is Installed
17     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
18     [Documentation]    Will Succeed if the given ${feature_name} is found in the output of "feature:list -i"
19     ${output}=    Issue Command On Karaf Console    feature:list -i | grep ${feature_name}    ${controller}    ${karaf_port}
20     Should Contain    ${output}    ${feature_name}
21     [Return]    ${output}
22
23 Verify Feature Is Not Installed
24     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
25     [Documentation]    Will Succeed if the given ${feature_name} is NOT found in the output of "feature:list -i"
26     ${output}=    Issue Command On Karaf Console    feature:list -i | grep ${feature_name}    ${controller}    ${karaf_port}
27     Should Not Contain    ${output}    ${feature_name}
28     [Return]    ${output}
29
30 Issue Command On Karaf Console
31     [Arguments]    ${cmd}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=5
32     [Documentation]    Will execute the given ${cmd} by ssh'ing to the karaf console running on ${CONTROLLER}
33     Open Connection    ${controller}    port=${karaf_port}    prompt=${KARAF_PROMPT}    timeout=${timeout}
34     Login    ${KARAF_USER}    ${KARAF_PASSWORD}
35     Write    ${cmd}
36     ${output}    Read Until    ${KARAF_PROMPT}
37     Close Connection
38     Log    ${output}
39     [Return]    ${output}
40
41 Verify Bundle Is Installed
42     [Arguments]    ${bundle_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
43     [Documentation]    Will succeed if the given ${bundle name} is present in the output of "bundle:list -s "
44     ${output}=    Issue Command On Karaf Console    bundle:list -s | grep ${bundle_name}    ${controller}    ${karaf_port}
45     Should Contain    ${output}    ${bundle_name}
46     [Return]    ${output}
47
48 Verify Bundle Is Not Installed
49     [Arguments]    ${bundle_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}
50     [Documentation]    Will succeed if the given ${bundle_name} is NOT found in the output of "bundle:list -s"
51     ${output}=    Issue Command On Karaf Console    bundle:list -i | grep ${bundle_name}    ${controller}    ${karaf_port}
52     Should Not Contain    ${output}    ${bundle_name}
53     [Return]    ${output}
54
55 Check Karaf Log Has Messages
56     [Arguments]    ${filter_string}    @{message_list}
57     [Documentation]    Will succeed if the @{messages} are found in \ the output of "log:display"
58     ${output}=    Issue Command On Karaf Console    log:display | grep ${filter_string}
59     : FOR    ${message}    IN    @{message_list}
60     \    Should Contain    ${output}    ${message}
61     [Return]    ${output}
62
63 Install a Feature
64     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=15
65     [Documentation]    Will Install the given ${feature_name}
66     Log    ${timeout}
67     ${output}=    Issue Command On Karaf Console    feature:install ${feature_name}    ${controller}    ${karaf_port}    ${timeout}
68     Log    ${output}
69     [Return]    ${output}
70
71 Uninstall a Feature
72     [Arguments]    ${feature_name}    ${controller}=${CONTROLLER}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=15
73     [Documentation]    Will UnInstall the given ${feature_name}
74     ${output}=    Issue Command On Karaf Console    feature:uninstall ${feature_name}    ${controller}    ${karaf_port}    ${timeout}
75     Log    ${output}
76     [Return]    ${output}