Cleaning tests 23/58023/2
authorMariusz Wagner <mariusz.wagner@nokia.com>
Mon, 30 Jul 2018 12:19:50 +0000 (14:19 +0200)
committerMariusz Wagner <mariusz.wagner@nokia.com>
Mon, 30 Jul 2018 12:36:10 +0000 (14:36 +0200)
Code refactor and clean TC code
Issue-ID: INT-604

Change-Id: I6b47dae37eb3b3897698bab738abcc8aac97d90d
Signed-off-by: Mariusz Wagner <mariusz.wagner@nokia.com>
test/csit/plans/dcaegen2/prh-testsuites/setup.sh
test/csit/tests/dcaegen2/prh-testcases/prh_tests.robot
test/csit/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
test/csit/tests/dcaegen2/prh-testcases/resources/prh_library.robot
test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator
test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator

index e4b1cd7..058ed20 100644 (file)
@@ -8,7 +8,7 @@ export AAI_SIMULATOR="aai_simulator"
 
 cd ${WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/resources/
 
-docker login -u docker -p docker nexus3.onap.org:10003
+docker login -u docker -p docker nexus3.onap.org:10001
 docker-compose up -d --build
 
 # Wait for initialization of Docker containers
@@ -39,8 +39,6 @@ echo AAI_SIMULATOR_IP=${AAI_SIMULATOR_IP}
 
 # Wait for initialization of docker services
 for i in {1..10}; do
-    curl -sS -m 1 localhost:2222 && \
-    curl -sS -m 1 localhost:3333 && \
     curl -sS -m 1 localhost:8100/heartbeat && break
     echo sleep ${i}
     sleep ${i}
index 1504895..b7013c4 100644 (file)
@@ -1,7 +1,7 @@
 *** Settings ***
 Documentation     Integration tests for PRH.
 ...               PRH receive events from DMaaP and produce or not PNF_READY notification depends on required fields in received event.
-Suite Setup       Run keywords    Create headers 
+Suite Setup       Run keywords    Create header 
 ...                               Create sessions
 Library           resources/PrhLibrary.py
 Resource          resources/prh_library.robot
@@ -46,8 +46,8 @@ Get valid event from DMaaP and record in AAI does not exist
     [Documentation]    PRH get valid event from DMaaP with all required fields and in AAI record doesn't exist - PRH does not produce PNF_READY notification
     [Tags]    PRH    Missing AAI record
     [Timeout]    30s
-    Set pnf name in AAI    wrong_aai_record
-    Set event in DMAAP    ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
+    Set PNF name in AAI    wrong_aai_record
+    Set event in DMaaP    ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
     Wait Until Keyword Succeeds    100x    300ms    Check PRH log    org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException: Incorrect response code for continuation of tasks workflow
 
 Get valid event from DMaaP and AAI is not responding
@@ -55,5 +55,5 @@ Get valid event from DMaaP and AAI is not responding
     [Tags]    PRH    AAI
     [Timeout]    180s
     Stop AAI
-    Set event in DMAAP    ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
+    Set event in DMaaP    ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
     Wait Until Keyword Succeeds    100x    300ms    Check PRH log    java.net.NoRouteToHostException: Host is unreachable (Host unreachable)
index 03e84b3..3cac3b4 100644 (file)
@@ -1,7 +1,7 @@
 version: '3'
 services:
   prh:
-    image: nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.prh.prh-app-server
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.prh.prh-app-server
     command: >
           --dmaap.dmaapConsumerConfiguration.dmaapPortNumber=2222
           --dmaap.dmaapProducerConfiguration.dmaapPortNumber=2222
index 226973b..10bc26c 100644 (file)
@@ -3,29 +3,29 @@ Library           RequestsLibrary
 Library           Collections
 
 *** Keywords ***
-Create headers
+Create header
     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
-    Set Suite Variable    ${global_headers}    ${headers}
+    Set Suite Variable    ${suite_headers}    ${headers}
 
 Create sessions
     Create Session    dmaap_session    ${DMAAP_SIMULATOR_URL}
-    Set Suite Variable    ${global_dmaap_session}    dmaap_session
+    Set Suite Variable    ${suite_dmaap_session}    dmaap_session
     Create Session    aai_session    ${AAI_SIMULATOR_URL}
-    Set Suite Variable    ${global_aai_session}    aai_session
+    Set Suite Variable    ${suite_aai_session}    aai_session
 
 Invalid event processing
     [Arguments]    ${input_invalid_event_in_dmaap}
     [Timeout]    30s
-    Set event in DMAAP    ${input_invalid_event_in_dmaap}
+    Set event in DMaaP    ${input_invalid_event_in_dmaap}
     Wait Until Keyword Succeeds    100x    100ms    Check PRH log    INFO 1 --- [pool-2-thread-1] o.o.d.s.prh.tasks.DmaapConsumerTaskImpl \ : Consumed model from DmaaP: ${input_invalid_event_in_dmaap}
 
 Valid event processing
     [Arguments]    ${input_valid_event_in_dmaap}
     [Timeout]    30s
-    ${posted_event_to_dmaap}=    Create pnf ready notification    ${input_valid_event_in_dmaap}
-    ${pnf_name}=    Create pnf name    ${input_valid_event_in_dmaap}
-    Set pnf name in AAI    ${pnf_name}
-    Set event in DMAAP    ${input_valid_event_in_dmaap}
+    ${posted_event_to_dmaap}=    Create PNF_Ready notification    ${input_valid_event_in_dmaap}
+    ${pnf_name}=    Create PNF name    ${input_valid_event_in_dmaap}
+    Set PNF name in AAI    ${pnf_name}
+    Set event in DMaaP    ${input_valid_event_in_dmaap}
     Wait Until Keyword Succeeds    100x    300ms    Check PNF_READY notification    ${posted_event_to_dmaap}
 
 Check PRH log
@@ -35,16 +35,16 @@ Check PRH log
 
 Check PNF_READY notification
     [Arguments]    ${posted_event_to_dmaap}
-    ${resp}=    Get Request    ${global_dmaap_session}    /events/pnfReady    headers=${global_headers}
+    ${resp}=    Get Request    ${suite_dmaap_session}    /events/pnfReady    headers=${suite_headers}
     Should Be Equal    ${resp.text}    ${posted_event_to_dmaap}
 
-Set pnf name in AAI
+Set PNF name in AAI
     [Arguments]    ${pnfs_name}
     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=text/html
-    ${resp}=    Put Request    ${global_aai_session}    /set_pnfs    headers=${headers}    data=${pnfs_name}
+    ${resp}=    Put Request    ${suite_aai_session}    /set_pnfs    headers=${headers}    data=${pnfs_name}
     Should Be Equal As Strings    ${resp.status_code}    200
 
-Set event in DMAAP
+Set event in DMaaP
     [Arguments]    ${event_in_dmaap}
-    ${resp}=    Put Request    ${global_dmaap_session}    /set_get_event    headers=${global_headers}    data=${event_in_dmaap}
+    ${resp}=    Put Request    ${suite_dmaap_session}    /set_get_event    headers=${suite_headers}    data=${event_in_dmaap}
     Should Be Equal As Strings    ${resp.status_code}    200
index d5deaca..ca8bdd1 100644 (file)
@@ -11,9 +11,7 @@ class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             global pnfs
             content_length = int(self.headers['Content-Length'])
             pnfs = self.rfile.read(content_length)
-            self.send_response(200)
-            self.send_header('Content-Type', 'application/json')
-            self.end_headers()
+            _header_200_and_json(self)
             
         return
 
@@ -28,14 +26,11 @@ class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             
         return
 
-    def do_GET(self):
-        self.send_response(200)
-        self.send_header('Content-Type', 'application/json')
-        self.end_headers()
-        self.wfile.write('GET')
-        self.wfile.close()
-        
-        return
+
+def _header_200_and_json(self):
+    self.send_response(200)
+    self.send_header('Content-Type', 'application/json')
+    self.end_headers()
 
 
 def _main_(handler_class=AAIHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
index b538282..dd2d194 100644 (file)
@@ -12,9 +12,7 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             global received_event_to_get_method
             content_length = int(self.headers['Content-Length'])
             received_event_to_get_method = self.rfile.read(content_length)
-            self.send_response(200)
-            self.send_header('Content-Type', 'application/json')
-            self.end_headers()
+            _header_200_and_json(self)
             
         return
 
@@ -23,35 +21,29 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             global posted_event_from_prh
             content_length = int(self.headers['Content-Length'])
             posted_event_from_prh = self.rfile.read(content_length)
-            self.send_response(200)
-            self.send_header('Content-Type', 'application/json')
-            self.end_headers()
+            _header_200_and_json(self)
             
         return
 
     def do_GET(self):
         if re.search('/events/unauthenticated.SEC_OTHER_OUTPUT/OpenDcae-c12/c12', self.path):
-            self.send_response(200)
-            self.send_header('Content-Type', 'application/json')
-            self.end_headers()
+            _header_200_and_json(self)
             self.wfile.write(received_event_to_get_method)
             self.wfile.close()
         elif re.search('/events/pnfReady', self.path):
-            self.send_response(200)
-            self.send_header('Content-Type', 'application/json')
-            self.end_headers()
+            _header_200_and_json(self)
             self.wfile.write(posted_event_from_prh)
             self.wfile.close()
-        else:
-            self.send_response(200)
-            self.send_header('Content-Type', 'application/json')
-            self.end_headers()
-            self.wfile.write('GET else')
-            self.wfile.close()
-            
+
         return
 
 
+def _header_200_and_json(self):
+    self.send_response(200)
+    self.send_header('Content-Type', 'application/json')
+    self.end_headers()
+
+
 def _main_(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
 
     if sys.argv[1:]: