46296d8c3d03d22740623473465465d127f3d67c
[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 *** Keywords ***
30 Get Request node b gnb
31     Sleep    1s
32     GET      ${getNodeb}
33
34 Update Ran request
35     Sleep  1s
36     PUT    ${update_gnb_url}   ${update_gnb_body}
37
38
39 Update Ran request not valid
40     Sleep  1s
41     PUT    ${update_gnb_url}   ${update_gnb_body_notvalid}
42
43 Remove log files
44     Remove File  ${EXECDIR}/${gnb_log_filename}
45     Remove File  ${EXECDIR}/${e2mgr_log_filename}
46     Remove File  ${EXECDIR}/${e2t_log_filename}
47     Remove File  ${EXECDIR}/${rm_sim_log_filename}
48
49 Save logs
50     Sleep   1s
51     Run     ${Save_sim_log}
52     Run     ${Save_e2mgr_log}
53     Run     ${Save_e2t_log}
54     Run     ${Save_rm_sim_log}
55
56 Stop Simulator
57     Run And Return Rc And Output    ${stop_simu}
58
59 Prepare Enviorment
60      Log To Console  Starting preparations
61      ${starting_timestamp}    Evaluate   datetime.datetime.now(datetime.timezone.utc).isoformat("T")   modules=datetime 
62      ${e2t_log_filename}      Evaluate      "e2t.${SUITE NAME}.log".replace(" ","-")
63      ${e2mgr_log_filename}    Evaluate      "e2mgr.${SUITE NAME}.log".replace(" ","-")
64      ${gnb_log_filename}      Evaluate      "gnb.${SUITE NAME}.log".replace(" ","-")
65      ${rm_sim_log_filename}   Evaluate      "rm_sim.${SUITE NAME}.log".replace(" ","-")
66      ${Save_sim_log}          Evaluate   'docker logs --since ${starting_timestamp} gnbe2_oran_simu > ${gnb_log_filename}'
67      ${Save_e2mgr_log}        Evaluate   'docker logs --since ${starting_timestamp} e2mgr > ${e2mgr_log_filename}'
68      ${Save_e2t_log}          Evaluate   'docker logs --since ${starting_timestamp} e2 > ${e2t_log_filename}'
69      ${Save_rm_sim_log}       Evaluate   'docker logs --since ${starting_timestamp} rm_sim > ${rm_sim_log_filename}'
70      Set Suite Variable  ${e2t_log_filename}
71      Set Suite Variable  ${e2mgr_log_filename}  
72      Set Suite Variable  ${gnb_log_filename}   
73      Set Suite Variable  ${rm_sim_log_filename}
74      Set Suite Variable  ${Save_sim_log}
75      Set Suite Variable  ${Save_e2mgr_log}
76      Set Suite Variable  ${Save_e2t_log}
77      Set Suite Variable  ${Save_rm_sim_log}
78
79          Log To Console  Ready to flush db
80      ${flush}  cleanup_db.flush
81      Should Be Equal As Strings  ${flush}  True
82      Run And Return Rc And Output    ${stop_simu}
83      Run And Return Rc And Output    ${docker_Remove}
84      Run And Return Rc And Output    ${run_simu_regular}
85      Sleep  3s
86      Log To Console  Validating dockers are up
87      ${result}=  Run And Return Rc And Output     ${docker_command}
88      Should Be Equal As Integers    ${result[1]}    ${docker_number}
89
90 Start E2
91      Run And Return Rc And Output    ${start_e2}
92      ${result}=  Run And Return Rc And Output     ${docker_command}
93      Should Be Equal As Integers    ${result[1]}    ${docker_number}
94      Sleep  2s
95
96 Stop E2
97      Run And Return Rc And Output    ${stop_e2}
98      ${result}=  Run And Return Rc And Output     ${docker_command}
99      Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
100      Sleep  2s
101
102 Start Dbass
103      Run And Return Rc And Output    ${dbass_remove}
104      Run And Return Rc And Output    ${dbass_start}
105      ${result}=  Run And Return Rc And Output     ${docker_command}
106      Should Be Equal As Integers    ${result[1]}    ${docker_number}
107
108 Stop Dbass
109      Run And Return Rc And Output    ${dbass_stop}
110      ${result}=  Run And Return Rc And Output     ${docker_command}
111      Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
112
113 Restart simulator
114     Run And Return Rc And Output    ${restart_simu}
115     ${result}=  Run And Return Rc And Output     ${docker_command}
116     Should Be Equal As Integers    ${result[1]}    ${docker_number}
117
118 Start RoutingManager Simulator
119     Run And Return Rc And Output    ${start_routingmanager_sim}
120
121 Stop RoutingManager Simulator
122     Run And Return Rc And Output    ${stop_routingmanager_sim}
123
124 Restart simulator with less docker
125     Run And Return Rc And Output    ${restart_simu}
126     ${result}=  Run And Return Rc And Output     ${docker_command}
127     Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
128