Issue ID: RIC-779: xAPP Functionality Enhancement- Subscription Duplication Automation
[it/test.git] / ric_robot_suite / helm / nanobot / configmap-src / public / resources / submgr_interface.robot
1 *** Settings ***
2 Documentation  Tests for the UE Event Collector XApp
3
4 Resource       /robot/resources/global_properties.robot
5 Resource       /robot/resources/ric/ric_utils.robot
6 Resource       /robot/resources/json_templater.robot
7
8 Library        String
9 Library        Collections
10 Library        XML
11 Library        RequestsLibrary
12 Library        UUID
13 Library        Process
14 Library        OperatingSystem
15
16 Library        KubernetesEntity  ${GLOBAL_RICPLT_NAMESPACE}
17
18 *** Variables ***
19 ${SUBMGR_BASE_PATH}    /ric/v1/health/alive
20 ${SUBMGR_SUBDATA_PATH}    /ric/v1/subscriptions
21 ${gnb_id} =     Set Variable    ${GLOBAL_GNBID}
22
23
24 *** Keywords ***
25 Run submgr Health Check
26      [Documentation]    Runs SubMgr Health check
27      ${data_path}=      Set Variable    ${SUBMGR_BASE_PATH}
28      ${resp} =   Run Keyword    Run submgr GET Request  ${data_path}
29
30 Run submgr GET Request
31      [Documentation]  Make an HTTP GET request against the submgr
32      [Arguments]   ${data_path}
33      ${auth}=  Create List  ${GLOBAL_INJECTED_SUBMGR_USER}    ${GLOBAL_INJECTED_SUBMGR_PASSWORD}
34      ${c} =            Get From Dictionary  ${GLOBAL_RICPLT_COMPONENTS}  submgr
35      ${ctrl}  ${submgr1} =  Split String         ${c}       |
36      ${name} =  Run Keyword     RetrievePodsForDeployment       ${submgr1}
37      ${name1} = Set Variable    ${name[0]}
38      Log To Console     ${name1}
39      ${cType} =        Set Variable    Pod
40      ${ctrl1} = Run Keyword     ${cType}        ${name1}
41      ${podIP} = Set Variable    ${ctrl1.status.pod_ip}
42      Log To Console     ${podIP}
43      #${SUBMGR_ENDPOINT}=       Set Variable    ${GLOBAL_SUBMGR_SERVER_PROTOCOL}://${GLOBAL_SUBMGR_HTTP_SERVER}:${GLOBAL_SUBMGR_PORT}
44      ${SUBMGR_ENDPOINT}=        Set Variable    ${GLOBAL_SUBMGR_SERVER_PROTOCOL}://${podIP}:8080
45      ${session}=    Create Session      robosubmgr      ${SUBMGR_ENDPOINT}   auth=${auth}
46      ${uuid}=    Generate UUID
47      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
48      ${resp}=   Get Request     robosubmgr    ${data_path}     headers=${headers}
49      Log    Received response from SubMgr ${resp.text}
50      Should Be Equal As Strings        ${resp.status_code}     200
51      [Return]    ${resp}
52
53 Run submgr SUBSCRIPTIONGET Request
54      [Documentation]  Make an HTTP GET request against the submgr
55      [Arguments]   ${sub_data_path}
56      ${auth}=  Create List  ${GLOBAL_INJECTED_SUBMGR_USER}    ${GLOBAL_INJECTED_SUBMGR_PASSWORD}
57      ${c} =            Get From Dictionary  ${GLOBAL_RICPLT_COMPONENTS}  submgr
58      ${ctrl}  ${submgr1} =  Split String         ${c}       |
59      ${name} =  Run Keyword     RetrievePodsForDeployment       ${submgr1}
60      ${name1} = Set Variable    ${name[0]}
61      Log To Console     ${name1}
62      ${cType} =        Set Variable    Pod
63      ${ctrl1} = Run Keyword     ${cType}        ${name1}
64      ${podIP} = Set Variable    ${ctrl1.status.pod_ip}
65      Log To Console     ${podIP}
66      #${SUBMGR_ENDPOINT}=       Set Variable    ${GLOBAL_SUBMGR_SERVER_PROTOCOL}://${GLOBAL_SUBMGR_HTTP_SERVER}:${GLOBAL_SUBMGR_PORT}
67      ${SUBMGR_ENDPOINT}=        Set Variable    ${GLOBAL_SUBMGR_SERVER_PROTOCOL}://${podIP}:8088
68      Log To Console     ${SUBMGR_ENDPOINT}
69      ${session}=    Create Session      subscriptioncheck       ${SUBMGR_ENDPOINT}   auth=${auth}
70      ${uuid}=    Generate UUID
71      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
72      ${resp}=   Get Request     subscriptioncheck    ${sub_data_path}     headers=${headers}
73      Log To Console     ${resp}
74      Log TO Console     ${resp.text}
75      Log TO Console     ${gnb_id}
76      ${ret} =    Run Keyword And Return Status   Should Contain         ${resp.text}            "${GLOBAL_GNBID}"
77      [Return]    ${ret}
78
79
80
81 Run submgr SUBSCRIPTIONMERGE Check
82      [Documentation]  Make an HTTP GET request against the submgr
83      [Arguments]   ${sub_data_path}
84      ${auth}=  Create List  ${GLOBAL_INJECTED_SUBMGR_USER}    ${GLOBAL_INJECTED_SUBMGR_PASSWORD}
85      ${c} =            Get From Dictionary  ${GLOBAL_RICPLT_COMPONENTS}  submgr
86      ${ctrl}  ${submgr1} =  Split String         ${c}       |
87      ${name} =  Run Keyword     RetrievePodsForDeployment       ${submgr1}
88      ${name1} = Set Variable    ${name[0]}
89      Log To Console     ${name1}
90      ${cType} =        Set Variable    Pod
91      ${ctrl1} = Run Keyword     ${cType}        ${name1}
92      ${podIP} = Set Variable    ${ctrl1.status.pod_ip}
93      Log To Console     ${podIP}
94      #${SUBMGR_ENDPOINT}=       Set Variable    ${GLOBAL_SUBMGR_SERVER_PROTOCOL}://${GLOBAL_SUBMGR_HTTP_SERVER}:${GLOBAL_SUBMGR_PORT}
95      ${SUBMGR_ENDPOINT}=        Set Variable    ${GLOBAL_SUBMGR_SERVER_PROTOCOL}://${podIP}:8088
96      Log To Console     ${SUBMGR_ENDPOINT}
97      ${session}=    Create Session      subscriptioncheck1      ${SUBMGR_ENDPOINT}   auth=${auth}
98      ${uuid}=    Generate UUID
99      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
100      ${resp}=   Get Request     subscriptioncheck1    ${sub_data_path}     headers=${headers}
101      Log To Console     ${resp}
102      Log TO Console     ${resp.text}
103      Log TO Console     ${gnb_id}
104      @{jsonoutput} =    To Json         ${resp.text}
105      Log TO Console     ${jsonoutput}
106      FOR         ${item}         IN     @{jsonoutput}
107         Log To Console  ${item}
108         ${json}=  Set variable    ${item['Endpoint']}
109         ${len_endpointfromjson} =    Get Length         ${json}
110         Log To Console  ${json}
111         Log To Console  ${len_endpointfromjson}
112         ${ret} =        Run Keyword And Return Status   Should Be Equal As Integers     ${len_endpointfromjson} 2
113         Log To Console  ${ret}
114      END
115      [Return]   ${ret}
116