Copy latest code
[ric-plt/e2mgr.git] / Automation / Tests / Resource / Keywords.robot
1 ##############################################################################
2 #
3 #   Copyright (c) 2019 AT&T Intellectual Property.
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #
17 ##############################################################################
18 #
19 #   This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 #   platform project (RICP).
21 #
22
23 *** Settings ***
24 Documentation   Keywords file
25 Library     ../Scripts/cleanup_db.py
26 Resource   ../Resource/resource.robot
27 Library     OperatingSystem
28
29
30
31
32
33 *** Keywords ***
34 Post Request setup node b x-2
35     Set Headers     ${header}
36     POST        /v1/nodeb/x2-setup    ${json}
37
38
39 Put Request Resource Status Start
40     Set Headers     ${header}
41     PUT        /v1/general/resourcestatus  ${resource_status_start_json}
42
43
44 Put Request Resource Status Stop
45     Set Headers     ${header}
46     PUT        /v1/general/resourcestatus  ${resource_status_stop_json}
47
48 Get Request node b enb test1
49     Sleep    1s
50     GET      /v1/nodeb/test1
51
52
53 Get Request node b enb test2
54     Sleep    1s
55     GET      /v1/nodeb/test2
56
57
58 Remove log files
59     Remove File  ${EXECDIR}/${gnb_log_filename}
60     Remove File  ${EXECDIR}/${e2mgr_log_filename}
61     Remove File  ${EXECDIR}/${e2t_log_filename}
62     Remove File  ${EXECDIR}/${rsm_log_filename}
63     Remove File  ${EXECDIR}/${e2e_simu_log_filename}
64     Remove File  ${EXECDIR}/${rm_sim_log_filename}
65     Remove File  ${EXECDIR}/${e2adapter_log_filename}
66
67 Save logs
68     Sleep   1s
69     Run     ${Save_sim_log}
70     Run     ${Save_e2mgr_log}
71     Run     ${Save_e2t_log}
72     Run     ${Save_rsm_log}
73     Run     ${Save_e2e_simu_log}
74     Run     ${Save_rm_sim_log}
75     Run     ${Save_e2adapter_log}
76
77
78 Post Request setup node b endc-setup
79     Set Headers     ${header}
80     POST        /v1/nodeb/endc-setup    ${endcjson}
81
82 Stop Simulator
83     Run And Return Rc And Output    ${stop_simu}
84
85
86
87 Prepare Simulator For Load Information
88      Run And Return Rc And Output    ${stop_simu}
89      Run And Return Rc And Output    ${docker_Remove}
90      ${flush}  cleanup_db.flush
91      Should Be Equal As Strings  ${flush}  True
92      Run And Return Rc And Output    ${run_simu_load}
93      ${result}=  Run And Return Rc And Output     ${docker_command}
94      Should Be Equal As Integers    ${result[1]}    ${docker_number}
95
96 Prepare Enviorment
97      ${starting_timestamp}    Evaluate   datetime.datetime.now(datetime.timezone.utc).isoformat("T")   modules=datetime 
98      ${e2t_log_filename}      Evaluate      "e2t.${SUITE NAME}.log".replace(" ","-")
99      ${e2mgr_log_filename}    Evaluate      "e2mgr.${SUITE NAME}.log".replace(" ","-")
100      ${gnb_log_filename}      Evaluate      "gnb.${SUITE NAME}.log".replace(" ","-")
101      ${rsm_log_filename}      Evaluate      "rsm.${SUITE NAME}.log".replace(" ","-")
102      ${e2e_simu_log_filename}      Evaluate      "e2e_simu.${SUITE NAME}.log".replace(" ","-")
103      ${rm_sim_log_filename}   Evaluate      "rm_sim.${SUITE NAME}.log".replace(" ","-")
104      ${e2adapter_log_filename}    Evaluate  "e2adapter.${SUITE NAME}.log".replace(" ","-")
105      ${Save_sim_log}          Evaluate   'docker logs --since ${starting_timestamp} gnbe2_simu > ${gnb_log_filename}'
106      ${Save_e2mgr_log}        Evaluate   'docker logs --since ${starting_timestamp} e2mgr > ${e2mgr_log_filename}'
107      ${Save_e2t_log}          Evaluate   'docker logs --since ${starting_timestamp} e2 > ${e2t_log_filename}'
108      ${Save_rsm_log}          Evaluate   'docker logs --since ${starting_timestamp} rsm > ${rsm_log_filename}'
109      ${Save_e2e_simu_log}     Evaluate   'docker logs --since ${starting_timestamp} e2e_simu > ${e2e_simu_log_filename}'
110      ${Save_rm_sim_log}       Evaluate   'docker logs --since ${starting_timestamp} rm_sim > ${rm_sim_log_filename}'
111      ${Save_e2adapter_log}    Evaluate   'docker logs --since ${starting_timestamp} e2adapter > ${e2adapter_log_filename}'
112      Set Suite Variable  ${e2t_log_filename}  
113      Set Suite Variable  ${e2mgr_log_filename}  
114      Set Suite Variable  ${gnb_log_filename}   
115      Set Suite Variable  ${rsm_log_filename}  
116      Set Suite Variable  ${e2e_simu_log_filename}
117      Set Suite Variable  ${rm_sim_log_filename}
118      Set Suite Variable  ${e2adapter_log_filename} 
119      Set Suite Variable  ${Save_sim_log}
120      Set Suite Variable  ${Save_e2mgr_log}
121      Set Suite Variable  ${Save_e2t_log}
122      Set Suite Variable  ${Save_rsm_log}
123      Set Suite Variable  ${Save_e2e_simu_log}
124      Set Suite Variable  ${Save_rm_sim_log}
125      Set Suite Variable  ${Save_e2adapter_log}
126         
127      ${flush}  cleanup_db.flush
128      Should Be Equal As Strings  ${flush}  True
129      Run And Return Rc And Output    ${stop_simu}
130      Run And Return Rc And Output    ${stop_e2e_simu}
131      Run And Return Rc And Output    ${docker_Remove}
132      Run And Return Rc And Output    ${docker_remove_e2e_simu}
133      Run And Return Rc And Output    ${run_simu_regular}
134      Run And Return Rc And Output    ${run_e2e_simu_regular}
135      Run And Return Rc And Output    ${restart_e2adapter}
136      Sleep  2s
137      ${result}=  Run And Return Rc And Output     ${docker_command}
138      Should Be Equal As Integers    ${result[1]}    ${docker_number}
139
140 Start E2
141      Run And Return Rc And Output    ${start_e2}
142      ${result}=  Run And Return Rc And Output     ${docker_command}
143      Should Be Equal As Integers    ${result[1]}    ${docker_number}
144      Sleep  2s
145
146 Stop E2
147      Run And Return Rc And Output    ${stop_e2}
148      ${result}=  Run And Return Rc And Output     ${docker_command}
149      Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
150      Sleep  2s
151
152 Start Dbass
153      Run And Return Rc And Output    ${dbass_remove}
154      Run And Return Rc And Output    ${dbass_start}
155      ${result}=  Run And Return Rc And Output     ${docker_command}
156      Should Be Equal As Integers    ${result[1]}    ${docker_number}
157
158 Stop Dbass
159      Run And Return Rc And Output    ${dbass_stop}
160      ${result}=  Run And Return Rc And Output     ${docker_command}
161      Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
162
163 Restart simulator
164
165     Run And Return Rc And Output    ${restart_docker_sim}
166     ${result}=  Run And Return Rc And Output     ${docker_command}
167     Should Be Equal As Integers    ${result[1]}    ${docker_number}
168
169
170
171
172