Verify kafka headers by header name 26/135926/6
authorhalil.cakal <halil.cakal@est.tech>
Mon, 11 Sep 2023 11:34:37 +0000 (12:34 +0100)
committerhalil.cakal <halil.cakal@est.tech>
Mon, 11 Sep 2023 16:14:38 +0000 (17:14 +0100)
- Change subscription notification flow
- Change data operations flow

Issue-ID: CPS-1613
Change-Id: I5c8aeb26c925071d810975dd6686309b7ad6b76f
Signed-off-by: halil.cakal <halil.cakal@est.tech>
csit/tests/cps-data-operations/cps-data-operations.robot
csit/tests/cps-subscriptions/cps-subscription-notification.robot

index b2912ee..16eb5f2 100644 (file)
@@ -58,17 +58,20 @@ Consume cloud event from client topic
     ${messages}=         Poll                group_id=${group_id}     only_value=false
     ${event}                        Set Variable                      ${messages}[0]
     ${headers}                      Set Variable                      ${event.headers()}
-    ${specVersionHeaderValue}       Set Variable                      ${headers[1][1]}
-    ${sourceHeaderValue}            Set Variable                      ${headers[3][1]}
-    ${typeHeaderValue}              Set Variable                      ${headers[4][1]}
-    ${correlationIdHeaderValue}     Set Variable                      ${headers[8][1]}
-    Should Be Equal As Strings      ${specVersionHeaderValue}         1.0
-    Should Be Equal As Strings      ${sourceHeaderValue}              DMI
-    Should Be Equal As Strings      ${correlationIdHeaderValue}       ${expectedRequestId}
-    Should Be Equal As Strings      ${typeHeaderValue}                org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent
+    FOR   ${header_key_value_pair}   IN  @{headers}
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}      "ce_specversion"      "1.0"
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}      "ce_source"           "DMI"
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}      "ce_type"             "org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent"
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}      "ce_correlationid"    "${expectedRequestId}"
+    END
     [Teardown]                      Basic Teardown                    ${group_id}
 
 *** Keywords ***
+Compare Header Values
+    [Arguments]                    ${header_key}        ${header_value}     ${header_to_check}       ${expected_header_value}
+    IF   "${header_key}" == ${header_to_check}
+        Should Be Equal As Strings              "${header_value}"    ${expected_header_value}
+    END
 
 Basic Teardown
     [Arguments]     ${group_id}
index b0e8665..2d5152a 100644 (file)
@@ -69,16 +69,20 @@ All Messages Are Produced and Consumed
     ${result}=                      Poll                        group_id=${GROUP_ID}      only_value=False
     ${headers}                      Set Variable                      ${result[0].headers()}
     ${value}                        Set Variable                      ${result[0].value()}
-    ${valueAsDict}=                 Evaluate                          json.loads("""${value}""")                              json
-    ${specVersionHeaderValue}       Set Variable                      ${headers[1][1]}
-    ${sourceHeaderValue}            Set Variable                      ${headers[3][1]}
-    ${typeHeaderValue}              Set Variable                      ${headers[4][1]}
-    ${correlationIdHeaderValue}     Set Variable                      ${headers[6][1]}
+    ${valueAsDict}=                 Evaluate                          json.loads("""${value}""")                        json
+    FOR   ${header_key_value_pair}   IN  @{headers}
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}     "ce_specversion"      "1.0"
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}     "ce_source"           "NCMP"
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}     "ce_type"             "subscriptionCreatedStatus"
+        Compare Header Values       ${header_key_value_pair[0]}   ${header_key_value_pair[1]}     "ce_correlationid"    "SCO-9989752cm-subscription-001"
+    END
     Dictionaries Should Be Equal    ${valueAsDict}                    ${ncmpOutEventJsonGlobal}
-    Should Be Equal As Strings      ${specVersionHeaderValue}         1.0
-    Should Be Equal As Strings      ${sourceHeaderValue}              NCMP
-    Should Be Equal As Strings      ${typeHeaderValue}                subscriptionCreatedStatus
-    Should Be Equal As Strings      ${correlationIdHeaderValue}       SCO-9989752cm-subscription-001
+
+Compare Header Values
+    [Arguments]                    ${header_key}        ${header_value}      ${header_to_check}       ${expected_header_value}
+    IF   "${header_key}" == ${header_to_check}
+        Should Be Equal As Strings              "${header_value}"    ${expected_header_value}
+    END
 
 Basic Teardown
     [Arguments]                     ${group_id}