[openstack-dev] Openvswitch agent unit tests

Assaf Muller amuller at redhat.com
Tue Sep 29 22:54:16 UTC 2015


On Tue, Sep 29, 2015 at 5:00 PM, Sławek Kapłoński <slawek at kaplonski.pl>
wrote:

> Hello,
>
> Thx for Your tips. So I should focus more on write new functional tests
> for ovs agent if there are missing some rather then doing unit tests for
> it?
>

If a method is conceivably testable with unit tests (Without over relying
on mock), that is preferable.
Failing that, functional tests are the way to go. The general idea is to
test bottom up: Lots of unit
tests, fewer functional tests, fewer API/integration/fullstack tests, and
even fewer Tempest scenario
tests. In the case of the OVS agent (And other Neutron agents that interact
with the underlying hypervisor)
it is difficult to test the agent with unit tests effectively, which is why
I encourage developers to test
via functional, mock-less tests, like the tests I linked you in my previous
email.


>
> --
> Best regards / Pozdrawiam
> Sławek Kapłoński
> slawek at kaplonski.pl
>
> On Mon, 28 Sep 2015, Assaf Muller wrote:
>
> > Generally speaking, testing agent methods that interact with the system
> > heavily with unit tests provide very little,
> > and arguably negative value to the project. Mocking internal methods and
> > asserting that they were called is a
> > clear anti-pattern to my mind. In Neutron-land we prefer to test agent
> code
> > with functional tests.
> > Since 'functional tests' is a very over-loaded term, what I mean by that
> is
> > specifically running the actual unmocked
> > code on the system and asserting the expected behavior.
> >
> > Check out:
> > neutron/tests/functional/agent/test_ovs_lib
> > neutron/tests/functional/agent/test_l2_ovs_agent
> >
> > On Mon, Sep 28, 2015 at 3:45 PM, Sławek Kapłoński <slawek at kaplonski.pl>
> > wrote:
> >
> > > Hello,
> > >
> > > I'm new developer who want to start contributing to neutron. I have
> some
> > > small experience with neutron already but I didn't do anything which I
> > > could push to upstream for now. So I searched for some bug on launchpad
> > > and I found such bug which I took:
> > > https://bugs.launchpad.net/neutron/+bug/1285893 and I started to
> > > checking how I can write new tests (I think that it is quite easy job
> to
> > > do for the beginning but maybe I'm wrong).
> > > Now I have some questions to You:
> > > 1. From test-coverage I can see that for example there is missing
> > > coverage like in lines 349-350 in method _restore_local_vlan_map(self)
> -
> > > should
> > > I create new test and call that metod to check if proper exception will
> > > be raised? or maybe it is not neccessary at all and such "one lines"
> > > missing coverage is not really needed to be checked? Or maybe it should
> > > be done in some different way?
> > >
> > > 2. What about tests for methods like: "_local_vlan_for_flat" which is
> > > not checked at all? should be created new test for such method? or
> maybe
> > > it should be covered by some different test?
> > >
> > > Thanks in advance for any advice and tips how to write such unit tests
> > > properly :)
> > >
> > > --
> > > Best regards / Pozdrawiam
> > > Sławek Kapłoński
> > > slawek at kaplonski.pl
> > >
> > >
> > >
> __________________________________________________________________________
> > > OpenStack Development Mailing List (not for usage questions)
> > > Unsubscribe:
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> > > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> > >
> > >
>
> >
> __________________________________________________________________________
> > OpenStack Development Mailing List (not for usage questions)
> > Unsubscribe:
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150929/9c0bcebc/attachment.html>


More information about the OpenStack-dev mailing list