Add cloudtaf framework
[ta/cloudtaf.git] / testcases / smoke-tests / smoke-tests.robot
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 *** Settings ***
16 Library             Collections
17 Library             cluster.cluster.Cluster    WITH NAME    Cluster
18 Library             crl.remotesession.remotesession.RemoteSession
19 ...                 WITH NAME    RemoteSession
20 Resource            ssh.robot
21 Test Setup          ssh.Setup Connections
22
23 *** Keywords ***
24
25 Validate Cluster
26
27     :FOR    ${node}     IN      @{ALL_MASTERS_IN_SYSTEM}
28     \    ${output}=     Ssh.Execute Command     hostname      ${node}
29     \    Should Be Equal    ${node}    ${output}
30
31     :FOR    ${node}     IN      @{ALL_PURE_WORKERS_IN_SYSTEM}
32     \    ${output}=     Ssh.Execute Command     hostname      ${node}
33     \    Should Be Equal    ${node}    ${output}
34
35     :FOR    ${node}     IN      @{ALL_PURE_STORAGES_IN_SYSTEM}
36     \    ${output}=     Ssh.Execute Command     hostname      ${node}
37     \    Should Be Equal    ${node}    ${output}
38
39     ${hosts}=   Cluster.Get Hosts
40     :FOR  ${node}      IN       @{hosts}
41     \    ${output}=     Ssh.Execute Command     hostname      ${node.name}
42     \    Should Be Equal    ${node.name}    ${output}
43
44     ${masters_len}=  Get Length    ${ALL_MASTERS_IN_SYSTEM}
45
46     Should Be True    ${masters_len} == 3
47     ...   Number of masters should be 3 not ${masters_len}
48     Verify Database
49
50 Reboot Management VIP Node
51     RemoteSession.Execute Background Command In Target    sleep 1; reboot
52     ...    target=sudo-default
53     Sleep    1
54     RemoteSession.Close
55     ssh.Setup Connections
56
57 Stop Database
58     [Arguments]    ${node}
59     ${result}=    RemoteSession.Execute Command In Target
60     ...    systemctl stop mariadb.service    ${node}
61     Should Be Equal   ${result.status}    0    ${result.stderr}
62
63 Start Database
64     [Arguments]    ${node}
65     ${result}=    RemoteSession.Execute Command In Target
66     ...    systemctl start mariadb.service    ${node}
67     Should Be Equal   ${result.status}    0    ${result.stderr}
68
69 Verify Database
70     [Arguments]    ${node}=sudo-default    ${expected_cluster_size}=3
71     ${out}=    ssh.Execute Command    mysql <<< "show status like 'wsrep_cluster_size';"
72     ...    ${node}
73     Should match     ${out}     *wsrep_cluster_size*${expected_cluster_size}*
74
75 *** Test Cases ***
76
77 Verify Cluster Config Management
78     Validate Cluster
79
80 Verify Cluster Config Management After Reboot Management VIP Node
81     Reboot Management VIP Node
82     Wait Until Keyword Succeeds    600s    1s     Validate Cluster
83
84 Verify Database Stop And Start
85     ${first_master}=    Collections.Get From List    ${ALL_MASTERS_IN_SYSTEM}    0
86     Stop Database    sudo-${first_master}
87     Wait Until Keyword Succeeds    6x    18s    Verify Database    sudo-${first_master}
88     ...    expected_cluster_size=2
89     Start Database    sudo-${first_master}
90     Wait Until Keyword Succeeds    6x    18s    Verify Database    sudo-${first_master}
91
92 Verify Create All And No Roles
93     [Documentation]    Verify no_roles and all_roles user creation
94     ${all_roles}=    Cluster.Create User With Roles    all_roles
95     Log    ${all_roles}
96     ${no_roles}=    Cluster.Create User With Roles    no_roles
97     Log    ${no_roles}
98
99 Verify SudoShells
100     [Documentation]    Test SudoShells
101     ${hosts}=   Cluster.Get Hosts
102     :FOR  ${node}      IN       @{hosts}
103     \     ${result}=     RemoteSession.Execute Command In Target   whoami
104     \     ...    target=sudo-${node.name}
105     \     Should Be Equal    ${result.stdout}    root
106
107     ${result}=    RemoteSession.Execute Command In Target   whoami
108     ...    target=sudo-default
109     Should Be Equal     ${result.stdout}     root
110
111 Verify Remotescript Default
112     [Documentation]    test target remotescript-default
113     ${result}=    RemoteSession.Execute Command In Target   echo -n out
114     ...    target=remotescript-default
115     Should Be Equal    ${result.stdout}    out