onap on kubernetes source files
[oom.git] / kubernetes / config / docker / init / src / config / robot / robot / resources / stack_validation / policy_check_vfw.robot
1 *** Settings ***
2 Documentation     Testing openstack.
3 Library    OperatingSystem
4 Library    Process
5 Library    SSHLibrary
6 Library    RequestsLibrary
7 Library    JSONUtils
8 Library    OpenstackLibrary
9 Library    HEATUtils
10 Library    Collections
11 LIbrary    String
12 Resource          ../../resources/openstack/keystone_interface.robot
13 Resource          ../../resources/openstack/nova_interface.robot
14 Resource          ../../resources/openstack/heat_interface.robot
15 Resource          ../../resources/ssh/files.robot
16 Resource          ../../resources/ssh/processes.robot
17 Resource          packet_generator_interface.robot
18 Resource          darkstat_interface.robot
19 Resource          validate_common.robot
20 Resource          ../../resources/test_templates/vnf_orchestration_test_template.robot
21
22
23 *** Variables ***
24
25 *** Keywords ***
26 Policy Check Firewall Stack
27     [Documentation]    Executes the vFW policy closed loop test.
28     [Arguments]    ${stack_name}    ${policy_rate}
29     Run Openstack Auth Request    auth
30     ${stack_info}=    Wait for Stack to Be Deployed    auth    ${stack_name}
31     ${stack_id}=    Get From Dictionary    ${stack_info}    id
32     ${server_list}=    Get Openstack Servers    auth
33     Log     ${server_list}
34     ${vpg_unprotected_ip}=    Get From Dictionary    ${stack_info}    vpg_private_ip_0
35     ${vsn_protected_ip}=    Get From Dictionary    ${stack_info}    vsn_private_ip_0
36     ${vpg_public_ip}=    Get Server Ip    ${server_list}    ${stack_info}   vpg_name_0    network_name=public
37     ${vsn_public_ip}=    Get Server Ip    ${server_list}    ${stack_info}   vsn_name_0    network_name=public
38     ${upper_bound}=    Evaluate    ${policy_rate}*2
39     Wait Until Keyword Succeeds    300s    1s    Run VFW Policy Check    ${vpg_public_ip}   ${policy_rate}    ${upper_bound}    1
40
41 Run VFW Policy Check
42     [Documentation]     Push traffic above upper bound, wait for policy to fix it, push traffic to lower bound, wait for policy to fix it,
43     [Arguments]    ${vpg_public_ip}    ${policy_rate}    ${upper_bound}    ${lower_bound}
44     # Force traffic above threshold
45     Check For Policy Enforcement    ${vpg_public_ip}    ${policy_rate}    ${upper_bound}
46     # Force traffic below threshold
47     Check For Policy Enforcement    ${vpg_public_ip}    ${policy_rate}    ${lower_bound}
48
49
50 Check For Policy Enforcement
51     [Documentation]     Push traffic above upper bound, wait for policy to fix it, push traffic to lower bound, wait for policy to fix it,
52     [Arguments]    ${vpg_public_ip}    ${policy_rate}    ${forced_rate}
53     Enable Streams    ${vpg_public_ip}    ${forced_rate}
54     Wait Until Keyword Succeeds    20s    5s    Test For Expected Rate    ${vpg_public_ip}    ${forced_rate}
55     Wait Until Keyword Succeeds    280s    5s    Test For Expected Rate    ${vpg_public_ip}    ${policy_rate}
56
57 Test For Expected Rate
58     [Documentation]    Ge the number of pg-streams from the PGN, and test to see if it is what we expect.
59     [Arguments]    ${vpg_public_ip}    ${number_of_streams}
60     ${list}=    Get List Of Enabled Streams    ${vpg_public_ip}
61     ${list}=    Evaluate   ${list['sample-plugin']}['pg-streams']['pg-stream']
62     Length Should Be    ${list}    ${number_of_streams}
63
64
65
66 Policy Check vLB Stack
67     [Documentation]    Executes the vLB policy closed loop test
68     [Arguments]    ${stack_name}    ${policy_rate}
69     Run Openstack Auth Request    auth
70     ${stack_info}=    Wait for Stack to Be Deployed    auth    ${stack_name}
71     ${stack_id}=    Get From Dictionary    ${stack_info}    id
72     ${server_list}=    Get Openstack Servers    auth
73     ${vlb_public_ip}=    Get Server Ip    ${server_list}    ${stack_info}   vlb_name_0    network_name=public
74     ${upper_bound}=    Evaluate    ${policy_rate}*2
75     Start DNS Traffic    ${vlb_public_ip}    ${upper_bound}
76
77     # Now wiat for the dnsscaling stack to be deployed
78     ${prefix}=    Get DNSScaling Prefix
79     ${dnsscaling}=    Replace String Using Regexp    ${stack_name}    ^Vfmodule_    ${prefix}
80     ${dnsscaling_info}=    Wait for Stack to Be Deployed    auth    ${dnsscaling}
81     VLB Closed Loop Hack Update   ${dnsscaling}
82     # TO DO: Log into vLB and cehck that traffic is flowing to the new DNS
83     [Return]    ${dnsscaling}
84
85 Get DNSScaling Prefix
86     ${mapping}=    Get From Dictionary   ${GLOBAL_SERVICE_TEMPLATE_MAPPING}   vLB
87     :for   ${dict}    in   @{mapping}
88     \    Return From Keyword If    '${dict['isBase']}' == 'false'    ${dict['prefix']}
89     [Return]   None
90
91
92 Start DNS Traffic
93     [Documentation]   Run nslookups at rate per second. Run for 10 minutes or until it is called by the terminate process
94     [Arguments]    ${vlb_public_ip}    ${rate}
95     ${pid}=   Start Process   ./dnstraffic.sh   ${vlb_public_ip}   ${rate}   ${GLOBAL_DNS_TRAFFIC_DURATION}
96     [Return]    ${pid}