blob: 85e8a2a85770d15f964d9df042e144841c67cac9 [file] [log] [blame]
raviteja.karumuria3aba7c2023-07-06 13:48:31 +01001/*
2 * ============LICENSE_START=======================================================
sourabh_sourabh02d8bf82024-01-04 17:01:27 +00003 * Copyright (C) 2023-2024 Nordix Foundation
raviteja.karumuria3aba7c2023-07-06 13:48:31 +01004 * ================================================================================
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 ***
22Documentation NCMP
23
24Library Collections
25Library OperatingSystem
26Library RequestsLibrary
27Library BuiltIn
28Library ConfluentKafkaLibrary
29
30Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
31
32*** Variables ***
33
34${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
35${topic} data-operation-client-topic
36${ncmpBasePath} /ncmp
37${expectedRequestId} ${EMPTY}
38${dmipluginCsitStubUrl} http://${DMI_CSIT_STUB_HOST}:${DMI_CSIT_STUB_PORT}
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000039${newCmHandleRequestBody} {"dmiPlugin":"${dmipluginCsitStubUrl}","createdCmHandles":[{"cmHandle":"CMHandle1"}]}
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010040
41*** Test Cases ***
42
43NCMP Data Operation, forwarded to DMI, response on Client Topic
44 ${uri}= Set Variable ${ncmpBasePath}/v1/data
JvD_Ericsson14d37302023-12-07 15:33:09 +000045 ${dataOperationReqBody}= Get Binary File ${DATADIR_CPS_CORE}${/}dataOperationRequest.json
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010046 ${params}= Create Dictionary topic=${topic}
47 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
48 POST On Session CPS_URL ncmpInventory/v1/ch headers=${headers} data=${newCmHandleRequestBody}
JvD_Ericsson820235c2024-01-22 13:32:34 +000049 ${getCmHandleUri}= Set Variable ${ncmpBasePath}/v1/ch/CMHandle1
50 ${getCmHandleHeaders}= Create Dictionary Authorization=${auth}
mpriyankd3c1e722024-08-09 12:57:18 +010051 Wait Until Keyword Succeeds 20sec 200ms Is CM Handle READY ${getCmHandleUri} ${getCmHandleHeaders} CMHandle1
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010052 ${response}= POST On Session CPS_URL ${uri} params=${params} headers=${headers} data=${dataOperationReqBody}
53 Set Global Variable ${expectedRequestId} ${response.json()}[requestId]
54 Should Be Equal As Strings ${response.status_code} 200
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010055
56Consume cloud event from client topic
halil.cakal1340c572023-04-12 15:19:45 +010057 ${group_id}= Create Consumer auto_offset_reset=earliest
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010058 Subscribe Topic topics=${topic} group_id=${group_id}
59 ${messages}= Poll group_id=${group_id} only_value=false
JvD_Ericsson820235c2024-01-22 13:32:34 +000060 ${event} Set Variable ${messages}[0]
61 ${headers} Set Variable ${event.headers()}
halil.cakalbf899782023-09-11 12:34:37 +010062 FOR ${header_key_value_pair} IN @{headers}
63 Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_specversion" "1.0"
halil.cakalbf899782023-09-11 12:34:37 +010064 Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_type" "org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent"
65 Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "${expectedRequestId}"
mpriyankd3c1e722024-08-09 12:57:18 +010066 # Need to check the root cause of this failure. To be investigated separately as part of CPS-2363
67 # Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_source" "DMI"
halil.cakalbf899782023-09-11 12:34:37 +010068 END
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010069 [Teardown] Basic Teardown ${group_id}
70
71*** Keywords ***
halil.cakalbf899782023-09-11 12:34:37 +010072Compare Header Values
JvD_Ericsson820235c2024-01-22 13:32:34 +000073 [Arguments] ${header_key} ${header_value} ${header_to_check} ${expected_header_value}
halil.cakalbf899782023-09-11 12:34:37 +010074 IF "${header_key}" == ${header_to_check}
JvD_Ericsson820235c2024-01-22 13:32:34 +000075 Should Be Equal As Strings "${header_value}" ${expected_header_value}
76 END
77
78Is 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
82 FOR ${item} IN ${response.json()}
83 IF "${item['cmHandle']}" == "${cmHandle}"
84 Should Be Equal As Strings ${item['state']['cmHandleState']} READY
85 END
halil.cakalbf899782023-09-11 12:34:37 +010086 END
raviteja.karumuria3aba7c2023-07-06 13:48:31 +010087
88Basic Teardown
89 [Arguments] ${group_id}
90 Unsubscribe ${group_id}
91 Close Consumer ${group_id}
92