Пример #1
0
 def test_missing_image(self):
     worker = yield self.setupWorker('worker', image='no-such-image')
     self._http.expect(method='get',
                       ep='/storage/template',
                       content_json=upcloudStorageTemplatePayload)
     with self.assertRaises(LatentWorkerFailedToSubstantiate):
         yield worker.substantiate(None, FakeBuild())
Пример #2
0
    def setUp(self):
        super(TestStashStatusPush, self).setUp()

        self.setUpLogging()
        self.build = FakeBuild()
        self.status = StashStatusPush('fake host', 'fake user',
                                      'fake password')
Пример #3
0
    def setUp(self):
        super(TestGitHubStatus, self).setUp()
        if not txgithub:
            raise unittest.SkipTest("txgithub not found.")

        self.setUpLogging()
        self.build = FakeBuild()
        self.status = GitHubStatus(
            token='token', repoOwner='owner', repoName='name')
Пример #4
0
    def test_start_worker_but_error(self):
        worker = yield self.setupWorker('worker')

        def createPod(namespace, spec):
            raise KubeError({'message': "yeah, but no"})

        self.patch(self._kube, 'createPod', createPod)
        with self.assertRaises(LatentWorkerFailedToSubstantiate):
            yield worker.substantiate(None, FakeBuild())
        self.assertEqual(worker.instance, None)
Пример #5
0
    def test_start_worker_but_error(self):
        worker = self.setupWorker('worker')

        def createPod(self, namespace, spec):
            raise KubeError({'message': "yeah, but no"})

        self.patch(self._kube, 'createPod', createPod)
        d = worker.substantiate(None, FakeBuild())
        self.failureResultOf(d)
        self.assertEqual(worker.instance, None)
Пример #6
0
 def test_start_worker(self):
     worker = self.setupWorker('worker')
     d = worker.substantiate(None, FakeBuild())
     worker.attached(FakeBot())
     self.successResultOf(d)
     self.assertEqual(len(worker._kube.pods), 1)
     pod_name = list(worker._kube.pods.keys())[0]
     self.assertRegex(pod_name, r'default/buildbot-worker-[0-9a-f]+')
     pod = worker._kube.pods[pod_name]
     self.assertEqual(sorted(pod['spec'].keys()),
                      ['containers', 'restartPolicy'])
     self.assertEqual(sorted(pod['spec']['containers'][0].keys()),
                      ['env', 'image', 'name', 'resources'])
     self.assertEqual(pod['spec']['containers'][0]['image'],
                      'rendered:buildbot/buildbot-worker')
     self.assertEqual(pod['spec']['restartPolicy'], 'Never')
Пример #7
0
    def setUp(self):
        super(TestStashStatusSend, self).setUp()

        self.setUpLogging()
        self.build = FakeBuild()
        self.build.builder.status.getURLForThing.return_value = 'fake_build_url'
        self.my_key_format = '%(prop:builderName)s-%(src::branch)s'
        self.my_name_format = '%(prop:builderName)s-%(src::branch)s-%(prop:buildNumber)s'
        self.status = StashStatusPush('fake host',
                                      'fake user',
                                      'fake password',
                                      key_format=self.my_key_format,
                                      name_format=self.my_name_format)
        self.status._sha = Interpolate('fake_sha')
        self.status.key_interpolation = Interpolate(
            'fakeBuilderName-fake_branch')
        self.status.name_interpolation = Interpolate(
            'fakeBuilderName-fake_branch-fake_buildNumber')
        self.status._send = Mock()
Пример #8
0
 def test_start_worker(self):
     worker = yield self.setupWorker('worker', image='test-image')
     # resolve image to storage uuid
     self._http.expect(method='get',
                       ep='/storage/template',
                       content_json=upcloudStorageTemplatePayload)
     # actually start server
     self._http.expect(
         method='post',
         ep='/server',
         params=None,
         data=None,
         json={
             'server': {
                 'zone': 'de-fra1',
                 'title': 'buildbot-worker-87de7e',
                 'hostname': 'worker',
                 'user_data': '',
                 'login_user': {
                     'username': '******',
                     'ssh_keys': {
                         'ssh_key': []
                     }
                 },
                 'password_delivery': 'none',
                 'storage_devices': {
                     'storage_device': [{
                         'action':
                         'clone',
                         'storage':
                         '8b47d21b-b4c3-445d-b75c-5a723ff39681',
                         'title':
                         'buildbot-worker-{}'.format(self.masterhash),
                         'size':
                         10,
                         'tier':
                         'maxiops'
                     }]
                 },
                 'plan': '1xCPU-1GB'
             }
         },
         content_json=upcloudServerCreatePayload,
         code=202)
     # determine it's up & running
     self._http.expect(method='get',
                       ep='/server/438b5b08-4147-4193-bf64-a5318f51d3bd',
                       content_json=upcloudServerStartedPayload)
     # get root password
     self._http.expect(method='get',
                       ep='/server/438b5b08-4147-4193-bf64-a5318f51d3bd',
                       content_json=upcloudServerStartedPayload)
     # stop server
     self._http.expect(
         method='post',
         ep='/server/438b5b08-4147-4193-bf64-a5318f51d3bd/stop',
         json={'stop_server': {
             'stop_type': 'hard',
             'timeout': '1'
         }},
         content_json=upcloudServerStartedPayload)
     # now it's stopped
     self._http.expect(method='get',
                       ep='/server/438b5b08-4147-4193-bf64-a5318f51d3bd',
                       content_json=upcloudServerStoppedPayload)
     # then delete it
     self._http.expect(
         method='delete',
         ep='/server/438b5b08-4147-4193-bf64-a5318f51d3bd?storages=1',
         code=204)
     d = worker.substantiate(None, FakeBuild())
     yield worker.attached(FakeBot())
     yield d
Пример #9
0
 def setUp(self):
     super(TestGitHubStatus, self).setUp()
     self.setUpLogging()
     self.build = FakeBuild()
     self.status = GitHubStatus(
         token='token', repoOwner='owner', repoName='name')