From 796568ad0c9f4e62f22b57845cae46b5af3280d1 Mon Sep 17 00:00:00 2001 From: steiler Date: Wed, 3 Apr 2024 13:41:30 +0200 Subject: [PATCH 01/10] fix must statement tests --- Makefile | 9 +- tests/robot/keywords/client.robot | 231 +++++++++++++++---- tests/robot/keywords/server.robot | 11 +- tests/robot/tests/collocated/colloc.robot | 10 +- tests/robot/tests/must/autoneg_fail.json | 6 + tests/robot/tests/must/autoneg_pass.json | 6 + tests/robot/tests/must/bfd.json | 6 + tests/robot/tests/must/breakout_autoneg.json | 13 ++ tests/robot/tests/must/breakout_speed.json | 11 + tests/robot/tests/must/cache.yaml | 33 --- tests/robot/tests/must/data-server.yaml | 92 ++++---- tests/robot/tests/must/lag_lacp_fail.json | 6 + tests/robot/tests/must/lag_lacp_pass.json | 11 + tests/robot/tests/must/lag_speed.json | 6 + tests/robot/tests/must/lag_vlan_tagging.json | 12 + tests/robot/tests/must/lldp_tun_fail.json | 29 +++ tests/robot/tests/must/lldp_tun_pass.json | 19 ++ tests/robot/tests/must/must_statements.robot | 142 ++++-------- tests/robot/tests/must/schema-server.yaml | 38 --- tests/robot/tests/must/srl1_target.json | 4 + tests/robot/tests/must/sync.json | 5 + tests/robot/tests/must/system0_disable.json | 6 + tests/robot/tests/must/system0_enable.json | 6 + 23 files changed, 443 insertions(+), 269 deletions(-) create mode 100644 tests/robot/tests/must/autoneg_fail.json create mode 100644 tests/robot/tests/must/autoneg_pass.json create mode 100644 tests/robot/tests/must/bfd.json create mode 100644 tests/robot/tests/must/breakout_autoneg.json create mode 100644 tests/robot/tests/must/breakout_speed.json delete mode 100644 tests/robot/tests/must/cache.yaml create mode 100644 tests/robot/tests/must/lag_lacp_fail.json create mode 100644 tests/robot/tests/must/lag_lacp_pass.json create mode 100644 tests/robot/tests/must/lag_speed.json create mode 100644 tests/robot/tests/must/lag_vlan_tagging.json create mode 100644 tests/robot/tests/must/lldp_tun_fail.json create mode 100644 tests/robot/tests/must/lldp_tun_pass.json delete mode 100644 tests/robot/tests/must/schema-server.yaml create mode 100644 tests/robot/tests/must/srl1_target.json create mode 100644 tests/robot/tests/must/sync.json create mode 100644 tests/robot/tests/must/system0_disable.json create mode 100644 tests/robot/tests/must/system0_enable.json diff --git a/Makefile b/Makefile index dab2740b..bfaff48e 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,17 @@ build: CGO_ENABLED=0 ${GO_BIN} build -o bin/datactl client/main.go CGO_ENABLED=0 ${GO_BIN} build -o bin/data-server main.go -test: +install-sdctl: + ${GO_BIN} install github.com/sdcio/sdctl@latest + +robot-tests: build robot tests/robot + +go-tests: go test ./... +test: go-tests robot-tests + docker-build: ssh-add ./keys/id_rsa 2>/dev/null; true docker build --build-arg USERID=$(USERID) . -t $(IMAGE) --ssh default=$(SSH_AUTH_SOCK) diff --git a/tests/robot/keywords/client.robot b/tests/robot/keywords/client.robot index 897e098c..281bdf25 100644 --- a/tests/robot/keywords/client.robot +++ b/tests/robot/keywords/client.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation The Library relies on the following variables being available on execution -... CLIENT-BIN: Pointing to the client binary +... SDCTL: Pointing to the client binary ... DATA-SERVER-IP: IP of data server ... DATA-SERVER-PORT: TCP port of data server ... SCHEMA-SERVER-IP: IP of schema server @@ -13,96 +13,235 @@ Library OperatingSystem *** Keywords *** ListDataStores [Documentation] List datastores in a data-server - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore list - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore + ... list + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} GetDataStore [Documentation] Get a target from a data-server [Arguments] ${datastore} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore get --ds ${datastore} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore + ... get + ... --ds ${datastore} + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} -CreateDataStore +CreateDataStoreTarget [Documentation] Create a target in a data-server - [Arguments] ${datastore} ${target-definition-file} ${sync-file} ${schema-name} ${schema-vendor} ${schema-version} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore create --ds ${datastore} --target ${target-definition-file} --sync ${target-sync-file} --name ${schema-name} --vendor ${schema-vendor} --version ${schema-version} - RETURN ${rc} ${result} + [Arguments] ${datastore} ${target-definition-file} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore + ... create + ... --ds + ... ${datastore} + ... --target + ... ${target-definition-file} + ... --sync + ... ${target-sync-file} + ... --name + ... ${schema-name} + ... --vendor + ... ${schema-vendor} + ... --version + ... ${schema-version} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} DeleteDatastore [Documentation] Delete a target from a data-server [Arguments] ${datastore} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore delete --ds ${datastore} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore + ... delete + ... --ds + ... ${datastore} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} CreateCandidate [Documentation] Create a new named Candidate in the given Datastore - [Arguments] ${datastore} ${candidate} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore create --ds ${datastore} --candidate ${candidate} - RETURN ${rc} ${result} + [Arguments] ${datastore} ${candidate} ${owner} ${priority} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore create + ... --ds ${datastore} + ... --candidate ${candidate} + ... --owner ${owner} + ... --priority ${priority} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} GetCandidate [Documentation] Create a new named Candidate in the given Datastore [Arguments] ${datastore} ${candidate} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore get --ds ${datastore} --candidate ${candidate} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore get + ... --ds ${datastore} + ... --candidate ${candidate} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} DeleteCandidate [Documentation] Delete a named Candidate in the given Datastore [Arguments] ${datastore} ${candidate} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore delete --ds ${datastore} --candidate ${candidate} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore + ... delete + ... --ds + ... ${datastore} + ... --candidate + ... ${candidate} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} Diff [Documentation] Performs a diff on a datastore and a candidate [Arguments] ${datastore} ${candidate} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data diff --ds ${datastore} --candidate ${candidate} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... data diff + ... --ds ${datastore} + ... --candidate ${candidate} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} Commit [Documentation] Performs a commit on the given datastore/candidate and returns the Process Result object https://robotframework.org/robotframework/latest/libraries/Process.html#Result%20object [Arguments] ${datastore} ${candidate} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore commit --ds ${datastore} --candidate ${candidate} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore commit + ... --ds ${datastore} + ... --candidate ${candidate} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} Get [Documentation] Get a path from the datastore [Arguments] ${datastore} ${ds-get-flags} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data get --ds ${datastore} ${ds-get-flags} - Log ${result} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... data get + ... --ds ${datastore} + ... @{ds-get-flags} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} GetFromCandidate [Documentation] Get a path from the datastore candidate [Arguments] ${datastore} ${candidate} ${path} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data get --ds ${datastore} --candidate ${candidate} --path ${path} - Log ${result} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... data get + ... --ds ${datastore} + ... --candidate ${candidate} + ... --path ${path} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} Set [Documentation] Applies to the candidate of the given datastore the provided update [Arguments] ${datastore} ${candidate} ${set-flags} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data set --ds ${datastore} --candidate ${candidate} ${set-flags} - Log ${result} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... data set + ... --ds ${datastore} + ... --candidate ${candidate} + ... ${set-flags} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} + +SetIntent + [Documentation] Applies the given intent to the provided candidate datastore + [Arguments] ${datastore} ${candidate} ${intent} ${priority} ${file} @{set-flags} + ${result} = Run Process + ... ${SDCTL} + ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... data set-intent + ... --ds ${datastore} + ... --candidate ${candidate} + ... --priority ${priority} + ... --intent ${intent} + ... --body ${file} + ... @{set-flags} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} + GetSchema [Documentation] Retrieve the schema element described by name (plattform name), version and vendor under the given path. [Arguments] ${name} ${version} ${vendor} ${path} - ${rc} ${result} = Run And Return Rc And Output - ... ${CLIENT-BIN} -a ${SCHEMA-SERVER-IP}:${SCHEMA-SERVER-PORT} schema get --name ${name} --version ${version} --vendor ${vendor} --path ${path} - RETURN ${rc} ${result} + ${result} = Run Process + ... ${SDCTL} + ... -a ${SCHEMA-SERVER-IP}:${SCHEMA-SERVER-PORT} + ... schema get + ... --name ${name} + ... --version ${version} + ... --vendor ${vendor} + ... --path ${path} + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} # Helper ExtractResponse diff --git a/tests/robot/keywords/server.robot b/tests/robot/keywords/server.robot index 0dfe660a..72f1c017 100644 --- a/tests/robot/keywords/server.robot +++ b/tests/robot/keywords/server.robot @@ -24,9 +24,9 @@ DestroyLab Log ${result} RETURN ${rc} ${result} -Setupcollocated +Setup Collocated [Documentation] Starts a data-server with an embeded schema and cache stores. - [Arguments] ${doBuild} ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} + [Arguments] ${doBuild} ${data-server-bin} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} IF ${doBuild} == $True ${result} = Run Process make build Log Many stdout: ${result.stdout} stderr: ${result.stderr} @@ -76,4 +76,9 @@ CheckServerState [Arguments] ${schema-server-process-alias} ${data-server-process-alias} ${cache-server-process-alias} Process Should Be Running handle=${schema-server-process-alias} error_message="schema-server failed" Process Should Be Running handle=${data-server-process-alias} error_message="data-server failed" - Process Should Be Running handle=${cache-server-process-alias} error_message="cache-server failed" \ No newline at end of file + Process Should Be Running handle=${cache-server-process-alias} error_message="cache-server failed" + +CheckServerState Colocated + [Documentation] Check that data-server are still running + [Arguments] ${data-server-process-alias} + Process Should Be Running handle=${data-server-process-alias} error_message="data-server failed" diff --git a/tests/robot/tests/collocated/colloc.robot b/tests/robot/tests/collocated/colloc.robot index 989b5cca..c5f79135 100644 --- a/tests/robot/tests/collocated/colloc.robot +++ b/tests/robot/tests/collocated/colloc.robot @@ -45,13 +45,13 @@ Create and delete a Datastore server.Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} # create first datastore - ${rc} ${result} = client.CreateDataStore ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} + ${rc} ${result} = client.CreateDataStoreTarget ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} Log ${result} Should Be Equal As Integers ${rc} 0 Should Contain ${result} ${datastore1} # create second datastore - ${rc} ${result} = client.CreateDataStore ${datastore2} ${target-file2} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} + ${rc} ${result} = client.CreateDataStoreTarget ${datastore2} ${target-file2} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} Log ${result} Should Be Equal As Integers ${rc} 0 Sleep 30s @@ -84,13 +84,13 @@ Create and delete a Datastore and candidate server.Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} # create first datastore - ${rc} ${result} = client.CreateDataStore ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} + ${rc} ${result} = client.CreateDataStoreTarget ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} Log ${result} Should Be Equal As Integers ${rc} 0 Should Contain ${result} ${datastore1} # create second datastore - ${rc} ${result} = client.CreateDataStore ${datastore2} ${target-file2} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} + ${rc} ${result} = client.CreateDataStoreTarget ${datastore2} ${target-file2} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} Log ${result} Should Be Equal As Integers ${rc} 0 @@ -139,7 +139,7 @@ Configure Router gNMI - Set / Delete Leaf Log ${result} Should Be Equal As Integers ${rc} 0 - ${rc} ${result} = client.CreateDataStore ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} + ${rc} ${result} = client.CreateDataStoreTarget ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} Log ${result} Should Be Equal As Integers ${rc} 0 Sleep 30s diff --git a/tests/robot/tests/must/autoneg_fail.json b/tests/robot/tests/must/autoneg_fail.json new file mode 100644 index 00000000..ce78ce3f --- /dev/null +++ b/tests/robot/tests/must/autoneg_fail.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=ethernet-0/1]/ethernet/auto-negotiate", + "value": true + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/autoneg_pass.json b/tests/robot/tests/must/autoneg_pass.json new file mode 100644 index 00000000..81ed1bdb --- /dev/null +++ b/tests/robot/tests/must/autoneg_pass.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=ethernet-1/1]/ethernet/auto-negotiate", + "value": true + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/bfd.json b/tests/robot/tests/must/bfd.json new file mode 100644 index 00000000..b76e230c --- /dev/null +++ b/tests/robot/tests/must/bfd.json @@ -0,0 +1,6 @@ +[ + { + "path": "/bfd/subinterface/id", + "value": "ethernet-1/1.26" + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/breakout_autoneg.json b/tests/robot/tests/must/breakout_autoneg.json new file mode 100644 index 00000000..3fd0f90e --- /dev/null +++ b/tests/robot/tests/must/breakout_autoneg.json @@ -0,0 +1,13 @@ +[ + { + "path": "interface[name=ethernet-1/1]", + "value": { + "ethernet": { + "auto-negotiate": true + }, + "breakout-mode": { + "num-breakout-ports": 2 + } + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/breakout_speed.json b/tests/robot/tests/must/breakout_speed.json new file mode 100644 index 00000000..719b29ea --- /dev/null +++ b/tests/robot/tests/must/breakout_speed.json @@ -0,0 +1,11 @@ +[ + { + "path": "interface[name=ethernet-1/1]", + "value": { + "breakout-mode": { + "num-breakout-ports": 2, + "breakout-port-speed": "25G" + } + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/cache.yaml b/tests/robot/tests/must/cache.yaml deleted file mode 100644 index 6dbf7ed3..00000000 --- a/tests/robot/tests/must/cache.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2024 Nokia -# -# 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. - -grpc-server: - address: :50100 - # TLS config - # tls: - # ca: - # cert: - # key: - # skip-verify: - max-recv-msg-size: 0 - rpc-timeout: 60s - -cache: - store-type: badgerdb - dir: /tmp/caches - max-caches: 16 - # max-candidate-per-cache: 100 - -prometheus: - address: :50190 \ No newline at end of file diff --git a/tests/robot/tests/must/data-server.yaml b/tests/robot/tests/must/data-server.yaml index f0ff62db..1b55f777 100644 --- a/tests/robot/tests/must/data-server.yaml +++ b/tests/robot/tests/must/data-server.yaml @@ -1,53 +1,65 @@ -# Copyright 2024 Nokia -# -# 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. - grpc-server: + # gRPC listening address address: ":56000" + # rpc-timeout: 5m + ## TLS config # tls: - data-server: - # if true, enables datastore and data RPCs + # ca: + # cert: + # key: + # skip-verify: + # client-auth: + + # expose local schema store over gRPC + schema-server: + # enables the schema gRPC server enabled: true + # directory to store the uploaded schemas + schemas-directory: ./schemas + + # data-server attributes + data-server: # max number of candidates per DS max-candidates: 16 - max-send-msg-size: 25165824 # (24MB) = 24 * 1024 * 1024 - rpc-timeout: 9000000000000 -# data server config -## known data stores -datastores: # this creates MAIN datastores - - name: srl1 - schema: - name: srl - vendor: Nokia - version: 22.11.2 - sbi: - type: noop #, nc, nats, redis - address: "127.0.0.1" - sync: - write-workers: 5 + # max message size in bytes the server can receive. + # If this is not set, it defaults to 4 * 1024 * 1024 (4MB) + max-recv-msg-size: 25165824 # 24 * 1024 * 1024 (24MB) -# remote schema server details -schema-server: - # schema server remote address - address: 127.0.0.1:55000 - # tls config to connect to the schema server - # tls: +# starts a local schema store/client +schema-store: + # type is either memory or persistent (default) + type: memory + cache: + ttl: 60s + capacity: 100 + schemas: + - name: srl + vendor: Nokia + version: 22.11.2 + files: + - ./lab/common/yang/srl-22.11.2/srl_nokia/models + directories: + - ./lab/common/yang/srl-22.11.2/ietf + - ./lab/common/yang/srl-22.11.2/openconfig + excludes: + - .*tools.* +# cache config, defaults to +# type: local +# store-type: badgerdb +# dir: ./cached/caches cache: - type: remote - address: 127.0.0.1:50100 + # type: remote + type: local + # store-type if type == local + store-type: badgerdb + # local directory for caches if type == local + dir: "./cached/caches" + # remote cache address, if type == remote + # address: localhost:50100 +# expose a prometheus server with cpu, mem and grpc metrics prometheus: - address: :56090 \ No newline at end of file + address: ":56090" \ No newline at end of file diff --git a/tests/robot/tests/must/lag_lacp_fail.json b/tests/robot/tests/must/lag_lacp_fail.json new file mode 100644 index 00000000..d0281e51 --- /dev/null +++ b/tests/robot/tests/must/lag_lacp_fail.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=lag1]/lag/lag-type", + "value":"lacp" + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/lag_lacp_pass.json b/tests/robot/tests/must/lag_lacp_pass.json new file mode 100644 index 00000000..6cc0e341 --- /dev/null +++ b/tests/robot/tests/must/lag_lacp_pass.json @@ -0,0 +1,11 @@ +[ + { + "path": "interface[name=lag1]/lag", + "value": { + "lag-type": "lacp", + "lacp": { + "admin-key": 1 + } + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/lag_speed.json b/tests/robot/tests/must/lag_speed.json new file mode 100644 index 00000000..f48c1322 --- /dev/null +++ b/tests/robot/tests/must/lag_speed.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=ethernet-1/1]/ethernet/aggregate-id", + "value":"lag1" + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/lag_vlan_tagging.json b/tests/robot/tests/must/lag_vlan_tagging.json new file mode 100644 index 00000000..d3bd0992 --- /dev/null +++ b/tests/robot/tests/must/lag_vlan_tagging.json @@ -0,0 +1,12 @@ +[ + { + "path": "interface[name=ethernet-1/1]", + "value": { + "vlan-tagging": true, + "ethernet": { + "port-speed": "10G", + "aggregate-id": "lag1" + } + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/lldp_tun_fail.json b/tests/robot/tests/must/lldp_tun_fail.json new file mode 100644 index 00000000..054c1780 --- /dev/null +++ b/tests/robot/tests/must/lldp_tun_fail.json @@ -0,0 +1,29 @@ +[ + { + "path": "/", + "value": { + "system": { + "lldp": { + "interface": [ + { + "name": "ethernet-1/1", + "admin-state": "enable" + } + ] + } + }, + "interface": [ + { + "name": "ethernet-1/1", + "ethernet": { + "l2cp-transparency": { + "lldp": { + "tunnel": true + } + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/lldp_tun_pass.json b/tests/robot/tests/must/lldp_tun_pass.json new file mode 100644 index 00000000..0caa70b8 --- /dev/null +++ b/tests/robot/tests/must/lldp_tun_pass.json @@ -0,0 +1,19 @@ +[ + { + "path": "/", + "value": { + "interface": [ + { + "name": "ethernet-1/1", + "ethernet": { + "l2cp-transparency": { + "lldp": { + "tunnel": true + } + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/must_statements.robot b/tests/robot/tests/must/must_statements.robot index 6b2769e4..ed10f006 100644 --- a/tests/robot/tests/must/must_statements.robot +++ b/tests/robot/tests/must/must_statements.robot @@ -4,20 +4,20 @@ Resource ../../keywords/client.robot Library OperatingSystem Library String Library Process -#Suite Setup Setup True ${server-bin} ${cache-bin} ${schema-server-config} ${schema-server-process-alias} ${schema-server-stderr} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} ${cache-server-config} ${cache-server-process-alias} ${cache-server-stderr} -#Suite Teardown Teardown +Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} +Suite Teardown Teardown *** Variables *** -${server-bin} ./bin/server -${client-bin} ./bin/client -${cache-bin} ../cache/bin/cached -${schema-server-config} ./tests/robot/tests/must/schema-server.yaml -${data-server-config} ./tests/robot/tests/must/data-server.yaml -${cache-server-config} ./tests/robot/tests/must/cache.yaml -${schema-server-ip} 127.0.0.1 -${schema-server-port} 55000 -${data-server-ip} 127.0.0.1 -${data-server-port} 56000 +${DATA-SERVER-BIN} ./bin/data-server +${SDCTL} sdctl + +${DATA-SERVER-CONFIG} ./tests/robot/tests/must/data-server.yaml + +${DATA-SERVER-IP} 127.0.0.1 +${DATA-SERVER-PORT} 56000 + +${SCHEMA-SERVER-IP} 127.0.0.1 +${SCHEMA-SERVER-PORT} 56000 # TARGET ${srlinux1-name} srl1 @@ -25,7 +25,10 @@ ${srlinux1-candidate} default ${srlinux1-schema-name} srl ${srlinux1-schema-version} 22.11.2 ${srlinux1-schema-Vendor} Nokia - +${srlinux1-target-def} ./tests/robot/tests/must/srl1_target.json +${srlinux1-sync-def} ./tests/robot/tests/must/sync.json +${owner} test +${priority} 100 # internal vars ${schema-server-process-alias} ssa @@ -38,17 +41,17 @@ ${cache-server-stderr} /tmp/cs-out *** Test Cases *** Check Server State - CheckServerState ${schema-server-process-alias} ${data-server-process-alias} ${cache-server-process-alias} + CheckServerState Colocated ${data-server-process-alias} + +Create SRL1 Target + ${result} = CreateDataStoreTarget ${srlinux1-name} ${srlinux1-target-def} ${srlinux1-sync-def} ${srlinux1-schema-name} ${srlinux1-schema-Vendor} ${srlinux1-schema-version} + Should Be Equal As Integers ${result.rc} 0 Set system0 admin-state disable -> Fail LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=system0]/admin-state - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=system0]/admin-state:::disable - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/system0_disable.json + Should Contain ${result.stderr} admin-state must be enable Should Be Equal As Integers ${result.rc} 1 @@ -57,7 +60,7 @@ Set system0 admin-state disable -> Fail Set system0 admin-state enable -> Pass LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=system0]/admin-state - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} + CreateCandidate ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=system0]/admin-state:::enable Should Be Equal As Integers ${result.rc} 0 @@ -70,7 +73,7 @@ Set system0 admin-state enable -> Pass Set ethernet-1/1 admin-state disable -> Pass LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=system0]/admin-state - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} + CreateCandidate ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/admin-state:::disable Should Be Equal As Integers ${result.rc} 0 @@ -83,12 +86,8 @@ Set ethernet-1/1 admin-state disable -> Pass Set lag-type without 'interface[name=xyz]/lag/lacp' existence LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=lag1]/lag/lag-type - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=lag1]/lag/lag-type:::lacp - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_lacp_fail.json + Should Contain ${result.stderr} lacp container must be configured when lag-type is lacp Should Be Equal As Integers ${result.rc} 1 @@ -98,15 +97,8 @@ Set lag-type with 'interface[name=xyz]/lag/lacp' existence LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=lag1]/lag/lacp/admin-key LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=lag1]/lag/lag-type - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=lag1]/lag/lacp/admin-key:::1 - Should Be Equal As Integers ${result.rc} 0 - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=lag1]/lag/lag-type:::lacp - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_lacp_pass.json + Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} @@ -114,13 +106,8 @@ Set lag-type with 'interface[name=xyz]/lag/lacp' existence Set auto-negotiate on non allowed interface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-0/1]/ethernet/auto-negotiate - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-0/1]/ethernet/auto-negotiate:::true - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/autoneg_fail.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Contain ${result.stderr} auto-negotiation not supported on this interface Should Be Equal As Integers ${result.rc} 1 @@ -129,13 +116,7 @@ Set auto-negotiate on non allowed interface Set auto-negotiate on allowed interface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/auto-negotiate - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/ethernet/auto-negotiate:::true - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/autoneg_pass.json Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} @@ -144,34 +125,19 @@ Set auto-negotiation on breakout-mode port LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/auto-negotiate LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/breakout-mode/num-breakout-ports - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/breakout-mode/num-breakout-ports:::4 - Should Be Equal As Integers ${result.rc} 0 - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/ethernet/auto-negotiate:::true - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/breakout_autoneg.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Contain ${result.stderr} auto-negotiate not configurable when breakout-mode is enabled Should Be Equal As Integers ${result.rc} 1 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} -Set breakout-port num to 2 and port-speed to 100G +Set breakout-port num to 2 and port-speed to 25G LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/breakout-mode/breakout-port-speed LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/breakout-mode/num-breakout-ports - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/breakout-mode/breakout-port-speed:::25G - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/breakout-mode/num-breakout-ports:::2 - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/breakout_speed.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Be Equal As Integers ${result.rc} 1 Should Contain ${result.stderr} breakout-port-speed must be 100G when num-breakout-ports is 2 @@ -181,13 +147,8 @@ Set breakout-port num to 2 and port-speed to 100G Set interface ethernet l2cp-transparency lldp tunnel true LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/l2cp-transparency/lldp/tunnel - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/ethernet/l2cp-transparency/lldp/tunnel:::true - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lldp_tun_pass.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} @@ -195,16 +156,8 @@ Set interface ethernet l2cp-transparency lldp tunnel true Set interface ethernet l2cp-transparency lldp tunnel true on lldp true interface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/l2cp-transparency/lldp/tunnel - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lldp_tun_fail.json - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} /system/lldp/interface[name=ethernet-1/1]/admin-state:::enable - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} /interface[name=ethernet-1/1]/ethernet/l2cp-transparency/lldp/tunnel:::true - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Be Equal As Integers ${result.rc} 1 Should Contain ${result.stderr} this interface must not have lldp enabled @@ -213,13 +166,8 @@ Set interface ethernet l2cp-transparency lldp tunnel true on lldp true interface Set bfd for non existing subinterface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} /bfd/subinterface/id - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} /bfd/subinterface/id:::ethernet-1/1.26 - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/bfd.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Be Equal As Integers ${result.rc} 1 Should Contain ${result.stderr} Must be an existing subinterface name @@ -228,12 +176,8 @@ Set bfd for non existing subinterface Check LAG interface member speed is set LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/aggregate-id - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/ethernet/aggregate-id:::lag1 - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_speed.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Contain ${result.stderr} member-speed must be configured on associated aggregate-id interface Should Be Equal As Integers ${result.rc} 1 @@ -242,16 +186,8 @@ Check LAG interface member speed is set Check LAG interface vlan-tagging not set on member LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/aggregate-id - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/vlan-tagging:::true - Should Be Equal As Integers ${result.rc} 0 - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/ethernet/port-speed:::10G - Should Be Equal As Integers ${result.rc} 0 - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/ethernet/aggregate-id:::lag1 - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_vlan_tagging.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Contain ${result.stderr} vlan-tagging and aggregate-id can not be configured together Should Be Equal As Integers ${result.rc} 1 diff --git a/tests/robot/tests/must/schema-server.yaml b/tests/robot/tests/must/schema-server.yaml deleted file mode 100644 index 0814499b..00000000 --- a/tests/robot/tests/must/schema-server.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2024 Nokia -# -# 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. - -grpc-server: - address: ":55000" - #tls: - schema-server: - # if true, enables schema RPCs - enabled: true - # directory to store teh uploaded schemas - schemas-directory: ./schemas - max-send-msg-size: 25165824 # (24MB) = 24 * 1024 * 1024 - -# schema-server -schemas: - - name: srl - vendor: Nokia - version: 22.11.2 - files: - - ./schema/testdata/srl-latest-yang-models/srl_nokia/models - directories: - - ./schema/testdata/srl-latest-yang-models/ietf - excludes: - - .*tools.* - -prometheus: - address: :55090 \ No newline at end of file diff --git a/tests/robot/tests/must/srl1_target.json b/tests/robot/tests/must/srl1_target.json new file mode 100644 index 00000000..d12fd8eb --- /dev/null +++ b/tests/robot/tests/must/srl1_target.json @@ -0,0 +1,4 @@ +{ + "type": "noop", + "address": "clab-collocated-srl1:57400" +} \ No newline at end of file diff --git a/tests/robot/tests/must/sync.json b/tests/robot/tests/must/sync.json new file mode 100644 index 00000000..51c0a575 --- /dev/null +++ b/tests/robot/tests/must/sync.json @@ -0,0 +1,5 @@ +{ + "validate": true, + "config": [ + ] +} \ No newline at end of file diff --git a/tests/robot/tests/must/system0_disable.json b/tests/robot/tests/must/system0_disable.json new file mode 100644 index 00000000..0f7a72a8 --- /dev/null +++ b/tests/robot/tests/must/system0_disable.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=system0]/admin-state", + "value":"disable" + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/system0_enable.json b/tests/robot/tests/must/system0_enable.json new file mode 100644 index 00000000..d0281e51 --- /dev/null +++ b/tests/robot/tests/must/system0_enable.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=lag1]/lag/lag-type", + "value":"lacp" + } +] \ No newline at end of file From 7d48a3c60fbcb90b2b3aaff0e8c5e60400ba314b Mon Sep 17 00:00:00 2001 From: steiler Date: Wed, 3 Apr 2024 14:22:03 +0200 Subject: [PATCH 02/10] update --- .../must/{ => intents}/autoneg_fail.json | 0 .../must/{ => intents}/autoneg_pass.json | 0 tests/robot/tests/must/{ => intents}/bfd.json | 0 .../must/{ => intents}/breakout_autoneg.json | 0 .../must/{ => intents}/breakout_speed.json | 0 .../robot/tests/must/intents/e11_disable.json | 6 +++ .../must/{ => intents}/lag_lacp_fail.json | 0 .../must/{ => intents}/lag_lacp_pass.json | 0 .../tests/must/{ => intents}/lag_speed.json | 0 .../must/{ => intents}/lag_vlan_tagging.json | 0 .../must/{ => intents}/lldp_tun_fail.json | 0 .../must/{ => intents}/lldp_tun_pass.json | 0 .../must/{ => intents}/system0_disable.json | 0 .../tests/must/intents/system0_enable.json | 6 +++ tests/robot/tests/must/must_statements.robot | 50 +++++++------------ tests/robot/tests/must/system0_enable.json | 6 --- 16 files changed, 30 insertions(+), 38 deletions(-) rename tests/robot/tests/must/{ => intents}/autoneg_fail.json (100%) rename tests/robot/tests/must/{ => intents}/autoneg_pass.json (100%) rename tests/robot/tests/must/{ => intents}/bfd.json (100%) rename tests/robot/tests/must/{ => intents}/breakout_autoneg.json (100%) rename tests/robot/tests/must/{ => intents}/breakout_speed.json (100%) create mode 100644 tests/robot/tests/must/intents/e11_disable.json rename tests/robot/tests/must/{ => intents}/lag_lacp_fail.json (100%) rename tests/robot/tests/must/{ => intents}/lag_lacp_pass.json (100%) rename tests/robot/tests/must/{ => intents}/lag_speed.json (100%) rename tests/robot/tests/must/{ => intents}/lag_vlan_tagging.json (100%) rename tests/robot/tests/must/{ => intents}/lldp_tun_fail.json (100%) rename tests/robot/tests/must/{ => intents}/lldp_tun_pass.json (100%) rename tests/robot/tests/must/{ => intents}/system0_disable.json (100%) create mode 100644 tests/robot/tests/must/intents/system0_enable.json delete mode 100644 tests/robot/tests/must/system0_enable.json diff --git a/tests/robot/tests/must/autoneg_fail.json b/tests/robot/tests/must/intents/autoneg_fail.json similarity index 100% rename from tests/robot/tests/must/autoneg_fail.json rename to tests/robot/tests/must/intents/autoneg_fail.json diff --git a/tests/robot/tests/must/autoneg_pass.json b/tests/robot/tests/must/intents/autoneg_pass.json similarity index 100% rename from tests/robot/tests/must/autoneg_pass.json rename to tests/robot/tests/must/intents/autoneg_pass.json diff --git a/tests/robot/tests/must/bfd.json b/tests/robot/tests/must/intents/bfd.json similarity index 100% rename from tests/robot/tests/must/bfd.json rename to tests/robot/tests/must/intents/bfd.json diff --git a/tests/robot/tests/must/breakout_autoneg.json b/tests/robot/tests/must/intents/breakout_autoneg.json similarity index 100% rename from tests/robot/tests/must/breakout_autoneg.json rename to tests/robot/tests/must/intents/breakout_autoneg.json diff --git a/tests/robot/tests/must/breakout_speed.json b/tests/robot/tests/must/intents/breakout_speed.json similarity index 100% rename from tests/robot/tests/must/breakout_speed.json rename to tests/robot/tests/must/intents/breakout_speed.json diff --git a/tests/robot/tests/must/intents/e11_disable.json b/tests/robot/tests/must/intents/e11_disable.json new file mode 100644 index 00000000..9162de66 --- /dev/null +++ b/tests/robot/tests/must/intents/e11_disable.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=ethernet-1/1]/admin-state", + "value":"disable" + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/lag_lacp_fail.json b/tests/robot/tests/must/intents/lag_lacp_fail.json similarity index 100% rename from tests/robot/tests/must/lag_lacp_fail.json rename to tests/robot/tests/must/intents/lag_lacp_fail.json diff --git a/tests/robot/tests/must/lag_lacp_pass.json b/tests/robot/tests/must/intents/lag_lacp_pass.json similarity index 100% rename from tests/robot/tests/must/lag_lacp_pass.json rename to tests/robot/tests/must/intents/lag_lacp_pass.json diff --git a/tests/robot/tests/must/lag_speed.json b/tests/robot/tests/must/intents/lag_speed.json similarity index 100% rename from tests/robot/tests/must/lag_speed.json rename to tests/robot/tests/must/intents/lag_speed.json diff --git a/tests/robot/tests/must/lag_vlan_tagging.json b/tests/robot/tests/must/intents/lag_vlan_tagging.json similarity index 100% rename from tests/robot/tests/must/lag_vlan_tagging.json rename to tests/robot/tests/must/intents/lag_vlan_tagging.json diff --git a/tests/robot/tests/must/lldp_tun_fail.json b/tests/robot/tests/must/intents/lldp_tun_fail.json similarity index 100% rename from tests/robot/tests/must/lldp_tun_fail.json rename to tests/robot/tests/must/intents/lldp_tun_fail.json diff --git a/tests/robot/tests/must/lldp_tun_pass.json b/tests/robot/tests/must/intents/lldp_tun_pass.json similarity index 100% rename from tests/robot/tests/must/lldp_tun_pass.json rename to tests/robot/tests/must/intents/lldp_tun_pass.json diff --git a/tests/robot/tests/must/system0_disable.json b/tests/robot/tests/must/intents/system0_disable.json similarity index 100% rename from tests/robot/tests/must/system0_disable.json rename to tests/robot/tests/must/intents/system0_disable.json diff --git a/tests/robot/tests/must/intents/system0_enable.json b/tests/robot/tests/must/intents/system0_enable.json new file mode 100644 index 00000000..93132fb6 --- /dev/null +++ b/tests/robot/tests/must/intents/system0_enable.json @@ -0,0 +1,6 @@ +[ + { + "path": "interface[name=system0]/admin-state", + "value": "enable" + } +] \ No newline at end of file diff --git a/tests/robot/tests/must/must_statements.robot b/tests/robot/tests/must/must_statements.robot index ed10f006..4326d016 100644 --- a/tests/robot/tests/must/must_statements.robot +++ b/tests/robot/tests/must/must_statements.robot @@ -8,10 +8,10 @@ Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVE Suite Teardown Teardown *** Variables *** -${DATA-SERVER-BIN} ./bin/data-server +${DATA-SERVER-BIN} ${CURDIR}/../../../data-server ${SDCTL} sdctl -${DATA-SERVER-CONFIG} ./tests/robot/tests/must/data-server.yaml +${DATA-SERVER-CONFIG} ${CURDIR}/data-server.yaml ${DATA-SERVER-IP} 127.0.0.1 ${DATA-SERVER-PORT} 56000 @@ -25,18 +25,14 @@ ${srlinux1-candidate} default ${srlinux1-schema-name} srl ${srlinux1-schema-version} 22.11.2 ${srlinux1-schema-Vendor} Nokia -${srlinux1-target-def} ./tests/robot/tests/must/srl1_target.json -${srlinux1-sync-def} ./tests/robot/tests/must/sync.json +${srlinux1-target-def} ${CURDIR}/srl1_target.json +${srlinux1-sync-def} ${CURDIR}/sync.json ${owner} test ${priority} 100 # internal vars -${schema-server-process-alias} ssa -${schema-server-stderr} /tmp/ss-out ${data-server-process-alias} dsa ${data-server-stderr} /tmp/ds-out -${cache-server-process-alias} csa -${cache-server-stderr} /tmp/cs-out *** Test Cases *** @@ -50,7 +46,7 @@ Create SRL1 Target Set system0 admin-state disable -> Fail LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=system0]/admin-state - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/system0_disable.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/system0_disable.json Should Contain ${result.stderr} admin-state must be enable Should Be Equal As Integers ${result.rc} 1 @@ -60,12 +56,7 @@ Set system0 admin-state disable -> Fail Set system0 admin-state enable -> Pass LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=system0]/admin-state - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=system0]/admin-state:::enable - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/system0_enable.json Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} @@ -73,12 +64,7 @@ Set system0 admin-state enable -> Pass Set ethernet-1/1 admin-state disable -> Pass LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=system0]/admin-state - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} interface[name=ethernet-1/1]/admin-state:::disable - Should Be Equal As Integers ${result.rc} 0 - - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/e11_disable.json Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} @@ -86,7 +72,7 @@ Set ethernet-1/1 admin-state disable -> Pass Set lag-type without 'interface[name=xyz]/lag/lacp' existence LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=lag1]/lag/lag-type - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_lacp_fail.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lag_lacp_fail.json Should Contain ${result.stderr} lacp container must be configured when lag-type is lacp Should Be Equal As Integers ${result.rc} 1 @@ -97,7 +83,7 @@ Set lag-type with 'interface[name=xyz]/lag/lacp' existence LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=lag1]/lag/lacp/admin-key LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=lag1]/lag/lag-type - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_lacp_pass.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lag_lacp_pass.json Should Be Equal As Integers ${result.rc} 0 @@ -106,7 +92,7 @@ Set lag-type with 'interface[name=xyz]/lag/lacp' existence Set auto-negotiate on non allowed interface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-0/1]/ethernet/auto-negotiate - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/autoneg_fail.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/autoneg_fail.json Should Contain ${result.stderr} auto-negotiation not supported on this interface Should Be Equal As Integers ${result.rc} 1 @@ -116,7 +102,7 @@ Set auto-negotiate on non allowed interface Set auto-negotiate on allowed interface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/auto-negotiate - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/autoneg_pass.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/autoneg_pass.json Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} @@ -125,7 +111,7 @@ Set auto-negotiation on breakout-mode port LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/auto-negotiate LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/breakout-mode/num-breakout-ports - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/breakout_autoneg.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/breakout_autoneg.json Should Contain ${result.stderr} auto-negotiate not configurable when breakout-mode is enabled Should Be Equal As Integers ${result.rc} 1 @@ -136,7 +122,7 @@ Set breakout-port num to 2 and port-speed to 25G LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/breakout-mode/breakout-port-speed LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/breakout-mode/num-breakout-ports - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/breakout_speed.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/breakout_speed.json Should Be Equal As Integers ${result.rc} 1 Should Contain ${result.stderr} breakout-port-speed must be 100G when num-breakout-ports is 2 @@ -147,7 +133,7 @@ Set breakout-port num to 2 and port-speed to 25G Set interface ethernet l2cp-transparency lldp tunnel true LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/l2cp-transparency/lldp/tunnel - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lldp_tun_pass.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lldp_tun_pass.json Should Be Equal As Integers ${result.rc} 0 @@ -156,7 +142,7 @@ Set interface ethernet l2cp-transparency lldp tunnel true Set interface ethernet l2cp-transparency lldp tunnel true on lldp true interface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/l2cp-transparency/lldp/tunnel - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lldp_tun_fail.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lldp_tun_fail.json Should Be Equal As Integers ${result.rc} 1 Should Contain ${result.stderr} this interface must not have lldp enabled @@ -166,7 +152,7 @@ Set interface ethernet l2cp-transparency lldp tunnel true on lldp true interface Set bfd for non existing subinterface LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} /bfd/subinterface/id - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/bfd.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/bfd.json Should Be Equal As Integers ${result.rc} 1 Should Contain ${result.stderr} Must be an existing subinterface name @@ -176,7 +162,7 @@ Set bfd for non existing subinterface Check LAG interface member speed is set LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/aggregate-id - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_speed.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lag_speed.json Should Contain ${result.stderr} member-speed must be configured on associated aggregate-id interface Should Be Equal As Integers ${result.rc} 1 @@ -186,7 +172,7 @@ Check LAG interface member speed is set Check LAG interface vlan-tagging not set on member LogMustStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} interface[name=ethernet-1/1]/ethernet/aggregate-id - ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/lag_vlan_tagging.json + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lag_vlan_tagging.json Should Contain ${result.stderr} vlan-tagging and aggregate-id can not be configured together Should Be Equal As Integers ${result.rc} 1 diff --git a/tests/robot/tests/must/system0_enable.json b/tests/robot/tests/must/system0_enable.json deleted file mode 100644 index d0281e51..00000000 --- a/tests/robot/tests/must/system0_enable.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "path": "interface[name=lag1]/lag/lag-type", - "value":"lacp" - } -] \ No newline at end of file From cd5fe9265fd952dd42994f08877c8b7e093280ab Mon Sep 17 00:00:00 2001 From: steiler Date: Wed, 3 Apr 2024 15:04:48 +0200 Subject: [PATCH 03/10] fix string conversion --- pkg/datastore/data_rpc.go | 13 +++++++++++++ tests/robot/tests/must/must_statements.robot | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/datastore/data_rpc.go b/pkg/datastore/data_rpc.go index a4a8811d..7d0ce367 100644 --- a/pkg/datastore/data_rpc.go +++ b/pkg/datastore/data_rpc.go @@ -852,6 +852,19 @@ func (d *Datastore) expandUpdate(ctx context.Context, upd *sdcpb.Update, include upds := append(upds, rs...) return upds, nil case *sdcpb.SchemaElem_Field: + var v interface{} + var err error + switch upd.GetValue().Value.(type) { + case *sdcpb.TypedValue_JsonVal: + err = json.Unmarshal(upd.GetValue().GetJsonVal(), &v) + if err == nil { + switch v := v.(type) { + case string: + upd.Value = &sdcpb.TypedValue{Value: &sdcpb.TypedValue_StringVal{StringVal: v}} + } + } + } + // TODO: Check if value is json and convert to String ? upds = append(upds, upd) return upds, nil diff --git a/tests/robot/tests/must/must_statements.robot b/tests/robot/tests/must/must_statements.robot index 4326d016..67f86ed2 100644 --- a/tests/robot/tests/must/must_statements.robot +++ b/tests/robot/tests/must/must_statements.robot @@ -4,11 +4,11 @@ Resource ../../keywords/client.robot Library OperatingSystem Library String Library Process -Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} -Suite Teardown Teardown +# Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} +# Suite Teardown Teardown *** Variables *** -${DATA-SERVER-BIN} ${CURDIR}/../../../data-server +${DATA-SERVER-BIN} ${CURDIR}/../../../../bin/data-server ${SDCTL} sdctl ${DATA-SERVER-CONFIG} ${CURDIR}/data-server.yaml From 0891f5e02025f344bd4356862adc381e4a4d1b34 Mon Sep 17 00:00:00 2001 From: steiler Date: Thu, 4 Apr 2024 14:13:54 +0200 Subject: [PATCH 04/10] fixing leafref validation (removing early return nil) --- pkg/datastore/datastore_rpc.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/datastore/datastore_rpc.go b/pkg/datastore/datastore_rpc.go index 19541bc2..be413a28 100644 --- a/pkg/datastore/datastore_rpc.go +++ b/pkg/datastore/datastore_rpc.go @@ -575,7 +575,6 @@ func (d *Datastore) resolveLeafref(ctx context.Context, candidate string, leafRe leafRefPath.Elem[len(leafRefPath.Elem)-2].Key[leafRefPath.Elem[len(leafRefPath.Elem)-1].Name] = value // remove the last elem, we now have the key value stored in the one before last leafRefPath.Elem = leafRefPath.Elem[:len(leafRefPath.Elem)-1] - return nil } } From 326e74cf865f4a9e39ff20605ef7293a9f0ef769 Mon Sep 17 00:00:00 2001 From: steiler Date: Thu, 4 Apr 2024 14:14:41 +0200 Subject: [PATCH 05/10] leafref tests --- .../leafref/intents/bgp_policy_fail.json | 24 ++++ .../leafref/intents/bgp_policy_pass.json | 34 ++++++ .../intents/lref_abs_current_fail.json | 36 ++++++ .../intents/lref_abs_current_pass.json | 41 +++++++ .../intents/lref_relative_path_fail.json | 28 +++++ .../intents/lref_relative_path_pass.json | 33 ++++++ .../tests/leafref/leafref_statements.robot | 105 ++++++++++++------ tests/robot/tests/must/must_statements.robot | 4 +- 8 files changed, 268 insertions(+), 37 deletions(-) create mode 100644 tests/robot/tests/leafref/intents/bgp_policy_fail.json create mode 100644 tests/robot/tests/leafref/intents/bgp_policy_pass.json create mode 100644 tests/robot/tests/leafref/intents/lref_abs_current_fail.json create mode 100644 tests/robot/tests/leafref/intents/lref_abs_current_pass.json create mode 100644 tests/robot/tests/leafref/intents/lref_relative_path_fail.json create mode 100644 tests/robot/tests/leafref/intents/lref_relative_path_pass.json diff --git a/tests/robot/tests/leafref/intents/bgp_policy_fail.json b/tests/robot/tests/leafref/intents/bgp_policy_fail.json new file mode 100644 index 00000000..9b277b22 --- /dev/null +++ b/tests/robot/tests/leafref/intents/bgp_policy_fail.json @@ -0,0 +1,24 @@ +[ + { + "path": "/", + "value": { + "network-instance": [ + { + "name": "default", + "protocols": { + "bgp": { + "router-id": "1.2.3.4", + "autonomous-system":"65001", + "group": [ + { + "group-name": "foo", + "export-policy": "mypolicy" + } + ] + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/leafref/intents/bgp_policy_pass.json b/tests/robot/tests/leafref/intents/bgp_policy_pass.json new file mode 100644 index 00000000..45614532 --- /dev/null +++ b/tests/robot/tests/leafref/intents/bgp_policy_pass.json @@ -0,0 +1,34 @@ +[ + { + "path": "/", + "value": { + "network-instance": [ + { + "name": "default", + "protocols": { + "bgp": { + "router-id": "1.2.3.4", + "autonomous-system":"65001", + "group": [ + { + "group-name": "foo", + "export-policy": "mypolicy" + } + ] + } + } + } + ], + "routing-policy": { + "policy": [ + { + "name": "mypolicy", + "default-action": { + "policy-result": "reject" + } + } + ] + } + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/leafref/intents/lref_abs_current_fail.json b/tests/robot/tests/leafref/intents/lref_abs_current_fail.json new file mode 100644 index 00000000..b8a2ada4 --- /dev/null +++ b/tests/robot/tests/leafref/intents/lref_abs_current_fail.json @@ -0,0 +1,36 @@ +[ + { + "path": "/", + "value": { + "interface": [ + { + "name": "ethernet-1/1", + "subinterface": [ + { + "index": 0, + "admin-state": "enable" + } + ] + } + ], + "network-instance": [ + { + "name": "default", + "protocols": { + "bgp": { + "router-id": "1.2.3.4", + "autonomous-system": "65001", + "dynamic-neighbors": { + "interface": [ + { + "interface-name": "ethernet-1/1.0" + } + ] + } + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/leafref/intents/lref_abs_current_pass.json b/tests/robot/tests/leafref/intents/lref_abs_current_pass.json new file mode 100644 index 00000000..11b1ca74 --- /dev/null +++ b/tests/robot/tests/leafref/intents/lref_abs_current_pass.json @@ -0,0 +1,41 @@ +[ + { + "path": "/", + "value": { + "interface": [ + { + "name": "ethernet-1/1", + "subinterface": [ + { + "index": 0, + "admin-state": "enable" + } + ] + } + ], + "network-instance": [ + { + "name": "default", + "interface": [ + { + "name": "ethernet-1/1.0" + } + ], + "protocols": { + "bgp": { + "router-id": "1.2.3.4", + "autonomous-system": "65001", + "dynamic-neighbors": { + "interface": [ + { + "interface-name": "ethernet-1/1.0" + } + ] + } + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/leafref/intents/lref_relative_path_fail.json b/tests/robot/tests/leafref/intents/lref_relative_path_fail.json new file mode 100644 index 00000000..7ee302e0 --- /dev/null +++ b/tests/robot/tests/leafref/intents/lref_relative_path_fail.json @@ -0,0 +1,28 @@ +[ + { + "path": "/", + "value": { + "network-instance": [ + { + "name": "default", + "protocols": { + "bgp": { + "router-id": "1.2.3.4", + "autonomous-system":"65001", + "dynamic-neighbors": { + "accept": { + "match": [ + { + "prefix": "1.2.3.4/32", + "peer-group": "mypg" + } + ] + } + } + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/leafref/intents/lref_relative_path_pass.json b/tests/robot/tests/leafref/intents/lref_relative_path_pass.json new file mode 100644 index 00000000..92cf5524 --- /dev/null +++ b/tests/robot/tests/leafref/intents/lref_relative_path_pass.json @@ -0,0 +1,33 @@ +[ + { + "path": "/", + "value": { + "network-instance": [ + { + "name": "default", + "protocols": { + "bgp": { + "router-id": "1.2.3.4", + "autonomous-system":"65001", + "dynamic-neighbors": { + "accept": { + "match": [ + { + "prefix": "1.2.3.4/32", + "peer-group": "mypg" + } + ] + } + }, + "group": [ + { + "group-name": "mypg" + } + ] + } + } + } + ] + } + } +] \ No newline at end of file diff --git a/tests/robot/tests/leafref/leafref_statements.robot b/tests/robot/tests/leafref/leafref_statements.robot index 2da29d6a..095c3080 100644 --- a/tests/robot/tests/leafref/leafref_statements.robot +++ b/tests/robot/tests/leafref/leafref_statements.robot @@ -4,76 +4,111 @@ Resource ../../keywords/client.robot Library OperatingSystem Library String Library Process -#Suite Setup Setup True ${server-bin} ${cache-bin} ${schema-server-config} ${schema-server-process-alias} ${schema-server-stderr} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} ${cache-server-config} ${cache-server-process-alias} ${cache-server-stderr} -#Suite Teardown Teardown +Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} +Suite Teardown Teardown *** Variables *** -${server-bin} ./bin/server -${client-bin} ./bin/client -${cache-bin} ../cache/bin/cached -${schema-server-config} ./tests/robot/tests/must/schema-server.yaml -${data-server-config} ./tests/robot/tests/must/data-server.yaml -${cache-server-config} ./tests/robot/tests/must/cache.yaml -${schema-server-ip} 127.0.0.1 -${schema-server-port} 55000 -${data-server-ip} 127.0.0.1 -${data-server-port} 56000 +${DATA-SERVER-BIN} ${CURDIR}/../../../../bin/data-server +${SDCTL} sdctl + +${DATA-SERVER-CONFIG} ${CURDIR}/../must/data-server.yaml + +${DATA-SERVER-IP} 127.0.0.1 +${DATA-SERVER-PORT} 56000 + +${SCHEMA-SERVER-IP} 127.0.0.1 +${SCHEMA-SERVER-PORT} 56000 + # TARGET ${srlinux1-name} srl1 ${srlinux1-candidate} default ${srlinux1-schema-name} srl ${srlinux1-schema-version} 22.11.2 -${srlinux1-schema-Vendor} Nokia +${srlinux1-schema-vendor} Nokia +${srlinux1-target-def} ${CURDIR}/../must/srl1_target.json +${srlinux1-sync-def} ${CURDIR}/../must/sync.json +${owner} test +${priority} 100 # internal vars -${schema-server-process-alias} ssa -${schema-server-stderr} /tmp/ss-out ${data-server-process-alias} dsa ${data-server-stderr} /tmp/ds-out -${cache-server-process-alias} csa -${cache-server-stderr} /tmp/cs-out + *** Test Cases *** -# Check Server State -# CheckServerState ${schema-server-process-alias} ${data-server-process-alias} ${cache-server-process-alias} +Check Server State + CheckServerState Colocated ${data-server-process-alias} + +Create SRL1 Target + ${result} = CreateDataStoreTarget ${srlinux1-name} ${srlinux1-target-def} ${srlinux1-sync-def} ${srlinux1-schema-name} ${srlinux1-schema-Vendor} ${srlinux1-schema-version} + Should Be Equal As Integers ${result.rc} 0 BGP export-policy non-existing + [Documentation] This tests a LeafRef that contains an absolute path. LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance[name=default]/protocols/bgp/group - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} + ${result} = GetSchema ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance[name=default]/protocols/bgp/group + Log ${result.stdout} + Log ${result.stderr} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} network-instance[name=default]/protocols/bgp/group[group-name=foo]/export-policy:::bar-policy - Should Be Equal As Integers ${result.rc} 0 + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/bgp_policy_fail.json - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} Should Contain ${result.stderr} missing leaf reference Should Be Equal As Integers ${result.rc} 1 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} BGP export-policy existing + [Documentation] This tests a LeafRef that contains an absolute path. LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance[name=default]/protocols/bgp/group - CreateCandidate ${srlinux1-name} ${srlinux1-candidate} + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/bgp_policy_pass.json + Should Be Equal As Integers ${result.rc} 0 - ${result} = GetSchema ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} routing-policy/policy[name=bar-policy]/default-action/policy-result:::reject - Log ${result.stdout} - Log ${result.stderr} + DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} routing-policy/policy[name=mypolicy]/default-action/policy-result:::reject - Log ${result.stdout} - Log ${result.stderr} - Should Be Equal As Integers ${result.rc} 0 +BGP dynamic-neighbor peer-group - fail + [Documentation] This is a LeafRef that contains a relative path. + LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance/protocols/bgp/dynamic-neighbors/accept/match/peer-group + + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lref_relative_path_fail.json + + Should Contain ${result.stderr} missing leaf reference + Should Be Equal As Integers ${result.rc} 1 + + DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} + +BGP dynamic-neighbor peer-group - pass + [Documentation] This is a LeafRef that contains a relative path. + LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance/protocols/bgp/dynamic-neighbors/accept/match/peer-group + + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lref_relative_path_pass.json - ${result} = Set ${srlinux1-name} ${srlinux1-candidate} network-instance[name=default]/protocols/bgp/group[group-name=foo]/export-policy:::mypolicy Should Be Equal As Integers ${result.rc} 0 - ${result} = Commit ${srlinux1-name} ${srlinux1-candidate} - Log ${result.stderr} + DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} + +BGP danymic-neighbor interface - fail + [Documentation] This is a LeafRef that contains an absolute path with a key that utilizes the current() reference. + LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance/protocols/bgp/dynamic-neighbors/interface/interface-name + + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lref_abs_current_fail.json + + Should Contain ${result.stderr} missing leaf reference + Should Be Equal As Integers ${result.rc} 1 + + DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} + +BGP danymic-neighbor interface - pass + [Documentation] This is a LeafRef that contains an absolute path with a key that utilizes the current() reference. + LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance/protocols/bgp/dynamic-neighbors/interface/interface-name + + ${result} = SetIntent ${srlinux1-name} ${srlinux1-candidate} ${owner} ${priority} ${CURDIR}/intents/lref_abs_current_pass.json + Should Be Equal As Integers ${result.rc} 0 DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} + diff --git a/tests/robot/tests/must/must_statements.robot b/tests/robot/tests/must/must_statements.robot index 67f86ed2..b62279ca 100644 --- a/tests/robot/tests/must/must_statements.robot +++ b/tests/robot/tests/must/must_statements.robot @@ -4,8 +4,8 @@ Resource ../../keywords/client.robot Library OperatingSystem Library String Library Process -# Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} -# Suite Teardown Teardown +Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} +Suite Teardown Teardown *** Variables *** ${DATA-SERVER-BIN} ${CURDIR}/../../../../bin/data-server From 7ad6ca8f5aa0cd50b2876201008a47710f76c194 Mon Sep 17 00:00:00 2001 From: steiler Date: Fri, 5 Apr 2024 14:27:20 +0200 Subject: [PATCH 06/10] update colocated tests --- tests/robot/keywords/client.robot | 62 +- tests/robot/keywords/gnmic.robot | 36 +- tests/robot/tests/collocated/colloc.robot | 786 ++++++++++-------- .../tests/collocated/collocated_test.yaml | 49 +- .../tests/collocated/lab/collocated.clab.yaml | 10 +- 5 files changed, 503 insertions(+), 440 deletions(-) diff --git a/tests/robot/keywords/client.robot b/tests/robot/keywords/client.robot index 281bdf25..c163c547 100644 --- a/tests/robot/keywords/client.robot +++ b/tests/robot/keywords/client.robot @@ -31,7 +31,8 @@ GetDataStore ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} ... datastore ... get - ... --ds ${datastore} + ... --ds + ... ${datastore} Log ${result.rc} Log ${result.stdout} Log ${result.stderr} @@ -80,16 +81,22 @@ DeleteDatastore RETURN ${result} CreateCandidate - [Documentation] Create a new named Candidate in the given Datastore + [Documentation] Create a new named Candidate in the given Datastore. [Arguments] ${datastore} ${candidate} ${owner} ${priority} ${result} = Run Process ... ${SDCTL} - ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} - ... datastore create - ... --ds ${datastore} - ... --candidate ${candidate} - ... --owner ${owner} - ... --priority ${priority} + ... -a + ... ${DATA-SERVER-IP}:${DATA-SERVER-PORT} + ... datastore + ... create + ... --ds + ... ${datastore} + ... --candidate + ... ${candidate} + ... --owner + ... ${owner} + ... --priority + ... ${priority} Log ${result.rc} Log ${result.stdout} @@ -97,10 +104,10 @@ CreateCandidate RETURN ${result} GetCandidate - [Documentation] Create a new named Candidate in the given Datastore + [Documentation] Retrieve the given candidate from the referenced Datastore [Arguments] ${datastore} ${candidate} ${result} = Run Process - ... ${SDCTL} + ... ${SDCTL} ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} ... datastore get ... --ds ${datastore} @@ -161,7 +168,7 @@ Commit Get [Documentation] Get a path from the datastore - [Arguments] ${datastore} ${ds-get-flags} + [Arguments] ${datastore} @{ds-get-flags} ${result} = Run Process ... ${SDCTL} ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} @@ -184,6 +191,8 @@ GetFromCandidate ... --ds ${datastore} ... --candidate ${candidate} ... --path ${path} + ... --type CONFIG + ... timeout=5sec Log ${result.rc} Log ${result.stdout} @@ -192,14 +201,14 @@ GetFromCandidate Set [Documentation] Applies to the candidate of the given datastore the provided update - [Arguments] ${datastore} ${candidate} ${set-flags} + [Arguments] ${datastore} ${candidate} @{set-flags} ${result} = Run Process ... ${SDCTL} ... -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} ... data set ... --ds ${datastore} ... --candidate ${candidate} - ... ${set-flags} + ... @{set-flags} Log ${result.rc} Log ${result.stdout} @@ -243,6 +252,33 @@ GetSchema Log ${result.stderr} RETURN ${result} +ListSchemas + ${result} = Run Process + ... ${SDCTL} + ... -a + ... ${SCHEMA-SERVER-IP}:${SCHEMA-SERVER-PORT} + ... schema + ... list + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} + +Check Datastore Connected + [Documentation] Checks weather the provided Datastore is in the connected state. + [Arguments] ${datastore} + + ${result} = client.GetDataStore ${datastore} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} name: "${datastore}" + Should Contain ${result.stdout} status: CONNECTED + RETURN ${result} + +Wait Until Datastore connected + [Arguments] ${datastore} ${retry} ${interval} + Wait Until Keyword Succeeds ${retry} ${interval} Check Datastore Connected ${datastore} + # Helper ExtractResponse [Documentation] Takes the output of the client binary and returns just the response part, stripping the request diff --git a/tests/robot/keywords/gnmic.robot b/tests/robot/keywords/gnmic.robot index 9b0b62a5..48c13514 100644 --- a/tests/robot/keywords/gnmic.robot +++ b/tests/robot/keywords/gnmic.robot @@ -15,19 +15,35 @@ Capabilities Get [Documentation] run Get using gNMIc - [Arguments] ${router} ${gnmic_flags} - ${rc} ${result} = Run And Return Rc And Output - ... gnmic -a ${router} get ${gnmic_flags} --log - Log ${result} - RETURN ${rc} ${result} + [Arguments] ${router} @{gnmic_flags} + ${result} = Run Process + ... gnmic + ... -a + ... ${router} + ... get + ... @{gnmic_flags} + ... --log + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} Set [Documentation] run Set using gNMIc - [Arguments] ${router} ${gnmic_flags} - ${rc} ${result} = Run And Return Rc And Output - ... gnmic -a ${router} set ${gnmic_flags} --log - Log ${result} - RETURN ${rc} ${result} + [Arguments] ${router} @{gnmic_flags} + ${result} = Run Process + ... gnmic + ... -a + ... ${router} + ... set + ... @{gnmic_flags} + ... --log + + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} SubscribeOnce [Documentation] run Subscribe mode ONCE using gNMIc diff --git a/tests/robot/tests/collocated/colloc.robot b/tests/robot/tests/collocated/colloc.robot index c5f79135..76b5281e 100644 --- a/tests/robot/tests/collocated/colloc.robot +++ b/tests/robot/tests/collocated/colloc.robot @@ -1,386 +1,442 @@ *** Settings *** -Resource ../../keywords/server.robot -Resource ../../keywords/client.robot -Resource ../../keywords/gnmic.robot -Library OperatingSystem -Library String -Library Process -Suite Setup server.DeployLab ${topology-file} -Suite Teardown server.DestroyLab ${topology-file} +Resource ../../keywords/server.robot +Resource ../../keywords/client.robot +Resource ../../keywords/gnmic.robot +Library OperatingSystem +Library String +Library Process + +Suite Setup DeployLab ${topology-file} +Suite Teardown DestroyLab ${topology-file} +Test Setup Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} +Test Teardown Teardown + *** Variables *** -${data-server-bin} ../../bin/data-server -${data-server-config} ./tests/collocated/collocated_test.yaml -${client-bin} ../../bin/datactl -${data-server-ip} 127.0.0.1 -${data-server-port} 56000 -${topology-file} ./tests/collocated/lab/collocated.clab.yaml +${DATA-SERVER-BIN} ${CURDIR}/../../../../bin/data-server +${SDCTL} sdctl +${data-server-config} ${CURDIR}/collocated_test.yaml +${topology-file} ${CURDIR}/lab/collocated.clab.yaml + +${DATA-SERVER-IP} 127.0.0.1 +${DATA-SERVER-PORT} 56000 + +${SCHEMA-SERVER-IP} 127.0.0.1 +${SCHEMA-SERVER-PORT} 56000 # TARGET -${schema-name} srl -${schema-version} 23.10.1 -${schema-vendor} Nokia -${candidate-name} default +${schema-name} srl +${schema-version} 23.10.1 +${schema-vendor} Nokia +${candidate-name} default -${datastore1} srl1 -${datastore2} srl2 -${target-file1} ./tests/collocated/robot_srl1.json -${target-file2} ./tests/collocated/robot_srl2.json -${target-sync-file} ./tests/collocated/sync.json +${owner} test +${priority} 100 -${router} "" -${gnmic_flags} "" +${datastore1} srl1 +${devicename1} clab-collocated-srl1 +${target-file1} ${CURDIR}/robot_srl1.json +${datastore2} srl2 +${devicename2} clab-collocated-srl2 +${target-file2} ${CURDIR}/robot_srl2.json + +${target-sync-file} ${CURDIR}/sync.json + +${router} "" +${gnmic_flags} "" # internal vars ${data-server-process-alias} dsa -${data-server-stderr} /tmp/ds-out +${data-server-stderr} /tmp/ds-out *** Test Cases *** - Create and delete a Datastore - [Tags] robot:continue-on-failure - - server.Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} - - # create first datastore - ${rc} ${result} = client.CreateDataStoreTarget ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - - # create second datastore - ${rc} ${result} = client.CreateDataStoreTarget ${datastore2} ${target-file2} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Sleep 30s - - ${rc} ${result} = client.GetDataStore ${datastore1} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} name: "${datastore1}" - Should Contain ${result} status: CONNECTED - - ${rc} ${result} = client.DeleteDatastore ${datastore1} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.GetDataStore ${datastore1} - Log ${result} - Should Not Be Equal As Integers ${rc} 0 - Should Contain ${result} unknown datastore ${datastore1} - - # ${rc} ${result} = server.DestroyLab ${topology-file} - # Log ${result} - # Should Be Equal As Integers ${rc} 0 - - server.Teardown + [Tags] robot:continue-on-failure + + # create first datastore + ${result} = CreateDataStoreTarget + ... ${datastore1} + ... ${target-file1} + ... ${target-sync-file} + ... ${schema-name} + ... ${schema-vendor} + ... ${schema-version} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + + # create second datastore + ${result} = CreateDataStoreTarget + ... ${datastore2} + ... ${target-file2} + ... ${target-sync-file} + ... ${schema-name} + ... ${schema-vendor} + ... ${schema-version} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore2} + + Wait Until Datastore connected ${datastore1} 30s 1s + + ${result} = DeleteDatastore ${datastore1} + Should Be Equal As Integers ${result.rc} 0 + + ${result} = GetDataStore ${datastore1} + Should Not Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} unknown datastore ${datastore1} Create and delete a Datastore and candidate - [Tags] robot:continue-on-failure - - - server.Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} - - # create first datastore - ${rc} ${result} = client.CreateDataStoreTarget ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - - # create second datastore - ${rc} ${result} = client.CreateDataStoreTarget ${datastore2} ${target-file2} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - Sleep 30s - - ${rc} ${result} = client.GetDataStore ${datastore1} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} name: "${datastore1}" - Should Contain ${result} status: CONNECTED - - ${rc} ${result} = client.CreateCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.GetCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - Should Contain ${result} ${candidate-name} - - ${rc} ${result} = client.DeleteCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - - ${rc} ${result} = client.GetCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - Should Not Contain ${result} ${candidate-name} - - server.Teardown + [Tags] robot:continue-on-failure + + # create first datastore + ${result} = client.CreateDataStoreTarget + ... ${datastore1} + ... ${target-file1} + ... ${target-sync-file} + ... ${schema-name} + ... ${schema-vendor} + ... ${schema-version} + + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + + # create second datastore + ${result} = client.CreateDataStoreTarget + ... ${datastore2} + ... ${target-file2} + ... ${target-sync-file} + ... ${schema-name} + ... ${schema-vendor} + ... ${schema-version} + Should Be Equal As Integers ${result.rc} 0 + + Wait Until Datastore connected ${datastore1} 30s 1s + + ${result} = client.CreateCandidate ${datastore1} ${candidate-name} ${owner} ${priority} + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.ListDataStores + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Contain ${result.stdout} ${candidate-name} + + ${result} = client.GetCandidate ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Contain ${result.stdout} ${candidate-name} + + ${result} = client.DeleteCandidate ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + + ${result} = client.GetCandidate ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Not Contain ${result.stdout} ${candidate-name} Configure Router gNMI - Set / Delete Leaf - [Tags] robot:continue-on-failure - - server.Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} - - ${rc} ${result} = Run And Return Rc And Output - ... schemac -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} schema list - Log ${result} - - # delete interface config - ${rc} ${result} = gnmic.Set clab-collocated-srl1 --skip-verify -u admin -p NokiaSrl1! --delete /interface[name=ethernet-1/1] - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.CreateDataStoreTarget ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Sleep 30s - - ${rc} ${result} = client.GetDataStore ${datastore1} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} name: "${datastore1}" - Should Contain ${result} status: CONNECTED - - # create candidate - ${rc} ${result} = client.CreateCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.GetCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - Should Contain ${result} ${candidate-name} - - # set config into candidate - ${rc} ${result} = client.Set ${datastore1} ${candidate-name} --update /interface[name=ethernet-1/1]/description:::Desc1 - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # get config from candidate - ${rc} ${result} = client.GetFromCandidate ${datastore1} ${candidate-name} /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # run diff - ${rc} ${result} = client.Diff ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # commit - ${rc} ${result} = client.Commit ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # query fom intended store - ${rc} ${result} = client.Get ${datastore1} --intended --path /interface[name=ethernet-1/1]/description --priority -1 - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # query fom router - ${rc} ${result} = gnmic.Get clab-collocated-srl1 --skip-verify -e JSON_IETF -u admin -p NokiaSrl1! --format flat --path /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # DELETE - # create candidate - ${rc} ${result} = client.CreateCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.GetCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - Should Contain ${result} ${candidate-name} - - # set config into candidate - ${rc} ${result} = client.Set ${datastore1} ${candidate-name} --delete /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # get config from candidate - ${rc} ${result} = client.GetFromCandidate ${datastore1} ${candidate-name} /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} Desc1 - - # run diff - ${rc} ${result} = client.Diff ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # commit - ${rc} ${result} = client.Commit ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # query fom intended store - ${rc} ${result} = client.Get ${datastore1} --intended --path /interface[name=ethernet-1/1]/description --priority -1 - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} Desc1 - - # query fom router - ${rc} ${result} = gnmic.Get clab-collocated-srl1 --skip-verify -e JSON_IETF -u admin -p NokiaSrl1! --format flat --path /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} Desc1 - - server.Teardown - + [Tags] robot:continue-on-failure + + ${result} = ListSchemas + Should Be Equal As Integers ${result.rc} 0 + + # delete interface config + ${result} = gnmic.Set + ... ${devicename1} + ... --skip-verify + ... -u admin + ... -p NokiaSrl1! + ... --delete /interface[name=ethernet-1/1] + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.CreateDataStoreTarget + ... ${datastore1} + ... ${target-file1} + ... ${target-sync-file} + ... ${schema-name} + ... ${schema-vendor} + ... ${schema-version} + Should Be Equal As Integers ${result.rc} 0 + + Wait Until Datastore connected ${datastore1} 30s 1s + + # create candidate + ${result} = client.CreateCandidate ${datastore1} ${candidate-name} ${owner} ${priority} + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.GetCandidate ${datastore1} ${candidate-name} + + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Contain ${result.stdout} ${candidate-name} + + # set config into candidate + ${result} = client.Set + ... ${datastore1} + ... ${candidate-name} + ... --update /interface[name=ethernet-1/1]/description:::Desc1 + Should Be Equal As Integers ${result.rc} 0 + + # get config from candidate + ${result} = client.GetFromCandidate + ... ${datastore1} + ... ${candidate-name} + ... /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # run diff + ${result} = client.Diff ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # commit + ${result} = client.Commit ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + + # query fom intended store + ${result} = client.Get + ... ${datastore1} + ... --intended + ... --path /interface[name=ethernet-1/1]/description + + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # query fom router + ${result} = gnmic.Get + ... ${devicename1} + ... --skip-verify + ... -e JSON_IETF + ... -u admin + ... -p NokiaSrl1! + ... --format flat + ... --path + ... /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # DELETE + # create candidate + ${result} = client.CreateCandidate ${datastore1} ${candidate-name} ${owner} ${priority} + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.GetCandidate ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Contain ${result.stdout} ${candidate-name} + + # set config into candidate + ${result} = client.Set + ... ${datastore1} + ... ${candidate-name} + ... --delete /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + + # get config from candidate + ${result} = client.GetFromCandidate + ... ${datastore1} + ... ${candidate-name} + ... /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} Desc1 + + # run diff + ${result} = client.Diff ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # commit + ${result} = client.Commit ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + + # query fom intended store + ${result} = client.Get + ... ${datastore1} + ... --intended + ... --path /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} Desc1 + + # query fom router + ${result} = gnmic.Get + ... ${devicename1} + ... --skip-verify + ... -e JSON_IETF + ... -u admin + ... -p NokiaSrl1! + ... --format flat + ... --path /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} Desc1 Configure Router gNMI - Create / Delete List item - [Tags] robot:continue-on-failure - - server.Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} - - ${rc} ${result} = Run And Return Rc And Output - ... schemac -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} schema list - Log ${result} - - # delete interface config in case there are some remains - ${rc} ${result} = gnmic.Set clab-collocated-srl1 --skip-verify -u admin -p NokiaSrl1! --delete /interface[name=ethernet-1/1] - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.CreateDataStore ${datastore1} ${target-file1} ${target-sync-file} ${schema-name} ${schema-vendor} ${schema-version} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Sleep 30s - - ${rc} ${result} = client.GetDataStore ${datastore1} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} name: "${datastore1}" - Should Contain ${result} status: CONNECTED - - # create candidate - ${rc} ${result} = client.CreateCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.GetCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - Should Contain ${result} ${candidate-name} - - # set config into candidate - ${rc} ${result} = client.Set - ... ${datastore1} ${candidate-name} --update /interface[name=ethernet-1/1]/description:::Desc1 --update /interface[name=ethernet-1/1]/subinterface[index=0]/admin-state:::enable --update /interface[name=ethernet-1/1]/subinterface[index=0]/description:::DescSub0 - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # get config from candidate - ${rc} ${result} = client.GetFromCandidate ${datastore1} ${candidate-name} /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # get config from candidate - ${rc} ${result} = client.GetFromCandidate ${datastore1} ${candidate-name} /interface[name=ethernet-1/1]/subinterface[index=0] - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} DescSub0 - - # run diff - ${rc} ${result} = client.Diff ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - Should Contain ${result} DescSub0 - - # commit - ${rc} ${result} = client.Commit ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # query from router - ${rc} ${result} = gnmic.Get clab-collocated-srl1 --skip-verify -e ASCII -u admin -p NokiaSrl1! --format flat --path /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - - # query from router - ${rc} ${result} = gnmic.Get clab-collocated-srl1 --skip-verify -e ASCII -u admin -p NokiaSrl1! --format flat --path /interface[name=ethernet-1/1]/subinterface[index=0]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} DescSub0 - - # DELETE - # create candidate - ${rc} ${result} = client.CreateCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - ${rc} ${result} = client.GetCandidate ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} ${datastore1} - Should Contain ${result} ${candidate-name} - - # set config into candidate - ${rc} ${result} = client.Set - ... ${datastore1} ${candidate-name} --delete /interface[name=ethernet-1/1]/description --delete /interface[name=ethernet-1/1]/subinterface[index=0]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # get config from candidate - ${rc} ${result} = client.GetFromCandidate ${datastore1} ${candidate-name} /interface[name=ethernet-1/1] - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} Desc1 - Should Not Contain ${result} DescSub0 - - # run diff - ${rc} ${result} = client.Diff ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Contain ${result} Desc1 - Should Contain ${result} DescSub0 - - # commit - ${rc} ${result} = client.Commit ${datastore1} ${candidate-name} - Log ${result} - Should Be Equal As Integers ${rc} 0 - - # query fom intended store - ${rc} ${result} = client.Get ${datastore1} --intended --path /interface[name=ethernet-1/1]/description --priority -1 - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} Desc1 - - # query from router - ${rc} ${result} = gnmic.Get clab-collocated-srl1 --skip-verify -e ASCII -u admin -p NokiaSrl1! --format flat --path /interface[name=ethernet-1/1]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} Desc1 - - # query fom intended store - ${rc} ${result} = client.Get ${datastore1} --intended --path /interface[name=ethernet-1/1]/subinterface[index=0]/description --priority -1 - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} DescSub0 - - # query from router - ${rc} ${result} = gnmic.Get clab-collocated-srl1 --skip-verify -e ASCII -u admin -p NokiaSrl1! --format flat --path /interface[name=ethernet-1/1]/subinterface[index=0]/description - Log ${result} - Should Be Equal As Integers ${rc} 0 - Should Not Contain ${result} DescSub0 - - server.Teardown + [Tags] robot:continue-on-failure + + ${result} = client.ListSchemas + Should Be Equal As Integers ${result.rc} 0 + + # delete interface config in case there are some remains + ${result} = gnmic.Set + ... ${devicename1} + ... --skip-verify + ... -u admin + ... -p NokiaSrl1! + ... --delete /interface[name=ethernet-1/1] + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.CreateDataStoreTarget + ... ${datastore1} + ... ${target-file1} + ... ${target-sync-file} + ... ${schema-name} + ... ${schema-vendor} + ... ${schema-version} + Should Be Equal As Integers ${result.rc} 0 + Wait Until Datastore connected ${datastore1} 30s 1s + + # create candidate + ${result} = client.CreateCandidate ${datastore1} ${candidate-name} ${owner} ${priority} + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.GetCandidate ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Contain ${result.stdout} ${candidate-name} + + # set config into candidate + ${result} = client.Set + ... ${datastore1} + ... ${candidate-name} + ... --update /interface[name=ethernet-1/1]/description:::Desc1 --update /interface[name=ethernet-1/1]/subinterface[index=0]/admin-state:::enable + ... --update /interface[name=ethernet-1/1]/subinterface[index=0]/description:::DescSub0 + Should Be Equal As Integers ${result.rc} 0 + + # get config from candidate + ${result} = client.GetFromCandidate + ... ${datastore1} + ... ${candidate-name} + ... /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # get config from candidate + ${result} = client.GetFromCandidate + ... ${datastore1} + ... ${candidate-name} + ... /interface[name=ethernet-1/1]/subinterface[index=0] + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} DescSub0 + + # run diff + ${result} = client.Diff ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + Should Contain ${result.stdout} DescSub0 + + # commit + ${result} = client.Commit ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + + # query from router + ${result} = gnmic.Get + ... ${devicename1} + ... --skip-verify + ... -e ASCII + ... -u admin + ... -p NokiaSrl1! + ... --format flat + ... --path /interface[name=ethernet-1/1]/description + + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + + # query from router + ${result} = gnmic.Get + ... ${devicename1} + ... --skip-verify + ... -e ASCII + ... -u admin + ... -p NokiaSrl1! + ... --format flat + ... --path /interface[name=ethernet-1/1]/subinterface[index=0]/description + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} DescSub0 + + # DELETE + # create candidate + ${result} = client.CreateCandidate ${datastore1} ${candidate-name} ${owner} ${priority} + Should Be Equal As Integers ${result.rc} 0 + + ${result} = client.GetCandidate ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} ${datastore1} + Should Contain ${result.stdout} ${candidate-name} + + # set config into candidate + ${result} = client.Set + ... ${datastore1} + ... ${candidate-name} + ... --delete /interface[name=ethernet-1/1]/description + ... --delete /interface[name=ethernet-1/1]/subinterface[index=0]/description + Should Be Equal As Integers ${result.rc} 0 + + # get config from candidate + ${result} = client.GetFromCandidate + ... ${datastore1} + ... ${candidate-name} + ... /interface[name=ethernet-1/1] + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} Desc1 + Should Not Contain ${result.stdout} DescSub0 + + # run diff + ${result} = client.Diff ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stdout} Desc1 + Should Contain ${result.stdout} DescSub0 + + # commit + ${result} = client.Commit ${datastore1} ${candidate-name} + Should Be Equal As Integers ${result.rc} 0 + + # query fom intended store + ${result} = client.Get + ... ${datastore1} + ... --intended + ... --path /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} Desc1 + + # query from router + ${result} = gnmic.Get + ... ${devicename1} + ... --skip-verify + ... -e ASCII + ... -u admin + ... -p NokiaSrl1! + ... --format flat + ... --path /interface[name=ethernet-1/1]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} Desc1 + + # query fom intended store + ${result} = client.Get + ... ${datastore1} + ... --intended + ... --path /interface[name=ethernet-1/1]/subinterface[index=0]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} DescSub0 + + # query from router + ${result} = gnmic.Get + ... ${devicename1} + ... --skip-verify + ... -e ASCII + ... -u admin + ... -p NokiaSrl1! + ... --format flat + ... --path /interface[name=ethernet-1/1]/subinterface[index=0]/description + Should Be Equal As Integers ${result.rc} 0 + Should Not Contain ${result.stdout} DescSub0 diff --git a/tests/robot/tests/collocated/collocated_test.yaml b/tests/robot/tests/collocated/collocated_test.yaml index dd542550..b4a42046 100644 --- a/tests/robot/tests/collocated/collocated_test.yaml +++ b/tests/robot/tests/collocated/collocated_test.yaml @@ -35,57 +35,20 @@ schema-store: vendor: Nokia version: 22.11.2 files: - - ./srlinux-yang-models/all/v22.11.2/srl_nokia/models + - ./lab/common/yang/srl-22.11.2/srl_nokia/models directories: - - ./srlinux-yang-models/all/v22.11.2/ietf + - ./lab/common/yang/srl-22.11.2/ietf + - ./lab/common/yang/srl-22.11.2/openconfig excludes: - .*tools.* - name: srl vendor: Nokia version: 23.10.1 files: - - ./srlinux-yang-models/all/v23.10.1/srl_nokia/models + - ./lab/common/yang/srl-23.10.1/srl_nokia/models directories: - - ./srlinux-yang-models/all/v23.10.1/ietf - - ./srlinux-yang-models/all/v23.10.1/openconfig/extensions - - ./srlinux-yang-models/all/v23.10.1/openconfig - excludes: - - .*tools.* - - name: srl - vendor: Nokia - version: 22.11.1 - files: - - ./srlinux-yang-models/all/v22.11.1/srl_nokia/models - directories: - - ./srlinux-yang-models/all/v22.11.1/ietf - excludes: - - .*tools.* - - - name: srl - vendor: Nokia - version: 22.6.4 - files: - - ./srlinux-yang-models/all/v22.6.4/srl_nokia/models - directories: - - ./srlinux-yang-models/all/v22.6.4/ietf - excludes: - - .*tools.* - - name: srl - vendor: Nokia - version: 22.3.2 - files: - - ./srlinux-yang-models/all/v22.3.2/srl_nokia/models - directories: - - ./srlinux-yang-models/all/v22.3.2/ietf - excludes: - - .*tools.* - - name: srl - vendor: Nokia - version: 21.11.3 - files: - - ./srlinux-yang-models/all/v21.11.3/srl_nokia/models - directories: - - ./srlinux-yang-models/all/v21.11.3/ietf + - ./lab/common/yang/srl-23.10.1/ietf + - ./lab/common/yang/srl-23.10.1/openconfig excludes: - .*tools.* diff --git a/tests/robot/tests/collocated/lab/collocated.clab.yaml b/tests/robot/tests/collocated/lab/collocated.clab.yaml index 61c3b2ea..47059699 100644 --- a/tests/robot/tests/collocated/lab/collocated.clab.yaml +++ b/tests/robot/tests/collocated/lab/collocated.clab.yaml @@ -18,18 +18,10 @@ topology: kinds: srl: image: ghcr.io/nokia/srlinux:23.10.1-218 - # vr-sros: - # image: registry.kmrd.dev/kmrd/vr-sros:23.10.R1 - # license: license23.lic nodes: - # sr1: - # kind: vr-sros - # sr2: - # kind: vr-sros srl1: kind: srl srl2: kind: srl links: - - endpoints: ["srl1:e1-1", "srl2:e1-1"] - # - endpoints: ["sr1:eth1", "sr2:eth1"] \ No newline at end of file + - endpoints: ["srl1:e1-1", "srl2:e1-1"] \ No newline at end of file From 69984409f243f7dfbd2b506482621a07f7d0a1c1 Mon Sep 17 00:00:00 2001 From: steiler Date: Fri, 5 Apr 2024 14:30:26 +0200 Subject: [PATCH 07/10] license --- tests/robot/tests/collocated/colloc.robot | 14 ++++++++++++++ tests/robot/tests/leafref/leafref_statements.robot | 14 ++++++++++++++ tests/robot/tests/must/data-server.yaml | 14 ++++++++++++++ tests/robot/tests/must/must_statements.robot | 14 ++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/tests/robot/tests/collocated/colloc.robot b/tests/robot/tests/collocated/colloc.robot index 76b5281e..7a5fd164 100644 --- a/tests/robot/tests/collocated/colloc.robot +++ b/tests/robot/tests/collocated/colloc.robot @@ -1,3 +1,17 @@ +# Copyright 2024 Nokia +# +# 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. + *** Settings *** Resource ../../keywords/server.robot Resource ../../keywords/client.robot diff --git a/tests/robot/tests/leafref/leafref_statements.robot b/tests/robot/tests/leafref/leafref_statements.robot index 095c3080..786b5ab0 100644 --- a/tests/robot/tests/leafref/leafref_statements.robot +++ b/tests/robot/tests/leafref/leafref_statements.robot @@ -1,3 +1,17 @@ +# Copyright 2024 Nokia +# +# 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. + *** Settings *** Resource ../../keywords/server.robot Resource ../../keywords/client.robot diff --git a/tests/robot/tests/must/data-server.yaml b/tests/robot/tests/must/data-server.yaml index 1b55f777..acde71dc 100644 --- a/tests/robot/tests/must/data-server.yaml +++ b/tests/robot/tests/must/data-server.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Nokia +# +# 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. + grpc-server: # gRPC listening address address: ":56000" diff --git a/tests/robot/tests/must/must_statements.robot b/tests/robot/tests/must/must_statements.robot index b62279ca..1483a61f 100644 --- a/tests/robot/tests/must/must_statements.robot +++ b/tests/robot/tests/must/must_statements.robot @@ -1,3 +1,17 @@ +# Copyright 2024 Nokia +# +# 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. + *** Settings *** Resource ../../keywords/server.robot Resource ../../keywords/client.robot From e5731a9c4331059297eb7e2bfc3be9de5479f543 Mon Sep 17 00:00:00 2001 From: steiler Date: Mon, 8 Apr 2024 09:34:27 +0200 Subject: [PATCH 08/10] StripPathElemPrefix: fix namespace in key --- pkg/utils/path.go | 16 +- pkg/utils/path_test.go | 156 +++++++++++++++++- .../tests/leafref/leafref_statements.robot | 4 +- 3 files changed, 171 insertions(+), 5 deletions(-) diff --git a/pkg/utils/path.go b/pkg/utils/path.go index a40f1f9c..8982f17d 100644 --- a/pkg/utils/path.go +++ b/pkg/utils/path.go @@ -305,12 +305,24 @@ func StripPathElemPrefix(p string) (string, error) { if i := strings.Index(pe.Name, ":"); i > 0 { pe.Name = pe.Name[i+1:] } - // delete prefix from keys + // process keys for k, v := range pe.Key { + // delete prefix from key name if i := strings.Index(k, ":"); i > 0 { delete(pe.Key, k) - pe.Key[k[i+1:]] = v + k = k[i+1:] } + // delete prefix from key value + if strings.Contains(v, ":") { + kelems := strings.Split(v, "/") + for idx, kelem := range kelems { + if i := strings.Index(kelem, ":"); i > 0 { + kelems[idx] = kelem[i+1:] + } + } + v = strings.Join(kelems, "/") + } + pe.Key[k] = v } } prefix := "" diff --git a/pkg/utils/path_test.go b/pkg/utils/path_test.go index f44a5ccc..e417cb87 100644 --- a/pkg/utils/path_test.go +++ b/pkg/utils/path_test.go @@ -14,7 +14,11 @@ package utils -import "testing" +import ( + "testing" + + sdcpb "github.com/sdcio/sdc-protos/sdcpb" +) func TestStripPathElemPrefix(t *testing.T) { type args struct { @@ -98,6 +102,14 @@ func TestStripPathElemPrefix(t *testing.T) { want: "", wantErr: true, }, + { + name: "path with current() function in key", + args: args{ + p: "/srl_nokia-netinst:network-instance[srl_nokia-netinst:name = current()/../../../../../srl_nokia-netinst:name]/srl_nokia-netinst:interface/srl_nokia-netinst:name", + }, + want: "/network-instance[name = current()/../../../../../name]/interface/name", + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -112,3 +124,145 @@ func TestStripPathElemPrefix(t *testing.T) { }) } } + +func TestToXPath(t *testing.T) { + type args struct { + p *sdcpb.Path + noKeys bool + } + tests := []struct { + name string + args args + want string + }{ + { + name: "Path without keys, noKeys = false", + args: args{ + noKeys: false, + p: &sdcpb.Path{ + Elem: []*sdcpb.PathElem{ + { + Name: "One", + }, + { + Name: "Two", + }, + { + Name: "Three", + }, + }, + }, + }, + want: "One/Two/Three", + }, + { + name: "Path without keys, noKeys = true", + args: args{ + noKeys: true, + p: &sdcpb.Path{ + Elem: []*sdcpb.PathElem{ + { + Name: "One", + }, + { + Name: "Two", + }, + { + Name: "Three", + }, + }, + }, + }, + want: "One/Two/Three", + }, + { + name: "Path with keys, NoKeys = True", + args: args{ + noKeys: true, + p: &sdcpb.Path{Elem: []*sdcpb.PathElem{ + {Name: "interface", Key: map[string]string{ + "name": "ethernet-1/1", + }}, + { + Name: "subinterface", Key: map[string]string{ + "index": "0", + }, + }, + { + Name: "admin-state", + }, + }}, + }, + want: "interface/subinterface/admin-state", + }, + { + name: "Path with keys, NoKeys = false", + args: args{ + noKeys: false, + p: &sdcpb.Path{Elem: []*sdcpb.PathElem{ + {Name: "interface", Key: map[string]string{ + "name": "ethernet-1/1", + }}, + { + Name: "subinterface", Key: map[string]string{ + "index": "0", + }, + }, + { + Name: "admin-state", + }, + }}, + }, + want: "interface[name=ethernet-1/1]/subinterface[index=0]/admin-state", + }, + { + name: "Path with multiple keys, NoKeys = True", + args: args{ + noKeys: true, + p: &sdcpb.Path{Elem: []*sdcpb.PathElem{ + {Name: "interface", Key: map[string]string{ + "name": "ethernet-1/1", + "schnitzel": "foo", + }}, + { + Name: "subinterface", Key: map[string]string{ + "index": "0", + }, + }, + { + Name: "admin-state", + }, + }}, + }, + want: "interface/subinterface/admin-state", + }, + { + name: "Path with multiple keys, NoKeys = false", + args: args{ + noKeys: false, + p: &sdcpb.Path{Elem: []*sdcpb.PathElem{ + {Name: "interface", Key: map[string]string{ + "name": "ethernet-1/1", + "schnitzel": "foo", + }}, + { + Name: "subinterface", Key: map[string]string{ + "index": "0", + }, + }, + { + Name: "admin-state", + }, + }}, + }, + want: "interface[name=ethernet-1/1][schnitzel=foo]/subinterface[index=0]/admin-state", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := ToXPath(tt.args.p, tt.args.noKeys); got != tt.want { + t.Errorf("ToXPath() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/tests/robot/tests/leafref/leafref_statements.robot b/tests/robot/tests/leafref/leafref_statements.robot index 786b5ab0..64b9a67f 100644 --- a/tests/robot/tests/leafref/leafref_statements.robot +++ b/tests/robot/tests/leafref/leafref_statements.robot @@ -105,7 +105,7 @@ BGP dynamic-neighbor peer-group - pass DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} -BGP danymic-neighbor interface - fail +BGP dynamic-neighbor interface - fail [Documentation] This is a LeafRef that contains an absolute path with a key that utilizes the current() reference. LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance/protocols/bgp/dynamic-neighbors/interface/interface-name @@ -116,7 +116,7 @@ BGP danymic-neighbor interface - fail DeleteCandidate ${srlinux1-name} ${srlinux1-candidate} -BGP danymic-neighbor interface - pass +BGP dynamic-neighbor interface - pass [Documentation] This is a LeafRef that contains an absolute path with a key that utilizes the current() reference. LogLeafRefStatements ${srlinux1-schema-name} ${srlinux1-schema-version} ${srlinux1-schema-vendor} network-instance/protocols/bgp/dynamic-neighbors/interface/interface-name From 199e4a6494961207505a97fbb30d1c8bc3452e52 Mon Sep 17 00:00:00 2001 From: steiler Date: Mon, 8 Apr 2024 13:19:27 +0200 Subject: [PATCH 09/10] expandUpdate: JsonIetf string conversion --- pkg/datastore/data_rpc.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/datastore/data_rpc.go b/pkg/datastore/data_rpc.go index 7d0ce367..395a5656 100644 --- a/pkg/datastore/data_rpc.go +++ b/pkg/datastore/data_rpc.go @@ -854,14 +854,24 @@ func (d *Datastore) expandUpdate(ctx context.Context, upd *sdcpb.Update, include case *sdcpb.SchemaElem_Field: var v interface{} var err error + + var jsonValue []byte switch upd.GetValue().Value.(type) { case *sdcpb.TypedValue_JsonVal: - err = json.Unmarshal(upd.GetValue().GetJsonVal(), &v) - if err == nil { - switch v := v.(type) { - case string: - upd.Value = &sdcpb.TypedValue{Value: &sdcpb.TypedValue_StringVal{StringVal: v}} - } + jsonValue = upd.GetValue().GetJsonVal() + case *sdcpb.TypedValue_JsonIetfVal: + jsonValue = upd.GetValue().GetJsonIetfVal() + } + + // process value + if jsonValue != nil { + err = json.Unmarshal(jsonValue, &v) + if err != nil { + return nil, err + } + switch v := v.(type) { + case string: + upd.Value = &sdcpb.TypedValue{Value: &sdcpb.TypedValue_StringVal{StringVal: v}} } } From 993230bd6e788003617abacb74fa8303ba5a924b Mon Sep 17 00:00:00 2001 From: steiler Date: Mon, 8 Apr 2024 13:19:50 +0200 Subject: [PATCH 10/10] update tests --- tests/robot/keywords/server.robot | 33 ++++++++++++++++--- .../colloc.robot => colocated/coloc.robot} | 10 +++--- .../colocated_test.yaml} | 0 .../lab/colocated.clab.yaml} | 2 +- .../{collocated => colocated}/robot_srl1.json | 2 +- .../{collocated => colocated}/robot_srl2.json | 2 +- .../tests/{collocated => colocated}/sync.json | 0 .../tests/leafref/leafref_statements.robot | 2 +- .../tests/must/intents/lldp_tun_pass.json | 10 ++++++ tests/robot/tests/must/must_statements.robot | 2 +- 10 files changed, 48 insertions(+), 15 deletions(-) rename tests/robot/tests/{collocated/colloc.robot => colocated/coloc.robot} (97%) rename tests/robot/tests/{collocated/collocated_test.yaml => colocated/colocated_test.yaml} (100%) rename tests/robot/tests/{collocated/lab/collocated.clab.yaml => colocated/lab/colocated.clab.yaml} (97%) rename tests/robot/tests/{collocated => colocated}/robot_srl1.json (78%) rename tests/robot/tests/{collocated => colocated}/robot_srl2.json (78%) rename tests/robot/tests/{collocated => colocated}/sync.json (100%) diff --git a/tests/robot/keywords/server.robot b/tests/robot/keywords/server.robot index 72f1c017..c1897fb9 100644 --- a/tests/robot/keywords/server.robot +++ b/tests/robot/keywords/server.robot @@ -19,18 +19,41 @@ DeployLab DestroyLab [Documentation] Destroys a containerlab topology [Arguments] ${topology-file} - ${rc} ${result} = Run And Return Rc And Output - ... sudo containerlab des -t ${topology-file} -c - Log ${result} - RETURN ${rc} ${result} + ${result} = Run Process + ... sudo + ... containerlab + ... destroy + ... -t ${topology-file} + ... -c + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} + +RestoreLabSnapshot + [Documentation] Restore the config snapshot taken after deployment + [Arguments] ${topology-file} + ${result} = Run Process + ... sudo + ... containerlab + ... exec + ... -t ${topology-file} + ... --cmd sr_cli -d -e -- load checkpoint name clab-initial auto-commit + ... --label clab-node-kind=srl + Log ${result.rc} + Log ${result.stdout} + Log ${result.stderr} + RETURN ${result} -Setup Collocated +SetupColocated [Documentation] Starts a data-server with an embeded schema and cache stores. [Arguments] ${doBuild} ${data-server-bin} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} IF ${doBuild} == $True ${result} = Run Process make build Log Many stdout: ${result.stdout} stderr: ${result.stderr} END + Remove Directory ./cached recursive=${True} + Remove Directory ./schema-dir recursive=${True} Start Process ${data-server-bin} -c ${data-server-config} alias=${data-server-process-alias} stderr=${data-server-stderr} WaitForOutput ${data-server-stderr} ready... 10x 1s diff --git a/tests/robot/tests/collocated/colloc.robot b/tests/robot/tests/colocated/coloc.robot similarity index 97% rename from tests/robot/tests/collocated/colloc.robot rename to tests/robot/tests/colocated/coloc.robot index 7a5fd164..52f9bc0b 100644 --- a/tests/robot/tests/collocated/colloc.robot +++ b/tests/robot/tests/colocated/coloc.robot @@ -22,15 +22,15 @@ Library Process Suite Setup DeployLab ${topology-file} Suite Teardown DestroyLab ${topology-file} -Test Setup Setupcollocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} +Test Setup SetupColocated True ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr} Test Teardown Teardown *** Variables *** ${DATA-SERVER-BIN} ${CURDIR}/../../../../bin/data-server ${SDCTL} sdctl -${data-server-config} ${CURDIR}/collocated_test.yaml -${topology-file} ${CURDIR}/lab/collocated.clab.yaml +${data-server-config} ${CURDIR}/colocated_test.yaml +${topology-file} ${CURDIR}/lab/colocated.clab.yaml ${DATA-SERVER-IP} 127.0.0.1 ${DATA-SERVER-PORT} 56000 @@ -48,11 +48,11 @@ ${owner} test ${priority} 100 ${datastore1} srl1 -${devicename1} clab-collocated-srl1 +${devicename1} clab-colocated-srl1 ${target-file1} ${CURDIR}/robot_srl1.json ${datastore2} srl2 -${devicename2} clab-collocated-srl2 +${devicename2} clab-colocated-srl2 ${target-file2} ${CURDIR}/robot_srl2.json ${target-sync-file} ${CURDIR}/sync.json diff --git a/tests/robot/tests/collocated/collocated_test.yaml b/tests/robot/tests/colocated/colocated_test.yaml similarity index 100% rename from tests/robot/tests/collocated/collocated_test.yaml rename to tests/robot/tests/colocated/colocated_test.yaml diff --git a/tests/robot/tests/collocated/lab/collocated.clab.yaml b/tests/robot/tests/colocated/lab/colocated.clab.yaml similarity index 97% rename from tests/robot/tests/collocated/lab/collocated.clab.yaml rename to tests/robot/tests/colocated/lab/colocated.clab.yaml index 47059699..7da0216a 100644 --- a/tests/robot/tests/collocated/lab/collocated.clab.yaml +++ b/tests/robot/tests/colocated/lab/colocated.clab.yaml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: collocated +name: colocated topology: kinds: diff --git a/tests/robot/tests/collocated/robot_srl1.json b/tests/robot/tests/colocated/robot_srl1.json similarity index 78% rename from tests/robot/tests/collocated/robot_srl1.json rename to tests/robot/tests/colocated/robot_srl1.json index 0a396d04..11fdc150 100644 --- a/tests/robot/tests/collocated/robot_srl1.json +++ b/tests/robot/tests/colocated/robot_srl1.json @@ -1,6 +1,6 @@ { "type": "gnmi", - "address": "clab-collocated-srl1:57400", + "address": "clab-colocated-srl1:57400", "credentials": { "username": "admin", "password": "NokiaSrl1!" diff --git a/tests/robot/tests/collocated/robot_srl2.json b/tests/robot/tests/colocated/robot_srl2.json similarity index 78% rename from tests/robot/tests/collocated/robot_srl2.json rename to tests/robot/tests/colocated/robot_srl2.json index bdbff38d..e099180a 100644 --- a/tests/robot/tests/collocated/robot_srl2.json +++ b/tests/robot/tests/colocated/robot_srl2.json @@ -1,6 +1,6 @@ { "type": "gnmi", - "address": "clab-collocated-srl2:57400", + "address": "clab-colocated-srl2:57400", "credentials": { "username": "admin", "password": "NokiaSrl1!" diff --git a/tests/robot/tests/collocated/sync.json b/tests/robot/tests/colocated/sync.json similarity index 100% rename from tests/robot/tests/collocated/sync.json rename to tests/robot/tests/colocated/sync.json diff --git a/tests/robot/tests/leafref/leafref_statements.robot b/tests/robot/tests/leafref/leafref_statements.robot index 64b9a67f..da167639 100644 --- a/tests/robot/tests/leafref/leafref_statements.robot +++ b/tests/robot/tests/leafref/leafref_statements.robot @@ -18,7 +18,7 @@ Resource ../../keywords/client.robot Library OperatingSystem Library String Library Process -Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} +Suite Setup SetupColocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} Suite Teardown Teardown *** Variables *** diff --git a/tests/robot/tests/must/intents/lldp_tun_pass.json b/tests/robot/tests/must/intents/lldp_tun_pass.json index 0caa70b8..ce5d35b2 100644 --- a/tests/robot/tests/must/intents/lldp_tun_pass.json +++ b/tests/robot/tests/must/intents/lldp_tun_pass.json @@ -2,6 +2,16 @@ { "path": "/", "value": { + "system": { + "lldp": { + "interface": [ + { + "name": "ethernet-1/1", + "admin-state": "disable" + } + ] + } + }, "interface": [ { "name": "ethernet-1/1", diff --git a/tests/robot/tests/must/must_statements.robot b/tests/robot/tests/must/must_statements.robot index 1483a61f..42835f72 100644 --- a/tests/robot/tests/must/must_statements.robot +++ b/tests/robot/tests/must/must_statements.robot @@ -18,7 +18,7 @@ Resource ../../keywords/client.robot Library OperatingSystem Library String Library Process -Suite Setup Setup Collocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} +Suite Setup SetupColocated True ${DATA-SERVER-BIN} ${DATA-SERVER-CONFIG} ${data-server-process-alias} ${data-server-stderr} Suite Teardown Teardown *** Variables ***