These are chat archives for ManageIQ/manageiq/performance

23rd
Sep 2016
Keenan Brock
@kbrock
Sep 23 2016 16:03

so I have:

it "counts" do
  FactoryGirl.create_list(:vm_vmware, 5)
  expect { expect(Vms.count).to eq(5) }.to match_query_limit_of(1)
end

Ideas how to change this to:

before do # assuming we need to move this outside the it block
  FactoryGirl.create_list(:vm_vmware, 5)
end
it "counts", :max_queries => 1 do
  expect(Vm.count).to eq(5)
end
Nick LaMuro
@NickLaMuro
Sep 23 2016 16:06
Are you more concerned about the :max_queries part, or the before part?
oh, the comment makes it seem like the former
Keenan Brock
@kbrock
Sep 23 2016 16:14
:max_queries
I don't want to have to embed that block all over the place
just tacking that into a few spots would be great
I can keep the before below and have max_queries => 6
which is probably fine
I just introduced a minor regression (one that no one would have noticed it is such a special case) but it is our job to run numbers...
maybe have a yaml file that knows how much time / queries PER rspec test, and then compares after the run... ;)
that would be a maintanance nightmare
but neat
Nick LaMuro
@NickLaMuro
Sep 23 2016 16:23
@kbrock Not the rspec expert, but I think what you are suggesting is going outside of the usecase of rspec filters: http://www.relishapp.com/rspec/rspec-core/v/3-5/docs/filtering/inclusion-filters
If this query limit changes with each it, and you are just trying to reduce the number of "characters per line", then I would argue to just suck it up and move on in this case, because what you are suggesting will be "hacking" rspec (as far as I can tell)
Keenan Brock
@kbrock
Sep 23 2016 16:26
perfect - thanks
I'm moving on
Nick LaMuro
@NickLaMuro
Sep 23 2016 16:27
but if you are trying to reduce the duplication since the max_queries would stay the same between each test case (it), then maybe doing it in a before block would make sense
that said, not sure how max_queries works under the hood, so that might be easier said than done
Keenan Brock
@kbrock
Sep 23 2016 16:28
I was able to implement expect {}.to match_query_limit_of(5)
and expect {}.not_to exceed_query_limit(5) (not good english - I didn't write ;) )
that was sure better than the alternative
so I was wondering if putting that into the it block would be easier to read and less crud
it was trivial to add the custom expect
so I was trying to figure out if it was as easy to add the other.
hmm. I'll look at vcr, that has it "works", :cassette => "X" do
whoa ==> [example]
I'll have to put that in my back burner list
thanks. looks pretty easy, but I'm ejecting
Nick LaMuro
@NickLaMuro
Sep 23 2016 16:36
Yeah, metadata might be something that you could use, but didn't see a good example in the docs. Maybe that is interfaced the same way as filters, so I might have been confused
Chris Arcand
@chrisarcand
Sep 23 2016 16:38
(catching up) What you’re looking for isn’t really intended with metadata. And while I see it’s pretty, I think it’s adding more complex sugar than usefulness, tbh.
Nick LaMuro
@NickLaMuro
Sep 23 2016 16:39
I figured you would have had an opinion matter, but didn't want to rope you in unless you wanted to
Chris Arcand
@chrisarcand
Sep 23 2016 16:39
+1, I’m not the RSpec gatekeeper ;)
Keenan Brock
@kbrock
Sep 23 2016 16:46
lol
thanks for feedback
needed feedback whether something like this would even be worth researching
(too many ideas)