Fix Automation and add reset tests

Change-Id: I43ac4d889a0a847322f9f6ce6e82f4cd76cb1c9e
Signed-off-by: ss412g <shuky.har-noy@intl.att.com>
diff --git a/Automation/Tests/ConfigurationUpdate/ConfigurationUpdate_prepartations_tests.robot b/Automation/Tests/ConfigurationUpdate/ConfigurationUpdate_prepartations_tests.robot
index 849052d..2aec47f 100644
--- a/Automation/Tests/ConfigurationUpdate/ConfigurationUpdate_prepartations_tests.robot
+++ b/Automation/Tests/ConfigurationUpdate/ConfigurationUpdate_prepartations_tests.robot
@@ -25,10 +25,6 @@
 Library     REST      ${url}
 
 
-*** Variables ***
-${Run_Config}       docker exec gnbe2_simu pkill gnbe2_simu -INT
-${Save_e2_log}      docker logs --tail 300 gnbe2_simu > gnb.log
-${Save_e2mgr_log}   docker logs --tail 300 e2mgr > e2mgr.log
 
 *** Test Cases ***
 X2 - Setup and Get
diff --git a/Automation/Tests/LoadInfomation/Loadinformation_adding_data_and_overwrite.robot b/Automation/Tests/LoadInfomation/Loadinformation_adding_data_and_overwrite.robot
index 3aab161..d94482a 100644
--- a/Automation/Tests/LoadInfomation/Loadinformation_adding_data_and_overwrite.robot
+++ b/Automation/Tests/LoadInfomation/Loadinformation_adding_data_and_overwrite.robot
@@ -25,7 +25,7 @@
 Library     Process
 Library     ${CURDIR}/loadscripts.py
 Library     REST      ${url}
-
+Suite Teardown  Stop Simulator
 
 
 *** Test Cases ***
diff --git a/Automation/Tests/LoadInfomation/Loadinformation_verify_saving.robot b/Automation/Tests/LoadInfomation/Loadinformation_verify_saving.robot
index 0422dd1..e02b5eb 100644
--- a/Automation/Tests/LoadInfomation/Loadinformation_verify_saving.robot
+++ b/Automation/Tests/LoadInfomation/Loadinformation_verify_saving.robot
@@ -25,7 +25,7 @@
 Library     Process
 Library     ${CURDIR}/loadscripts.py
 Library     REST      ${url}
-
+Suite Teardown  Stop Simulator
 
 
 
diff --git a/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot b/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot
new file mode 100644
index 0000000..8415c47
--- /dev/null
+++ b/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot
@@ -0,0 +1,57 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+*** Settings ***
+Suite Setup   Prepare Enviorment
+Resource   ../Resource/resource.robot
+Resource   ../Resource/Keywords.robot
+Library     OperatingSystem
+Library    Collections
+Library     REST      ${url}
+
+
+
+
+
+*** Test Cases ***
+
+Pre Condition for Connecting - no simu
+    Run And Return Rc And Output    ${stop_simu}
+    ${result}=  Run And Return Rc And Output     ${docker_command}
+    Should Be Equal As Integers    ${result[1]}    4
+
+
+Prepare Ran in Connecting connectionStatus
+    Sleep  1s
+    Post Request setup node b x-2
+    Integer     response status       200
+    Sleep  1s
+    GET      /v1/nodeb/test1
+    Integer  response status  200
+    String   response body ranName    test1
+    #String   response body connectionStatus    CONNECTING
+
+
+
+Verfiy Disconnected ConnectionStatus
+    Sleep    1s
+    GET      /v1/nodeb/test1
+    Integer  response status  200
+    String   response body ranName    test1
+    String   response body connectionStatus    DISCONNECTED
+    Integer   response body connectionAttempts    3
+
diff --git a/Automation/Tests/Lost_Connection/__init__.robot b/Automation/Tests/Lost_Connection/__init__.robot
new file mode 100644
index 0000000..3cb82d4
--- /dev/null
+++ b/Automation/Tests/Lost_Connection/__init__.robot
@@ -0,0 +1,20 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+*** Settings ***
+Documentation    ORAN Lost Connection scenarios
diff --git a/Automation/Tests/Reset_RAN_TO_RIC/Reset_RAN_Found.robot b/Automation/Tests/Reset_RAN_TO_RIC/Reset_RAN_Found.robot
new file mode 100644
index 0000000..aa52bf9
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC/Reset_RAN_Found.robot
@@ -0,0 +1,52 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+*** Settings ***
+Suite Setup   Prepare Enviorment
+Resource   ../Resource/resource.robot
+Resource   ../Resource/Keywords.robot
+Library     OperatingSystem
+Library     Collections
+Library     REST      ${url}
+
+
+
+
+*** Test Cases ***
+
+Prepare Ran in Connected connectionStatus
+    Post Request setup node b x-2
+    Integer     response status       200
+    Sleep  1s
+    GET      /v1/nodeb/test1
+    Integer  response status  200
+    String   response body ranName    test1
+    String   response body connectionStatus    CONNECTED
+
+Run Reset from RAN
+    Run    ${Run_Config}
+    Sleep   1s
+
+Remove log files
+    Remove File  ${EXECDIR}/gnb.log
+    Remove File  ${EXECDIR}/e2mgr.log
+
+Save logs
+    Sleep   1s
+    Run     ${Save_e2_log}
+    Run     ${Save_e2mgr_log}
\ No newline at end of file
diff --git a/Automation/Tests/Reset_RAN_TO_RIC/Reset_Ran_To_Ric_Verify_logs.py b/Automation/Tests/Reset_RAN_TO_RIC/Reset_Ran_To_Ric_Verify_logs.py
new file mode 100644
index 0000000..fd03b24
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC/Reset_Ran_To_Ric_Verify_logs.py
@@ -0,0 +1,48 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+
+def verify(directory):
+
+    file = 'e2mgr.log'
+
+    path = '/'
+
+    file_path = directory + path + file
+
+    f = open(file_path,'r')
+
+    found_message_10070 = False
+    found_message_10071 = False
+
+    for l in f:
+        if l.find('MType: 10070') > 0 and l.find('Meid: \\"test1\\"') > 0:
+            found_message_10070 = True
+        elif l.find('MType: 10071') > 0 and l.find('Meid: \\"test1\\"') > 0:
+            found_message_10071 = True
+
+        if found_message_10070 and found_message_10071:
+            break
+
+    if found_message_10070 and found_message_10071:
+        return True
+    else:
+        return False
+
+
+
diff --git a/Automation/Tests/Reset_RAN_TO_RIC/Reset_Verify_logs.robot b/Automation/Tests/Reset_RAN_TO_RIC/Reset_Verify_logs.robot
new file mode 100644
index 0000000..cfecbaf
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC/Reset_Verify_logs.robot
@@ -0,0 +1,35 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+
+*** Settings ***
+Library     String
+Library     OperatingSystem
+Library     Process
+Library     ${CURDIR}/Reset_Ran_To_Ric_Verify_logs.py
+
+
+*** Test Cases ***
+Verify logs - Reset Sent by simulator
+    ${Reset}=   Grep File  ./gnb.log  ResetRequest has been sent
+    #Log to console      ${Reset}
+    Should Be Equal     ${Reset}     gnbe2_simu: ResetRequest has been sent
+
+Verify logs - e2mgr logs
+   ${result}    Reset_Ran_To_Ric_Verify_logs.verify   ${EXECDIR}
+   Should Be Equal As Strings    ${result}      True
\ No newline at end of file
diff --git a/Automation/Tests/Reset_RAN_TO_RIC/__init__.robot b/Automation/Tests/Reset_RAN_TO_RIC/__init__.robot
new file mode 100644
index 0000000..9ff2052
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC/__init__.robot
@@ -0,0 +1,20 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+*** Settings ***
+Documentation    ORAN Reset - RAN to RIC Scenario 1
diff --git a/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_RNIB.robot b/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_RNIB.robot
new file mode 100644
index 0000000..d0319b6
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_RNIB.robot
@@ -0,0 +1,56 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+*** Settings ***
+Suite Setup   Prepare Enviorment
+Resource   ../Resource/resource.robot
+Resource   ../Resource/Keywords.robot
+Library     OperatingSystem
+Library     Collections
+Library     REST      ${url}
+
+
+
+
+
+*** Test Cases ***
+
+Prepare Ran in Connected connectionStatus
+    Post Request setup node b x-2
+    Integer     response status       200
+    Sleep  1s
+    GET      /v1/nodeb/test1
+    Integer  response status  200
+    String   response body ranName    test1
+    String   response body connectionStatus    CONNECTED
+
+Stop RNIB
+      Run   docker stop redis
+
+Run Reset from RAN
+    Run    ${Run_Config}
+    Sleep   1s
+
+Remove log files
+    Remove File  ${EXECDIR}/gnb.log
+    Remove File  ${EXECDIR}/e2mgr.log
+
+Save logs
+    Sleep   1s
+    Run     ${Save_e2_log}
+    Run     ${Save_e2mgr_log}
\ No newline at end of file
diff --git a/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_Ran_To_Ric_RNIB_Down_Verify_logs.py b/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_Ran_To_Ric_RNIB_Down_Verify_logs.py
new file mode 100644
index 0000000..1174480
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_Ran_To_Ric_RNIB_Down_Verify_logs.py
@@ -0,0 +1,47 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+
+def verify(directory):
+
+    file = 'e2mgr.log'
+
+    path = '/'
+
+    file_path = directory + path + file
+
+    f = open(file_path,'r')
+
+    found_message_10070 = False
+    found_message_error = False
+
+    for l in f:
+        if l.find('MType: 10070') > 0 and l.find('Meid: \\"test1\\"') > 0:
+            found_message_10070 = True
+        elif l.find('RanName: test1') > 0 and l.find('Error:') > 0:
+            found_message_error = True
+        if found_message_10070 and found_message_error:
+            break
+
+    if found_message_10070 and found_message_error:
+        return True
+    else:
+        return False
+
+
+
diff --git a/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_Verify_logs.robot b/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_Verify_logs.robot
new file mode 100644
index 0000000..583d11b
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC_2/Reset_Verify_logs.robot
@@ -0,0 +1,38 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+
+*** Settings ***
+Library     String
+Library     OperatingSystem
+Library     Process
+Library     ${CURDIR}/Reset_Ran_To_Ric_RNIB_Down_Verify_logs.py
+Resource   ../Resource/Keywords.robot
+
+
+
+*** Test Cases ***
+Verify logs - Reset Sent by simulator
+    ${Reset}=   Grep File  ./gnb.log  ResetRequest has been sent
+    #Log to console      ${Reset}
+    Should Be Equal     ${Reset}     gnbe2_simu: ResetRequest has been sent
+
+Verify logs - e2mgr logs
+   ${result}    Reset_Ran_To_Ric_RNIB_Down_Verify_logs.verify   ${EXECDIR}
+   log to console   ${result}
+   Should Be Equal As Strings    ${result}      True
\ No newline at end of file
diff --git a/Automation/Tests/Reset_RAN_TO_RIC_2/__init__.robot b/Automation/Tests/Reset_RAN_TO_RIC_2/__init__.robot
new file mode 100644
index 0000000..3eb15e6
--- /dev/null
+++ b/Automation/Tests/Reset_RAN_TO_RIC_2/__init__.robot
@@ -0,0 +1,20 @@
+##############################################################################
+#
+#   Copyright (c) 2019 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+##############################################################################
+
+*** Settings ***
+Documentation    ORAN Reset - RAN to RIC Scenario 2
diff --git a/Automation/Tests/Reset_RIC_TO_RAN/Reset_unhappy.robot b/Automation/Tests/Reset_RIC_TO_RAN/Reset_unhappy.robot
index 587ded7..91fd82f 100755
--- a/Automation/Tests/Reset_RIC_TO_RAN/Reset_unhappy.robot
+++ b/Automation/Tests/Reset_RIC_TO_RAN/Reset_unhappy.robot
@@ -22,6 +22,7 @@
 Library     OperatingSystem
 Library    Collections
 Library     REST      ${url}
+Suite Teardown   Start E2
 
 *** Variables ***
 ${stop_docker_e2}      docker stop e2
diff --git a/Automation/Tests/Resource/Keywords.robot b/Automation/Tests/Resource/Keywords.robot
index 20b4e3a..b5caaaf 100755
--- a/Automation/Tests/Resource/Keywords.robot
+++ b/Automation/Tests/Resource/Keywords.robot
@@ -23,12 +23,16 @@
 Library     OperatingSystem
 
 
+
+
+
 *** Keywords ***
 Post Request setup node b x-2
     Set Headers     ${header}
     POST        /v1/nodeb/x2-setup    ${json}
 
 
+
 Get Request node b enb test1
     Sleep    1s
     GET      /v1/nodeb/test1
@@ -38,10 +42,15 @@
     Sleep    1s
     GET      /v1/nodeb/test2
 
+
+
 Post Request setup node b endc-setup
     Set Headers     ${header}
     POST        /v1/nodeb/endc-setup    ${endcjson}
 
+Stop Simulator
+    Run And Return Rc And Output    ${stop_simu}
+
 
 Prepare Simulator For Load Information
      Run And Return Rc And Output    ${stop_simu}
diff --git a/Automation/Tests/Resource/resource.robot b/Automation/Tests/Resource/resource.robot
index 9382db5..42d7ed1 100755
--- a/Automation/Tests/Resource/resource.robot
+++ b/Automation/Tests/Resource/resource.robot
@@ -27,11 +27,10 @@
 ${resetcausejson}   {"cause": "misc:not-enough-user-plane-processing-resources"}
 ${header}  {"Content-Type": "application/json"}
 ${docker_command}  docker ps | grep 1.0 | wc --lines
-${run_simu_load}   docker run -d --name gnbe2_simu --env gNBipv4=localhost  --env gNBport=36422  --env duration=600000000000 --env indicationReportRate=1000000000 --env indicationInsertRate=0 -p 5577:36422/sctp snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/gnbe2_sim:1.0.5
+${run_simu_load}   docker run -d --name gnbe2_simu --env gNBipv4=localhost  --env gNBport=36422  --env duration=600000000000 --env indicationReportRate=1000000000 --env indicationInsertRate=0 -p 5577:36422/sctp snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/gnbe2_simu:1.0.6
 ${stop_simu}  docker stop gnbe2_simu
-${run_simu_regular}  docker run -d --name gnbe2_simu --env gNBipv4=localhost  --env gNBport=36422 --env duration=600000000000 --env indicationReportRate=0 --env indicationInsertRate=0 -p 5577:36422/sctp snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/gnbe2_sim:1.0.5
+${run_simu_regular}  docker run -d --name gnbe2_simu --env gNBipv4=localhost  --env gNBport=36422 --env duration=600000000000 --env indicationReportRate=0 --env indicationInsertRate=0 -p 5577:36422/sctp snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/gnbe2_simu:1.0.6
 ${docker_Remove}    docker rm gnbe2_simu
-${docker_cp}        docker cp ../Resource/configuration.yaml e2mgr:/opt/E2Manager/resources/configuration.yaml
 ${docker_restart}   docker restart e2mgr
 ${restart_simu}  docker restart gnbe2_simu
 ${restart_e2adapter}  docker restart e2adapter
@@ -39,6 +38,13 @@
 ${stop_docker_e2}      docker stop e2
 ${start_redis}   docker run -d --name redis -p 6379:6379 --env DBAAS_SERVICE_HOST=10.0.2.15  snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/dbass:1.0.0
 ${redis_remove}    docker rm redis
+${restart_simu}  docker restart gnbe2_simu
+${start_e2}  docker start e2
+${stop_docker_e2}      docker stop e2
+${Run_Config}       docker exec gnbe2_simu pkill gnbe2_simu -INT
+${Save_e2_log}      docker logs gnbe2_simu > gnb.log
+${Save_e2mgr_log}   docker logs e2mgr > e2mgr.log
+
 
 
 
diff --git a/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot b/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot
index 08ed01b..aa61d40 100755
--- a/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot
+++ b/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot
@@ -29,7 +29,7 @@
     Integer     response status       200
 
 X2 - Get Nodeb
-    Get Request node b enb test1
+    Get Request Node B Enb test1
     Integer  response status  200
     String   response body ranName    test1
     String   response body ip    10.0.2.15