diff options
author | 2021-09-13 18:01:11 +0100 | |
---|---|---|
committer | 2021-09-22 10:44:13 +0100 | |
commit | 8d443ef01e1c85773a9c82910443199de85f24ab (patch) | |
tree | 8faefeb00fafec379a77cd0d7be458f5d908e320 /csit/tests | |
parent | 564e5e96c4ee9a4ae9715865cf6491b4266c601f (diff) |
CSIT for cps-temporal
Issue-ID: CPS-482
Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Change-Id: I5069bdaf36ada7d2e5092669fd58404ed0a19063
Diffstat (limited to 'csit/tests')
-rw-r--r-- | csit/tests/actuator/actuator.robot | 40 | ||||
-rwxr-xr-x | csit/tests/cps-temporal/cps-temporal.robot | 103 |
2 files changed, 143 insertions, 0 deletions
diff --git a/csit/tests/actuator/actuator.robot b/csit/tests/actuator/actuator.robot new file mode 100644 index 0000000..4da25fd --- /dev/null +++ b/csit/tests/actuator/actuator.robot @@ -0,0 +1,40 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Bell Canada. +# ================================================================================ +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +*** Settings *** +Documentation CPS Temporal - Actuator endpoints + +Library Collections +Library RequestsLibrary + +Suite Setup Create Session MANAGEMENT_URL http://${CPS_TEMPORAL_HOST}:${MANAGEMENT_PORT}/manage + +*** Test Cases *** +Test Liveness Probe Endpoint + ${response}= GET On Session MANAGEMENT_URL health/liveness expected_status=200 + Should Be Equal As Strings ${response.json()['status']} UP + +Test Readiness Probe Endpoint + ${response}= GET On Session MANAGEMENT_URL health/readiness expected_status=200 + Should Be Equal As Strings ${response.json()['status']} UP + +Test Info Endpoint + ${response}= GET On Session MANAGEMENT_URL info expected_status=200 + +Test prometheus Endpoint + ${response}= GET On Session MANAGEMENT_URL prometheus expected_status=200 diff --git a/csit/tests/cps-temporal/cps-temporal.robot b/csit/tests/cps-temporal/cps-temporal.robot new file mode 100755 index 0000000..d7e63bd --- /dev/null +++ b/csit/tests/cps-temporal/cps-temporal.robot @@ -0,0 +1,103 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Bell Canada. +# ================================================================================ +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +*** Settings *** +Documentation CPS Temporal REST API + +Library Collections +Library OperatingSystem +Library RequestsLibrary + +Suite Setup Create Session CPS_CORE_URL http://${CPS_HOST}:${CPS_PORT} + +*** Variables *** + +${cps_core_auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= +${cps_core_basePath} /cps/api +${cps_temporal_auth} Basic Y3BzdGVtcG9yYWw6Y3BzdGVtcG9yYWw= +${cps_temporal_basePath} /cps-temporal/api +${dataspaceName} CSIT-Dataspace +${schemaSetName} CSIT-SchemaSet +${anchorName} CSIT-Anchor +${observedTimestampCreation} 2021-03-21T00:00:00.000+0000 +${observedTimestampUpdate} 2021-05-21T00:00:00.000+0000 + + +*** Test Cases *** +Create Dataspace + ${uri}= Set Variable ${cps_core_basePath}/v1/dataspaces + ${params}= Create Dictionary dataspace-name=${dataspaceName} + ${headers}= Create Dictionary Authorization=${cps_core_auth} + ${response}= POST On Session CPS_CORE_URL ${uri} params=${params} headers=${headers} + Should Be Equal As Strings ${response.status_code} 201 + +Create Schema Set from YANG file + ${uri}= Set Variable ${cps_core_basePath}/v1/dataspaces/${dataspaceName}/schema-sets + ${params}= Create Dictionary schema-set-name=${schemaSetName} + ${fileData}= Get Binary File ${DATADIR}${/}test-tree.yang + ${fileTuple}= Create List test.yang ${fileData} application/zip + &{files}= Create Dictionary file=${fileTuple} + ${headers}= Create Dictionary Authorization=${cps_core_auth} + ${response}= POST On Session CPS_CORE_URL ${uri} files=${files} params=${params} headers=${headers} + Should Be Equal As Strings ${response.status_code} 201 + +Create Anchor + ${uri}= Set Variable ${cps_core_basePath}/v1/dataspaces/${dataspaceName}/anchors + ${params}= Create Dictionary schema-set-name=${schemaSetName} anchor-name=${anchorName} + ${headers}= Create Dictionary Authorization=${cps_core_auth} + ${response}= POST On Session CPS_CORE_URL ${uri} params=${params} headers=${headers} + Should Be Equal As Strings ${response.status_code} 201 + +Create Data Node + ${uri}= Set Variable ${cps_core_basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes + ${headers} Create Dictionary Content-Type=application/json accept=text/plain Authorization=${cps_core_auth} + ${params}= Create Dictionary observed-timestamp=${observedTimestampCreation} + ${jsonData}= Get Binary File ${DATADIR}${/}test-tree.json + ${response}= POST On Session CPS_CORE_URL ${uri} params=${params} headers=${headers} data=${jsonData} + Should Be Equal As Strings ${response.status_code} 201 + +Get Anchor History by dataspace and anchor name when Data node is created + Create Session CPS_TEMPORAL_URL http://${CPS_TEMPORAL_HOST}:${CPS_TEMPORAL_PORT} + ${uri}= Set Variable ${cps_temporal_basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/history + ${headers}= Create Dictionary Authorization=${cps_temporal_auth} + ${response}= Get On Session CPS_TEMPORAL_URL ${uri} headers=${headers} expected_status=200 + ${responseJson}= Set Variable ${response.json()} + Should Be Equal As Strings ${response.status_code} 200 + Length Should Be ${responseJson['records']} 1 + Should Be Equal As Strings ${responseJson['records'][0]['observedTimestamp']} ${observedTimestampCreation} + Should Not Be Equal As Strings ${responseJson['records'][0]['observedTimestamp']} ${observedTimestampUpdate} + +Update Data Node + ${uri}= Set Variable ${cps_core_basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes + ${headers} Create Dictionary Content-Type=application/json Authorization=${cps_core_auth} + ${params}= Create Dictionary xpath=/test-tree/branch[@name='Left'] observed-timestamp=${observedTimestampUpdate} + ${jsonData}= Get Binary File ${DATADIR}${/}update-test-tree.json + ${response}= PATCH On Session CPS_CORE_URL ${uri} params=${params} headers=${headers} data=${jsonData} + Should Be Equal As Strings ${response.status_code} 200 + +Get Anchor History by dataspace and anchor name with updated data node + Create Session CPS_TEMPORAL_URL http://${CPS_TEMPORAL_HOST}:${CPS_TEMPORAL_PORT} + ${uri}= Set Variable ${cps_temporal_basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/history + ${headers}= Create Dictionary Authorization=${cps_temporal_auth} + ${params}= Create Dictionary sort=observed-timestamp:desc + ${response}= Get On Session CPS_TEMPORAL_URL ${uri} headers=${headers} expected_status=200 + ${responseJson}= Set Variable ${response.json()} + Should Be Equal As Strings ${response.status_code} 200 + Length Should Be ${responseJson['records']} 2 + Should Be Equal As Strings ${responseJson['records'][1]['observedTimestamp']} ${observedTimestampCreation} + Should Be Equal As Strings ${responseJson['records'][0]['observedTimestamp']} ${observedTimestampUpdate} |