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