Coder Social home page Coder Social logo

Test Suite Refactor about minimart HOT 15 CLOSED

electric-it avatar electric-it commented on August 26, 2024
Test Suite Refactor

from minimart.

Comments (15)

tapickell avatar tapickell commented on August 26, 2024

Still seeing randomness in failures, this needs to be much better.

from minimart.

EYurchenko avatar EYurchenko commented on August 26, 2024

Minimart::Mirror::InventoryBuilder#build errors should not happen any longer, there was wrong/new uri to match in tests. Now these tests do not fail (at least for me).
Somehow randomness affects testing results, so to have consistent failures that do not change from one run to another I removed
--order rand
from .rspec.
and now I am getting:
rspec ./spec/lib/minimart/inventory_requirement/git_requirement_spec.rb:53 # Minimart::InventoryRequirement::GitRequirement#requirements should not eq {"yum"=>"> 3.0.0"}
rspec ./spec/lib/minimart/mirror/dependency_graph_spec.rb:26 # Minimart::Mirror::DependencyGraph#add_artifact should not have any dependencies
rspec ./spec/lib/minimart/mirror/dependency_graph_spec.rb:30 # Minimart::Mirror::DependencyGraph#add_artifact should not add any possible dependencies to the graph
rspec ./spec/lib/minimart/mirror/dependency_graph_spec.rb:102 # Minimart::Mirror::DependencyGraph#resolved_requirements when all dependencies are met should not return a resolved yum version for the mysql dependency
rspec ./spec/lib/minimart/mirror/dependency_graph_spec.rb:114 # Minimart::Mirror::DependencyGraph#resolved_requirements when a dependency cannot be resolved should not raise an error

The only thing that puzzles me is when you perform the only one block it always succeeds:
$ bundle exec rspec ./spec/lib/minimart/mirror/dependency_graph_spec.rb

Minimart::Mirror::DependencyGraph
#add_artifact
should add the cookbook to the graph
should not have any dependencies
should not add any possible dependencies to the graph
when the cookbook has already been added
should not add any new dependencies
#source_cookbook_added?
when the cookbook has been added
should return true
when the cookbook has not been added
should return false
#add_requirement
should add the requirement
#resolved_requirements
when all dependencies are met
should not return a resolved mysql version
should not return a resolved apt version
should not return a resolved yum version for the mysql dependency
when a dependency cannot be resolved
should not raise an error

Finished in 0.03031 seconds (files took 0.76827 seconds to load)
11 examples, 0 failures

from minimart.

tapickell avatar tapickell commented on August 26, 2024

interesting I just ran that and saw the same results as well with just the single spec running.

from minimart.

tapickell avatar tapickell commented on August 26, 2024

Then when running the full suite the number of failures jumps from 3 to 5.
I hate tests that fail randomly. I would like to keep the random option in the .rspec as our tests should pass no matter what the order. I created a branch for this lets-fix-the-tests

from minimart.

EYurchenko avatar EYurchenko commented on August 26, 2024

I would like to keep the random option in the .rspec as our tests should pass no matter what the order.
Sure! Just for debugging/troubleshooting - all what I am saying is disabling randomness gives me consistent results - always 5 failures and I love consistency -) Will dig further when have some time.

from minimart.

tapickell avatar tapickell commented on August 26, 2024

If I run bundle exec rspec ./spec/lib/minimart/inventory_requirement/git_requirement_spec.rb then all those specs pass but running the full suite rspec ./spec/lib/minimart/inventory_requirement/git_requirement_spec.rb:53 # Minimart::InventoryRequirement::GitRequirement#requirements should not eq {"yum"=>"> 3.0.0"} fails :(

from minimart.

tapickell avatar tapickell commented on August 26, 2024

Cool @EYurchenko thank you for your help with this. 👍

from minimart.

tapickell avatar tapickell commented on August 26, 2024

Finished in 16.01 seconds (files took 1.01 seconds to load) 260 examples, 0 failures, 3 pending Lols Rspec you so silly.

from minimart.

EYurchenko avatar EYurchenko commented on August 26, 2024

somehow the one who feels silly is me -(
I was taught that computers do exactly what they are told to do, it's silly we humans break things -)

from minimart.

tapickell avatar tapickell commented on August 26, 2024

Lol it's silly that the test suite was not written better to begin with.

from minimart.

EYurchenko avatar EYurchenko commented on August 26, 2024

Please take a look at the last two commits at https://github.com/EYurchenko/minimart/commits/master . The problem we are seeing is because @load_deps is a class variable and depending on the order of tests execution it may go uninitialized ever which lead to weird results. If I get the logic right we want Minimart by default resolve all dependencies so my commit should be correct. It makes behavior persistent at least.
Then we get bunch of tests failing at Minimart::Mirror::DependencyGraph. They all fail now because we assume here that dependencies should not be added. Who wrote this tests? I don't understand why by default want no dependencies??? So I can easily fix these tests if they indeed want no dependencies added.

from minimart.

tapickell avatar tapickell commented on August 26, 2024

That is true, originally this was designed to load all dependencies by default but there was a lot of users wanting this as an option. We decided to change to have it not load the cookbooks dependencies by default but only when it is passed the load_deps option from the cli during the mirror call.

from minimart.

tapickell avatar tapickell commented on August 26, 2024

@EYurchenko thank you for finding that, I believe that will resolve this testing issue.

from minimart.

EYurchenko avatar EYurchenko commented on August 26, 2024

Ok, sorry for misunderstanding. I believe it is good now.

from minimart.

tapickell avatar tapickell commented on August 26, 2024

Thank you @EYurchenko for your work on this.

from minimart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.