[RIC-433] increment tag to 5.2.15
[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 Set General Configuration request
39     Sleep  1s
40     PUT    ${set_general_configuration}   ${set_general_configuration_body}
41
42 Update Ran request not valid
43     Sleep  1s
44     PUT    ${update_gnb_url}   ${update_gnb_body_notvalid}
45
46 Remove log files
47     Remove File  ${EXECDIR}/${gnb_log_filename}
48     Remove File  ${EXECDIR}/${e2mgr_log_filename}
49     Remove File  ${EXECDIR}/${e2t_log_filename}
50
51 Save logs
52     Sleep   1s
53     Run     ${Save_sim_log}
54     Run     ${Save_e2mgr_log}
55     Run     ${Save_e2t_log}
56
57 Prepare Enviorment
58      [Arguments]     ${need_to_restart_pods}=${False}     ${set_new_timestamp}=${True}
59      Init logs
60      Flush And Populate DB    ${set_new_timestamp}
61      Run keyword if  ${need_to_restart_pods}==${True}   Restart RM and GNB Simulator
62      Wait until keyword succeeds  1 min    10 sec    Validate Required Dockers
63
64 Restart RM and GNB Simulator
65     Restart routing manager
66     Wait until keyword succeeds  1 min    10 sec    Validate Required Dockers
67     Restart simulator
68
69
70 Init logs
71     ${starting_timestamp}    Evaluate   datetime.datetime.now(datetime.timezone.utc).isoformat("T")   modules=datetime
72     ${e2t_log_filename}      Evaluate      "e2t.${SUITE NAME}.log".replace(" ","-")
73     ${e2mgr_log_filename}    Evaluate      "e2mgr.${SUITE NAME}.log".replace(" ","-")
74     ${gnb_log_filename}      Evaluate      "gnb.${SUITE NAME}.log".replace(" ","-")
75     ${Save_sim_log}          Evaluate  "kubectl -n ricplt logs --since-time=${starting_timestamp} $(${gnbe2_sim_pod}) > ${gnb_log_filename}"
76     ${Save_e2mgr_log}        Evaluate   "kubectl -n ricplt logs --since-time=${starting_timestamp} $(${e2mgr_pod}) > ${e2mgr_log_filename}"
77     ${Save_e2t_log}          Evaluate   "kubectl -n ricplt logs --since-time=${starting_timestamp} $(${e2term_pod}) > ${e2t_log_filename}"
78
79     Set Suite Variable  ${e2t_log_filename}
80     Set Suite Variable  ${e2mgr_log_filename}
81     Set Suite Variable  ${gnb_log_filename}
82     Set Suite Variable  ${Save_sim_log}
83     Set Suite Variable  ${Save_e2mgr_log}
84     Set Suite Variable  ${Save_e2t_log}
85
86 Validate Required Dockers
87     [Arguments]    ${required_number_of_dockers}=${pods_number}
88     Log To Console  Validating all required dockers are up
89     ${result}=  Run And Return Rc And Output     ${verify_all_pods_are_ready_command}
90     Should Be Equal As Integers    ${result[1]}    ${required_number_of_dockers}
91
92 Start E2
93      Log to Console  Starting E2Term
94      Run And Return Rc And Output    ${start_e2}
95      Sleep  5s
96
97 Stop E2
98      Log to Console  Stopping E2Term
99      Run And Return Rc And Output    ${stop_e2}
100      Sleep  5s
101
102 Start E2 Manager
103      Log to Console  Starting E2Mgr
104      Run And Return Rc And Output    ${start_e2mgr}
105      Sleep  5s
106
107 Stop E2 Manager
108      Log to Console  Stopping E2Mgr
109      Run And Return Rc And Output    ${stop_e2mgr}
110      Sleep  5s
111
112 Start Dbass
113      Log to Console  Starting redis
114      Run And Return Rc And Output    ${dbass_start}
115      Sleep  5s
116
117 Stop Dbass
118      Log to Console  Stopping redis
119      Run And Return Rc And Output    ${dbass_stop}
120      Sleep  5s
121
122 Stop Simulator
123     log to console  Stopping gnbe2 simulator
124     Run And Return Rc And Output    ${stop_simu}
125     Sleep  50s
126
127 Start Simulator
128     log to console  Starting gnbe2 simulator
129     Run And Return Rc And Output    ${start_simu}
130
131 Restart simulator
132    Log to Console  Restarting gnbe2 simulator
133    Stop Simulator
134    Start Simulator
135
136 Start Routing Manager
137     Log to Console  Starting routing manager
138     Run And Return Rc And Output    ${start_routing_manager}
139     Sleep  5s
140
141 Stop Routing Manager
142     Log to Console  Stopping routing manager
143     Run And Return Rc And Output    ${stop_routing_manager}
144     Sleep  5s
145
146 Restart Routing Manager
147     Log to Console  Restarting routing manager
148     Stop Routing Manager
149     Start Routing Manager
150
151 Flush And Populate DB
152     [Arguments]    ${set_new_timestamp}=${True}
153     Log To Console  Flushing and populating DB
154     ${flush}=  cleanup_db.flush    ${set_new_timestamp}
155     Sleep  2s
156     Should Be Equal As Strings  ${flush}  True
157
158 Stop All Pods Except Simulator
159     Stop E2 Manager
160     Stop Dbass
161     Stop E2
162     Stop Routing Manager
163