Example #1
0
    def test_sanity_check(self):
        t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'],
                         log, self.db_factory, self.tempdir)
        t.id = 'f17-updates-testing'
        t.init_path()

        # test without any arches
        try:
            t.sanity_check_repo()
            assert False, "Sanity check didn't fail with empty dir"
        except:
            pass

        # test with valid repodata
        for arch in ('i386', 'x86_64', 'armhfp'):
            repo = os.path.join(t.path, t.id, arch)
            os.makedirs(repo)
            mkmetadatadir(repo)

        t.sanity_check_repo()

        # test with truncated/busted repodata
        xml = os.path.join(t.path, t.id, 'i386', 'repodata', 'repomd.xml')
        repomd = open(xml).read()
        with open(xml, 'w') as f:
            f.write(repomd[:-10])

        from bodhi.exceptions import RepodataException
        try:
            t.sanity_check_repo()
            assert False, 'Busted metadata passed'
        except RepodataException:
            pass
Example #2
0
    def test_sanity_check(self):
        t = MasherThread(u"F17", u"testing", [u"bodhi-2.0-1.fc17"], log, self.db_factory, self.tempdir)
        t.id = "f17-updates-testing"
        t.init_path()

        # test without any arches
        try:
            t.sanity_check_repo()
            assert False, "Sanity check didn't fail with empty dir"
        except:
            pass

        # test with valid repodata
        for arch in ("i386", "x86_64", "armhfp"):
            repo = os.path.join(t.path, t.id, arch)
            os.makedirs(repo)
            mkmetadatadir(repo)

        t.sanity_check_repo()

        # test with truncated/busted repodata
        xml = os.path.join(t.path, t.id, "i386", "repodata", "repomd.xml")
        repomd = open(xml).read()
        with open(xml, "w") as f:
            f.write(repomd[:-10])

        from bodhi.exceptions import RepodataException

        try:
            t.sanity_check_repo()
            assert False, "Busted metadata passed"
        except RepodataException:
            pass
Example #3
0
    def test_testing_digest(self, mail, *args):
        t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'],
                         log, self.db_factory, self.tempdir)
        with self.db_factory() as session:
            t.db = session
            t.work()
            t.db = None
        self.assertEquals(t.testing_digest[u'Fedora 17'][u'bodhi-2.0-1.fc17'], """\
================================================================================
 libseccomp-2.1.0-1.fc20 (FEDORA-%s-0001)
 Enhanced seccomp library
--------------------------------------------------------------------------------
Update Information:

Useful details!
--------------------------------------------------------------------------------
References:

  [ 1 ] Bug #12345 - None
        https://bugzilla.redhat.com/show_bug.cgi?id=12345
  [ 2 ] CVE-1985-0110
        http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1985-0110
--------------------------------------------------------------------------------

""" % time.strftime('%Y'))

        mail.assert_called_with(config.get('bodhi_email'), config.get('fedora_test_announce_list'), mock.ANY)
        assert len(mail.mock_calls) == 2, len(mail.mock_calls)
        body = mail.mock_calls[1][1][2]
        assert body.startswith('From: [email protected]\r\nTo: %s\r\nSubject: Fedora 17 updates-testing report\r\n\r\nThe following builds have been pushed to Fedora 17 updates-testing\n\n    bodhi-2.0-1.fc17\n\nDetails about builds:\n\n\n================================================================================\n libseccomp-2.1.0-1.fc20 (FEDORA-%s-0001)\n Enhanced seccomp library\n--------------------------------------------------------------------------------\nUpdate Information:\n\nUseful details!\n--------------------------------------------------------------------------------\nReferences:\n\n  [ 1 ] Bug #12345 - None\n        https://bugzilla.redhat.com/show_bug.cgi?id=12345\n  [ 2 ] CVE-1985-0110\n        http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1985-0110\n--------------------------------------------------------------------------------\n\n' % (config.get('fedora_test_announce_list'), time.strftime('%Y'))), repr(body)
Example #4
0
 def test_modify_stable_bugs(self, close, comment, *args):
     self.set_stable_request('bodhi-2.0-1.fc17')
     t = MasherThread(u'F17', u'stable', [u'bodhi-2.0-1.fc17'], log,
                      self.db_factory, self.tempdir)
     with self.db_factory() as session:
         t.db = session
         t.work()
         t.db = None
     close.assert_called_with(12345, fixedin=u'2.0-1.fc17')
     comment.assert_called_with(12345, u'bodhi-2.0-1.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.')
Example #5
0
 def test_modify_stable_bugs(self, close, comment, *args):
     self.set_stable_request("bodhi-2.0-1.fc17")
     t = MasherThread(u"F17", u"stable", [u"bodhi-2.0-1.fc17"], log, self.db_factory, self.tempdir)
     with self.db_factory() as session:
         t.db = session
         t.work()
         t.db = None
     close.assert_called_with(12345, versions=dict(bodhi=u"bodhi-2.0-1.fc17"))
     comment.assert_called_with(
         12345,
         u"bodhi-2.0-1.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.",
     )
Example #6
0
 def test_get_security_updates(self, *args):
     build = u"bodhi-2.0-1.fc17"
     t = MasherThread(u"F17", u"testing", [build], log, self.db_factory, self.tempdir)
     with self.db_factory() as session:
         t.db = session
         u = session.query(Update).one()
         u.type = UpdateType.security
         u.status = UpdateStatus.testing
         u.request = None
         release = session.query(Release).one()
         updates = t.get_security_updates(release.long_name)
         self.assertEquals(len(updates), 1)
         self.assertEquals(updates[0].title, build)
Example #7
0
 def test_get_security_updates(self, *args):
     build = u'bodhi-2.0-1.fc17'
     t = MasherThread(u'F17', u'testing', [build], log, self.db_factory,
                      self.tempdir)
     with self.db_factory() as session:
         t.db = session
         u = session.query(Update).one()
         u.type = UpdateType.security
         u.status = UpdateStatus.testing
         u.request = None
         release = session.query(Release).one()
         updates = t.get_security_updates(release.long_name)
         self.assertEquals(len(updates), 1)
         self.assertEquals(updates[0].title, build)
Example #8
0
 def test_statefile(self):
     t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'], log, self.db_factory, self.tempdir)
     t.id = 'f17-updates-testing'
     t.init_state()
     t.save_state()
     self.assertTrue(os.path.exists(t.mash_lock))
     with file(t.mash_lock) as f:
         state = json.load(f)
     try:
         self.assertEquals(state, {u'updates':
             [u'bodhi-2.0-1.fc17'], u'completed_repos': []})
     finally:
         t.remove_state()
Example #9
0
    def test_absent_gating(self, cmd, publish, *args):
        cmd.return_value = "", "", 0

        # Set the request to stable right out the gate so we can test gating
        self.set_stable_request("bodhi-2.0-1.fc17")

        t = MasherThread(u"F17", u"stable", [u"bodhi-2.0-1.fc17"], log, self.db_factory, self.tempdir)

        with self.db_factory() as session:
            t.db = session
            t.work()
            t.db = None

        # Also, ensure we reported success
        publish.assert_called_with(topic="mashtask.complete", force=True, msg=dict(success=True, repo="f17-updates"))
        publish.assert_any_call(topic="update.eject", msg=mock.ANY, force=True)

        self.assertIn(mock.call(["mash"] + [mock.ANY] * 7), cmd.mock_calls)
        self.assertEquals(len(t.state["completed_repos"]), 1)
Example #10
0
 def test_statefile(self):
     t = MasherThread(u"F17", u"testing", [u"bodhi-2.0-1.fc17"], log, self.db_factory, self.tempdir)
     t.id = "f17-updates-testing"
     t.init_state()
     t.save_state()
     self.assertTrue(os.path.exists(t.mash_lock))
     with file(t.mash_lock) as f:
         state = json.load(f)
     try:
         self.assertEquals(state, {u"updates": [u"bodhi-2.0-1.fc17"], u"completed_repos": []})
     finally:
         t.remove_state()
Example #11
0
 def test_stage(self):
     t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'], log,
                      self.db_factory, self.tempdir)
     t.id = 'f17-updates-testing'
     t.init_path()
     t.stage_repo()
     stage_dir = config.get('mash_stage_dir')
     link = os.path.join(stage_dir, t.id)
     self.assertTrue(os.path.islink(link))
Example #12
0
 def test_statefile(self):
     t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'], log, self.db_factory, self.tempdir)
     t.id = 'f17-updates-testing'
     t.init_state()
     t.save_state()
     self.assertTrue(os.path.exists(t.mash_lock))
     with file(t.mash_lock) as f:
         state = json.load(f)
     try:
         self.assertEquals(state, {u'tagged': False, u'updates':
             [u'bodhi-2.0-1.fc17'], u'completed_repos': []})
     finally:
         t.remove_state()
Example #13
0
    def test_testing_digest(self, mail, *args):
        t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'],
                         log, self.db_factory, self.tempdir)
        with self.db_factory() as session:
            t.db = session
            t.work()
            t.db = None
        self.assertEquals(t.testing_digest[u'Fedora 17'][u'bodhi-2.0-1.fc17'], """\
================================================================================
 libseccomp-2.1.0-1.fc20 (FEDORA-%s-a3bbe1a8f2)
 Enhanced seccomp library
--------------------------------------------------------------------------------
Update Information:

Useful details!
--------------------------------------------------------------------------------
References:

  [ 1 ] Bug #12345 - None
        https://bugzilla.redhat.com/show_bug.cgi?id=12345
  [ 2 ] CVE-1985-0110
        http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1985-0110
--------------------------------------------------------------------------------

""" % time.strftime('%Y'))

        mail.assert_called_with(config.get('bodhi_email'), config.get('fedora_test_announce_list'), mock.ANY)
        assert len(mail.mock_calls) == 2, len(mail.mock_calls)
        body = mail.mock_calls[1][1][2]
        assert body.startswith('From: [email protected]\r\nTo: %s\r\nX-Bodhi: fedoraproject.org\r\nSubject: Fedora 17 updates-testing report\r\n\r\nThe following builds have been pushed to Fedora 17 updates-testing\n\n    bodhi-2.0-1.fc17\n\nDetails about builds:\n\n\n================================================================================\n libseccomp-2.1.0-1.fc20 (FEDORA-%s-a3bbe1a8f2)\n Enhanced seccomp library\n--------------------------------------------------------------------------------\nUpdate Information:\n\nUseful details!\n--------------------------------------------------------------------------------\nReferences:\n\n  [ 1 ] Bug #12345 - None\n        https://bugzilla.redhat.com/show_bug.cgi?id=12345\n  [ 2 ] CVE-1985-0110\n        http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1985-0110\n--------------------------------------------------------------------------------\n\n' % (config.get('fedora_test_announce_list'), time.strftime('%Y'))), repr(body)
Example #14
0
    def test_absent_gating(self, cmd, publish, *args):
        cmd.return_value = '', '', 0

        # Set the request to stable right out the gate so we can test gating
        self.set_stable_request('bodhi-2.0-1.fc17')

        t = MasherThread(u'F17', u'stable', [u'bodhi-2.0-1.fc17'], log,
                         self.db_factory, self.tempdir)

        with self.db_factory() as session:
            t.db = session
            t.work()
            t.db = None

        # Also, ensure we reported success
        publish.assert_called_with(topic="mashtask.complete",
                                   force=True,
                                   msg=dict(success=True, repo='f17-updates'))
        publish.assert_any_call(topic='update.eject', msg=mock.ANY, force=True)

        self.assertIn(mock.call(['mash'] + [mock.ANY] * 7), cmd.mock_calls)
        self.assertEquals(len(t.state['completed_repos']), 1)
Example #15
0
 def test_stage(self):
     t = MasherThread(u"F17", u"testing", [u"bodhi-2.0-1.fc17"], log, self.db_factory, self.tempdir)
     t.id = "f17-updates-testing"
     t.init_path()
     t.stage_repo()
     stage_dir = config.get("mash_stage_dir")
     link = os.path.join(stage_dir, t.id)
     self.assertTrue(os.path.islink(link))
Example #16
0
 def test_stage(self):
     t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'],
                      log, self.db_factory, self.tempdir)
     t.id = 'f17-updates-testing'
     t.init_path()
     t.stage_repo()
     stage_dir = config.get('mash_stage_dir')
     link = os.path.join(stage_dir, t.id)
     self.assertTrue(os.path.islink(link))
Example #17
0
 def test_modify_stable_bugs(self, close, comment, *args):
     self.set_stable_request('bodhi-2.0-1.fc17')
     t = MasherThread(u'F17', u'stable', [u'bodhi-2.0-1.fc17'], log,
                      self.db_factory, self.tempdir)
     with self.db_factory() as session:
         t.db = session
         t.work()
         t.db = None
     close.assert_called_with(
         12345, versions=dict(bodhi=u'bodhi-2.0-1.fc17'))
     comment.assert_called_with(12345, u'bodhi-2.0-1.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.')
Example #18
0
    def test_absent_gating(self, cmd, publish, *args):
        cmd.return_value = '', '', 0

        # Set the request to stable right out the gate so we can test gating
        self.set_stable_request('bodhi-2.0-1.fc17')

        t = MasherThread(u'F17', u'stable', [u'bodhi-2.0-1.fc17'], log,
                         self.db_factory, self.tempdir)

        with self.db_factory() as session:
            t.db = session
            t.work()
            t.db = None

        # Also, ensure we reported success
        publish.assert_called_with(topic="mashtask.complete",
                                   force=True,
                                   msg=dict(success=True, repo='f17-updates'))
        publish.assert_any_call(topic='update.eject', msg=mock.ANY, force=True)

        self.assertIn(mock.call(['mash'] + [mock.ANY] * 7), cmd.mock_calls)
        self.assertEquals(len(t.state['completed_repos']), 1)
Example #19
0
    def test_sanity_check(self):
        t = MasherThread(u'F17', u'testing', [u'bodhi-2.0-1.fc17'], log,
                         self.db_factory, self.tempdir)
        t.id = 'f17-updates-testing'
        t.init_path()

        # test without any arches
        try:
            t.sanity_check_repo()
            assert False, "Sanity check didn't fail with empty dir"
        except:
            pass

        # test with valid repodata
        for arch in ('i386', 'x86_64', 'armhfp'):
            repo = os.path.join(t.path, t.id, arch)
            os.makedirs(repo)
            mkmetadatadir(repo)

        t.sanity_check_repo()

        # test with truncated/busted repodata
        xml = os.path.join(t.path, t.id, 'i386', 'repodata', 'repomd.xml')
        repomd = open(xml).read()
        with open(xml, 'w') as f:
            f.write(repomd[:-10])

        from bodhi.exceptions import RepodataException
        try:
            t.sanity_check_repo()
            assert False, 'Busted metadata passed'
        except RepodataException:
            pass