Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ nbn/
mocks/*
.vscode
schema-dir
dist/
dist/
.*.bak
clab-*
94 changes: 74 additions & 20 deletions tests/robot/keywords/client.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,98 @@ 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}

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}

CreateDataStore
[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}

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}

CreateCandidate
[Documentation] Create a new named Candidate in the given Datastore
[Arguments] ${datastore} ${candidate}
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore create --ds ${datastore} --candidate ${candidate}
RETURN ${result}
${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}

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}

DeleteCandidate
[Documentation] Delete a named Candidate in the given Datastore
[Arguments] ${datastore} ${candidate}
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore delete --ds ${datastore} --candidate ${candidate}
RETURN ${result}
${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}

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}

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}
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore commit --ds ${datastore} --candidate ${candidate}
RETURN ${result}
${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}

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}

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}

Set
[Documentation] Applies to the candidate of the given datastore the provided update
[Arguments] ${datastore} ${candidate} ${update}
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data set --ds ${datastore} --candidate ${candidate} --update ${update}
Log ${result.stdout}
Log ${result.stderr}
RETURN ${result}
[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}

GetSchema
[Documentation] Retrieve the schema element described by name (plattform name), version and vendor under the given path.
[Arguments] ${name} ${version} ${vendor} ${path}
${result} = Run Process ${CLIENT-BIN} -a ${SCHEMA-SERVER-IP}:${SCHEMA-SERVER-PORT} schema get --name ${name} --version ${version} --vendor ${vendor} --path ${path}
RETURN ${result}

GetDatastore
[Documentation] Performa get on the given Datastore
[Arguments] ${datastore}
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore get --ds ${datastore}
RETURN ${result}

${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}

# Helper
ExtractResponse
Expand Down
46 changes: 46 additions & 0 deletions tests/robot/keywords/gnmic.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
*** Settings ***
Documentation The Library allows running gnmic commands
Library String
Library Process
Library OperatingSystem

*** Keywords ***
Capabilities
[Documentation] run capabilities using gNMIc
[Arguments] ${router} ${gnmic_flags} ${path}
${rc} ${result} = Run And Return Rc And Output
... gnmic -a ${router} cap ${gnmic_flags} --log
Log ${result}
RETURN ${rc} ${result}

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}

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}

SubscribeOnce
[Documentation] run Subscribe mode ONCE using gNMIc
[Arguments] ${router} ${gnmic_flags}
${rc} ${result} = Run And Return Rc And Output
... gnmic -a ${router} sub ${gnmic_flags} --log
Log ${result}
RETURN ${rc} ${result}

Subscribe
[Documentation] run Subscribe using gNMIc
[Arguments] ${router} ${gnmic_flags}
${rc} ${result} = Run And Return Rc And Output
... gnmic -a ${router} sub ${gnmic_flags} --log
Start Process gnmic -a ${router} sub ${gnmic_flags} alias=${gnmic-process-alias} stderr=${gnmic-stderr}
WaitForOutput ${gnmic-stderr} "subscribing"
32 changes: 31 additions & 1 deletion tests/robot/keywords/server.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ Library OperatingSystem
#####
# Infra - Start / Stop Schema- and Data-server
#####

DeployLab
[Documentation] Deploys a containerlab topology
[Arguments] ${topology-file}
${rc} ${result} = Run And Return Rc And Output
... sudo containerlab deploy -t ${topology-file} -c
Log ${result}
RETURN ${rc} ${result}

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}

Setupcollocated
[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
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

Setup
[Documentation] Starts schema and data server. Waits for the dataserver to begin sync before returning
[Arguments] ${doBuild} ${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}
Expand All @@ -20,7 +47,10 @@ Setup
WaitForOutput ${data-server-stderr} sync 3x 3s

Teardown
[Documentation] Stop all the started schema-server, data-server and client processes
[Documentation] Stop the started data-server
${rc} ${result} = Run And Return Rc And Output
... rm -rf ../../cached/caches
Log ${result}
Terminate All Processes

# Infra Helper
Expand Down
12 changes: 12 additions & 0 deletions tests/robot/run-robot-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

cd $SCRIPTPATH

git clone https://github.com/nokia/srlinux-yang-models.git
cd srlinux-yang-models
./get-all-modules.sh

cd $SCRIPTPATH
robot --consolecolors on ./tests/collocated/colloc.robot
Loading