[asterisk-dev] [Code Review]: TestSuite archiving of Asterisk logs on test run failure
Paul Belanger
reviewboard at asterisk.org
Mon Sep 12 17:02:06 CDT 2011
> On Sept. 12, 2011, 3:20 p.m., Paul Belanger wrote:
> > /asterisk/trunk/runtests.py, line 190
> > <https://reviewboard.asterisk.org/r/1431/diff/1/?file=20561#file20561line190>
> >
> > Is it possible to access the asterisk instance astlogdir value?
>
> mjordan wrote:
> Probably not. If we created an Asterisk instance, we'd create a new directory structure, as opposed to merely querying for the potential location of the log directories. Right now the astlogdir is read from the config files, which are moved and copied (etc.) to the Asterisk instances on creation - when this happens, you've already created a directory structure, which we definitely want to avoid. Otherwise, we'd be creating directories in the same place we wanted to copy from.
>
> That's why I moved the base location of the asterisk temp directory to being static, so I didn't make any false instances of Asterisk (and create more directories)
>
> Paul Belanger wrote:
> Sorry, I was talking about the hard-coded path for /var/log/asterisk... could you not use: Dependency.__ast.directories["astlogdir"]
>
> mjordan wrote:
> Yup, I know. Let's say we make an instance of an Asterisk object and assign it to __ast (in whatever class). At that moment, we've created a new directory structure in the tmp/asterisk-testsuite directory, that has nothing to do with what we want to copy. Sure, it may (if we supplied the correct test name) have the correct config files, but we've just created a new directory in the same location as the directories we wanted to copy. For example, let's say a test run creates two Asterisk instances, so we have:
> * ast1\var\log\...
> * ast2\var\log\...
>
> We then want to reference the \var\log path using an instance of Asterisk. If we create that instance, we'll have on disk:
> * ast1\var\log\...
> * ast2\var\log\...
> * ast3\var\log\...
>
> No bueno. We've just created something to find out where we want to copy from - in the best case, we're creating (yet again) more file to copy around, and we'll always have an 'empty' log directory for each failed run. This makes this more confusing then it needs to be.
>
> If we don't create an instance by making the information static, then yes, we can do Asterisk.var_log_dir (or something similar) - however, right now that var log information is read from the configuration files that are copied to the instance's created directory structure. So it's not possible - and since the var log information is dependent on each test run, it's not really something that should be static.
>
> It does mean that overriding the \var\log information in a test's Asterisk.conf file is probably a bad idea.
I see what you are saying, and yes I knew that. For some reason my brain was saying we exposed the original /etc/asterisk/asterisk.conf file when we did Asterisk.__gen_ast_conf().
Okay, we'll have to leave the hardcoded path for now (yuck).
> On Sept. 12, 2011, 3:20 p.m., Paul Belanger wrote:
> > /asterisk/trunk/runtests.py, line 194
> > <https://reviewboard.asterisk.org/r/1431/diff/1/?file=20561#file20561line194>
> >
> > How about a symlink? Seems like a waste to copy it.
>
> mjordan wrote:
> You wouldn't want a symbolic link, as the thing that you link to is apparently being deleted by the test harness. We'd have a dangling link otherwise. If we aren't deleting the Asterisk logs between runs, then yes, a symbolic link would suffice here.
>
> Paul Belanger wrote:
> Well, we actually delete the testsuite directory and runtests.py before the /tmp/asterisk-testsuite folder, so symlinking is not an issue. We also have bamboo copy the files into the artifact directory before we at to this point too.
>
> mjordan wrote:
> I'm confused.
>
> Either we have the original Asterisk logs, or we don't. If we have the original Asterisk logs, then creating symbolic links is all find and good, but is merely a 'nice to have'. I was under the impression that we had no way to get the Asterisk logs after a test run. If that's not the case, then this is a nice to have, but not needed, patch to debug the voicemail tests that have been bouncing.
>
> If we don't have the Asterisk logs, e.g., everything in the /tmp/asterisk-testsuite/ directory is deleted, then symbolic links would be no bueno, and we need to copy the files. Whether or not the place the test copies them to is later manipulated by bamboo in someway (moving them yet again, etc.) is superfluous from the test's perspective - currently, our place for putting log results is in the .logs\ directory.
>
>
> mjordan wrote:
> er, that should be .\logs\ directory, but I think you know what I meant :-)
Let me explain how bamboo works, this should clear up some issues.
Bamboo start
-> remote agent runs build-asterisk.sh
--> checkout asterisk
---> compile / install / samples for asterisk
---> checkout testsuite
----> make addons / install asttest
----> runtests.py
----> cp xml results
---> uninstall asterisk
--> generate coverage
-> bamboo copies artifacts
-> bamboo deletes everything
At the point of 'bamboo copies artifacts' is where we look into testsuite/logs/ folder to get the information. So, we can get the symlink information, I'm actually not sure if this will work, because for whatever reason bamboo will not copy files into an artifact folder if they exist out side the sandbox instance it creates. And becuase /tmp/asterisk-testsuite exists outside of the sandbox instance, we cannot directly access this.
So, copying is an issue, however for local development boxes, because we are just eating up HDD space. Like I said, I don't even know if a symlink will work.
- Paul
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1431/#review4305
-----------------------------------------------------------
On Sept. 12, 2011, 1:42 p.m., mjordan wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1431/
> -----------------------------------------------------------
>
> (Updated Sept. 12, 2011, 1:42 p.m.)
>
>
> Review request for Asterisk Developers and Paul Belanger.
>
>
> Summary
> -------
>
> The TestSuite will now archive the Asterisk logs if a test run fails. All logs are copied to the local ./logs directory, using the same relative test path used for the /tmp/asterisk-testsuite/ directory.
>
> Note that since the top level script does not have knowledge of the number of instances of Asterisk created by a test, all Asterisk (ast1, etc.) directories created by the test are archived.
>
>
> Diffs
> -----
>
> /asterisk/trunk/runtests.py 2190
> /asterisk/trunk/lib/python/asterisk/asterisk.py 2188
>
> Diff: https://reviewboard.asterisk.org/r/1431/diff
>
>
> Testing
> -------
>
> local machine. Induced a test failure, tested multiple runs to ensure that archiving occurs even if directories were previously copied.
>
>
> Thanks,
>
> mjordan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110912/01d8a67e/attachment-0001.htm>
More information about the asterisk-dev
mailing list