[openstack-dev] [ceilometer] Unit Testing for Agents

Paulo Oliveira paulonascimento at av.it.pt
Mon May 26 19:31:18 UTC 2014


Hello Stackers,

Disclaimer: I'm on a quest to develop a new agent, already have coding a few lines. The next step is Unit Testing and enabling me to create a patch to test on a devstack. So, this is what brings me here, the need to understand and learn the best-pratices or rules to develop Unit Tests on the Ceilometer project.

I probably should mention that my Unit Tests knowledge should be classified as Basic (on a Java environment). I could synthesise it as: "I need to create a block the code and assert the output against with I expected". 
In this project seems a little bit more complex.
I have read it about Mock and Fixtures, the first one nevertheless the complexity it's much more easy to read and understand.

I will try to put this problem simply as possible.
I have analyze several files:
ceilometer/central/test_manager.py
ceilometer/compute/test_manager.py
ceilometer/compute/pollsters/test_cpu.py
ceilometer/agentbase.py
ceilometer/base.py
And I need to confess I'm a little lost on this part. I have realised that I should create a test for the manager and for every pollster and to the plugin if I think it is necessary.
So that being said, I infered the following topics:
on my test_manager.py I should declare two classes: TestManager and TestRunTasks
the first one should be responsible by test the manager.py of my agent, with 'test_load_plugins' verify if there is any pollster associated to this agent (seems to be straightforward)
the second one should be responsible by test the pollsters/*.py of my agent and in this case the things complicate a little bit...
Have I infered correctly? Anyone disagrees?

Moving forward...
Following the code on ceilometer/{central, compute}/test_manager.py, the method setUp(...) raises some questions, why to use setUp if we have already have a create_manager(...)? Should be for creating samples/alarms?
I have already figure out that .useFixture() comes from fixtures package: "The method useFixture will use another fixture, call setUp on it, call self.addCleanup(thefixture.cleanUp), attach any details from it and return the fixture. This allows simple composition of different fixtures."
Again, lost! Where are declarations of agents/ceilometer fixtures? How should I use them?

After that every test_* in TestRunTasks should execute a different test on which data? In every of them I must create the sample?

Where do I test the get_samples(), publish(), pipepline(sources, sinks) matters? In this files too?

I appreciate a lot your atention and patience with me. Thank you in advance.
Best Regards,
Paulo J. Nascimento Oliveira
http://about.me/pnascimento
Advanced Telecommunications and Networks Group - http://atnog.av.it.pt
Follow us - @ATNoG_ITAv



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140526/5cbd6041/attachment.html>


More information about the OpenStack-dev mailing list