Remove testplans and suites for openstack
[integration/test.git] / tools / deployment / openstack_ha / deploy / 07_csit_setup.robot
1 *** Settings ***
2 Documentation       Suite that configures the nodes to execute CSIT
3
4 Library             SSHLibrary
5 Library             OperatingSystem
6 Library             RequestsLibrary
7 Resource            ../../../../csit/libraries/OpenStackInstallUtils.robot
8 Resource            ../../../../csit/libraries/OpenStackOperations.robot
9 Resource            ../../../../csit/libraries/SystemUtils.robot
10 Resource            ../../../../csit/libraries/Utils.robot
11
12 Suite Setup         OpenStackInstallUtils.Get All Ssh Connections
13 Suite Teardown      Close All Connections
14
15
16 *** Test Cases ***
17 Create Jenkins User
18     #Generate Ssh Keys For VMs
19     #Local Install Rpm Package    sshpass
20     #Create Keypair    vm_keys    /tmp/vm_key    rc_file=/tmp/stackrc
21     #Run Keyword If    2 > ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_1_IP}    jenkins
22     #Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_1_IP}    jenkins
23     #Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_2_IP}    jenkins
24     #Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_3_IP}    jenkins
25     #Run Keyword If    3 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_4_IP}    jenkins
26     #Run Keyword If    4 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_5_IP}    jenkins
27     IF    0 < ${NUM_COMPUTE_NODES}
28         Create Csit User    ${OS_COMPUTE_1_IP}    jenkins
29     END
30     IF    1 < ${NUM_COMPUTE_NODES}
31         Create Csit User    ${OS_COMPUTE_2_IP}    jenkins
32     END
33
34 Create Required Image and Flavor
35     Run Command In Local Node
36     ...    export https_proxy=${PROXY_TEST};wget https://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img -O /tmp/cirros35.img;unset https_proxy
37     Create Image    cirros    /tmp/cirros35.img    rc_file=/tmp/stackrc
38     Create Image    cirros-0.3.5-x86_64-disk    /tmp/cirros35.img    rc_file=/tmp/stackrc
39     Create Flavor    cirros    128    0    rc_file=/tmp/stackrc
40     Create Flavor    m1.nano    128    0    rc_file=/tmp/stackrc
41     Run Command In Local Node
42     ...    export https_proxy=${PROXY_TEST};export http_proxy=${PROXY_TEST};wget "https://download.fedoraproject.org/pub/fedora/linux/releases/27/CloudImages/x86_64/images/Fedora-Cloud-Base-27-1.6.x86_64.qcow2" -O /tmp/fedora.qcow2;unset https_proxy;unset http_proxy
43     Create Image    fedora    /tmp/fedora.qcow2    rc_file=/tmp/stackrc
44     Create Flavor    fedora    2048    6    rc_file=/tmp/stackrc
45     Install Rpm Package    ${OS_CONTROL_1_IP}    wget
46     Download Scapy For Test    ${OS_CONTROL_1_IP}
47
48
49 *** Keywords ***
50 Set Password
51     [Arguments]    ${os_node_cxn}    ${user_name}
52     Switch Connection    ${os_node_cxn}
53     Write Commands Until Expected Prompt    sudo passwd ${user_name}    d:    30s
54     Write Commands Until Expected Prompt    ${user_name}    d:    30s
55     Write Commands Until Expected Prompt    ${user_name}    ${OS_NODE_PROMPT}    30s
56
57 Set Required Prompt
58     [Arguments]    ${os_node_cxn}    ${user_name}
59     Append To File    ${os_node_cxn}    /home/${user_name}/.bashrc    'PS1="[\\u@\\h \\W]>"'
60
61 Create Csit User
62     [Arguments]    ${os_node_cxn}    ${user_name}
63     Run Command    ${os_node_cxn}    sudo useradd ${user_name} -d /home/${user_name}
64     Run Command    ${os_node_cxn}    echo "${user_name} ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/${user_name}
65     Set Password    ${os_node_cxn}    ${user_name}
66     Set Required Prompt    ${os_node_cxn}    ${user_name}
67     Setup Passwordless Ssh    jenkins    ${os_node_cxn}
68
69 Setup Passwordless Ssh
70     [Arguments]    ${user_name}    ${node_ip}
71     Run Command In Local Node
72     ...    sshpass -p ${user_name} ssh-copy-id ${user_name}@${node_ip} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
73     Run Command In Local Node    scp /tmp/vm_key ${user_name}@${node_ip}:~
74     Run Command In Local Node    scp /tmp/vm_key.pub ${user_name}@${node_ip}:~
75
76 Generate Ssh Keys For Vms
77     Run Command In Local Node    ssh-keygen -t rsa -N "" -f /tmp/vm_key
78
79 Download Scapy For Test
80     [Arguments]    ${os_node_cxn}
81     Run Command
82     ...    ${os_node_cxn}
83     ...    export https_proxy=${PROXY_TEST};export http_proxy=${PROXY_TEST};wget scapy.net -O /tmp/scapy-master.zip;unset https_proxy;unset http_proxy
84     Install Rpm Package    ${os_node_cxn}    unzip
85     Run Command    ${os_node_cxn}    cd /tmp;unzip /tmp/scapy-master.zip