Skip to content

Commit

Permalink
cotnainerd smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steiler committed Jun 15, 2021
1 parent fa56d64 commit e549f60
Show file tree
Hide file tree
Showing 18 changed files with 557 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/01-docker/01-smoke/01-basic-flow.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
*** Settings ***
Library OperatingSystem
Library String
Suite Teardown Run sudo containerlab destroy -t ${CURDIR}/01-linux-nodes.clab.yml --cleanup

*** Variables ***
${lab-name} 2-linux-nodes

*** Test Cases ***
Deploy ${lab-name} lab
Log ${CURDIR}
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab deploy -t ${CURDIR}/01-linux-nodes.clab.yml
Log ${output}
Should Be Equal As Integers ${rc} 0

Inspect ${lab-name} lab
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab inspect -n ${lab-name}
Log ${output}
Should Be Equal As Integers ${rc} 0

Verify links in node l1
${rc} ${output} = Run And Return Rc And Output
... sudo docker exec clab-${lab-name}-l1 ip link show eth1
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} state UP
${rc} ${output} = Run And Return Rc And Output
... sudo docker exec clab-${lab-name}-l1 ip link show eth2
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} state UP

Verify links in node l2
${rc} ${output} = Run And Return Rc And Output
... sudo docker exec clab-${lab-name}-l2 ip link show eth1
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} state UP
${rc} ${output} = Run And Return Rc And Output
... sudo docker exec clab-${lab-name}-l2 ip link show eth2
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} state UP

Ensure "inspect all" outputs IP addresses
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab inspect --all
Log ${output}
Should Be Equal As Integers ${rc} 0
${line} = String.Get Line ${output} -2
Log ${line}
@{data} = Split String ${line} |
Log ${data}
# verify ipv4 address
${ipv4} = String.Strip String ${data}[10]
Should Match Regexp ${ipv4} ^[\\d\\.]+/\\d{1,2}$
# verify ipv6 address
${ipv6} = String.Strip String ${data}[11]
Should Match Regexp ${ipv6} ^[\\d:]+/\\d{1,2}$

Destroy ${lab-name} lab
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab destroy -t ${CURDIR}/01-linux-nodes.clab.yml --cleanup
Log ${output}
Should Be Equal As Integers ${rc} 0
18 changes: 18 additions & 0 deletions tests/01-docker/01-smoke/01-linux-nodes.clab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2020 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

name: 2-linux-nodes

topology:
nodes:
l1:
kind: linux
image: alpine:3
l2:
kind: linux
image: alpine:3

links:
- endpoints: ["l1:eth1", "l2:eth1"]
- endpoints: ["l1:eth2", "l2:eth2"]
11 changes: 11 additions & 0 deletions tests/01-docker/01-smoke/01-linux-single-node.clab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2020 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

name: single-node

topology:
nodes:
l1:
kind: linux
image: alpine:3
28 changes: 28 additions & 0 deletions tests/01-docker/01-smoke/02-destroy-all.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*** Settings ***
Library OperatingSystem
Suite Teardown Run sudo containerlab destroy --all --cleanup

*** Test Cases ***
Deploy first lab
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab deploy -t ${CURDIR}/01-linux-nodes.clab.yml
Log ${output}
Should Be Equal As Integers ${rc} 0

Deploy second lab
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab deploy -t ${CURDIR}/01-linux-single-node.clab.yml
Log ${output}
Should Be Equal As Integers ${rc} 0

Destroy all labs
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab destroy --all --cleanup
Log ${output}
Should Be Equal As Integers ${rc} 0

Check all labs have been removed
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab inspect --all
Log ${output}
Should Contain ${output} no containers found
39 changes: 39 additions & 0 deletions tests/01-docker/01-smoke/03-bridge.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
*** Settings ***
Library OperatingSystem
Suite Setup Run sudo ip l del ${bridge-name}
Suite Teardown Cleanup

*** Variables ***
${lab-name} 2-linux-nodes
${lab-file} 03-linux-nodes-to-bridge.clab.yml
${bridge-name} br-clab
${br-link1-name} l1-eth1
${br-link2-name} l1-eth2

*** Test Cases ***
Create linux bridge
${rc} ${output} = Run And Return Rc And Output
... sudo ip link add name ${bridge-name} type bridge && sudo ip link set ${bridge-name} up
Log ${output}
Should Be Equal As Integers ${rc} 0

Deploy ${lab-name} lab
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab deploy -t ${CURDIR}/${lab-file}
Log ${output}
Should Be Equal As Integers ${rc} 0

Verify links in bridge
${rc} ${output} = Run And Return Rc And Output
... sudo ip link show ${br-link1-name}
Log ${output}
Should Contain ${output} master ${bridge-name} state UP
${rc} ${output} = Run And Return Rc And Output
... sudo ip link show ${br-link2-name}
Log ${output}
Should Contain ${output} master ${bridge-name} state UP

*** Keywords ***
Cleanup
Run sudo containerlab destroy -t ${CURDIR}/${lab-file} --cleanup
Run sudo ip l del ${bridge-name}
17 changes: 17 additions & 0 deletions tests/01-docker/01-smoke/03-linux-nodes-to-bridge.clab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2020 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

name: 03-bridge

topology:
nodes:
l1:
kind: linux
image: alpine:3
br-clab:
kind: bridge

links:
- endpoints: ["l1:eth1", "br-clab:l1-eth1"]
- endpoints: ["br-clab:l1-eth2", "l1:eth2"]
31 changes: 31 additions & 0 deletions tests/01-docker/01-smoke/04-generate.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
*** Settings ***
Library OperatingSystem
Suite Teardown Cleanup

*** Variables ***
${lab-name} 3-clab-gen

*** Test Cases ***
Deploy ${lab-name} lab with generate command
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab generate --name ${lab-name} --kind linux --image alpine:latest --nodes 2,1,1 --deploy
Log ${output}
Should Be Equal As Integers ${rc} 0

Verify nodes
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab inspect --name ${lab-name}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} clab-${lab-name}-node1-1
Should Contain ${output} clab-${lab-name}-node1-2
Should Contain ${output} clab-${lab-name}-node2-1
Should Contain ${output} clab-${lab-name}-node3-1

*** Keywords ***
Cleanup
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab destroy -t ${lab-name}.clab.yml --cleanup
Log ${output}
Should Be Equal As Integers ${rc} 0
OperatingSystem.Remove File ${lab-name}.clab.yml
36 changes: 36 additions & 0 deletions tests/01-docker/02-basic-srl/01-two-srls.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*** Settings ***
Library OperatingSystem
Suite Teardown Run Keyword Cleanup

*** Variables ***
${lab-name} 02-01-two-srls

*** Test Cases ***
Deploy ${lab-name} lab
Log ${CURDIR}
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab deploy -t ${CURDIR}/02-srl02.clab.yml
Log ${output}
Should Be Equal As Integers ${rc} 0

Wait 5 seconds
Sleep 5s

Verify links in node srl1
${rc} ${output} = Run And Return Rc And Output
... sudo docker exec clab-${lab-name}-srl1 ip link show e1-1
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} state UP

Verify links in node srl2
${rc} ${output} = Run And Return Rc And Output
... sudo docker exec clab-${lab-name}-srl2 ip link show e1-1
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} state UP

*** Keywords ***
Cleanup
Run sudo containerlab destroy -t ${CURDIR}/02-srl02.clab.yml --cleanup
Run rm -rf ${CURDIR}/${lab-name}
19 changes: 19 additions & 0 deletions tests/01-docker/02-basic-srl/02-srl02.clab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2020 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

name: 02-01-two-srls

topology:
kinds:
srl:
image: srlinux:21.3.1-410
license: /home/gitlab-runner/srl-lic.key
nodes:
srl1:
kind: srl
srl2:
kind: srl

links:
- endpoints: ["srl1:e1-1", "srl2:e1-1"]
61 changes: 61 additions & 0 deletions tests/01-docker/03-basic-ceos/01-two-ceos.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
*** Settings ***
Library OperatingSystem
Library SSHLibrary
Suite Teardown Run Keyword Cleanup
Resource ../common.robot

*** Variables ***
${lab-name} 03-01-two-ceos
${lab-file-name} 03-ceos01-clab.yml
${node1-name} n1
${node2-name} n2
${n1-mgmt-ip}
${n2-mgmt-ip} 172.20.20.22

*** Test Cases ***
Deploy ${lab-name} lab
Log ${CURDIR}
${rc} ${output} = Run And Return Rc And Output
... sudo containerlab deploy -t ${CURDIR}/${lab-file-name}
Log ${output}
Should Be Equal As Integers ${rc} 0

Get nodes mgmt IPs
${rc} ${n1-mgmt-ip} = Run And Return Rc And Output
... sudo docker inspect clab-${lab-name}-${node1-name} -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
Should Be Equal As Integers ${rc} 0
Set Suite Variable ${n1-mgmt-ip}
${rc} ${inspected-n2-mgmt-ip} = Run And Return Rc And Output
... sudo docker inspect clab-${lab-name}-${node2-name} -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
Should Be Equal As Integers ${rc} 0
Should Be Equal As Strings ${inspected-n2-mgmt-ip} ${n2-mgmt-ip}

Ensure n1 mgmt IPv4 is in the config file
${f} = OperatingSystem.Get File ${EXECDIR}/clab-${lab-name}/${node1-name}/flash/startup-config
Log ${f}
Log ${n1-mgmt-ip}
Should Contain ${f} ${n1-mgmt-ip}

Ensure n2 mgmt IPv4 is in the config file
${f} = OperatingSystem.Get File ${EXECDIR}/clab-${lab-name}/${node2-name}/flash/startup-config
Log ${f}
Should Contain ${f} ${n2-mgmt-ip}

Ensure n1 is reachable over ssh
Common.Login via SSH with username and password
... address=${n1-mgmt-ip}
... username=admin
... password=admin
... try_for=60

Ensure n2 is reachable over ssh
Common.Login via SSH with username and password
... address=${n2-mgmt-ip}
... username=admin
... password=admin
... try_for=60

*** Keywords ***
Cleanup
Run sudo containerlab destroy -t ${CURDIR}/${lab-file-name} --cleanup
Run rm -rf ${CURDIR}/${lab-name}
19 changes: 19 additions & 0 deletions tests/01-docker/03-basic-ceos/03-ceos01-clab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2020 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

name: 03-01-two-ceos

topology:
kinds:
ceos:
image: ceos:4.25.0F
nodes:
n1:
kind: ceos
n2:
kind: ceos
mgmt_ipv4: 172.20.20.22

links:
- endpoints: ["n1:eth1", "n2:eth1"]
Loading

0 comments on commit e549f60

Please sign in to comment.