[PATCH] samba-tool throws error if there is an empty FSMO role

Andrew Bartlett abartlet at samba.org
Wed May 4 21:36:30 UTC 2016


On Wed, 2016-05-04 at 20:50 +0100, Rowland Penny wrote:
> On 04/05/16 20:27, Andrew Bartlett wrote:
> > 
> > On Mon, 2016-05-02 at 20:41 +0100, Rowland Penny wrote:
> > 
> > > 
> > > So Andrew, how do I write a test for something that tests itself
> > > every
> > > time it runs ??? and if there are errors, these errors will
> > > probably
> > > have nothing to do with my code
> > Exactly!  The vast majority of errors introduced into Samba,
> > particularly into the python code, are not intentional nor present
> > at
> > the time that particular code was developed.
> > 
> > I'm quite happy to trust, for the purpose of argument, that at this
> > point in time, your patches are OK.
> > 
> > > 
> > > Or to put it another way, I cannot think how to write a test for
> > > fsmo.py
> > > that doesn't replicate how I tested it before I sent my patch and
> > > there
> > > is no point in doing the same test over and over again, on the
> > > off
> > > chance it will develop an error.
> > The purpose of automated testing is to assert that this remains the
> > case!
> > Additionally, in python, there is no pre-compilation.  That means
> > that
> > the only way to guard against errors, such as we have seen in
> > demote,
> > where additional arguments are added BY OTHERS to functions called,
> > is
> > to run the code, and assert at the very least successful
> > completion.
> > Ideally we also assert some meaningful output, against what we
> > expect,
> > given the environment it runs in.
> > I know it feels really odd writing an assertion in much the same
> > way as
> > the code it is testing does internally - but it works, partly
> > because
> > the unintentional or helpful fix typically won't also
> > unintentionally
> > update the test to mask a breakage.
> > Without continuous integration, with such a small team Samba would
> > not
> > be what it is today - we would be chasing our tail, endlessly
> > fixing
> > our own regressions.
> > I hope this clarifies things,
> > 
> > Andrew Bartlett
> > 
> OK, I understand the why

Good.  This first step is very, very important.

> , but I will say this very loud, I HAVE NO IDEA 
> HOW TO DO THIS! :-)
> 
> How do I create two DCs ? how do I provision the first and then join
> the 
> second to the first ? Having done that, how do I then empty FSMO
> roles ? 
> how do I then call fsmo.py ?

I think you have perhaps imagined that your task is more complex than
it actually is.

There are already a number of test environments defined in
selftest/targets/Samba4.pm

One of them is called fl2000dc

If you run "SELFTEST_TESTENV=fl2000dc:local make testenv"

Then you can play in that environment.

Specifically, you can see that on git master 'samba-tool fsmo show'
faults.  That is perfect, because it already gives you everything you
need to show your patch is correct.  It doesn't matter if running in
fl2000 mode is practical in the real world - it just means you don't
need to do any more work to get a DC without a DNS partition, which is
the actual goal. 

Your task is to look at the examples I gave, and build a very simple
test that confirms that in every environment, this command runs to
completion. 

Bonus points for checking the results make sense (you have the test
confirm if there is a DNS partition), but start with 'it runs and
succeeds', because that is what catches the syntax errors.

Some hints:

Here is how we invoke the timecmd test:
source4/selftest/tests.py:
planpythontestsuite("ad_dc_ntvfs:local",
"samba.tests.samba_tool.timecmd")

See also the loops where we run some commands over multiple
environments.

Here is the timecmd test:
python/samba/tests/samba_tool/timecmd.py

An existing test for the fsmo code.  (You can still build a simple test
like timecmd rather than extending this one, if you prefer):

source4/torture/drs/python/fsmo.py

Also please re-read my previous mails. 

Thanks,

Andrew Bartlett

-- 
Andrew Bartlett
https://samba.org/~abartlet/
Authentication Developer, Samba Team         https://samba.org
Samba Development and Support, Catalyst IT   
https://catalyst.net.nz/services/samba









More information about the samba-technical mailing list