Skip to content

Commit

Permalink
Name custom simulation files model:desc:custom_simulation.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcheramy committed Jan 9, 2025
1 parent b248ab8 commit 44225b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion docs/ModelUnitTests.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Model Unit Tests
Oxidized includes automated unit tests for its models, which require very little
effort to use. There are three different unit tests for models:
effort to use. There are three different default unit tests for models:
- [Device Simulation](ModelUnitTests.md#device-simulation)
- [Device Prompt](ModelUnitTests.md#device-prompt)
- [Secrets](ModelUnitTests.md#secrets)
Expand All @@ -11,6 +11,9 @@ and the tests will be run automatically with `rake test`. See
development environment. In the following examples, we use
[Bundler](https://bundler.io/) and prefix all commands with `bundle exec`.

In addition, you can write [custom unit tests](ModelUnitTests.md#custom-tests)
for your model

## Device Simulation
### YAML Simulation File
You need a [YAML simulation file](/docs/DeviceSimulation.md) for your device.
Expand Down Expand Up @@ -173,3 +176,11 @@ pass:
- 'hash-mgmt-user oxidized password hash <secret removed>'
- 'hash-mgmt-user rocks password hash <secret removed> usertype read-only'
```

## Custom tests
When you write custom tests for your models, please do not use the filenames
mentioned above, as it will interfere with the standard tests. If you need to
store a custom simulation file, use `model:description:custom_simulation.yaml`.

The [cumulus test](/spec/model/cumulus_spec.rb) is an example of a custom
test.
4 changes: 2 additions & 2 deletions spec/model/cumulus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
model: 'cumulus',
vars: { cumulus_use_nvue: true })

model = YAML.load_file('spec/model/data/cumulus:MSN2010_5.9.2_nvue:simulation.yaml')
model = YAML.load_file('spec/model/data/cumulus:MSN2010_5.9.2_nvue:custom_simulation.yaml')
mockmodel = MockSsh.new(model)
Net::SSH.stubs(:start).returns mockmodel

Expand All @@ -32,7 +32,7 @@
vars: { cumulus_routing_daemon: 'frr',
enable: true })

model = YAML.load_file('spec/model/data/cumulus:VX_5.4.0_frr:simulation.yaml')
model = YAML.load_file('spec/model/data/cumulus:VX_5.4.0_frr:custom_simulation.yaml')
mockmodel = MockSsh.new(model)
Net::SSH.stubs(:start).returns mockmodel

Expand Down

0 comments on commit 44225b9

Please sign in to comment.