Re: [Avocado-devel] initializing class attributes

2018-11-28 Thread Cleber Rosa



On 11/28/18 12:30 PM, Brian J. Murrell wrote:
> Any opinions on the preference of initializing Test class attributes in
> setUp() vs. the more traditional __init__()?
> 
> I.e. if my tearDown() is:
> 
> def tearDown(self):
> print self.foo
> 
> self.foo needs to be initialized.  Typically in python objects, this is
> done in __init__(), but given that avocado always runs setUp(), it
> could be done at the start of it.
> 
> I wonder what the preferred method is.
> 

The general guideline is to use __init__() for your class instance
needs, and use setUp() for getting your test ready to run.

Given that the __init__() interface is used by the test runner, and
having the minimal amount of code there will minimize problems with
runner<->test communication, I'd leave it alone as much as possible and
use setUp() instead.

> Cheers,
> b.
> 

Cheers!

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]
[  7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3  ]



[Avocado-devel] initializing class attributes

2018-11-28 Thread Brian J. Murrell
Any opinions on the preference of initializing Test class attributes in
setUp() vs. the more traditional __init__()?

I.e. if my tearDown() is:

def tearDown(self):
print self.foo

self.foo needs to be initialized.  Typically in python objects, this is
done in __init__(), but given that avocado always runs setUp(), it
could be done at the start of it.

I wonder what the preferred method is.

Cheers,
b.



signature.asc
Description: This is a digitally signed message part


Re: [Avocado-devel] correlating xunit output to job-results

2018-11-28 Thread Lukáš Doktor
Dne 28. 11. 18 v 15:35 Brian J. Murrell napsal(a):
> On Mon, 2018-11-26 at 17:03 +0100, Lukáš Doktor wrote:
>>
>> This is a new information. So are you actually looking for job--
>> MM-DDTHH.MM-UID only, or are you looking for test-name => test-
>> output-dir mapping?
> 
> I'm looking to correlate a given display of one of mnay xunit test
> results in Jenkins job to the one of many job--MM-DDTHH.MM-UID
> directories I have collected for the test run.
> 
> My xunit output shows me I have a failed test.  I want to go to the
> job--MM-DDTHH.MM-UID I have in the archives for the job to see more
> information about it.
> 

I see, so I actually misunderstood you. This seems even simpler, how about 
this: https://github.com/avocado-framework/avocado/pull/2922

>> My idea was to basically do something like:
>>
>> for name in xunit.gettests().get('name'):
>> tid = name.split('-')[0]
>> print(glob.glob("latest/test-results/%s-*" % tid))
>>
>> which although not nice should always return only 1 match.
> 
> This doesn't correlate to an avocado/job-results/job--MM-DDTHH.MM-
> UID directory does it though?
> 
>>
>>> Looking at a given Test instance I can see lots of attributes and
>>> actually now that I look, I can see several attributes that embed
>>> that
>>> job--MM-DDTHH.MM-UID value into pathnames such as _stderr_file,
>>> _stdout_file, _Test__logfile, _Test__sysinfodir, _Test__logdir,
>>> _ssh_logfile, _Test__outputdir.
>>>
>>> I can surely peel the value I am looking for out of any one of
>>> these
>>> but of course, that feels like I am peeking under the kimono and
>>> using
>>> something that is subject to change in the future.
> 
> So while I can do this, I can't seem to display it in any way such that
> it gets into the xunit results in any way.  I can print it, in
> __init__(), say, but that doesn't end up in the xunit results file.
> 
> Hrm.  Looking again, I see that self.log.info() results end up on the
> xunit Standard Output.  This is probably where I can add this.  I just
> need to convert all tests to using my subclass and calling the parent's
> setUp() in their own setUp(), etc.
> 

That seems like an ugly hack... Hopefully we'll find a more suitable solution 
:-)

>> I think you understand well (based on the first response). Basically
>> I run a job, it produces several hundreds of MB of log files, which
>> are attached as artifacts and then several tenths of MB is attached
>> again as the XUNIT file, because the "debug.log" is always embedded
>> into the XUNIT results. It'd be nice to simply add link to the
>> archived results, but I haven't found a way back then...
> 
> You could just delete the duplicates before archiving them in Jenkins. 
> I do that for the jobs-results/*/html/ subdirs since the links in them
> are broken anyway.
> 

Well, it's just a symlink, not taking much space... It's there for 
compatibility reasons with 36lts and had been removed after 52lts was 
released...

Regards,
Lukáš

> Or maybe have avocado not produce the debug.log if xunit output is
> enabled.
> 
> Cheers,
> b.
> 




signature.asc
Description: OpenPGP digital signature


Re: [Avocado-devel] correlating xunit output to job-results

2018-11-28 Thread Brian J. Murrell
On Mon, 2018-11-26 at 17:03 +0100, Lukáš Doktor wrote:
> 
> This is a new information. So are you actually looking for job--
> MM-DDTHH.MM-UID only, or are you looking for test-name => test-
> output-dir mapping?

I'm looking to correlate a given display of one of mnay xunit test
results in Jenkins job to the one of many job--MM-DDTHH.MM-UID
directories I have collected for the test run.

My xunit output shows me I have a failed test.  I want to go to the
job--MM-DDTHH.MM-UID I have in the archives for the job to see more
information about it.

> My idea was to basically do something like:
> 
> for name in xunit.gettests().get('name'):
> tid = name.split('-')[0]
> print(glob.glob("latest/test-results/%s-*" % tid))
> 
> which although not nice should always return only 1 match.

This doesn't correlate to an avocado/job-results/job--MM-DDTHH.MM-
UID directory does it though?

> 
> > Looking at a given Test instance I can see lots of attributes and
> > actually now that I look, I can see several attributes that embed
> > that
> > job--MM-DDTHH.MM-UID value into pathnames such as _stderr_file,
> > _stdout_file, _Test__logfile, _Test__sysinfodir, _Test__logdir,
> > _ssh_logfile, _Test__outputdir.
> > 
> > I can surely peel the value I am looking for out of any one of
> > these
> > but of course, that feels like I am peeking under the kimono and
> > using
> > something that is subject to change in the future.

So while I can do this, I can't seem to display it in any way such that
it gets into the xunit results in any way.  I can print it, in
__init__(), say, but that doesn't end up in the xunit results file.

Hrm.  Looking again, I see that self.log.info() results end up on the
xunit Standard Output.  This is probably where I can add this.  I just
need to convert all tests to using my subclass and calling the parent's
setUp() in their own setUp(), etc.

> I think you understand well (based on the first response). Basically
> I run a job, it produces several hundreds of MB of log files, which
> are attached as artifacts and then several tenths of MB is attached
> again as the XUNIT file, because the "debug.log" is always embedded
> into the XUNIT results. It'd be nice to simply add link to the
> archived results, but I haven't found a way back then...

You could just delete the duplicates before archiving them in Jenkins. 
I do that for the jobs-results/*/html/ subdirs since the links in them
are broken anyway.

Or maybe have avocado not produce the debug.log if xunit output is
enabled.

Cheers,
b.



signature.asc
Description: This is a digitally signed message part