Skip to content

Commit f12082a

Browse files
committed
Add tests for --show-data-model xxx & Update documentation
1 parent bd53da1 commit f12082a

11 files changed

+374
-15
lines changed

docs/configuration.md

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ config:
3131

3232
ping:
3333
test: true
34+
35+
vlan:
36+
test: true
3437

3538
vrf:
3639
test: true

docs/contribute.md

+20
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,23 @@ def print_result(self):
130130
>
131131
> Compare function `_compare_transit_vlan` has to be defined in `netests.comparators.protocols_compare.py`
132132
133+
134+
135+
136+
137+
### Add data models
138+
139+
In `netests/data_models/{{ protocols }}.yml`
140+
141+
```shell
142+
⚡ netests --show-data-model vlan
143+
```
144+
145+
> Add tests !!
146+
147+
```shell
148+
⚡ behave tests/features/data_models_tests.feature --no-capture
149+
```
150+
151+
152+

docs/data_models.md

+30
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,36 @@ vrfs:
180180

181181

182182

183+
### VLAN
184+
185+
```shell
186+
⚡ netests --show-data-model vlan
187+
```
188+
189+
```yaml
190+
191+
- id: 1
192+
name: default
193+
vrf_name: default
194+
ipv4_addresses:
195+
- ip_address: 1.1.1.1
196+
netmask: 255.0.0.0
197+
- ip_address: 10.1.1.2
198+
netmask: 255.255.255.255
199+
ipv6_addresses:
200+
- ip_address: 2001:cafe::1
201+
netmask: 64
202+
- ip_address: 2001:c0ca::1
203+
netmask: 64
204+
assigned_ports:
205+
- swp1
206+
- swp2
207+
- swp3
208+
209+
```
210+
211+
212+
183213
### VRF
184214

185215
```shell

docs/index.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,14 @@ To run a test or get data from one of these hosts, the process is exactly the sa
140140
141141
### Protocols
142142
143-
For this version Netests.io is able to get information regarding <u>**6 "protocols"**</u>.
143+
For this version Netests.io is able to get information regarding u>**7 "protocols"**</u>.
144144
145145
* BGP
146146
* CDP
147147
* Facts
148148
* LLDP
149149
* OSPF
150+
* VLAN
150151
* VRF
151152
152153
All protocols have been simplified based on the OpenConfig data models. The idea of Netests.io is not to show some output but compare and check that your network is in an expected state. To see protocols definition, go on the following link.
@@ -308,21 +309,22 @@ With network the steps are a bit differents. The verification will not be done d
308309
},
309310
'lldp': None,
310311
'ospf': None,
312+
'vlan': None,
311313
'vrf': {
312314
Host: leaf02: True
313315
},
314316
}
315-
```
316-
317+
```
318+
317319
> Protocols with a "None" is the protocols that has not been tested
318320
>
319-
> Don't be affraid about them :smiley:
320-
321+
> Don't be affraid about them :smiley:
322+
321323
```shell
322324
⚡ echo $?
323325
0
324-
```
325-
326+
```
327+
326328
327329
328330
### Integrate in a CI/CD pipeline

docs/inventory.md

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ Device leaf05 is not reachable with the following infos:
322322
'lldp': True,
323323
'ospf': True,
324324
'ping': False,
325+
'vlan': False,
325326
'vrf': False}
326327
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
327328
All devices are reachable :) !

docs/protocols.md

+57
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,63 @@ The ping is validate if it works.
377377

378378

379379

380+
### VLAN
381+
382+
In the VLAN function the following parameters will be compare.
383+
384+
1. id
385+
386+
#### Parameter not compare
387+
388+
These values are not compare by default, it is possible to add them in the compare function
389+
390+
=> Check `Modify compared values`.
391+
392+
* vlan_name
393+
394+
* vrf_name
395+
* ipv4_addresses
396+
* ipv6_addresses
397+
* assigned_ports
398+
399+
These values are retrieved to have more informations and for some next features.
400+
401+
#### Compare function
402+
403+
```python
404+
class VLAN(NetestsProtocol):
405+
def __eq__(self, other):
406+
if not isinstance(other, VLAN):
407+
raise NotImplementedError()
408+
409+
return self.id == other.id
410+
```
411+
412+
#### Modify compared values
413+
414+
It's possible to add or remove some value from the compare function.
415+
416+
To do that, Modifiy Netests.io configuration file by adding `compare:` in protocols `options:`
417+
418+
```yaml
419+
config:
420+
protocols:
421+
vrf:
422+
test: false
423+
options:
424+
compare:
425+
id: True
426+
name: True
427+
vrf_name: false
428+
ipv4_addresses: false
429+
ipv6_addresses: True
430+
assigned_ports: True
431+
```
432+
433+
In this example `name`, `ipv6_addresses ` and `assigned_ports` are added to VLAN compare function
434+
435+
436+
380437
### VRF
381438

382439
In the VRF function the following parameters will be compare.

docs/release.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
Netests.io releases informations
22

3+
## Version 0.3.0
4+
5+
* Add VLAN structure and tests.
6+
7+
It's now possible to implement VLAN test for all devices - (only Cumulus SSH is implemeted yet).
8+
9+
* Add VLAN tests
10+
11+
* Add `pydantic` and `typing` to VLAN class
12+
313
## Version 0.2.0
414

515
Add possibility to modify compare function.

netests/data_models/vlan.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
- id: 1
3+
name: default
4+
vrf_name: default
5+
ipv4_addresses:
6+
- ip_address: 1.1.1.1
7+
netmask: 255.0.0.0
8+
- ip_address: 10.1.1.2
9+
netmask: 255.255.255.255
10+
ipv6_addresses:
11+
- ip_address: 2001:cafe::1
12+
netmask: 64
13+
- ip_address: 2001:c0ca::1
14+
netmask: 64
15+
assigned_ports:
16+
- swp1
17+
- swp2
18+
- swp3
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Feature: Test --show-data-model xxx argument
2+
Scenario:
3+
Given I try to execute netests --show-data-model bgp
4+
Then I print BGP data model
5+
And I can convert bgp.yml to dict with yaml
6+
7+
Scenario:
8+
Given I try to execute netests --show-data-model cdp
9+
Then I print CDP data model
10+
And I can convert cdp.yml to dict with yaml
11+
12+
Scenario:
13+
Given I try to execute netests --show-data-model facts
14+
Then I print Facts data model
15+
And I can convert facts.yml to dict with yaml
16+
17+
Scenario:
18+
Given I try to execute netests --show-data-model lldp
19+
Then I print LLDP data model
20+
And I can convert lldp.yml to dict with yaml
21+
22+
Scenario:
23+
Given I try to execute netests --show-data-model ospf
24+
Then I print OSPF data model
25+
And I can convert ospf.yml to dict with yaml
26+
27+
Scenario:
28+
Given I try to execute netests --show-data-model ping
29+
Then I print PING data model
30+
And I can convert ping.yml to dict with yaml
31+
32+
Scenario:
33+
Given I try to execute netests --show-data-model vlan
34+
Then I print VLAN data model
35+
And I can convert vlan.yml to dict with yaml
36+
37+
Scenario:
38+
Given I try to execute netests --show-data-model vrf
39+
Then I print VRF data model
40+
And I can convert vrf.yml to dict with yaml
41+
42+
Scenario:
43+
Given I get all protocols listed in netests/converters
44+
And I check that a data_model exist for each protocol

0 commit comments

Comments
 (0)