Define sulfur version
[integration/test.git] / csit / libraries / ODLMicroKeywords.robot
1 *** Settings ***
2 Documentation     A test suite which contains keywords of ODL micro which are used commonly.
3 Library           Collections
4 Library           OperatingSystem
5 Library           SSHLibrary
6 Library           String
7 Library           XML
8 Library           Collections
9 Library           RequestsLibrary
10
11 *** Variables ***
12
13 *** Keywords ***
14 Download ODL Micro
15     [Documentation]    Create SSH Connection and deploy odl micro
16     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}    alias=ODL_System
17     SSHLibrary.Set_Client_Configuration    timeout=10s
18     SSHLibrary.Set_Client_Configuration    prompt=${ODL_SYSTEM_PROMPT}
19     SSHKeywords.Flexible_SSH_Login    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    delay=4s
20     ${file_name} =    NexusKeywords.Deploy_Test_Tool    odl-micro    micro-netconf    micro    ${BASE_URL}    build_version=${ODL_MICRO_VERSION}    build_location=org/opendaylight/odlmicro
21     BuiltIn.Set_Suite_Variable    ${FILENAME}    ${filename}
22
23 Run ODL Micro
24     [Documentation]    Run ODL Micro
25     SSHLibrary.Switch_Connection    ODL_System
26     SSHLibrary.Write    tar -xvf ${FILE_NAME} -C ${ODL_MICRO_WORKSPACE}/
27     SSHLibrary.Write    cd ${ODL_MICRO_WORKSPACE}/micro-netconf-${ODL_MICRO_VERSION}
28     ${response} =    SSHLibrary.Execute_Command    ls
29     BuiltIn.Log    ${response}
30     ${command} =    NexusKeywords.Compose_Full_Java_Command    -Xms128M -Xmx2048m -XX:+UnlockDiagnosticVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dcom.sun.management.jmxremote -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom -cp "etc/initial/:lib/*" org.opendaylight.netconf.micro.NetconfMain > /tmp/odlmicro.log 2>&1
31     BuiltIn.Log    ${command}
32     SSHLibrary.Write    ${command}
33
34 Get pid
35     [Arguments]    ${process_name}
36     ${pid} =    SSHLibrary.Execute Command    ps -fu ${ODL_SYSTEM_USER} | grep "${process_name}" | grep -v "grep" | awk '{print $2}'
37     [Return]    ${pid}
38
39 Check netstat
40     [Arguments]    ${portno}    ${session}=ODL_Micro_instance
41     SSHLibrary.Switch_Connection    ${session}
42     SSHLibrary.Write    netstat -tunpl
43     SSHLibrary.Read Until Regexp    .*${portno}
44
45 Check Process Stats
46     [Arguments]    ${process_name}
47     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}    alias=ODL_Micro_instance
48     SSHLibrary.Set_Client_Configuration    timeout=10s
49     SSHLibrary.Set_Client_Configuration    prompt=${ODL_SYSTEM_PROMPT}
50     SSHKeywords.Flexible_SSH_Login    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    delay=4s
51     ${mock_pid}    Get pid    ${process_name}
52     BuiltIn.Run_Keyword_If    '${mock_pid}' == '${EMPTY}'    BuiltIn.Fail    No ${process_name} process is running
53
54 Kill process
55     [Arguments]    ${process_name}    ${ssh_alias}=ODL_Micro_instance
56     SSHLibrary.Switch_Connection    ${ssh_alias}
57     ${mock_pid}    Get pid    ${process_name}
58     SSHLibrary.Execute_Command    kill -9 ${mock_pid}
59
60 Download Netconf Testtool
61     [Documentation]    Download netconf testtool from opendaylight nexus
62     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=Netconf_System
63     SSHLibrary.Set_Client_Configuration    timeout=10s
64     SSHLibrary.Set_Client_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
65     SSHKeywords.Flexible_SSH_Login    ${TOOLS_SYSTEM_USER}    ${TOOLS_SYSTEM_PASSWORD}    delay=4s
66     ${file_name} =    NexusKeywords.Deploy_Test_Tool    netconf    netconf-testtool    build_version=${NETCONF_TESTTOOL_VERSION}    build_location=org/opendaylight/netconf
67     Set Global Variable    ${NETCONF_FILENAME}    ${filename}
68     ${file_name} =    NexusKeywords.Deploy_Test_Tool    netconf    netconf-testtool    rest-perf-client    build_version=${NETCONF_TESTTOOL_VERSION}    build_location=org/opendaylight/netconf
69     Set Global Variable    ${RESTPERF_FILENAME}    ${filename}
70
71 Run Netconf Testtool
72     [Arguments]    ${ssh_alias}=Netconf_System
73     NetconfKeywords.Start_Testtool    ${NETCONF_FILENAME}    device-count=1    schemas=${CURDIR}/../variables/netconf/CRUD/schemas