Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ATOMS - Automatic Trivial Oxidized Model Spec #3361

Merged
merged 48 commits into from
Jan 9, 2025
Merged

ATOMS - Automatic Trivial Oxidized Model Spec #3361

merged 48 commits into from
Jan 9, 2025

Conversation

robertcheramy
Copy link
Collaborator

@robertcheramy robertcheramy commented Jan 9, 2025

Pre-Request Checklist

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • Changes are reflected in the documentation
  • User-visible changes appended to CHANGELOG.md

Description

This PR introduces ATOMS (Automatic Trivial Oxidized Model Spec), which greatly simplifies model unit tests. Most of the code is from @ytti, @robertcheramy documented it and updated device2yaml.rb.

Note: the PR will be squashed & merged.

Summary by CodeRabbit

Based on the comprehensive summary, here are the release notes:

  • New Features

    • Added unit tests for the junos model
    • Added SCP support for the apc_aos model
    • Simplified and automated model unit tests
    • Moved device2yaml.rb to extra/ directory with enhanced command specification capabilities
  • Changes

    • Updated input/ssh to improve debug character dumping
    • Modified cumulus model to remove ANSI escape codes and improve prompt handling
    • Updated documentation for model creation, device simulation, and unit testing
  • Documentation

    • Created new documentation sections for device simulation and model unit tests
    • Updated links and formatting in existing documentation
  • Refactor

    • Streamlined configuration output files
    • Simplified test suite structure and mock model handling

ytti and others added 30 commits December 19, 2024 10:32
See if it makes sense to simplify simple case of model testing
a) output is plain ascii, not yaml (TODO, it is yaml, and uses
yaml_interpolate)
b) we no longer do n^2 to figure out files, much more streamlined way to
build test
Will make it easier to instantitate ATOMS test elsehwere too
This allows us to report why some test are skipped, for example if we
failed to load a data file
Flat list of tests instead of hash of tests with type key
Simplify creating the result object
No point requiring it in each model test
Removes the need to always instantiate test first in the model specs
New names make it more convenient to choose which tests to run, eg:

```
╰─ ruby -Ilib:test spec/model/model_atoms_spec.rb --name "/output:ios/" --verbose
Run options: --name /output:ios/ --verbose --seed 41151

ATOMS tests#test_0017_output:ios:C9200L-24P-4G_17.09.04a has expected output = 1.01 s = .
ATOMS tests#test_0019_output:ios:asr920_16.8.1b has expected output = 0.73 s = .
ATOMS tests#test_0018_output:ios:C9800-L-F-K9_17.06.05 has expected output = 0.72 s = .

Finished in 2.465471s, 1.2168 runs/s, 3.6504 assertions/s.

3 runs, 9 assertions, 0 failures, 0 errors, 0 skips
Coverage report generated for RSpec to /home/ytti/git/oxidized/coverage/coverage.xml. 658 / 1146 LOC (57.42%) covered
Coverage report generated for RSpec to /home/ytti/git/oxidized/coverage.
Line Coverage: 57.42% (658 / 1146)
```
I did comment atoms.rb while reading & understanding it. Nice peace of
code!
must_match is meant for a regexp, but test.output is plain text.
When we use must_equal, we get a nice diff of the differences when the
test fails.
"---" at the beginning of a YAML file is optional, and we have files
with and files without ---.
This commit makes all files comply to the decision (@ytti +
@robertcheramy) not to use ---.
robertcheramy and others added 16 commits December 30, 2024 15:33
- Removing garderos_spec.rb as is it covered with ATOMS
- Documenting atoms.rb further
- We may need a fail_with_expect: but I would only implement it when we
need it.
Avoids useless tests if previous tests about output would fail anyhow.
Intended to remove 'rescue nil' but only removed 'l'.
- include de command sets into device2yaml.rb / This could be solved in
a better way
- move examples/device-simulation/README.md to /docs/DeviceSimulation.md
- adapt the documentation to the new path
- remove examples/device-simulation
- the YAML Simulation files do not have an oxidized_output: section
anymore
- spec/model/README.md is still to be updated
k = ''
loop do
 k << 'a'
end

Wont work in future, because k is string literal, therefore frozen/immutable, and String#<< method tries to mutate it.

Fixes are
  k = String.new
  k = '' + ''   # expression is not string literal
  k = ''.dup
From ruby 3.5.0 forward ostruct won't be available by standard
- Preparing merge into master (some polishing is still needed)
- Adapt new tests from master (fsos and cumulus prompts) to ATOMS
- Place the yaml files under spec/model/data
- Remove command sets from master
- The cumulus tests needs further development, which will be done after
the merge, so the tests are skipped for now
@robertcheramy robertcheramy self-assigned this Jan 9, 2025
@robertcheramy robertcheramy requested a review from ytti January 9, 2025 14:23
@robertcheramy
Copy link
Collaborator Author

@ytti - I'm ready to merge. Do you want to make a last review?

@ytti
Copy link
Owner

ytti commented Jan 9, 2025

Go for it and thank you.

@robertcheramy robertcheramy removed the request for review from ytti January 9, 2025 14:26
@robertcheramy robertcheramy merged commit 0e19aed into master Jan 9, 2025
12 checks passed
@robertcheramy robertcheramy deleted the ATOMS branch January 9, 2025 14:29
@ytti
Copy link
Owner

ytti commented Jan 13, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Jan 13, 2025

✅ Actions performed

Full review triggered.

Copy link

coderabbitai bot commented Jan 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces significant changes to the Oxidized project, focusing on enhancing model unit testing, device simulation, and documentation. The changes include moving the device2yaml.rb script to the extra/ directory, updating documentation for model creation and unit tests, and removing device simulation command sets and example files. New unit test configurations have been added for various network device models, with improvements to how device outputs and secrets are handled.

Changes

File/Directory Change Summary
CHANGELOG.md Added entries for Junos unit tests, APC AOS SCP support, model unit test automation, and device2yaml.rb relocation
Rakefile Added extra/device2yaml.rb to xbit array for file permissions
docs/ Added DeviceSimulation.md, updated Creating-Models.md and Issues.md with new links and instructions
examples/device-simulation/ Removed README and all command set files
extra/device2yaml.rb Updated command-line options and error handling
spec/model/ Added new test configurations, removed individual model spec files, added atoms.rb and related test files

Poem

🐰 A Rabbit's Ode to Oxidized Evolution

In bits and bytes, a transformation gleams,
Unit tests dance, automation's sweet dreams
Device simulation, a new frontier so bright
Secrets hidden, configurations take flight

Hop, hop, hurrah! 🎉 The code grows wise and neat! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants