示例#1
0
    def __init__(self,
                 resource_type,
                 chart_wait,
                 labels,
                 get_resources,
                 min_ready="100%",
                 **kwargs):
        super(ControllerWait, self).__init__(resource_type, chart_wait, labels,
                                             get_resources, **kwargs)

        if isinstance(min_ready, str):
            match = re.match('(.*)%$', min_ready)
            if match:
                min_ready_percent = int(match.group(1))
                self.min_ready = CountOrPercent(number=min_ready_percent,
                                                is_percent=True,
                                                source=min_ready)
            else:
                raise manifest_exceptions.ManifestException(
                    "`min_ready` as string must be formatted as a percent "
                    "e.g. '80%'")
        else:
            self.min_ready = CountOrPercent(number=min_ready,
                                            is_percent=False,
                                            source=min_ready)
示例#2
0
    def test_test_controller_manifest_failure_returns_400(
            self, _, mock_manifest):
        rules = {'armada:test_manifest': '@'}
        self.policy.set_rules(rules)

        mock_manifest.return_value.get_manifest.side_effect = (
            manifest_exceptions.ManifestException(details='foo'))

        manifest_path = os.path.join(os.getcwd(), 'examples',
                                     'keystone-manifest.yaml')
        with open(manifest_path, 'r') as f:
            payload = f.read()

        resp = self.app.simulate_post('/api/v1.0/tests', body=payload)
        self.assertEqual(400, resp.status_code)

        resp_body = json.loads(resp.text)
        self.assertEqual(400, resp_body['code'])
        self.assertEqual(1, resp_body['details']['errorCount'])
        self.assertEqual([{
            'message':
            ('An error occurred while generating the manifest: foo.'),
            'error':
            True,
            'kind':
            'ValidationMessage',
            'level':
            'Error',
            'name':
            'ARM001',
            'documents': []
        }], resp_body['details']['messageList'])
        self.assertEqual(('Failed to validate documents or generate Armada '
                          'Manifest from documents.'), resp_body['message'])