[Kimchi-devel] Why do we use mockmodel?

Crístian Viana vianac at linux.vnet.ibm.com
Mon Aug 11 17:35:00 UTC 2014


Hi!

After creating a few patches for Kimchi, it occurred to me that the 
mockmodel design has more cons than pros. So I started wondering why we 
still use it.

I understand - and totally agree - that we should have an extensive test 
infrastructure to make sure the code runs as designed and to make it 
very easy to find regression bugs on every new feature we implement. And 
as Kimchi works very integrated to its host system, it may not be easy 
to create expected/failed situations for things we don't always have 
control.

But for every new feature we implement, we currently have to:

1) Implement the feature itself
2) Create tests for (1)
3) Implement the feature in a mock environment
4) Create tests for (3)

And by looking at some existing code, many of the mock tests don't 
actually test anything. They're just there so we can say we have a mock 
implementation and a test for it. Why create a mock function and a test 
for the mock function if what we need is to test the real code? And a 
lot of times, the mock implementation (and the tests) are just 
copy/paste of the original feature. For me, that seems very tedious and 
useless.

Why don't we get rid of the mockmodel and keep only the "real" model? I 
understand that it's not so simple to remove it right away, that's why 
I'm starting this discussion so we could see how to do it better - if 
we're actually going to do it. What would we miss if we didn't have the 
mockmodel anymore? I believe we'll need to be more careful when writing 
tests which run on a real environment (i.e. we can't "leak" VMs, 
networks, templates, or anything else) but at least we'll always test 
real code and we won't be writing code that won't be used.

Please share your opinion with us.

Best regards,
Crístian.




More information about the Kimchi-devel mailing list