summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorebo <eliezio.oliveira@est.tech>2019-08-16 13:18:47 +0000
committerebo <eliezio.oliveira@est.tech>2019-08-16 13:18:47 +0000
commitff445e6d950048c092c0a7ccd8a0a04cb18869b5 (patch)
treef73f0ccbe16c1d74c2b230b7990c4fc8b7505973 /components
parent11dbd17296d9572a04bb4e3aea9063c2d1ee3f1d (diff)
Fixed validation of resource-assignment-params.config-assign
- In order to preserve the validation of the whole BPP response, I added a normalization step that will convert any non-JSON part of the response into a JSON-equivalent representation. This normalization is carried out by the JSLT library that provides many JSON manipulations using a JSON-like specification. See https://github.com/schibsted/jslt for more details. - Fix UAT not being run by maven The Surefire plugin does accept '*Tests.java' but DOESN'T '*Tests.kt'! The UAT test class was renamed to use the 'Test' suffix only. - Improved maintainability of UAT-Engine by switching from explicitly field handling to POJO-based parsing using Jackson along with SnakeYaml. UAT-related POJOs created on new module UatDefinition.kt - Added a Protobuf-like description of an UAT YAML document. Change-Id: Id1178489caa4e97808747a99bc9324fc84e9b96e Issue-ID: CCSDK-1620 Signed-off-by: ebo <eliezio.oliveira@est.tech>
Diffstat (limited to 'components')
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/README.md70
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml5
2 files changed, 67 insertions, 8 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/README.md b/components/model-catalog/blueprint-model/uat-blueprints/README.md
index d6a335273..56cb32989 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/README.md
+++ b/components/model-catalog/blueprint-model/uat-blueprints/README.md
@@ -7,7 +7,7 @@ The BPP runs in an almost production-like configuration with some minor exceptio
- It uses an embedded, in-memory, and initially empty H2 database, running in MySQL/MariaDB compatibility mode;
- All external services are mocked.
-
+
## How it works?
The UATs are declarative, data-driven tests implemented in YAML 1.1 documents.
@@ -33,6 +33,62 @@ CDS project's `components/model-catalog/blueprint-model/uat-blueprints` director
## `uat.yaml` reference
+The structure of an UAT YAML file could be documented using the Protobuf language as follows:
+
+```proto
+message Uat {
+ message Path {}
+ message Json {}
+
+ message Process {
+ required string name = 1;
+ required Json request = 2;
+ required Json expectedResponse = 3;
+ optional Json responseNormalizerSpec = 4;
+ }
+
+ message Request {
+ required string method = 1;
+ required Path path = 2;
+ optional string contentType = 3 [default = None];
+ optional Json body = 4;
+ }
+
+ message Response {
+ optional int32 status = 1 [default = 200];
+ optional Json body = 2;
+ }
+
+ message Expectation {
+ required Request request = 1;
+ required Response response = 2;
+ }
+
+ message ExternalService {
+ required string selector = 1;
+ repeated Expectation expectations = 2; // min cardinality = 1
+ }
+
+ repeated Process processes = 1; // min cardinality = 1
+ repeated ExternalService externalServices = 2; // min cardinality = 0
+}
+
+```
+
+The optional `responseNormalizerSpec` specifies transformations that may be needed to apply to the response
+returned by BPP to get a full JSON representation. For example, it's possible to convert an string field "outer.inner"
+into JSON using the following specification:
+
+```yaml
+ responseNormalizerSpec:
+ outer:
+ inner: ?from-json(.outer.inner)
+
+```
+
+The "?" must prefix every expression that is NOT a literal string. The `from-json()` function and
+many others are documented [here](https://github.com/schibsted/jslt/blob/0.1.8/functions.md).
+
### Skeleton of a basic `uat.yaml`
```yaml
@@ -93,16 +149,16 @@ external-services:
### Composite URI paths
-In case your YAML document contains many URI path definitions, you'd better keep the duplications
+In case your YAML document contains many URI path definitions, it's recommended to keep the duplications
as low as possible in order to ease the document maintenance, and avoid inconsistencies.
-
+
Since YAML doesn't provide a standard mechanism to concatenate strings,
the UAT engine implements an ad-hoc mechanism based on multi-level lists.
Please note that currently this mechanism is only applied to URI paths.
To exemplify how it works, let's take the case of eliminating duplications when defining multiple OpenDaylight URLs.
-You might starting using the following definitions:
+You might start using the following definitions:
```yaml
nodeId: &nodeId "new-netconf-device"
# ...
@@ -127,7 +183,7 @@ The UAT engine will expand the above multi-level lists, resulting on the followi
# ...
- request:
path: restconf/config/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/mynetconf:netconflist
-```
+```
## License
@@ -135,9 +191,7 @@ Copyright (C) 2019 Nordix Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
+You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml
index 37029e181..789659eb2 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml
@@ -52,6 +52,11 @@ processes:
target: /
value: { netconflist: { netconf: [ { netconf-id: "30", netconf-param: "3000" }]}}
status: success
+ responseNormalizerSpec:
+ stepData:
+ properties:
+ resource-assignment-params:
+ config-assign: ?from-json(.stepData.properties.resource-assignment-params.config-assign)
- name: config-deploy
request:
commonHeader: *commonHeader