def test_job_pipeline_allow_untrusted_secrets(self):
        self.pipeline.post_review = False
        job = self.pcontext.job_parser.fromYaml({
            '_source_context': self.context,
            '_start_mark': self.start_mark,
            'name': 'job',
            'parent': None,
            'post-review': True
        })

        self.layout.addJob(job)

        project_config = self.pcontext.project_parser.fromYaml({
            '_source_context':
            self.context,
            '_start_mark':
            self.start_mark,
            'name':
            'project',
            'gate': {
                'jobs': ['job']
            }
        })
        self.layout.addProjectConfig(project_config)

        change = model.Change(self.project)
        # Test master
        change.branch = 'master'
        item = self.queue.enqueueChange(change, None)
        item.layout = self.layout
        with testtools.ExpectedException(
                Exception,
                "Pre-review pipeline gate does not allow post-review job"):
            item.freezeJobGraph()
Exemple #2
0
    def test_inheritance_keeps_matchers(self):
        pipeline = model.Pipeline('gate', self.layout)
        self.layout.addPipeline(pipeline)
        queue = model.ChangeQueue(pipeline)

        base = self.pcontext.job_parser.fromYaml({
            '_source_context': self.context,
            '_start_mark': self.start_mark,
            'name': 'base',
            'parent': None,
            'timeout': 30,
        })
        self.layout.addJob(base)
        python27 = self.pcontext.job_parser.fromYaml({
            '_source_context':
            self.context,
            '_start_mark':
            self.start_mark,
            'name':
            'python27',
            'parent':
            'base',
            'timeout':
            40,
            'irrelevant-files': ['^ignored-file$'],
        })
        self.layout.addJob(python27)

        project_config = self.pcontext.project_parser.fromYaml([{
            '_source_context':
            self.context,
            '_start_mark':
            self.start_mark,
            'name':
            'project',
            'gate': {
                'jobs': [
                    'python27',
                ]
            }
        }])
        self.layout.addProjectConfig(project_config)

        change = model.Change(self.project)
        change.branch = 'master'
        change.files = ['/COMMIT_MSG', 'ignored-file']
        item = queue.enqueueChange(change)
        item.layout = self.layout

        self.assertTrue(base.changeMatches(change))
        self.assertFalse(python27.changeMatches(change))

        item.freezeJobGraph()
        self.assertEqual([], item.getJobs())
Exemple #3
0
 def setUp(self):
     super(BaseTestMatcher, self).setUp()
     self.change = model.Change(self.project)
Exemple #4
0
 def test_change_matches_returns_true_for_single_unmatched_skip_if(self):
     change = model.Change('project')
     change.files = ['foo']
     self.assertTrue(self.job.changeMatches(change))
Exemple #5
0
 def test_change_matches_returns_false_for_single_matched_skip_if(self):
     change = model.Change('project')
     change.files = ['docs/foo']
     self.assertFalse(self.job.changeMatches(change))
    def test_job_inheritance_job_tree(self):
        queue = model.ChangeQueue(self.pipeline)

        base = self.pcontext.job_parser.fromYaml({
            '_source_context': self.context,
            '_start_mark': self.start_mark,
            'name': 'base',
            'parent': None,
            'timeout': 30,
        })
        self.layout.addJob(base)
        python27 = self.pcontext.job_parser.fromYaml({
            '_source_context': self.context,
            '_start_mark': self.start_mark,
            'name': 'python27',
            'parent': 'base',
            'timeout': 40,
        })
        self.layout.addJob(python27)
        python27diablo = self.pcontext.job_parser.fromYaml({
            '_source_context':
            self.context,
            '_start_mark':
            self.start_mark,
            'name':
            'python27',
            'branches': ['stable/diablo'],
            'timeout':
            50,
        })
        self.layout.addJob(python27diablo)

        project_config = self.pcontext.project_parser.fromYaml({
            '_source_context':
            self.context,
            '_start_mark':
            self.start_mark,
            'name':
            'project',
            'gate': {
                'jobs': [{
                    'python27': {
                        'timeout': 70,
                        'run': 'playbooks/python27.yaml'
                    }
                }]
            }
        })
        self.layout.addProjectConfig(project_config)

        change = model.Change(self.project)
        change.branch = 'master'
        item = queue.enqueueChange(change, None)
        item.layout = self.layout

        self.assertTrue(base.changeMatchesBranch(change))
        self.assertTrue(python27.changeMatchesBranch(change))
        self.assertFalse(python27diablo.changeMatchesBranch(change))

        item.freezeJobGraph()
        self.assertEqual(len(item.getJobs()), 1)
        job = item.getJobs()[0]
        self.assertEqual(job.name, 'python27')
        self.assertEqual(job.timeout, 70)

        change.branch = 'stable/diablo'
        item = queue.enqueueChange(change, None)
        item.layout = self.layout

        self.assertTrue(base.changeMatchesBranch(change))
        self.assertTrue(python27.changeMatchesBranch(change))
        self.assertTrue(python27diablo.changeMatchesBranch(change))

        item.freezeJobGraph()
        self.assertEqual(len(item.getJobs()), 1)
        job = item.getJobs()[0]
        self.assertEqual(job.name, 'python27')
        self.assertEqual(job.timeout, 70)