def test_nested_filters(self):
     with assertProducesWarnings(SomeWarning,
                                 messages_patterns=["some 1"]):
         with assertProducesWarnings(OtherWarning,
                                     messages_patterns=["other 1"]):
             warnings.warn("other 1", OtherWarning)
             warnings.warn("some 1", SomeWarning)
 def f3():
     # Assertion fails.
     with assertProducesWarnings(SomeWarning,
                                 messages_patterns=["1", "2"]):
         warnings.warn("msg 1", SomeWarning)
         warnings.warn("msg 2", SomeWarning)
         warnings.warn("msg 3", SomeWarning)
 def test_start_instance(self):
     c, r = self.botoSetup()
     amis = list(r.images.all())
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id
                                  )
     instance_id, image_id, start_time = bs._start_instance()
     self.assertTrue(instance_id.startswith('i-'))
     self.assertTrue(image_id.startswith('ami-'))
     self.assertTrue(start_time > 0)
     instances = r.instances.filter(
         Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
     instances = list(instances)
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, instance_id)
     self.assertEqual(instances[0].tags, [])
 def test_start_instance_tags(self):
     c, r = self.botoSetup('latent_buildbot_slave')
     amis = list(r.images.all())
     tags = {'foo': 'bar'}
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  tags=tags,
                                  ami=amis[0].id
                                  )
     id, _, _ = bs._start_instance()
     instances = r.instances.filter(
         Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
     instances = list(instances)
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, id)
     self.assertEqual(instances[0].tags, [{u'Value': 'bar', u'Key': 'foo'}])
 def test_start_spot_instance_retry(self):
     c, r = self.botoSetup('latent_buildbot_slave')
     amis = list(r.images.all())
     product_description = 'Linux/Unix'
     retry = 3
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id, retry=retry,
                                  spot_instance=True, max_spot_price=1.5,
                                  product_description=product_description
                                  )
     id, _, _ = bs._start_instance()
     instances = r.instances.filter(
         Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
     instances = list(instances)
     self.assertTrue(bs.spot_instance)
     self.assertEqual(bs.retry, 3)
     self.assertEqual(bs.attempt, 1)
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, id)
 def test_start_instance(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id
                                  )
     instance_id, image_id, start_time = bs._start_instance()
     self.assertTrue(instance_id.startswith('i-'))
     self.assertTrue(image_id.startswith('r-'))
     self.assertTrue(start_time > 0)
     instances = [i for i in c.get_only_instances()
                  if i.state != "terminated"]
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, instance_id)
     self.assertEqual(instances[0].tags, {})
 def test_warnigs_catched_patterns_check(self):
     # Assertion is correct.
     with assertProducesWarnings(SomeWarning,
                                 messages_patterns=["1", "2", "3"]):
         warnings.warn("log 1 message", SomeWarning)
         warnings.warn("log 2 message", SomeWarning)
         warnings.warn("log 3 message", SomeWarning)
 def test_start_spot_instance(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     product_description = 'Linux/Unix'
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id, spot_instance=True,
                                  max_spot_price=1.5,
                                  product_description=product_description
                                  )
     instance_id, _, _ = bs._start_instance()
     instances = [i for i in c.get_only_instances()
                  if i.state != "terminated"]
     self.assertTrue(bs.spot_instance)
     self.assertEqual(bs.retry, 1)
     self.assertEqual(bs.product_description, product_description)
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, instance_id)
     self.assertEqual(instances[0].tags, {})
 def test_start_instance_tags(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     tags = {"foo": "bar"}
     with assertProducesWarnings(
         DeprecatedWorkerNameWarning,
         messages_patterns=[
             r"Use of default value of 'keypair_name' of " r"EC2LatentWorker constructor is deprecated",
             r"Use of default value of 'security_name' of " r"EC2LatentWorker constructor is deprecated",
         ],
     ):
         bs = ec2.EC2LatentWorker(
             "bot1",
             "sekrit",
             "m1.large",
             identifier="publickey",
             secret_identifier="privatekey",
             tags=tags,
             ami=amis[0].id,
         )
     id, _, _ = bs._start_instance()
     instances = [i for i in c.get_only_instances() if i.state != "terminated"]
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, id)
     self.assertEqual(instances[0].tags, tags)
 def test_start_spot_instance_retry(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     product_description = "Linux/Unix"
     retry = 3
     with assertProducesWarnings(
         DeprecatedWorkerNameWarning,
         messages_patterns=[
             r"Use of default value of 'keypair_name' of " r"EC2LatentWorker constructor is deprecated",
             r"Use of default value of 'security_name' of " r"EC2LatentWorker constructor is deprecated",
         ],
     ):
         bs = ec2.EC2LatentWorker(
             "bot1",
             "sekrit",
             "m1.large",
             identifier="publickey",
             secret_identifier="privatekey",
             ami=amis[0].id,
             retry=retry,
             spot_instance=True,
             max_spot_price=1.5,
             product_description=product_description,
         )
     id, _, _ = bs._start_instance()
     instances = [i for i in c.get_only_instances() if i.state != "terminated"]
     self.assertTrue(bs.spot_instance)
     self.assertEqual(bs.retry, 3)
     self.assertEqual(bs.attempt, 1)
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, id)
Exemple #11
0
    def test_basic(self):
        build = yield self.insert_build_new()
        # we make sure proper calls to txrequests have been made
        self._http.expect('post',
                          '/repos/buildbot/buildbot/statuses/d34db33fd43db33f',
                          json={
                              'state': 'pending',
                              'target_url':
                              'http://localhost:8080/#builders/79/builds/0',
                              'description': 'Build started.',
                              'context': 'buildbot/Builder0'
                          })
        self._http.expect('post',
                          '/repos/buildbot/buildbot/statuses/d34db33fd43db33f',
                          json={
                              'state': 'success',
                              'target_url':
                              'http://localhost:8080/#builders/79/builds/0',
                              'description': 'Build done.',
                              'context': 'buildbot/Builder0'
                          })
        self._http.expect('post',
                          '/repos/buildbot/buildbot/statuses/d34db33fd43db33f',
                          json={
                              'state': 'failure',
                              'target_url':
                              'http://localhost:8080/#builders/79/builds/0',
                              'description': 'Build done.',
                              'context': 'buildbot/Builder0'
                          })

        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'new'), build)
        build['complete'] = True
        build['results'] = SUCCESS
        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)
        build['results'] = FAILURE
        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)
        self.assertEqual(self.sp.send_called_count, 3)
Exemple #12
0
    def setUp(self):
        self.setUpTestReactor()
        yield self.setUpChangeSource()

        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern="use ReconfigurablePollingChangeSource"):
            cs = self.Subclass(name="DummyCS")
        yield self.attachChangeSource(cs)
Exemple #13
0
    def _check_start_and_finish_build(self, build, parentPlan=False):
        # we make sure proper calls to txrequests have been made

        _name = "Builder_parent #1 \u00BB Builder0 #0" if parentPlan else "Builder0 #0"
        _parent = "Builder_parent" if parentPlan else "Builder0"

        self._http.expect(
            'post',
            '/rest/api/1.0/projects/example.org/repos/repo/commits/d34db33fd43db33f/builds',
            json={'name': _name, 'description': 'Build started.', 'key': 'Builder0',
                  'url': 'http://localhost:8080/#builders/79/builds/0',
                  'ref': 'refs/heads/master', 'buildNumber': '0', 'state': 'INPROGRESS',
                  'parent': _parent, 'duration': None, 'testResults': None},
            code=HTTP_PROCESSED)
        self._http.expect(
            'post',
            '/rest/api/1.0/projects/example.org/repos/repo/commits/d34db33fd43db33f/builds',
            json={'name': _name, 'description': 'Build done.', 'key': 'Builder0',
                  'url': 'http://localhost:8080/#builders/79/builds/0',
                  'ref': 'refs/heads/master', 'buildNumber': '0', 'state': 'SUCCESSFUL',
                  'parent': _parent, 'duration': 10000, 'testResults': None},
            code=HTTP_PROCESSED)
        self._http.expect(
            'post',
            '/rest/api/1.0/projects/example.org/repos/repo/commits/d34db33fd43db33f/builds',
            json={'name': _name, 'description': 'Build done.', 'key': 'Builder0',
                  'url': 'http://localhost:8080/#builders/79/builds/0',
                  'ref': 'refs/heads/master', 'buildNumber': '0', 'state': 'FAILED',
                  'parent': _parent, 'duration': 10000, 'testResults': None},
            code=HTTP_PROCESSED)
        build['started_at'] = datetime.datetime(2019, 4, 1, 23, 38, 33, 154354, tzinfo=tzutc())
        build['complete'] = False
        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'new'), build)
        build["complete_at"] = datetime.datetime(2019, 4, 1, 23, 38, 43, 154354, tzinfo=tzutc())
        build['complete'] = True
        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)
        build['results'] = FAILURE
        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)

        self.assertEqual(self.sp.send_called_count, 3)
Exemple #14
0
    def test_override_send(self):
        self.sp = HttpStatusPushBaseOverrideSend()
        yield self.sp.setServiceParent(self.master)

        build = yield self.insert_build_new()
        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'new'), build)

        build['complete'] = True
        build['results'] = SUCCESS

        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)
        self.assertEqual(self.sp.send_called_count, 2)
Exemple #15
0
 def test_check_config_raises_error_when_deprecated_and_generator(
         self, arg_name, arg_value):
     notifier = ReporterBase()
     with assertProducesWarnings(DeprecatedApiWarning,
                                 message_pattern='have been deprecated'):
         with self.assertRaisesConfigError(
                 'can\'t specify generators and deprecated notifier'):
             kwargs = {arg_name: arg_value}
             notifier.checkConfig(generators=[mock.Mock()], **kwargs)
Exemple #16
0
 def test_wantKwargsCheck(self):
     with assertProducesWarnings(DeprecatedApiWarning,
                                 message_pattern='have been deprecated'):
         yield self.createReporter(builders='Builder0', wantProperties=True, wantSteps=True,
                                   wantPreviousBuild=True, wantLogs=True)
     self._http.expect("post", "", json=BuildLookAlike(
         keys=['steps', 'prev_build']))
     build = yield self.insert_build_finished(SUCCESS)
     yield self.sp._got_event(('builds', 20, 'finished'), build)
Exemple #17
0
    def test_start_instance_volumes_deprecated(self):
        c, r = self.botoSetup()
        block_device_map_arg = {
            "/dev/xvdb": {
                "volume_type": "io1",
                "iops": 10,
                "size": 20,
            },
            "/dev/xvdc": {
                "volume_type": "gp2",
                "size": 30,
                "delete_on_termination": False
            }
        }
        block_device_map_res = [
            {
                'DeviceName': "/dev/xvdb",
                'Ebs': {
                    "VolumeType": "io1",
                    "Iops": 10,
                    "VolumeSize": 20,
                    "DeleteOnTermination": True,
                }
            },
            {
                'DeviceName': "/dev/xvdc",
                'Ebs': {
                    "VolumeType": "gp2",
                    "VolumeSize": 30,
                    "DeleteOnTermination": False,
                }
            },
        ]

        amis = list(r.images.all())
        with assertProducesWarnings(
                DeprecatedWorkerNameWarning,
                messages_patterns=
            [
                r"Use of dict value to 'block_device_map' of EC2LatentWorker "
                r"constructor is deprecated. Please use a list matching the AWS API"
            ]):
            bs = ec2.EC2LatentWorker('bot1',
                                     'sekrit',
                                     'm1.large',
                                     identifier='publickey',
                                     secret_identifier='privatekey',
                                     keypair_name="latent_buildbot_worker",
                                     security_name='latent_buildbot_worker',
                                     ami=amis[0].id,
                                     block_device_map=block_device_map_arg)
        # moto does not currently map volumes properly.  below ensures
        # that my conversion code properly composes it, including
        # delete_on_termination default.
        self.assertEqual(
            sorted(block_device_map_res, key=lambda x: x['DeviceName']),
            sorted(bs.block_device_map, key=lambda x: x['DeviceName']))
Exemple #18
0
    def test_start_instance_volumes_deprecated(self):
        c, r = self.botoSetup()
        block_device_map_arg = {
            "/dev/xvdb": {
                "volume_type": "io1",
                "iops": 10,
                "size": 20,
            },
            "/dev/xvdc": {
                "volume_type": "gp2",
                "size": 30,
                "delete_on_termination": False
            }
        }
        block_device_map_res = [
                {
                    'DeviceName': "/dev/xvdb",
                    'Ebs': {
                        "VolumeType": "io1",
                        "Iops": 10,
                        "VolumeSize": 20,
                        "DeleteOnTermination": True,
                        }
                    },
                {
                    'DeviceName': "/dev/xvdc",
                    'Ebs': {
                        "VolumeType": "gp2",
                        "VolumeSize": 30,
                        "DeleteOnTermination": False,
                        }
                    },
                ]

        amis = list(r.images.all())
        with assertProducesWarnings(
                DeprecatedWorkerNameWarning,
                messages_patterns=[
                    r"Use of dict value to 'block_device_map' of EC2LatentWorker "
                    r"constructor is deprecated. Please use a list matching the AWS API"
                ]):
            bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                     identifier='publickey',
                                     secret_identifier='privatekey',
                                     keypair_name="latent_buildbot_worker",
                                     security_name='latent_buildbot_worker',
                                     ami=amis[0].id,
                                     block_device_map=block_device_map_arg
                                     )
        # moto does not currently map volumes properly.  below ensures
        # that my conversion code properly composes it, including
        # delete_on_termination default.
        self.assertEqual(sorted(block_device_map_res,
                                key=lambda x: x['DeviceName']),
                         sorted(bs.block_device_map,
                                key=lambda x: x['DeviceName']))
Exemple #19
0
 def test_shell_arg_error_logfile_and_logname(self):
     with assertProducesWarnings(
             DeprecatedApiWarning,
             message_pattern="logfile is deprecated, use logname"):
         with self.assertRaisesConfigError(
                 "the 'logfile' parameter must not be specified when 'logname' is set"
         ):
             shellsequence.ShellArg(command="command",
                                    logname="logname",
                                    logfile="logfile")
Exemple #20
0
 def test_trigger_old_poller(self):
     with assertProducesWarnings(
             DeprecatedApiWarning,
             num_warnings=2,
             message_pattern="use ReconfigurablePollingChangeSource"):
         yield self.setUpRequest({b"poller": [b"example"]},
                                 poller_cls=self.OldstyleSubclass)
     self.assertEqual(self.request.written, b"no change found")
     self.assertEqual(self.changesrc.called, True)
     self.assertEqual(self.otherpoller.called, False)
 def test_0_9_0b5_config(self):
     with open(self.filename, "w") as f:
         f.write(sample_0_9_0b5)
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"'buildbot\.plugins\.buildslave' plugins namespace is deprecated",
                 r"'slavenames' keyword argument is deprecated",
                 r"c\['slaves'\] key is deprecated"]):
         config.FileLoader(self.basedir, self.filename).loadConfig()
Exemple #22
0
    def test_basic(self):
        yield self.createReporter()
        self._http.expect("post", "", json=BuildLookAlike(complete=False))
        self._http.expect("post", "", json=BuildLookAlike(complete=True))

        build = yield self.insert_build_new()
        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'new'), build)

        build['complete'] = True
        build['results'] = SUCCESS

        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)
        self.assertEqual(self.sp.send_called_count, 2)
Exemple #23
0
 def test_0_9_0b5_config(self):
     with open(self.filename, "w") as f:
         f.write(sample_0_9_0b5)
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"'buildbot\.plugins\.buildslave' plugins namespace is deprecated",
                 r"'slavenames' keyword argument is deprecated",
                 r"c\['slaves'\] key is deprecated"]):
         config.MasterConfig.loadConfig(self.basedir, self.filename)
    def test_start_instance_volumes(self):
        c = self.botoSetup('latent_buildbot_slave')
        amis = c.get_all_images()
        with assertProducesWarnings(
                DeprecatedWorkerNameWarning,
                messages_patterns=[
                    r"Use of default value of 'keypair_name' of "
                    r"EC2LatentWorker constructor is deprecated",
                    r"Use of default value of 'security_name' of "
                    r"EC2LatentWorker constructor is deprecated"
                ]):
            bs = ec2.EC2LatentWorker('bot1',
                                     'sekrit',
                                     'm1.large',
                                     identifier='publickey',
                                     secret_identifier='privatekey',
                                     ami=amis[0].id,
                                     block_device_map={
                                         "/dev/xvdb": {
                                             "volume_type": "io1",
                                             "iops": 10,
                                             "size": 20,
                                         },
                                         "/dev/xvdc": {
                                             "volume_type": "gp2",
                                             "size": 30,
                                             "delete_on_termination": False
                                         }
                                     })

        # moto does not currently map volumes properly.  below ensures
        # that my conversion code properly composes it, including
        # delete_on_termination default.
        from boto.ec2.blockdevicemapping import BlockDeviceType
        self.assertEqual(set(['/dev/xvdb', '/dev/xvdc']),
                         set(bs.block_device_map.keys()))

        def assertBlockDeviceEqual(a, b):
            self.assertEqual(a.volume_type, b.volume_type)
            self.assertEqual(a.iops, b.iops)
            self.assertEqual(a.size, b.size)
            self.assertEqual(a.delete_on_termination, b.delete_on_termination)

        assertBlockDeviceEqual(
            BlockDeviceType(volume_type='io1',
                            iops=10,
                            size=20,
                            delete_on_termination=True),
            bs.block_device_map['/dev/xvdb'])

        assertBlockDeviceEqual(
            BlockDeviceType(volume_type='gp2',
                            size=30,
                            delete_on_termination=False),
            bs.block_device_map['/dev/xvdc'])
 def test_warnigs_filter(self):
     with ignoreWarning(OtherWarning):
         with assertProducesWarnings(SomeWarning,
                                     messages_patterns=["1", "2", "3"]):
             warnings.warn("other", OtherWarning)
             warnings.warn("log 1 message", SomeWarning)
             warnings.warn("other", OtherWarning)
             warnings.warn("log 2 message", SomeWarning)
             warnings.warn("other", OtherWarning)
             warnings.warn("log 3 message", SomeWarning)
             warnings.warn("other", OtherWarning)
    def test_OldPerlModuleTest(self):
        # test old-style calls to self.getLog
        with assertProducesWarnings(
                DeprecatedApiWarning,
                num_warnings=2,
                message_pattern='Subclassing old-style step'):
            step = OldPerlModuleTest()
            builder_id = yield self.create_config_for_step(step)

            yield self.do_test_build(builder_id)
            yield self.assertBuildResults(1, results.SUCCESS)
 def test_0_7_6_config(self):
     with open(self.filename, "w") as f:
         f.write(sample_0_7_6)
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"BuildSlave was deprecated",
                 r"c\['slavePortnum'\] key is deprecated",
                 r"'slavename' keyword argument is deprecated",
                 r"c\['slaves'\] key is deprecated"]):
         config.FileLoader(self.basedir, self.filename).loadConfig()
Exemple #28
0
 def test_0_7_6_config(self):
     with open(self.filename, "w") as f:
         f.write(sample_0_7_6)
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"BuildSlave was deprecated",
                 r"c\['slavePortnum'\] key is deprecated",
                 r"'slavename' keyword argument is deprecated",
                 r"c\['slaves'\] key is deprecated"]):
         config.MasterConfig.loadConfig(self.basedir, self.filename)
 def test_warnigs_filter(self):
     with ignoreWarning(OtherWarning):
         with assertProducesWarnings(SomeWarning,
                                     messages_patterns=["1", "2", "3"]):
             warnings.warn("other", OtherWarning)
             warnings.warn("log 1 message", SomeWarning)
             warnings.warn("other", OtherWarning)
             warnings.warn("log 2 message", SomeWarning)
             warnings.warn("other", OtherWarning)
             warnings.warn("log 3 message", SomeWarning)
             warnings.warn("other", OtherWarning)
    def test_OldBuildEPYDoc(self):
        # test old-style calls to log.getText, figuring readlines will be ok
        with assertProducesWarnings(
                DeprecatedApiWarning,
                num_warnings=2,
                message_pattern='Subclassing old-style step'):
            step = OldBuildEPYDoc()
            builder_id = yield self.create_config_for_step(step)

            yield self.do_test_build(builder_id)
            yield self.assertBuildResults(1, results.FAILURE)
Exemple #31
0
 def test_deprecated_connection_and_uri(self):
     with self.assertRaises(config.ConfigErrors):
         with assertProducesWarnings(
                 DeprecatedApiWarning,
                 message_pattern='connection argument has been deprecated'):
             self.create_worker('bot',
                                'pass',
                                libvirtworker.Connection('test'),
                                'path',
                                'path',
                                uri='custom')
Exemple #32
0
    def setUp(self):
        baseurl = 'http://127.0.0.1:8080'
        self.parent = service.MasterService()

        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='getFakeService'):
            self._http = yield fakehttpclientservice.HTTPClientService.getFakeService(
                self.parent, self, baseurl)
        self.tested = myTestedService(baseurl)

        yield self.tested.setServiceParent(self.parent)
        yield self.parent.startService()
    def test_start_instance_volumes(self):
        c = self.botoSetup()
        amis = c.get_all_images()
        with assertProducesWarnings(
                DeprecatedWorkerNameWarning,
                messages_patterns=[
                    r"Use of default value of 'keypair_name' of "
                    r"EC2LatentWorker constructor is deprecated",
                    r"Use of default value of 'security_name' of "
                    r"EC2LatentWorker constructor is deprecated"
                ]):
            bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                     identifier='publickey',
                                     secret_identifier='privatekey',
                                     ami=amis[0].id,
                                     block_device_map={
                                         "/dev/xvdb": {
                                             "volume_type": "io1",
                                             "iops": 10,
                                             "size": 20,
                                         },
                                         "/dev/xvdc": {
                                             "volume_type": "gp2",
                                             "size": 30,
                                             "delete_on_termination": False
                                         }
                                     }
                                     )

        # moto does not currently map volumes properly.  below ensures
        # that my conversion code properly composes it, including
        # delete_on_termination default.
        from boto.ec2.blockdevicemapping import BlockDeviceType
        self.assertEqual(
            set(['/dev/xvdb', '/dev/xvdc']), set(bs.block_device_map.keys()))

        def assertBlockDeviceEqual(a, b):
            self.assertEqual(a.volume_type, b.volume_type)
            self.assertEqual(a.iops, b.iops)
            self.assertEqual(a.size, b.size)
            self.assertEqual(a.delete_on_termination, b.delete_on_termination)

        assertBlockDeviceEqual(
            BlockDeviceType(
                volume_type='io1', iops=10, size=20, delete_on_termination=True),
            bs.block_device_map['/dev/xvdb'])

        assertBlockDeviceEqual(
            BlockDeviceType(
                volume_type='gp2', size=30, delete_on_termination=False),
            bs.block_device_map['/dev/xvdc'])
Exemple #34
0
    def _check_start_and_finish_build(self, build):
        # we make sure proper calls to txrequests have been made
        self._http.expect(
            'post',
            '/rest/build-status/1.0/commits/d34db33fd43db33f',
            json={'url': 'http://localhost:8080/#builders/79/builds/0',
                  'state': 'INPROGRESS', 'key': 'Builder0',
                  'description': 'Build started.'},
            code=HTTP_PROCESSED)
        self._http.expect(
            'post',
            '/rest/build-status/1.0/commits/d34db33fd43db33f',
            json={'url': 'http://localhost:8080/#builders/79/builds/0',
                  'state': 'SUCCESSFUL', 'key': 'Builder0',
                  'description': 'Build done.'},
            code=HTTP_PROCESSED)
        self._http.expect(
            'post',
            '/rest/build-status/1.0/commits/d34db33fd43db33f',
            json={'url': 'http://localhost:8080/#builders/79/builds/0',
                  'state': 'FAILED', 'key': 'Builder0',
                  'description': 'Build done.'})
        build['complete'] = False
        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='send\\(\\) in reporters has been deprecated'):

            yield self.sp._got_event(('builds', 20, 'new'), build)
        build['complete'] = True
        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='send\\(\\) in reporters has been deprecated'):

            yield self.sp._got_event(('builds', 20, 'finished'), build)
        build['results'] = FAILURE
        with assertProducesWarnings(DeprecatedApiWarning,
                                    message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'finished'), build)

        self.assertEqual(self.sp.send_called_count, 3)
    def test_config_0_9_0b5(self):
        # Load configuration and start master.
        # TODO: check for expected warnings.
        configfile = self._write_config(sample_0_9_0b5)

        with assertProducesWarnings(
                DeprecatedWorkerNameWarning,
                messages_patterns=[
                    r"'buildbot\.plugins\.buildslave' plugins namespace is deprecated",
                    r"'slavenames' keyword argument is deprecated",
                    r"c\['slaves'\] key is deprecated"]):
            _, loaded_config = config.loadConfigDict(".", configfile.path)

            yield self._run_master(loaded_config)
 def test_use_of_default_keypair_security_warning(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     with assertProducesWarnings(
         DeprecatedWorkerNameWarning,
         messages_patterns=[
             r"Use of default value of 'keypair_name' of " r"EC2LatentWorker constructor is deprecated",
             r"Use of default value of 'security_name' of " r"EC2LatentWorker constructor is deprecated",
         ],
     ):
         bs = ec2.EC2LatentWorker(
             "bot1", "sekrit", "m1.large", identifier="publickey", secret_identifier="privatekey", ami=amis[0].id
         )
     self.assertEqual(bs.keypair_name, "latent_buildbot_slave")
     self.assertEqual(bs.security_name, "latent_buildbot_slave")
Exemple #37
0
 def test_build_started(self):
     yield self.createReporter(builder_user_map={'Builder0': '123'})
     build = yield self.insert_build_new()
     self._http.expect('post',
                       '/v2/user/123/message',
                       params=dict(auth_token='abc'),
                       json={
                           'message':
                           'Buildbot started build Builder0 here: '
                           'http://localhost:8080/#builders/79/builds/0'
                       })
     with assertProducesWarnings(
             DeprecatedApiWarning,
             message_pattern='send\\(\\) in reporters has been deprecated'):
         yield self.sp._got_event(('builds', 20, 'new'), build)
     self.assertEqual(self.sp.send_called_count, 1)
Exemple #38
0
 def test_use_of_default_security_warning(self):
     c, r = self.botoSetup()
     amis = list(r.images.all())
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated",
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id,
                                  keypair_name='test_keypair',
                                  )
     self.assertEqual(bs.keypair_name, 'test_keypair')
     self.assertEqual(bs.security_name, 'latent_buildbot_slave')
Exemple #39
0
 def test_use_of_default_security_warning(self):
     c, r = self.botoSetup()
     amis = list(r.images.all())
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated",
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id,
                                  keypair_name='test_keypair',
                                  )
     self.assertEqual(bs.keypair_name, 'test_keypair')
     self.assertEqual(bs.security_name, 'latent_buildbot_slave')
 def test_constructor_minimal(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     with assertProducesWarnings(
         DeprecatedWorkerNameWarning,
         messages_patterns=[
             r"Use of default value of 'keypair_name' of " r"EC2LatentWorker constructor is deprecated",
             r"Use of default value of 'security_name' of " r"EC2LatentWorker constructor is deprecated",
         ],
     ):
         bs = ec2.EC2LatentWorker(
             "bot1", "sekrit", "m1.large", identifier="publickey", secret_identifier="privatekey", ami=amis[0].id
         )
     self.assertEqual(bs.workername, "bot1")
     self.assertEqual(bs.password, "sekrit")
     self.assertEqual(bs.instance_type, "m1.large")
     self.assertEqual(bs.ami, amis[0].id)
Exemple #41
0
 def test_constructor_tags(self):
     c, r = self.botoSetup('latent_buildbot_slave')
     amis = list(r.images.all())
     tags = {'foo': 'bar'}
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  tags=tags,
                                  ami=amis[0].id
                                  )
     self.assertEqual(bs.tags, tags)
Exemple #42
0
 def test_constructor_tags(self):
     c, r = self.botoSetup('latent_buildbot_slave')
     amis = list(r.images.all())
     tags = {'foo': 'bar'}
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  tags=tags,
                                  ami=amis[0].id
                                  )
     self.assertEqual(bs.tags, tags)
Exemple #43
0
 def test_constructor_minimal(self):
     c = self.botoSetup('latent_buildbot_slave')
     amis = c.get_all_images()
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id
                                  )
     self.assertEqual(bs.workername, 'bot1')
     self.assertEqual(bs.password, 'sekrit')
     self.assertEqual(bs.instance_type, 'm1.large')
     self.assertEqual(bs.ami, amis[0].id)
Exemple #44
0
    def setupNotifier(self, old_style=False, *args, **kwargs):
        if old_style:
            with assertProducesWarnings(
                    DeprecatedApiWarning,
                    message_pattern='have been deprecated'):
                mn = ReporterBase(*args, **kwargs)
        else:
            if 'generators' not in kwargs:
                if 'watchedWorkers' in kwargs:
                    generator = WorkerMissingGenerator(
                        workers=kwargs.pop('watchedWorkers'))
                    kwargs['generators'] = [generator]

            mn = ReporterBase(*args, **kwargs)

        mn.sendMessage = mock.Mock(spec=mn.sendMessage)
        mn.sendMessage.return_value = "<message>"
        yield mn.setServiceParent(self.master)
        yield mn.startService()
        return mn
Exemple #45
0
    def test_build_started(self):
        yield self.setupZulipStatusPush(stream="xyz")
        build = yield self.insert_build_new()
        self._http.expect('post',
                          '/api/v1/external/buildbot?api_key=123&stream=xyz',
                          json={
                              "event": 'new',
                              "buildid": 20,
                              "buildername": "Builder0",
                              "url":
                              "http://localhost:8080/#builders/79/builds/0",
                              "project": "testProject",
                              "timestamp": 10000001
                          })
        with assertProducesWarnings(
                DeprecatedApiWarning,
                message_pattern='send\\(\\) in reporters has been deprecated'):
            yield self.sp._got_event(('builds', 20, 'new'), build)

        self.assertEqual(self.sp.send_called_count, 1)
Exemple #46
0
 def test_constructor_minimal(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1',
                                  'sekrit',
                                  'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  ami=amis[0].id)
     self.assertEqual(bs.workername, 'bot1')
     self.assertEqual(bs.password, 'sekrit')
     self.assertEqual(bs.instance_type, 'm1.large')
     self.assertEqual(bs.ami, amis[0].id)
 def test_constructor_tags(self):
     c = self.botoSetup()
     amis = c.get_all_images()
     tags = {"foo": "bar"}
     with assertProducesWarnings(
         DeprecatedWorkerNameWarning,
         messages_patterns=[
             r"Use of default value of 'keypair_name' of " r"EC2LatentWorker constructor is deprecated",
             r"Use of default value of 'security_name' of " r"EC2LatentWorker constructor is deprecated",
         ],
     ):
         bs = ec2.EC2LatentWorker(
             "bot1",
             "sekrit",
             "m1.large",
             identifier="publickey",
             secret_identifier="privatekey",
             tags=tags,
             ami=amis[0].id,
         )
     self.assertEqual(bs.tags, tags)
Exemple #48
0
 def test_start_instance_tags(self):
     c = self.botoSetup('latent_buildbot_slave')
     amis = c.get_all_images()
     tags = {'foo': 'bar'}
     with assertProducesWarnings(
             DeprecatedWorkerNameWarning,
             messages_patterns=[
                 r"Use of default value of 'keypair_name' of "
                 r"EC2LatentWorker constructor is deprecated",
                 r"Use of default value of 'security_name' of "
                 r"EC2LatentWorker constructor is deprecated"
             ]):
         bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
                                  identifier='publickey',
                                  secret_identifier='privatekey',
                                  tags=tags,
                                  ami=amis[0].id
                                  )
     id, _, _ = bs._start_instance()
     instances = [i for i in c.get_only_instances()
                  if i.state != "terminated"]
     self.assertEqual(len(instances), 1)
     self.assertEqual(instances[0].id, id)
     self.assertEqual(instances[0].tags, tags)
 def test_warnigs_catched_num_check(self):
     # Assertion is correct.
     with assertProducesWarnings(SomeWarning, num_warnings=3):
         warnings.warn("1", SomeWarning)
         warnings.warn("2", SomeWarning)
         warnings.warn("3", SomeWarning)
Exemple #50
0
 def test_deprecated_connection(self):
     with assertProducesWarnings(DeprecatedApiWarning,
                                 message_pattern='connection argument has been deprecated'):
         self.create_worker('bot', 'pass', libvirtworker.Connection('test'), 'path', 'path')
 def f1():
     with assertProducesWarnings(SomeWarning, num_warnings=2):
         pass
Exemple #52
0
 def test_builderTypeCheck(self):
     with assertProducesWarnings(DeprecatedApiWarning,
                                 message_pattern='have been deprecated'):
         yield self.createReporter(builders='Builder0')
     config._errors.addError.assert_any_call(
         "builders must be a list or None")
Exemple #53
0
 def test_filtering(self):
     with assertProducesWarnings(DeprecatedApiWarning,
                                 message_pattern='have been deprecated'):
         yield self.createReporter(builders=['foo'])
     build = yield self.insert_build_finished(SUCCESS)
     yield self.sp._got_event(('builds', 20, 'finished'), build)
 def f3():
     with assertProducesWarnings(SomeWarning, num_warnings=2):
         warnings.warn("1", SomeWarning)
         warnings.warn("2", SomeWarning)
         warnings.warn("3", SomeWarning)
Exemple #55
0
if parse_version(mock.__version__) < parse_version("0.8"):
    raise ImportError("\nBuildbot tests require mock version 0.8.0 or "
                      "higher; try 'pip install -U mock'")

[setuptools]  # force use for pylint

# This is where we load deprecated module-level APIs to ignore warning produced by importing them.
# After the deprecated API has been removed, leave at least one instance of the import in a
# commented state as reference.

with assertProducesWarnings(
        DeprecatedApiWarning,
        messages_patterns=[
            r" buildbot\.status\.build has been deprecated",
            r" buildbot\.status\.buildrequest has been deprecated",
            r" buildbot\.status\.event has been deprecated",
            r" buildbot\.status\.worker has been deprecated",
            r" buildbot\.status\.buildset has been deprecated",
            r" buildbot\.status\.master has been deprecated",
            r" buildbot\.status\.base has been deprecated",
        ]):
    import buildbot.status.base as _  # noqa

with assertProducesWarning(
        DeprecatedApiWarning,
        message_pattern=r" buildbot\.status\.worker has been deprecated"):
    import buildbot.status.worker as _  # noqa

# All deprecated modules should be loaded, consider future warnings in tests as errors.
# In order to not pollute the test outputs,
# warnings in tests shall be forcefully tested with assertProducesWarning,