Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renderable locks master #1670

Merged
merged 5 commits into from May 22, 2015
Merged

Conversation

vlovich
Copy link
Contributor

@vlovich vlovich commented May 17, 2015

As requested, this change cherry-picked onto master.

@vlovich vlovich mentioned this pull request May 17, 2015
@jaredgrubb
Copy link
Member

I was going to request tests, but I dont see any unit tests in "test_process_buildstep" dealing with locks right now, so this may not be easy. I'll leave it up to you.

@vlovich
Copy link
Contributor Author

vlovich commented May 17, 2015

I did look for tests to use as a template and didn't find any. If you have any suggestions on how to do that I'd be interested

@jaredgrubb
Copy link
Member

svn test "test_mode_incremental_repourl_renderable" is a test for renderable things.
shell test "test_describe_unrendered_WithProperties_list" also.

I dunno... up to you if you want to try to make it all work. You could have it render a Mock type and just verify that some method gets called.

Anyway, usually we have a strict "add unit tests" requirement for contributions, but this is a gray one and maybe not easy ... Our code would certainly be better off for it if you want to :) Would make it easier to do more tests in the future. Up to you.

@sa2ajj
Copy link
Contributor

sa2ajj commented May 17, 2015

@vlovich this feature did not appear out of nowhere, did it? :) I'd suggest looking at the way it's used and base the test on that.

@jaredgrubb
Copy link
Member

@sa2ajj I think it's just there's not a lot of testing around it and he'd have to write some of that basis himself .. which is a good thing in the end, but it is a little involved.

@sa2ajj
Copy link
Contributor

sa2ajj commented May 17, 2015

I agree it might require a bit of effort, I'd like to hear the estimate based on some practical approach though.

@vlovich please spend a bit of time to see how much effort it's gonna take.

@vlovich
Copy link
Contributor Author

vlovich commented May 17, 2015

One problem I've had is that running the tests locally there are failures. How do I know if they work or not?

PYTHONPATH=. trial buildbot.test

RealConfigs
    test_0_7_12_config ...                                                 [OK]
    test_0_7_6_config ...                                                  [OK]
    test_sample_config ...                                              [ERROR]
                                             [ERROR]
buildbot.test.integration.test_custom_buildstep
  RunSteps
    test_Latin1ProducingCustomBuildStep ...                                [OK]
    test_OldBuildEPYDoc ...                                                [OK]
    test_OldPerlModuleTest ...                                             [OK]
    test_OldStyleCustomBuildStep ...                                       [OK]
    test_OldStyleCustomBuildStepSlowDB ...                                 [OK]
    test_OldStyleCustomBuildStep_failure ...                               [OK]
    test_step_raising_buildstepfailed_in_start ...                         [OK]
    test_step_raising_connectionlost_in_start ...                          [OK]
    test_step_raising_exception_in_start ...                               [OK]
buildbot.test
  integration
    test_customservices ...                                             [ERROR]
    test_integration_template ...                                       [ERROR]
    test_mailnotifier ...                                               [ERROR]
    test_master ...                                                     [ERROR]
    test_setproperyfromcommand ...                                      [ERROR]
buildbot.test.integration.test_slave_comm
  TestSlaveComm
    test_connect_disconnect ...                                            [OK]
    test_duplicate_slave ...                                          [SKIPPED]
    test_duplicate_slave_old_dead ...                                      [OK]
buildbot.test
  integration
    test_stop_trigger ...                                               [ERROR]
    test_transfer ...                                                   [ERROR]
    test_trigger ...                                                    [ERROR]
    test_try_client ...                                                 [ERROR]
buildbot.test.integration.test_upgrade
  TestPickles
    test_sourcestamp_081 ...                                               [OK]
    test_sourcestamp_version3 ...                                          [OK]
  TestWeirdChanges
    testUpgradeChangeNoRevision ...                                        [OK]
    testUpgradeChangeProperties ...                                        [OK]
    testUpgradeListsAsFilenames ... ^C                                    [ERROR]

@jaredgrubb
Copy link
Member

I've seen failures in "integration" as well. Some tips:

  • remove pyc files if you're swaping between 8 & 9
  • if you still see errors, run on the main branch (eight/master) and note what the failures are ... then re-run on your branch and verify the failures are the same. Then you know it's not you :)

@vlovich
Copy link
Contributor Author

vlovich commented May 17, 2015

I do still see the same errors on master. It still doesn't leave me with a lot of confidence with making changes if tests are randomly failing only locally. Automation does not appear to have this problem...

@vlovich
Copy link
Contributor Author

vlovich commented May 17, 2015

@sa2ajj I agree there needs to be unit tests. I don't think my original suggestion would even work. It looks like the attributes are rendered after locks are acquired which is too late.

I've tried writing a test but I feel like I'm really off on a tangent at this point & there must be an easier way.

Here's what I have so far:

     @defer.inlineCallbacks                                               
     def test_renderableLocks(self):                                      
         from buildbot import locks                                       
         from buildbot.process.properties import renderer                 

         lock1 = mock.Mock(spec=locks.MasterLock)                         
         lock1.name = "masterlock"                                        

         lock2 = mock.Mock(spec=locks.SlaveLock)                          
         lock2.name = "slavelock"                                         

         renderedLocks = [False]                                          

         @renderer                                                        
         def rendered_locks(props):                                       
             renderedLocks[0] = True                                      
             access1 = locks.LockAccess(lock1, 'counting')                
             access2 = locks.LockAccess(lock2, 'exclusive')               
             return [access1, access2]                                    

         self.setupStep(self.FakeBuildStep(locks=rendered_locks))         
         yield self.runStep()                                             

         self.assertTrue(renderedLocks[0])                                

It fails with:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/twisted/internet/defer.py", line 1099, in _inlineCallbacks
    result = g.send(result)
  File "/Users/vlovich/projects/buildbot/master/buildbot/process/buildstep.py", line 450, in startStep
    for l, la in self.locks]
exceptions.AttributeError: FakeBuild instance has no attribute 'slavebuilder'

buildbot.test.unit.test_process_buildstep.TestBuildStep.test_renderableLocks
-------------------------------------------------------------------------------

@vlovich
Copy link
Contributor Author

vlovich commented May 17, 2015

OK. Took my best shot at writing a unit test. A couple of fakes were insufficient but hopefully I did it right. Turns out the implementation was wrong as the locks are acquired before we render the properties.

@@ -438,6 +438,8 @@ def startStep(self, remote):
name=util.ascii2unicode(self.name))
yield self.master.data.updates.startStep(self.stepid)

self.locks = yield self.build.render(self.locks)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test where the locks are not renderable? I'm not sure this line will work in that case.

@tardyp
Copy link
Member

tardyp commented May 18, 2015

test looks good. Need another one to make me confident.

@sa2ajj
Copy link
Contributor

sa2ajj commented May 18, 2015

I think it looks good. I agree w/ @tardyp about a non-renderable locks + I'd appreciate a phrase (or two) in the release notes.

@sa2ajj
Copy link
Contributor

sa2ajj commented May 20, 2015

  • test for non-renderable lock

(I'll move this todo to somebody who does it :))

Vitali Lovich added 2 commits May 21, 2015 10:41
Setup the slavebuilder & locks as well.
Setup the botmaster attribute.
Vitali Lovich added 3 commits May 21, 2015 12:12
The expected usage is that someone would create a renderable that
returns a list of locks so that this list can be dynamic.
@vlovich
Copy link
Contributor Author

vlovich commented May 21, 2015

Seems like tests pass even with non-renderable lock. Was there some reason to think that x.render(y) doesn't work when y is not a deferred value? It would seem like it would have to given how renderables in buildstep.py work.

@tardyp
Copy link
Member

tardyp commented May 21, 2015

👍

sa2ajj pushed a commit that referenced this pull request May 22, 2015
@sa2ajj sa2ajj merged commit 874ed59 into buildbot:master May 22, 2015
@tardyp
Copy link
Member

tardyp commented Jun 10, 2015

Hi looks like some users see that this change break their conf.
http://trac.buildbot.net/ticket/3277

@vlovich
Copy link
Contributor Author

vlovich commented Jun 10, 2015

The logs indicate buildbot-0.8.13 but only 0.8.12 has been released. Did someone try to backport this to 0.8.12? There's a separate pull request for that but it's blocked on some kind of test failure I can't figure out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants