raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ============LICENSE_START======================================================= |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 3 | * Copyright (C) 2023-2024 Nordix Foundation |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 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 | * SPDX-License-Identifier: Apache-2.0 |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
| 21 | *** Settings *** |
| 22 | Documentation NCMP |
| 23 | |
| 24 | Library Collections |
| 25 | Library OperatingSystem |
| 26 | Library RequestsLibrary |
| 27 | Library BuiltIn |
| 28 | Library ConfluentKafkaLibrary |
mpriyank | a4a5591 | 2024-08-14 15:02:45 +0100 | [diff] [blame] | 29 | Library String |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 30 | |
| 31 | Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT} |
| 32 | |
| 33 | *** Variables *** |
| 34 | |
| 35 | ${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= |
| 36 | ${topic} data-operation-client-topic |
| 37 | ${ncmpBasePath} /ncmp |
| 38 | ${expectedRequestId} ${EMPTY} |
| 39 | ${dmipluginCsitStubUrl} http://${DMI_CSIT_STUB_HOST}:${DMI_CSIT_STUB_PORT} |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 40 | ${newCmHandleRequestBody} {"dmiPlugin":"${dmipluginCsitStubUrl}","createdCmHandles":[{"cmHandle":"CMHandle1"}]} |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 41 | |
| 42 | *** Test Cases *** |
| 43 | |
| 44 | NCMP Data Operation, forwarded to DMI, response on Client Topic |
| 45 | ${uri}= Set Variable ${ncmpBasePath}/v1/data |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 46 | ${dataOperationReqBody}= Get Binary File ${DATADIR_CPS_CORE}${/}dataOperationRequest.json |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 47 | ${params}= Create Dictionary topic=${topic} |
| 48 | ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} |
| 49 | POST On Session CPS_URL ncmpInventory/v1/ch headers=${headers} data=${newCmHandleRequestBody} |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 50 | ${getCmHandleUri}= Set Variable ${ncmpBasePath}/v1/ch/CMHandle1 |
| 51 | ${getCmHandleHeaders}= Create Dictionary Authorization=${auth} |
mpriyank | d3c1e72 | 2024-08-09 12:57:18 +0100 | [diff] [blame] | 52 | Wait Until Keyword Succeeds 20sec 200ms Is CM Handle READY ${getCmHandleUri} ${getCmHandleHeaders} CMHandle1 |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 53 | ${response}= POST On Session CPS_URL ${uri} params=${params} headers=${headers} data=${dataOperationReqBody} |
| 54 | Set Global Variable ${expectedRequestId} ${response.json()}[requestId] |
| 55 | Should Be Equal As Strings ${response.status_code} 200 |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 56 | |
| 57 | Consume cloud event from client topic |
halil.cakal | 1340c57 | 2023-04-12 15:19:45 +0100 | [diff] [blame] | 58 | ${group_id}= Create Consumer auto_offset_reset=earliest |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 59 | Subscribe Topic topics=${topic} group_id=${group_id} |
| 60 | ${messages}= Poll group_id=${group_id} only_value=false |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 61 | ${event} Set Variable ${messages}[0] |
| 62 | ${headers} Set Variable ${event.headers()} |
halil.cakal | bf89978 | 2023-09-11 12:34:37 +0100 | [diff] [blame] | 63 | FOR ${header_key_value_pair} IN @{headers} |
| 64 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_specversion" "1.0" |
halil.cakal | bf89978 | 2023-09-11 12:34:37 +0100 | [diff] [blame] | 65 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_type" "org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent" |
| 66 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "${expectedRequestId}" |
mpriyank | 79ff69c | 2024-08-13 09:39:45 +0100 | [diff] [blame] | 67 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_source" "DMI" |
halil.cakal | bf89978 | 2023-09-11 12:34:37 +0100 | [diff] [blame] | 68 | END |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 69 | [Teardown] Basic Teardown ${group_id} |
| 70 | |
| 71 | *** Keywords *** |
halil.cakal | bf89978 | 2023-09-11 12:34:37 +0100 | [diff] [blame] | 72 | Compare Header Values |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 73 | [Arguments] ${header_key} ${header_value} ${header_to_check} ${expected_header_value} |
halil.cakal | bf89978 | 2023-09-11 12:34:37 +0100 | [diff] [blame] | 74 | IF "${header_key}" == ${header_to_check} |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 75 | Should Be Equal As Strings "${header_value}" ${expected_header_value} |
| 76 | END |
| 77 | |
| 78 | Is CM Handle READY |
| 79 | [Arguments] ${uri} ${headers} ${cmHandle} |
| 80 | ${response}= GET On Session CPS_URL ${uri} headers=${headers} |
| 81 | Should Be Equal As Strings ${response.status_code} 200 |
mpriyank | a4a5591 | 2024-08-14 15:02:45 +0100 | [diff] [blame] | 82 | ${number_of_items}= Count Items In JSON Response ${response} |
| 83 | Should Be True ${number_of_items} > 0 |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 84 | FOR ${item} IN ${response.json()} |
| 85 | IF "${item['cmHandle']}" == "${cmHandle}" |
| 86 | Should Be Equal As Strings ${item['state']['cmHandleState']} READY |
| 87 | END |
halil.cakal | bf89978 | 2023-09-11 12:34:37 +0100 | [diff] [blame] | 88 | END |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 89 | |
mpriyank | a4a5591 | 2024-08-14 15:02:45 +0100 | [diff] [blame] | 90 | Count Items In JSON Response |
| 91 | [Arguments] ${response} |
| 92 | ${json_data}= Evaluate json.loads('${response.content.decode("utf-8")}') json |
| 93 | ${number_of_items}= Get Length ${json_data} |
| 94 | RETURN ${number_of_items} |
| 95 | |
raviteja.karumuri | a3aba7c | 2023-07-06 13:48:31 +0100 | [diff] [blame] | 96 | Basic Teardown |
| 97 | [Arguments] ${group_id} |
| 98 | Unsubscribe ${group_id} |
| 99 | Close Consumer ${group_id} |
| 100 | |