7ac8ef7239e8e41d625c867a1868dd8a518fd15d
[testsuite.git] / 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    ONAPLibrary.JSON
8 Library    ONAPLibrary.Openstack
9 Library    Collections
10 Library    String
11 Library           ONAPLibrary.ServiceMapping
12
13 Resource          ../openstack/keystone_interface.robot
14 Resource          ../openstack/nova_interface.robot
15 Resource          ../openstack/heat_interface.robot
16 Resource          ../ssh/files.robot
17 Resource          ../ssh/processes.robot
18 Resource          ../demo_preload.robot
19 Resource          packet_generator_interface.robot
20 Resource          validate_common.robot
21 Resource          ../test_templates/vnf_orchestration_test_template.robot
22
23
24 *** Variables ***
25
26 *** Keywords ***
27 Policy Check FirewallCL Stack
28     [Documentation]    Executes the vFW policy closed loop test.
29     [Arguments]    ${stacknamemap}    ${policy_rate}
30     Run Openstack Auth Request    auth
31     ${vsnk_stack_name}=   Get From Dictionary    ${stacknamemap}    vFWSNK
32     ${vpkg_stack_name}=   Get From Dictionary    ${stacknamemap}    vPKG
33     ${vsnk_stack_info}=    Wait for Stack to Be Deployed    auth    ${vsnk_stack_name}
34     ${vpkg_stack_info}=    Wait for Stack to Be Deployed    auth    ${vpkg_stack_name}
35     ${server_list}=    Get Openstack Servers    auth
36     Log     ${server_list}
37     ${vpkg_id}=   Get From Dictionary     ${vpkg_stack_info}   vnf_id
38     ${status}  ${generic_vnf}=   Run Keyword And Ignore Error   Get Generic VNF By ID    ${vpkg_id}
39     Run Keyword If   '${status}' == 'FAIL'   FAIL   VNF ID: ${vpkg_id} is not found.
40     ${invariantUUID}   Get From Dictionary  ${generic_vnf}   persona-model-id
41     Update vVFWCL Policy   ${invariantUUID}
42
43     ${vpg_unprotected_ip}=    Get From Dictionary    ${vpkg_stack_info}    vpg_int_unprotected_private_ip_0
44     ${vsn_protected_ip}=    Get From Dictionary    ${vsnk_stack_info}    vsn_int_protected_private_ip_0
45     ${vpg_public_ip}=    Get Server Ip    ${server_list}    ${vpkg_stack_info}   vpg_name_0    network_name=public
46     ${vsn_public_ip}=    Get Server Ip    ${server_list}    ${vsnk_stack_info}   vsn_name_0    network_name=public
47     ${upper_bound}=    Evaluate    ${policy_rate}*2
48     Wait Until Keyword Succeeds    30m    2s    Run VFW Policy Check    ${vpg_public_ip}   ${policy_rate}    ${upper_bound}    1
49
50 Run VFW Policy Check
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}    ${upper_bound}    ${lower_bound}
53     # Force traffic above threshold
54     Check For Policy Enforcement    ${vpg_public_ip}    ${policy_rate}    ${upper_bound}
55     # Force traffic below threshold
56     Check For Policy Enforcement    ${vpg_public_ip}    ${policy_rate}    ${lower_bound}
57
58
59 Check For Policy Enforcement
60     [Documentation]     Push traffic above upper bound, wait for policy to fix it, push traffic to lower bound, wait for policy to fix it,
61     [Arguments]    ${vpg_public_ip}    ${policy_rate}    ${forced_rate}
62     Enable Streams    ${vpg_public_ip}    ${forced_rate}
63     Wait Until Keyword Succeeds    20s    2s    Test For Expected Rate    ${vpg_public_ip}    ${forced_rate}
64     Wait Until Keyword Succeeds    10m    2s    Test For Expected Rate    ${vpg_public_ip}    ${policy_rate}
65
66 Test For Expected Rate
67     [Documentation]    Ge the number of pg-streams from the PGN, and test to see if it is what we expect.
68     [Arguments]    ${vpg_public_ip}    ${number_of_streams}
69     ${list}=    Get List Of Enabled Streams    ${vpg_public_ip}
70     ${list}=    Evaluate   ${list['sample-plugin']}['pg-streams']['pg-stream']
71     Length Should Be    ${list}    ${number_of_streams}
72
73
74
75 Policy Check vLB Stack
76     [Documentation]    Executes the vLB policy closed loop test
77     [Arguments]    ${stack_name}    ${policy_rate}
78     Run Openstack Auth Request    auth
79     ${stack_info}=    Wait for Stack to Be Deployed    auth    ${stack_name}
80     ${stack_id}=    Get From Dictionary    ${stack_info}    id
81     ${server_list}=    Get Openstack Servers    auth
82     ${vlb_public_ip}=    Get Server Ip    ${server_list}    ${stack_info}   vlb_name_0    network_name=public
83     ${upper_bound}=    Evaluate    ${policy_rate}*2
84     Start DNS Traffic    ${vlb_public_ip}    ${upper_bound}
85
86     # Now wiat for the dnsscaling stack to be deployed
87     ${prefix}=    Get DNSScaling Prefix
88     ${dnsscaling}=    Replace String Using Regexp    ${stack_name}    ^Vfmodule_    ${prefix}
89     ${dnsscaling_info}=    Wait for Stack to Be Deployed    auth    ${dnsscaling}
90     VLB Closed Loop Hack Update   ${dnsscaling}
91     # TO DO: Log into vLB and cehck that traffic is flowing to the new DNS
92     [Return]    ${dnsscaling}
93
94 Get DNSScaling Prefix
95     Set Directory    default    ./demo/service_mapping
96     ${mapping}=    Get Service Template Mapping    default    vLB    vLB
97     :FOR   ${dict}    IN   @{mapping}
98     \    Return From Keyword If    '${dict['isBase']}' == 'false'    ${dict['prefix']}
99     [Return]   None
100
101
102 Start DNS Traffic
103     [Documentation]   Run nslookups at rate per second. Run for 10 minutes or until it is called by the terminate process
104     [Arguments]    ${vlb_public_ip}    ${rate}
105     ${pid}=   Start Process   ./dnstraffic.sh   ${vlb_public_ip}   ${rate}   ${GLOBAL_DNS_TRAFFIC_DURATION}
106     [Return]    ${pid}