Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 48 Next »


CPS-731 - Getting issue details... STATUS

Scope


It should be able to query all cm handles with a given set of public cm handle properties.

Requirements

  • We want all cm-Handles where both things are true.
  • If name is empty silently ignore, if value is empty (edge case test?)
  • Those properties also need to exist.
  • If query body does not follow supported structure return 400.
  • Empty query will return all cm-Handles.

A/C:

  1. Demo - with "and" behavior
  2. CI Test - two attributes


Issues/Decisions



IssueNotesDecision
1Does request body need to declare "publicCmHandleProperties"?

Do we need to explicitly declare "publicCmHandleProperties"? 

Will there be another possible variation to this in the future?

{
  "publicCmHandleProperties" : {
          "Colour": "red",
          "Size": "large"
   }
}
Yes
2

Are public properties always stored (in postgress) in the format of "name" : x, "value": y?

(does NOT affect implementation)

In the fragment table there are example that follow this format 

{
	"name": "Colour",
	"value": "red"
},
{
	"name": "Size",
	"value": "large"
}

Yes. But all this is hidden when using CpsPath type query

3Will there only ever be 1 kv pairs in public properties (in the DB)?
Yes, as each property is stored in a separate list-item Fragment
But all this is hidden when using CpsPath type query
4Does the order matter?

Does

{
  "publicCmHandleProperties" : {
          "Colour" : "green",
          "Size" : "small"
   }
}

==

{
  "publicCmHandleProperties" : {
          "Size" : "small"
          "Colour" : "green",
     }
}
No
But all this is hidden when using CpsPath type query
5Should search be case sensitive?

depend on CPSPath functionality - may be case-sensitive

https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html

Yes, that is the currently implement as such CpsPath type query. Given it is mostly machine-to-machine type queries this is good enough and performs better
6What format should the response take?

We have two options currently:


  1. Return List<String>
[
    "cmHandle1",
    "cmHandle2",
    ...,
    "cmHandleN"
]


2. Return CM Handle Objects

    1. Already defined in CPS
    2. <Example Pending>

Contact Tony Finnerty & kieran mccarthy regarding this.
Tony Finnerty Has no opinion on this matter


7what if we have valid entries and one entry  is empty?

We would return all cm handles and others that match would be included in this list anyway.

→ To avoid this should we first check the entries int map for empty entries as further processing is unnecessary in this case.

Discussed with Toine Siebelink and implementation changes are required for handling edges cases. we will handle empty and unknown properties separately.


Analysis/Implementation Proposal


High level Jiras:

  1. CPS-901 - Getting issue details... STATUS
  2. CPS-902 - Getting issue details... STATUS
  3. CPS-903 - Getting issue details... STATUS
  4. CPS-904 - Getting issue details... STATUS


Possible High-Level Implementation Steps:

  1. Match all xpaths using CPS Path Query

  2. Iterate over the list and retrieve all attributes

  3. Iterate over the attributes and collect those instances that match
  4. Return collected list of cm handles

Interface Proposal

#URIDesign NotesComment(s)
1POST /ncmp/v1/data/ch/searches

Scenario :  Request received to return all cm handles matching properties given
Method   : POST
URI          : {ncmpRoot}/ncmp/v1/data/ch/searches 
Header    : Content-Type: application/json

Request Body

{
  "publicCmHandleProperties" : {
     "Colour" : "green",
     "Size" : "small"
   }
}

Response Body Example 1

[
	"cmHandle1",
	"cmHandle2",
	...,
	"cmHandleN"
]

Below is a sample yaml for OpenAPI.

Sample OpenAPI yAML
executeSearchForMatchingPublicProperties:
  post:
    description: Execute search to get all cm handles for the given public properties
    tags:
      - network-cm-proxy
    summary: Execute cm handle search using
    operationId: executeSearchForMatchingPublicProperties
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: 'components.yaml#/components/schemas/PublicProperties'
    responses:
      200:
        description: OK
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
      400:
        $ref: 'components.yaml#/components/responses/BadRequest'
      401:
        $ref: 'components.yaml#/components/responses/Unauthorized'
      403:
        $ref: 'components.yaml#/components/responses/Forbidden'
      404:
        $ref: 'components.yaml#/components/responses/NotFound'
      500:
        $ref: 'components.yaml#/components/responses/InternalServerError'

Testing


Edge Cases

  • Null name, Value
  • Empty name, Value
  • no key value pairs at all 


Manual Testing


Data


insert sql
INSERT INTO public.fragment (xpath, "attributes") VALUES('/dmi-registry/cm-handles[@id=''PNFDemo'']/public-properties[@name=''Contact'']', '{"name": "Contact", "value": "newemailforstore@bookstore.com"}');
INSERT INTO public.fragment (xpath, "attributes") VALUES('/dmi-registry/cm-handles[@id=''Bookstore4'']/public-properties[@name=''color'']', '{"name": "color", "value": ""}');
INSERT INTO public.fragment (xpath, "attributes") VALUES('/dmi-registry/cm-handles[@id=''Bookstore3'']/public-properties[@name=''color'']', '{"name": "color", "value": "red"}');
INSERT INTO public.fragment (xpath, "attributes") VALUES('/dmi-registry/cm-handles[@id=''Bookstore2'']/public-properties[@name=''Contact'']', '{"name": "Contact", "value": "newemailforstore2@bookstore.com"}');
INSERT INTO public.fragment (xpath, "attributes") VALUES('/dmi-registry/cm-handles[@id=''Bookstore1'']/public-properties[@name=''Contact'']', '{"name": "Contact", "value": "newemailforstore@bookstore.com"}');


URL

http://localhost:8883/ncmp/v1/data/ch/searches


Results

Happy Path
#ScenarioRequestResponse
1

Both properties match

(Return CM Handles Returned that Match

{
    "publicCmHandleProperties": {
        "Contact""newemailforstore@bookstore.com"
    }
}

[
    "Bookstore1",
    "PNFDemo"
]

2

No properties given - all cm handles returned

(that contain public properties

{

    "publicCmHandleProperties": {
    }
}

[
    "Bookstore4",
    "Bookstore1",
    "Bookstore2",
    "Bookstore3",
    "PNFDemo"
]


Edge Cases
#ScenarioRequestResponse
1

Value doesn't match 

(Nothing Returned

{
    "publicCmHandleProperties": {
        "Contact""notAValidValue"
    }
}

[ ]
2

Unknown properties given - NO cm handles returned

(Return Empty Response)

{
    "publicCmHandleProperties": {
        "UnknwnProperty""doesnt matter"
    }
}

[ ]
3

Empty property name

Return 400

(BAD_REQUEST)

{

    "publicCmHandleProperties": {
        """doesnt matter "
    }
}

{
    "status""400 BAD_REQUEST",
    "message""Invalid data",
    "details""Missing property - please supply a valid property"
}

4

Empty value 

(Return CM Handles Returned that Match

{

    "publicCmHandleProperties": {
        "color"""
    }
}

[
    "Bookstore4"
]


Future Example (Out-of-scope)



POST /ncmp/v1/data/ch/searches

{
  "publicCmHandleProperties" : {
     "publicPropertyName-1" : "publicPropertyValue-1",
     "publicPropertyName-2" : "publicPropertyValue-2"
   },
  "modules": [
    {
           "moduleName": "", (Mandatory)
           "revision": "" (Optional)
        }
  ]
}

Modules in the example are to demonstrate future intentions but is out of scope for this user story.

References



CPS Swagger: http://localhost:8883/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config

https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html

https://www.freeformatter.com/xpath-tester.html#ad-output

//public-properties[@name='Contact' and @value='xyz']/ancestor::cm-handles

org.onap.cps.spi.impl.CpsDataPersistenceQueryDataNodeSpec#Query for attribute by cps path of type ancestor with #scenario.


  • No labels