예제 #1
0
    def test_frozen_enough(self):
        """Test frozen enough."""

        # already has requests
        self.assertEqual(
            self.wf.api.prj_frozen_enough('openSUSE:Factory:Staging:B'), True)

        self.wf.create_staging('A')

        # Unfrozen
        self.assertEqual(
            self.wf.api.prj_frozen_enough('openSUSE:Factory:Staging:A'), False)

        self.wf.create_staging('C', freeze=True, rings=1)
        self.assertEqual(
            self.wf.api.prj_frozen_enough('openSUSE:Factory:Staging:C'), True)

        # pretend it's old
        attribute_value_save(self.wf.apiurl, 'openSUSE:Factory:Staging:C',
                             'FreezeTime', "2021-03-04T10:23:55.127903")
        self.assertEqual(
            self.wf.api.prj_frozen_enough('openSUSE:Factory:Staging:C'), False)

        # test old method (which still shows it's recent)
        attribute_value_delete(self.wf.apiurl, 'openSUSE:Factory:Staging:C',
                               'FreezeTime')
        self.assertEqual(
            self.wf.api.prj_frozen_enough('openSUSE:Factory:Staging:C'), True)
예제 #2
0
    def test_automatic_update_modes(self):
        self.remote_config_set_age_minimum()

        upstream1_project = self.randomString('upstream1')
        package1 = self.randomString('package1')

        target_package1 = self.wf.create_package(self.target_project, package1)
        upstream1_package1 = self.wf.create_package(upstream1_project, package1)

        upstream1_package1.create_commit()
        copy_package(self.wf.apiurl, upstream1_project, package1,
                     self.wf.apiurl, self.target_project, package1)

        attribute_value_save(self.wf.apiurl, upstream1_project, 'ApprovedRequestSource', '', 'OBS')
        self.wf.create_attribute_type('OSRT', 'OriginUpdateSkip', 0)

        def config_write(delay=0, supersede=True, frequency=0):
            self.origin_config_write([
                {upstream1_project: {
                    'automatic_updates_delay': delay,
                    'automatic_updates_supersede': supersede,
                    'automatic_updates_frequency': frequency,
                }},
            ])

        # Default config with fresh commit.
        config_write()
        upstream1_package1.create_commit()

        # Check the full order of precidence available to mode attributes.
        for project in (upstream1_project, self.target_project):
            for package in (package1, None):
                # Ensure no update is triggered due to OSRT:OriginUpdateSkip.
                attribute_value_save(self.wf.apiurl, project, 'OriginUpdateSkip', '', package=package)
                self.assertNoUpdate(package1)
                attribute_value_delete(self.wf.apiurl, project, 'OriginUpdateSkip', package=package)

        # Configure a delay, make commit, and ensure no update until delayed.
        delay = 17  # Allow enough time for API speed fluctuation.
        config_write(delay=delay)
        upstream1_package1.create_commit()
        start = datetime.now()

        self.assertNoUpdate(package1)
        self.waitDelta(start, delay)
        request_id_package1_1 = self.assertUpdate(package1)

        # Configure no supersede and ensure no update generated for new commit.
        config_write(supersede=False)
        upstream1_package1.create_commit()
        self.assertNoUpdate(package1)

        # Accept request and ensure update since no request to supersede.
        self.assertReviewBot(request_id_package1_1, self.bot_user, 'new', 'accepted')
        request_state_change(self.wf.apiurl, request_id_package1_1, 'accepted')

        request_id_package1_2 = self.assertUpdate(package1)

        # Track time since last request created for testing frequency.
        start = datetime.now()

        # Configure frequency (removes supersede=False).
        config_write(frequency=delay)

        upstream1_package1.create_commit()
        self.assertNoUpdate(package1)

        # Fresh commit should not impact frequency which only looks at requests.
        self.waitDelta(start, delay)
        upstream1_package1.create_commit()

        request_id_package1_3 = self.assertUpdate(package1)
예제 #3
0
    def test_new_package_submission(self):
        self.remote_config_set_age_minimum()

        upstream1_project = self.randomString('upstream1')
        upstream2_project = self.randomString('upstream2')
        upstream3_project = self.randomString('upstream3')
        package1 = self.randomString('package1')
        package2 = self.randomString('package2')
        package3 = self.randomString('package3')

        target_package1 = self.wf.create_package(self.target_project, package1)
        upstream1_package1 = self.wf.create_package(upstream1_project, package1)
        upstream2_package1 = self.wf.create_package(upstream2_project, package1)

        upstream1_package1.create_commit()
        copy_package(self.wf.apiurl, upstream1_project, package1,
                     self.wf.apiurl, upstream2_project, package1)

        upstream3_package2 = self.wf.create_package(upstream3_project, package2)
        upstream3_package2.create_commit()

        upstream1_package3 = self.wf.create_package(upstream1_project, package3)
        upstream1_package3.create_commit()

        attribute_value_save(self.wf.apiurl, upstream1_project, 'ApprovedRequestSource', '', 'OBS')
        attribute_value_save(self.wf.apiurl, upstream2_project, 'ApprovedRequestSource', '', 'OBS')
        attribute_value_save(self.wf.apiurl, upstream3_project, 'ApprovedRequestSource', '', 'OBS')

        self.origin_config_write([
            {upstream1_project: { 'automatic_updates_initial': True }},
            {upstream2_project: { 'automatic_updates_initial': True }},
            {upstream3_project: {}},
        ])

        self.osc_user(self.bot_user)
        memoize_session_reset()
        request_future = origin_update(self.wf.apiurl, self.wf.project, package1)
        self.assertNotEqual(request_future, False)
        if request_future:
            request_id_package1 = request_future.print_and_create()

        # Ensure a second request is not triggered.
        memoize_session_reset()
        request_future = origin_update(self.wf.apiurl, self.wf.project, package1)
        self.assertEqual(request_future, False)

        # No new package submission from upstream3 since not automatic_updates_initial.
        memoize_session_reset()
        request_future = origin_update(self.wf.apiurl, self.wf.project, package2)
        self.assertEqual(request_future, False)
        self.osc_user_pop()

        upstream2_package2 = self.wf.create_package(upstream2_project, package2)
        upstream2_package2.create_commit()

        self.osc_user(self.bot_user)
        memoize_session_reset()
        request_future = origin_update(self.wf.apiurl, self.wf.project, package2)
        self.assertNotEqual(request_future, False)
        if request_future:
            request_id_package2 = request_future.print_and_create()
        self.osc_user_pop()

        request_state_change(self.wf.apiurl, request_id_package2, 'declined')
        upstream2_package2.create_commit()

        self.osc_user(self.bot_user)
        # No new package submission from upstream2 for new revision since
        # declined initial package submission.
        memoize_session_reset()
        request_future = origin_update(self.wf.apiurl, self.wf.project, package2)
        self.assertEqual(request_future, False)
        self.osc_user_pop()

        # Ensure blacklist prevents initial package submission.
        self.wf.create_attribute_type('OSRT', 'OriginUpdateInitialBlacklist', 1)
        attribute_value_save(self.wf.apiurl, self.target_project, 'OriginUpdateInitialBlacklist', package3)
        self.assertNoUpdate(package3)

        attribute_value_delete(self.wf.apiurl, self.target_project, 'OriginUpdateInitialBlacklist')
        self.assertUpdate(package3)