Esempio n. 1
0
 def create_master(self):
     # This eventually needs to be merged into RunMixin.
     os.makedirs(self.basedir)
     self.slaves = {}
     spec = db.DBSpec("sqlite3", os.path.join(self.basedir, "state.sqlite"))
     db.create_db(spec)
     self.master = master.BuildMaster(self.basedir, db=spec)
     return self.master
Esempio n. 2
0
 def test_must_not_exist(self):
     basedir = "db/must_not_exist"
     if not os.path.isdir(basedir):
         os.makedirs(basedir)
     spec = db.DBSpec("sqlite3", os.path.join(basedir, "existing.sqlite"))
     db.create_db(spec)
     d = self.shouldFail(db.DBAlreadyExistsError, "must_not_exist",
                         "Refusing to touch an existing database",
                         db.create_db, spec)
     return d
Esempio n. 3
0
 def testSender(self):
     basedir = "changes/Sender/sender"
     if not os.path.exists(basedir):
         os.makedirs(basedir)
     spec = db.DBSpec("sqlite3", os.path.join(basedir, "state.sqlite"))
     db.create_db(spec)
     self.master = master.BuildMaster(basedir, db=spec)
     self.master.readConfig = True
     self.master.startService()
     d = self.master.loadConfig(config_sender)
     d.addCallback(self._testSender_1)
     return d
Esempio n. 4
0
 def build_harness(self, basedir):
     self.harness_basedir = basedir
     m = FakeMaster()
     m.setServiceParent(self.parent)
     if not os.path.isdir(basedir):
         os.makedirs(basedir)
     spec = db.DBSpec("sqlite3", os.path.join(basedir, "state.sqlite"))
     db.create_db(spec)
     m.db = db.open_db(spec)
     m.change_svc = cm = ChangeManager()
     cm.setServiceParent(m)
     sm = SchedulerManager(m, m.db, cm)
     sm.setServiceParent(m)
     return m, cm, sm
Esempio n. 5
0
 def create_master(self, **kwargs):
     assert not self.master, "you called create_master twice"
     # probably because you subclassed RunMixin instead of MasterMixin
     self.slaves = {}
     if self.basedir is None:
         self.basedir = self.mktemp()
     basedir = self.basedir
     os.makedirs(basedir)
     self.master = master.BuildMaster(basedir, **kwargs)
     spec = db.DBSpec.from_url("sqlite:///state.sqlite", basedir=basedir)
     db.create_db(spec)
     self.master.loadDatabase(spec)
     self.master.readConfig = True
     self.master.startService()
     self.status = self.master.getStatus()
     self.control = interfaces.IControl(self.master)
Esempio n. 6
0
    def test_migrate(self):
        fn = self.create_pickle()
        spec = db.DBSpec("sqlite3", "db/migrate/state.sqlite")
        db.create_db(spec)
        the_db = db.open_db(spec)
        self.dbs.add(the_db)
        runner.migrate_changes_pickle_to_db(fn, the_db, silent=True)
        m = ChangeManager()
        m.parent = FakeMaster()
        m.parent.db = the_db

        c1 = m.getChangeNumberedNow(1)
        self.failUnlessEqual(c1.who, "brian")
        self.failUnlessEqual(c1.files, sorted(["foo.c", "subdir/bar.c"]))
        self.failUnlessEqual(c1.comments, "first change")
        self.failUnlessEqual(c1.revision, "1234")
        # more..

        c3 = Change("alice", ["baz.c"], "third change", revision="abcd")
        m.addChange(c3)
Esempio n. 7
0
 def test_create(self):
     basedir = "db/create"
     if not os.path.isdir(basedir):
         os.makedirs(basedir)
     spec = db.DBSpec("sqlite3", os.path.join(basedir, "db1.sqlite"))
     db.create_db(spec)
     db1 = db.open_db(spec)
     self.dbs.add(db1)
     version = db1.runQueryNow("SELECT version FROM version")[0][0]
     self.failUnlessEqual(version, 1)
     d = db1.runQuery("SELECT version FROM version")
     d.addCallback(lambda r: self.failUnlessEqual(r[0][0], 1, r))
     def _then(ign):
         db2 = db.DBConnector(spec)
         self.dbs.add(db2)
         version = db2.runQueryNow("SELECT version FROM version")[0][0]
         self.failUnlessEqual(version, 1)
         return db2.runQuery("SELECT version FROM version")
     d.addCallback(_then)
     d.addCallback(lambda r: self.failUnlessEqual(r[0][0], 1, r))
     return d
Esempio n. 8
0
 def __init__(self, basedir):
     spec = db.DBSpec("sqlite3", os.path.join(basedir, "state.sqlite"))
     db.create_db(spec)
     master.BuildMaster.__init__(self, basedir, db=spec)
     self.readConfig = True
Esempio n. 9
0
 def test_create_db_missingOK(self):
     db.create_db(self.dbspec) # note this does not return a DBConnector
     conn = self.trackConn(db.DBConnector(self.dbspec))
     conn.start()
     self.assertEqual(conn.runQueryNow("SELECT * from version"), [(1,)])
     conn.stop()
Esempio n. 10
0
 def create_db(self):
     from buildbot.db import create_db, DBSpec
     dbspec = DBSpec.from_url(self.config["db"], self.basedir)
     if not self.config['quiet']: print "creating database"
     create_db(dbspec)