blob: 451fb0a4247128391646375ba88ab77011cfd4f3 [file] [log] [blame]
raviteja.karumuria3aba7c2023-07-06 13:48:31 +01001/*
2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 Nordix Foundation
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 ***
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}
39${newCmHandleRequestBody} {"dmiPlugin":"${dmipluginCsitStubUrl}","createdCmHandles":[{"cmHandle":"850117873c9a4936856a5081be96e6a8"}]}
40
41*** Test Cases ***
42
43NCMP Data Operation, forwarded to DMI, response on Client Topic
44 ${uri}= Set Variable ${ncmpBasePath}/v1/data
45 ${dataOperationReqBody}= Get Binary File ${DATADIR}${/}dataOperationRequest.json
46 ${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}
49 Sleep 5 wait some time to get updated the cm handle state to READY
50 ${response}= POST On Session CPS_URL ${uri} params=${params} headers=${headers} data=${dataOperationReqBody}
51 Set Global Variable ${expectedRequestId} ${response.json()}[requestId]
52 Should Be Equal As Strings ${response.status_code} 200
53 Sleep 5 wait some time to get published a message to the client topic
54
55Consume cloud event from client topic
56 ${group_id}= Create Consumer port=19092 auto_offset_reset=earliest
57 Subscribe Topic topics=${topic} group_id=${group_id}
58 ${messages}= Poll group_id=${group_id} only_value=false
59 ${event} Set Variable ${messages}[0]
60 ${headers} Set Variable ${event.headers()}
61 ${specVersionHeaderValue} Set Variable ${headers[1][1]}
62 ${sourceHeaderValue} Set Variable ${headers[3][1]}
63 ${typeHeaderValue} Set Variable ${headers[4][1]}
64 ${correlationIdHeaderValue} Set Variable ${headers[8][1]}
65 Should Be Equal As Strings ${specVersionHeaderValue} 1.0
66 Should Be Equal As Strings ${sourceHeaderValue} DMI
67 Should Be Equal As Strings ${correlationIdHeaderValue} ${expectedRequestId}
68 Should Be Equal As Strings ${typeHeaderValue} org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent
69 [Teardown] Basic Teardown ${group_id}
70
71*** Keywords ***
72
73Basic Teardown
74 [Arguments] ${group_id}
75 Unsubscribe ${group_id}
76 Close Consumer ${group_id}
77