Skip to content

Commit d086f9f

Browse files
committed
add basic robot test
1 parent 4172d32 commit d086f9f

File tree

11 files changed

+713
-22
lines changed

11 files changed

+713
-22
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ nbn/
2121
mocks/*
2222
.vscode
2323
schema-dir
24-
dist/
24+
dist/
25+
.*.bak
26+
clab-*

tests/robot/keywords/client.robot

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,98 @@ Library OperatingSystem
1111

1212

1313
*** Keywords ***
14+
ListDataStores
15+
[Documentation] List datastores in a data-server
16+
${rc} ${result} = Run And Return Rc And Output
17+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore list
18+
RETURN ${rc} ${result}
19+
20+
GetDataStore
21+
[Documentation] Get a target from a data-server
22+
[Arguments] ${datastore}
23+
${rc} ${result} = Run And Return Rc And Output
24+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore get --ds ${datastore}
25+
RETURN ${rc} ${result}
26+
27+
CreateDataStore
28+
[Documentation] Create a target in a data-server
29+
[Arguments] ${datastore} ${target-definition-file} ${sync-file} ${schema-name} ${schema-vendor} ${schema-version}
30+
${rc} ${result} = Run And Return Rc And Output
31+
... ${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}
32+
RETURN ${rc} ${result}
33+
34+
DeleteDatastore
35+
[Documentation] Delete a target from a data-server
36+
[Arguments] ${datastore}
37+
${rc} ${result} = Run And Return Rc And Output
38+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore delete --ds ${datastore}
39+
RETURN ${rc} ${result}
40+
1441
CreateCandidate
1542
[Documentation] Create a new named Candidate in the given Datastore
1643
[Arguments] ${datastore} ${candidate}
17-
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore create --ds ${datastore} --candidate ${candidate}
18-
RETURN ${result}
44+
${rc} ${result} = Run And Return Rc And Output
45+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore create --ds ${datastore} --candidate ${candidate}
46+
RETURN ${rc} ${result}
47+
48+
GetCandidate
49+
[Documentation] Create a new named Candidate in the given Datastore
50+
[Arguments] ${datastore} ${candidate}
51+
${rc} ${result} = Run And Return Rc And Output
52+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore get --ds ${datastore} --candidate ${candidate}
53+
RETURN ${rc} ${result}
1954

2055
DeleteCandidate
2156
[Documentation] Delete a named Candidate in the given Datastore
2257
[Arguments] ${datastore} ${candidate}
23-
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore delete --ds ${datastore} --candidate ${candidate}
24-
RETURN ${result}
58+
${rc} ${result} = Run And Return Rc And Output
59+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore delete --ds ${datastore} --candidate ${candidate}
60+
RETURN ${rc} ${result}
61+
62+
Diff
63+
[Documentation] Performs a diff on a datastore and a candidate
64+
[Arguments] ${datastore} ${candidate}
65+
${rc} ${result} = Run And Return Rc And Output
66+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data diff --ds ${datastore} --candidate ${candidate}
67+
RETURN ${rc} ${result}
2568

2669
Commit
2770
[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
2871
[Arguments] ${datastore} ${candidate}
29-
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore commit --ds ${datastore} --candidate ${candidate}
30-
RETURN ${result}
72+
${rc} ${result} = Run And Return Rc And Output
73+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore commit --ds ${datastore} --candidate ${candidate}
74+
RETURN ${rc} ${result}
75+
76+
Get
77+
[Documentation] Get a path from the datastore
78+
[Arguments] ${datastore} ${ds-get-flags}
79+
${rc} ${result} = Run And Return Rc And Output
80+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data get --ds ${datastore} ${ds-get-flags}
81+
Log ${result}
82+
RETURN ${rc} ${result}
83+
84+
GetFromCandidate
85+
[Documentation] Get a path from the datastore candidate
86+
[Arguments] ${datastore} ${candidate} ${path}
87+
${rc} ${result} = Run And Return Rc And Output
88+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data get --ds ${datastore} --candidate ${candidate} --path ${path}
89+
Log ${result}
90+
RETURN ${rc} ${result}
3191

3292
Set
3393
[Documentation] Applies to the candidate of the given datastore the provided update
34-
[Arguments] ${datastore} ${candidate} ${update}
35-
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data set --ds ${datastore} --candidate ${candidate} --update ${update}
36-
Log ${result.stdout}
37-
Log ${result.stderr}
38-
RETURN ${result}
94+
[Arguments] ${datastore} ${candidate} ${set-flags}
95+
${rc} ${result} = Run And Return Rc And Output
96+
... ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} data set --ds ${datastore} --candidate ${candidate} ${set-flags}
97+
Log ${result}
98+
RETURN ${rc} ${result}
3999

40100
GetSchema
41101
[Documentation] Retrieve the schema element described by name (plattform name), version and vendor under the given path.
42102
[Arguments] ${name} ${version} ${vendor} ${path}
43-
${result} = Run Process ${CLIENT-BIN} -a ${SCHEMA-SERVER-IP}:${SCHEMA-SERVER-PORT} schema get --name ${name} --version ${version} --vendor ${vendor} --path ${path}
44-
RETURN ${result}
45-
46-
GetDatastore
47-
[Documentation] Performa get on the given Datastore
48-
[Arguments] ${datastore}
49-
${result} = Run Process ${CLIENT-BIN} -a ${DATA-SERVER-IP}:${DATA-SERVER-PORT} datastore get --ds ${datastore}
50-
RETURN ${result}
51-
103+
${rc} ${result} = Run And Return Rc And Output
104+
... ${CLIENT-BIN} -a ${SCHEMA-SERVER-IP}:${SCHEMA-SERVER-PORT} schema get --name ${name} --version ${version} --vendor ${vendor} --path ${path}
105+
RETURN ${rc} ${result}
52106

53107
# Helper
54108
ExtractResponse

tests/robot/keywords/gnmic.robot

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
*** Settings ***
2+
Documentation The Library allows running gnmic commands
3+
Library String
4+
Library Process
5+
Library OperatingSystem
6+
7+
*** Keywords ***
8+
Capabilities
9+
[Documentation] run capabilities using gNMIc
10+
[Arguments] ${router} ${gnmic_flags} ${path}
11+
${rc} ${result} = Run And Return Rc And Output
12+
... gnmic -a ${router} cap ${gnmic_flags} --log
13+
Log ${result}
14+
RETURN ${rc} ${result}
15+
16+
Get
17+
[Documentation] run Get using gNMIc
18+
[Arguments] ${router} ${gnmic_flags}
19+
${rc} ${result} = Run And Return Rc And Output
20+
... gnmic -a ${router} get ${gnmic_flags} --log
21+
Log ${result}
22+
RETURN ${rc} ${result}
23+
24+
Set
25+
[Documentation] run Set using gNMIc
26+
[Arguments] ${router} ${gnmic_flags}
27+
${rc} ${result} = Run And Return Rc And Output
28+
... gnmic -a ${router} set ${gnmic_flags} --log
29+
Log ${result}
30+
RETURN ${rc} ${result}
31+
32+
SubscribeOnce
33+
[Documentation] run Subscribe mode ONCE using gNMIc
34+
[Arguments] ${router} ${gnmic_flags}
35+
${rc} ${result} = Run And Return Rc And Output
36+
... gnmic -a ${router} sub ${gnmic_flags} --log
37+
Log ${result}
38+
RETURN ${rc} ${result}
39+
40+
Subscribe
41+
[Documentation] run Subscribe using gNMIc
42+
[Arguments] ${router} ${gnmic_flags}
43+
${rc} ${result} = Run And Return Rc And Output
44+
... gnmic -a ${router} sub ${gnmic_flags} --log
45+
Start Process gnmic -a ${router} sub ${gnmic_flags} alias=${gnmic-process-alias} stderr=${gnmic-stderr}
46+
WaitForOutput ${gnmic-stderr} "subscribing"

tests/robot/keywords/server.robot

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ Library OperatingSystem
77
#####
88
# Infra - Start / Stop Schema- and Data-server
99
#####
10+
11+
DeployLab
12+
[Documentation] Deploys a containerlab topology
13+
[Arguments] ${topology-file}
14+
${rc} ${result} = Run And Return Rc And Output
15+
... sudo containerlab deploy -t ${topology-file} -c
16+
Log ${result}
17+
RETURN ${rc} ${result}
18+
19+
DestroyLab
20+
[Documentation] Destroys a containerlab topology
21+
[Arguments] ${topology-file}
22+
${rc} ${result} = Run And Return Rc And Output
23+
... sudo containerlab des -t ${topology-file} -c
24+
Log ${result}
25+
RETURN ${rc} ${result}
26+
27+
Setupcollocated
28+
[Documentation] Starts a data-server with an embeded schema and cache stores.
29+
[Arguments] ${doBuild} ${data-server-bin} ${data-server-config} ${data-server-process-alias} ${data-server-stderr}
30+
IF ${doBuild} == $True
31+
${result} = Run Process make build
32+
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
33+
END
34+
Start Process ${data-server-bin} -c ${data-server-config} alias=${data-server-process-alias} stderr=${data-server-stderr}
35+
WaitForOutput ${data-server-stderr} ready... 10x 1s
36+
1037
Setup
1138
[Documentation] Starts schema and data server. Waits for the dataserver to begin sync before returning
1239
[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}
@@ -20,7 +47,10 @@ Setup
2047
WaitForOutput ${data-server-stderr} sync 3x 3s
2148

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

2656
# Infra Helper

tests/robot/run-robot-test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
4+
5+
cd $SCRIPTPATH
6+
7+
git clone https://github.com/nokia/srlinux-yang-models.git
8+
cd srlinux-yang-models
9+
./get-all-modules.sh
10+
11+
cd $SCRIPTPATH
12+
robot --consolecolors on ./tests/collocated/colloc.robot

0 commit comments

Comments
 (0)