Bodhi Comment directive
ClosedPublic

Authored by jskladan on Apr 23 2014, 11:11 AM.

Details

Summary

Updated version of the Bodhi Comment directive

Test Plan

Unit tests appended. I still need to write tests for the _is_email_needed stuff, though.

Diff Detail

Branch
arcpatch-D67
Lint
No Linters Available
Unit
No Unit Test Coverage
jskladan updated this revision.Apr 29 2014, 12:42 PM

Added some tests

jskladan updated this revision.Apr 29 2014, 12:47 PM

Trying to post proper diff

tflink requested changes to this revision.Apr 29 2014, 3:18 PM

Minor change request for the test class name.

If you've tested this with a local taskotron runner and fake_fedorainfra, I'm ok with the code. Bodhi comments need to go away soon and I'm not all that worried about fully unit tested code as long as it works.

Just to make sure I understood you over IRC, you did test this with fake_fedorainfra, right?

testing/test_bodhi_comment_directive.py
16

Shouldn't this be TestBodhiCommentReport or something that isn't Resultsdb?

I did test this with fake-fedorainfra, but not with local taskotron instance. I have not yet one set up'n'running. I'll try and set one up, but could you run it in the meantime?

Thanks

testing/test_bodhi_comment_directive.py
16

Ouch, thanks for the catch. Ye'ol' copy-paste error strikes again.

I did test this with fake-fedorainfra, but not with local taskotron instance. I have not yet one set up'n'running. I'll try and set one up, but could you run it in the meantime?

I'm not so worried about the differences between running tasks locally through the command line and running them in the full stg system. We're eventually going to test it in stg or a dev system but in theory, that should be almost the same as running the runner locally while pointed at a fake_fedorainfra instance

Can you go into more detail on how you tested this code?

I used a code very similar to this (managed to delete it in the mean time, as it was even nastier than this is):

def test_with_boji(self):
    import fedora.client
    Config = config.get_config()
    Config.fas_password = "secret"
    Config.bodhi_server = "http://virt_resultsdb:5000/bodhi/"
    Config.reporting_enabled = True
    Config.report_to_bodhi = True

    mock_bodhi = fedora.client.bodhi.BodhiClient(username=Config.fas_username,
                                            password=Config.fas_password,
                                            base_url=Config.bodhi_server)

    directive = bodhi_comment_directive.BodhiCommentDirective()
    directive.bodhi_api.bodhi = mock_bodhi

    ref_envdata = {"checkname": "depcheck"}
    ref_input = {"doreport": "onchange"}

    check_details = [check.CheckDetail(
                item = 'perl-Term-ProgressBar-2.15-1.fc19',
                report_type = check.ReportType.BODHI_UPDATE,
                outcome = result,
                arch = 'x86_64') for result in ['FAILED', 'FAILED', 'PASSED', 'PASSED', 'FAILED']]


    for detail in check_details:
        ref_input['results'] = "TAP version 13\n1..1\n%s" % check.export_TAP(detail)
        directive.process(ref_input, ref_envdata)

And run it with different checkname, doreport and arch values.

I'm having trouble running this against a fakefedorainfra instance. I'm getting tracebacks like:

[libtaskotron:logger.py:34] 2014-04-30 00:16:02 CRITICAL Traceback (most recent call last):
  File "runtask.py", line 4, in <module>
    runner.main()
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 184, in main
    task_runner.run()
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 33, in run
    self.do_actions()
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 107, in do_actions
    self.do_single_action(action)
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/runner.py", line 93, in do_single_action
    directive_callable = getattr(directive_object, directive_classname)()
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/directives/bodhi_comment_directive.py", line 381, in __init__
    self.bodhi_api = bodhi_utils()
TypeError: 'module' object is not callable

Using the command (substituting where appropriate):

python runtask.py -i <update_id> -t bodhi_id /path/to/task-examplebodhi/examplebodhi.yml -a x86_64

And the task yaml file {F1856}

Tim, are you sure you have the right pieces of code? Since the line you get tracebacks on:

self.bodhi_api = bodhi_utils()

is a tiny bit different in the diff provided here:

self.bodhi_api = bodhi_utils

Tim, are you sure you have the right pieces of code? Since the line you get tracebacks on is a tiny bit different in the diff provided here

Sorry, I grabbed the wrong traceback. I tried a few simple things to see if I could make it work and must have not scrolled back far enough.

[libtaskotron:bodhi_comment_directive.py:360] 2014-04-30 00:13:34 ERROR   'module' object has no attribute 'query_update'
Traceback (most recent call last):
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/directives/bodhi_comment_directive.py", line 327, in _post_testresult
    (old_result, comment_time) = _already_commented(bodhi_api, update, testname, arch)
  File "/home/tflink/code/taskotron/libtaskotron/libtaskotron/directives/bodhi_comment_directive.py", line 224, in _already_commented
    u = bodhi_api.query_update(update)

Were you able to get that task yaml file to work with libtaskotron and a fakefedorainfra instance?

*sigh* I know where the problem is - apparently the bodhi_utils.py changed last Thursday... 7b24f6fe00f087bca9ba20498ca7c7adc91178c9 and the bodhi_comment_directive is written based on how it looked the whole time before it.

jskladan updated this revision.Apr 30 2014, 2:45 PM
  • T46 - Fixes to work with new bodhi_utils
jskladan updated this revision.Apr 30 2014, 2:48 PM
  • T46 - Fixed the name of test class
tflink accepted this revision.Apr 30 2014, 3:34 PM

It works with a local runner and fake_fedorainfra once I apply the patch from D79.

Please fix the missing docs about checkname and merge into develop

libtaskotron/directives/bodhi_comment_directive.py
373

This isn't quite right: it needs checkname as well

jskladan closed this revision.May 6 2014, 7:52 AM