[RICPLT-2523] Add Setup automation tests... 11/2011/1
authoris005q <idan.shalom@intl.att.com>
Thu, 12 Dec 2019 11:21:41 +0000 (13:21 +0200)
committeris005q <idan.shalom@intl.att.com>
Thu, 12 Dec 2019 11:21:47 +0000 (13:21 +0200)
Change-Id: Ib09fd0eed7dba01a8f99482c0905b931155f93d2
Signed-off-by: is005q <idan.shalom@intl.att.com>
Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot
Automation/Tests/Resource/Keywords.robot
Automation/Tests/Resource/resource.robot
Automation/Tests/Scripts/e2mdbscripts.py [new file with mode: 0644]
Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot
Automation/Tests/X2-Setup/x2_setup_existing_assoc_test.robot [new file with mode: 0644]
Automation/Tests/X2-Setup/x2_setup_existing_not_assoc_test.robot [new file with mode: 0644]
E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go

index 8891608..364b7d5 100755 (executable)
@@ -25,9 +25,6 @@ Library     Collections
 Library     REST      ${url}
 
 
 Library     REST      ${url}
 
 
-*** Variables ***
-${restart_docker_sim}      docker restart gnbe2_simu
-
 
 *** Test Cases ***
 
 
 *** Test Cases ***
 
@@ -55,11 +52,7 @@ Verfiy Shutdown ConnectionStatus
     String   response body connectionStatus    SHUT_DOWN
 
 Restart simualtor
     String   response body connectionStatus    SHUT_DOWN
 
 Restart simualtor
-
-    Run And Return Rc And Output    ${restart_docker_sim}
-    ${result}=  Run And Return Rc And Output     ${docker_command}
-    Should Be Equal As Integers    ${result[1]}    ${docker_number}
-
+    Restart simulator
 
 repare Ran in Connected connectionStatus
     Post Request setup node b x-2
 
 repare Ran in Connected connectionStatus
     Post Request setup node b x-2
index 96e5b57..982fe57 100755 (executable)
@@ -77,6 +77,7 @@ Stop Simulator
     Run And Return Rc And Output    ${stop_simu}
 
 
     Run And Return Rc And Output    ${stop_simu}
 
 
+
 Prepare Simulator For Load Information
      Run And Return Rc And Output    ${stop_simu}
      Run And Return Rc And Output    ${docker_Remove}
 Prepare Simulator For Load Information
      Run And Return Rc And Output    ${stop_simu}
      Run And Return Rc And Output    ${docker_Remove}
@@ -149,6 +150,12 @@ Stop Dbass
      ${result}=  Run And Return Rc And Output     ${docker_command}
      Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
 
      ${result}=  Run And Return Rc And Output     ${docker_command}
      Should Be Equal As Integers    ${result[1]}    ${docker_number-1}
 
+Restart simulator
+
+    Run And Return Rc And Output    ${restart_docker_sim}
+    ${result}=  Run And Return Rc And Output     ${docker_command}
+    Should Be Equal As Integers    ${result[1]}    ${docker_number}
+
 
 
 
 
 
 
index dd54137..cdecf81 100755 (executable)
@@ -58,6 +58,7 @@ ${dbass_stop}      docker stop dbass
 ${restart_simu}  docker restart gnbe2_simu
 ${start_e2}  docker start e2
 ${stop_docker_e2}      docker stop e2
 ${restart_simu}  docker restart gnbe2_simu
 ${start_e2}  docker start e2
 ${stop_docker_e2}      docker stop e2
+${restart_docker_sim}      docker restart gnbe2_simu
 ${Run_Config}       docker exec gnbe2_simu pkill gnbe2_simu -INT
 ${403_reset_message}    "Activity X2_RESET rejected. RAN current state DISCONNECTED does not allow its execution "
 
 ${Run_Config}       docker exec gnbe2_simu pkill gnbe2_simu -INT
 ${403_reset_message}    "Activity X2_RESET rejected. RAN current state DISCONNECTED does not allow its execution "
 
diff --git a/Automation/Tests/Scripts/e2mdbscripts.py b/Automation/Tests/Scripts/e2mdbscripts.py
new file mode 100644 (file)
index 0000000..7b9475b
--- /dev/null
@@ -0,0 +1,49 @@
+##############################################################################
+#
+#   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.
+#
+##############################################################################
+
+import config
+import redis
+import cleanup_db
+import json
+
+def getRedisClientDecodeResponse():
+    c = config.redis_ip_address
+    p = config.redis_ip_port
+    return redis.Redis(host=c, port=p, db=0, decode_responses=True)
+
+def verify_ran_is_associated_with_e2t_instance(ranName, e2tAddress):
+    r = getRedisClientDecodeResponse()
+    e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
+    e2tInstanceDic = json.loads(e2tInstanceJson)
+    assocRanList = e2tInstanceDic.get("associatedRanList")
+    return ranName in assocRanList
+
+# def dissociate_ran_from_e2tInstance(ranName, e2tAddress):
+#     r = getRedisClientDecodeResponse()
+#     e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
+#     e2tInstanceDic = json.loads(e2tInstanceJson)
+#     assocRanList = e2tInstanceDic.get("associatedRanList")
+#     print(assocRanList)
+#     assocRanList.remove(ranName)
+#     updatedE2tInstanceJson = json.dumps(e2tInstanceDic)
+#     print(updatedE2tInstanceJson)
+#     r.set("{e2Manager},E2TInstance:"+e2tAddress, updatedE2tInstanceJson)
+#     nodebBytes = r.get("{e2Manager},RAN:"+ranName)
+#     encoded = nodebBytes.decode().replace(e2tAddress,"").encode()
+#     r.set("{e2Manager},RAN:"+ranName, encoded)
+
index da14d32..4ad0dbe 100755 (executable)
@@ -24,6 +24,7 @@ Resource    ../Resource/scripts_variables.robot
 Library     OperatingSystem
 Library     ../Scripts/find_rmr_message.py
 Library     ../Scripts/rsmscripts.py
 Library     OperatingSystem
 Library     ../Scripts/find_rmr_message.py
 Library     ../Scripts/rsmscripts.py
+Library     ../Scripts/e2mdbscripts.py
 Library     REST      ${url}
 
 *** Test Cases ***
 Library     REST      ${url}
 
 *** Test Cases ***
@@ -39,6 +40,7 @@ X2 - Get Nodeb
     Integer  response body port     5577
     String   response body connectionStatus    CONNECTED
     String   response body nodeType     ENB
     Integer  response body port     5577
     String   response body connectionStatus    CONNECTED
     String   response body nodeType     ENB
+    String   response body associatedE2tInstanceAddress     e2t.att.com:38000  
     String   response body enb enbType     MACRO_ENB
     Integer  response body enb servedCells 0 pci  99
     String   response body enb servedCells 0 cellId   02f829:0007ab00
     String   response body enb enbType     MACRO_ENB
     Integer  response body enb servedCells 0 pci  99
     String   response body enb servedCells 0 cellId   02f829:0007ab00
@@ -65,4 +67,11 @@ RSM RESOURCE STATUS REQUEST message sent
 
 Verify RSM RAN info exists in redis
    ${result}=   rsmscripts.verify_rsm_ran_info_start_false
 
 Verify RSM RAN info exists in redis
    ${result}=   rsmscripts.verify_rsm_ran_info_start_false
-   Should Be Equal As Strings  ${result}    True
\ No newline at end of file
+   Should Be Equal As Strings  ${result}    True
+
+Verify RAN is associated with E2T instance
+   ${result}    e2mdbscripts.verify_ran_is_associated_with_e2t_instance     test1    e2t.att.com:38000
+   Should Be True    ${result}
+
+
+
diff --git a/Automation/Tests/X2-Setup/x2_setup_existing_assoc_test.robot b/Automation/Tests/X2-Setup/x2_setup_existing_assoc_test.robot
new file mode 100644 (file)
index 0000000..e3eb058
--- /dev/null
@@ -0,0 +1,63 @@
+##############################################################################
+#
+#   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
+Resource    ../Resource/scripts_variables.robot
+Library     OperatingSystem
+Library     ../Scripts/find_rmr_message.py
+Library     ../Scripts/rsmscripts.py
+Library     ../Scripts/e2mdbscripts.py
+Library     REST      ${url}
+
+*** Test Cases ***
+X2 - Setup Test 1
+    Post Request setup node b x-2
+    Integer     response status       204
+
+X2 - Setup Test 2
+    Post Request setup node b x-2
+    Integer     response status       204
+
+X2 - Get Nodeb
+    Get Request Node B Enb test1
+    Integer  response status  200
+    String   response body ranName    test1
+    String   response body associatedE2tInstanceAddress     e2t.att.com:38000  
+
+prepare logs for tests
+    Remove log files
+    Save logs
+
+X2 - RAN Connected message going to be sent
+    ${result}    find_rmr_message.verify_logs     ${EXECDIR}   ${e2mgr_log_filename}  ${RAN_CONNECTED_message_type}    ${Meid_test1}
+    Should Be Equal As Strings    ${result}      True
+
+RSM RESOURCE STATUS REQUEST message sent
+    ${result}    find_rmr_message.verify_logs     ${EXECDIR}    ${rsm_log_filename}  ${RIC_RES_STATUS_REQ_message_type_successfully_sent}    ${RAN_NAME_test1}
+    Should Be Equal As Strings    ${result}      True
+
+Verify RSM RAN info exists in redis
+   ${result}=   rsmscripts.verify_rsm_ran_info_start_false
+   Should Be Equal As Strings  ${result}    True
+
+Verify RAN is associated with E2T instance
+   ${result}    e2mdbscripts.verify_ran_is_associated_with_e2t_instance     test1    e2t.att.com:38000
+   Should Be True    ${result}
diff --git a/Automation/Tests/X2-Setup/x2_setup_existing_not_assoc_test.robot b/Automation/Tests/X2-Setup/x2_setup_existing_not_assoc_test.robot
new file mode 100644 (file)
index 0000000..457ca9c
--- /dev/null
@@ -0,0 +1,71 @@
+##############################################################################
+#
+#   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
+Resource    ../Resource/scripts_variables.robot
+Library     OperatingSystem
+Library     ../Scripts/find_rmr_message.py
+Library     ../Scripts/rsmscripts.py
+Library     ../Scripts/e2mdbscripts.py
+Library     REST      ${url}
+
+*** Test Cases ***
+X2 - Setup Test 1
+    Post Request setup node b x-2
+    Integer     response status       204
+
+Restart Simulator
+    Restart Simulator
+
+Verify RAN is NOT associated with E2T instance
+   ${result}    e2mdbscripts.verify_ran_is_associated_with_e2t_instance     test1    e2t.att.com:38000
+   Should Be True    ${result} == False
+
+
+X2 - Setup Test 2
+    Post Request setup node b x-2
+    Integer     response status       204
+
+X2 - Get Nodeb
+    Get Request Node B Enb test1
+    Integer  response status  200
+    String   response body ranName    test1
+    String   response body associatedE2tInstanceAddress     e2t.att.com:38000  
+
+prepare logs for tests
+    Remove log files
+    Save logs
+
+X2 - RAN Connected message going to be sent
+    ${result}    find_rmr_message.verify_logs     ${EXECDIR}   ${e2mgr_log_filename}  ${RAN_CONNECTED_message_type}    ${Meid_test1}
+    Should Be Equal As Strings    ${result}      True
+
+RSM RESOURCE STATUS REQUEST message sent
+    ${result}    find_rmr_message.verify_logs     ${EXECDIR}    ${rsm_log_filename}  ${RIC_RES_STATUS_REQ_message_type_successfully_sent}    ${RAN_NAME_test1}
+    Should Be Equal As Strings    ${result}      True
+
+Verify RSM RAN info exists in redis
+   ${result}=   rsmscripts.verify_rsm_ran_info_start_false
+   Should Be Equal As Strings  ${result}    True
+
+Verify RAN is associated with E2T instance
+   ${result}    e2mdbscripts.verify_ran_is_associated_with_e2t_instance     test1    e2t.att.com:38000
+   Should Be True    ${result}
index 9f1fbb2..6ca7b0b 100644 (file)
@@ -326,6 +326,20 @@ func TestSetupExistingRanWithAssocE2TInstanceUpdateNodebFailure(t *testing.T) {
        ranSetupManagerMock.AssertNotCalled(t, "ExecuteSetup")
 }
 
        ranSetupManagerMock.AssertNotCalled(t, "ExecuteSetup")
 }
 
+func TestSetupExistingRanWithAssocE2TInstanceExecuteSetupRmrError(t *testing.T) {
+       readerMock, writerMock, handler, e2tInstancesManagerMock, ranSetupManagerMock := initSetupRequestTest(t, entities.E2ApplicationProtocol_X2_SETUP_REQUEST)
+       nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress:E2TAddress, ConnectionStatus: entities.ConnectionStatus_CONNECTED}
+       readerMock.On("GetNodeb", RanName).Return(nb , nil)
+       updatedNb := *nb
+       updatedNb.ConnectionAttempts = 0
+       writerMock.On("UpdateNodebInfo", &updatedNb).Return(nil)
+       ranSetupManagerMock.On("ExecuteSetup", &updatedNb, entities.ConnectionStatus_CONNECTED).Return(e2managererrors.NewRmrError())
+       _, err := handler.Handle(models.SetupRequest{"127.0.0.1", 8080, RanName,})
+       assert.IsType(t, &e2managererrors.RmrError{}, err)
+       e2tInstancesManagerMock.AssertNotCalled(t, "SelectE2TInstance")
+       e2tInstancesManagerMock.AssertNotCalled(t, "AssociateRan")
+}
+
 func TestSetupExistingRanWithAssocE2TInstanceConnectedSuccess(t *testing.T) {
        readerMock, writerMock, handler, e2tInstancesManagerMock, ranSetupManagerMock := initSetupRequestTest(t, entities.E2ApplicationProtocol_X2_SETUP_REQUEST)
        nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress:E2TAddress, ConnectionStatus: entities.ConnectionStatus_CONNECTED}
 func TestSetupExistingRanWithAssocE2TInstanceConnectedSuccess(t *testing.T) {
        readerMock, writerMock, handler, e2tInstancesManagerMock, ranSetupManagerMock := initSetupRequestTest(t, entities.E2ApplicationProtocol_X2_SETUP_REQUEST)
        nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress:E2TAddress, ConnectionStatus: entities.ConnectionStatus_CONNECTED}