Esempio n. 1
0
    def test_get_dictionary_no_file(self):
        # record
        (self._open_mock.expect_call(self._path, "rb").and_raises(IOError("blah")))

        # playback
        db = database.dict_database(self._path)
        self.assertEqual(db.get_dictionary(_open_func=self._open_mock), {})

        self.god.check_playback()
Esempio n. 2
0
    def test_get_dictionary_no_file(self):
        # record
        (self._open_mock.expect_call(self._path,
                                     'rb').and_raises(IOError('blah')))

        # playback
        db = database.dict_database(self._path)
        self.assertEqual(db.get_dictionary(_open_func=self._open_mock), {})

        self.god.check_playback()
Esempio n. 3
0
    def test_get_dictionary(self):
        # record
        (self._open_mock.expect_call(self._path, "rb").and_return(self._file_instance))
        (database.cPickle.load.expect_call(self._file_instance).and_return(self._db_contents))
        self._file_instance.close.expect_call()

        # playback
        db = database.dict_database(self._path)
        self.assertEqual(db.get_dictionary(_open_func=self._open_mock), self._db_contents)

        self.god.check_playback()
Esempio n. 4
0
    def test_get_dictionary(self):
        # record
        (self._open_mock.expect_call(self._path,
                                     'rb').and_return(self._file_instance))
        (database.cPickle.load.expect_call(self._file_instance).and_return(
            self._db_contents))
        self._file_instance.close.expect_call()

        # playback
        db = database.dict_database(self._path)
        self.assertEqual(db.get_dictionary(_open_func=self._open_mock),
                         self._db_contents)

        self.god.check_playback()
Esempio n. 5
0
    def _setup_merge_dictionary(self):
        # setup
        db = database.dict_database(self._path)
        self.god.stub_function(db, "get_dictionary")
        self.god.stub_function(db, "_aquire_lock")

        new_files = {"file3": database.item("file3", 30, 30000), "file4": database.item("file4", 40, 40000)}
        all_files = dict(self._db_contents)
        all_files.update(new_files)

        # record
        db._aquire_lock.expect_call().and_return(3)
        db.get_dictionary.expect_call().and_return(self._db_contents)
        (database.tempfile.mkstemp.expect_call(prefix=self._path, dir="").and_return((4, "tmpfile")))
        database.os.fdopen.expect_call(4, "wb").and_return(self._file_instance)

        return db, new_files, all_files
Esempio n. 6
0
    def _setup_merge_dictionary(self):
        # setup
        db = database.dict_database(self._path)
        self.god.stub_function(db, 'get_dictionary')
        self.god.stub_function(db, '_aquire_lock')

        new_files = {
            'file3': database.item('file3', 30, 30000),
            'file4': database.item('file4', 40, 40000),
            }
        all_files = dict(self._db_contents)
        all_files.update(new_files)

        # record
        db._aquire_lock.expect_call().and_return(3)
        db.get_dictionary.expect_call().and_return(self._db_contents)
        (database.tempfile.mkstemp.expect_call(prefix=self._path, dir='')
                .and_return((4, 'tmpfile')))
        database.os.fdopen.expect_call(4, 'wb').and_return(self._file_instance)

        return db, new_files, all_files
Esempio n. 7
0
    def _setup_merge_dictionary(self):
        # setup
        db = database.dict_database(self._path)
        self.god.stub_function(db, 'get_dictionary')
        self.god.stub_function(db, '_aquire_lock')

        new_files = {
            'file3': database.item('file3', 30, 30000),
            'file4': database.item('file4', 40, 40000),
        }
        all_files = dict(self._db_contents)
        all_files.update(new_files)

        # record
        db._aquire_lock.expect_call().and_return(3)
        db.get_dictionary.expect_call().and_return(self._db_contents)
        (database.tempfile.mkstemp.expect_call(prefix=self._path,
                                               dir='').and_return(
                                                   (4, 'tmpfile')))
        database.os.fdopen.expect_call(4, 'wb').and_return(self._file_instance)

        return db, new_files, all_files
Esempio n. 8
0
the filename, otherwise the filename is just filtered out); if "filter_exprs"
is not defined (or defined to be empty) then no filtering is performed

- an optional "trigger" instance of a trigger class; by default this is
initialized with trigger.trigger() but you can set it to another instance
(of your own site specific trigger class); even if you don't set it you
most certainly want to add a couple of actions to the trigger instance to
be executed for the new kernels (by default the list is empty and nothing
will happen with the new kernels other than being included in the known
kernels database so future lookups will not consider them new again)
"""
from autotest_lib.mirror import database, source as source_module
from autotest_lib.mirror import trigger as trigger_module

# create a database object where to store information about known files
db = database.dict_database('rsync.kernel.org.db')

# create a source object that will be used to fetch the list of new kernel
# files (this example uses rsync_source)
source = source_module.rsync_source(
    db,
    'rsync://rsync.kernel.org/pub/linux/kernel',
    excludes=('2.6.0-test*/', 'broken-out/', '*.sign', '*.gz'))
source.add_path('v2.6/patch-2.6.*.bz2', 'v2.6')
source.add_path('v2.6/linux-2.6.[0-9].tar.bz2', 'v2.6')
source.add_path('v2.6/linux-2.6.[0-9][0-9].tar.bz2', 'v2.6')
source.add_path('v2.6/testing/patch*.bz2', 'v2.6/testing')
source.add_path('v2.6/snapshots/*.bz2', 'v2.6/snapshots')
source.add_path('people/akpm/patches/2.6/*', 'akpm')

# Given a list of files filter and transform it for entries that look like
Esempio n. 9
0
the filename, otherwise the filename is just filtered out); if "filter_exprs"
is not defined (or defined to be empty) then no filtering is performed

- an optional "trigger" instance of a trigger class; by default this is
initialized with trigger.trigger() but you can set it to another instance
(of your own site specific trigger class); even if you don't set it you
most certainly want to add a couple of actions to the trigger instance to
be executed for the new kernels (by default the list is empty and nothing
will happen with the new kernels other than being included in the known
kernels database so future lookups will not consider them new again)
"""
from autotest_lib.mirror import database, source as source_module
from autotest_lib.mirror import trigger as trigger_module

# create a database object where to store information about known files
db = database.dict_database("rsync.kernel.org.db")

# create a source object that will be used to fetch the list of new kernel
# files (this example uses rsync_source)
source = source_module.rsync_source(
    db, "rsync://rsync.kernel.org/pub/linux/kernel", excludes=("2.6.0-test*/", "broken-out/", "*.sign", "*.gz")
)
source.add_path("v2.6/patch-2.6.*.bz2", "v2.6")
source.add_path("v2.6/linux-2.6.[0-9].tar.bz2", "v2.6")
source.add_path("v2.6/linux-2.6.[0-9][0-9].tar.bz2", "v2.6")
source.add_path("v2.6/testing/patch*.bz2", "v2.6/testing")
source.add_path("v2.6/snapshots/*.bz2", "v2.6/snapshots")
source.add_path("people/akpm/patches/2.6/*", "akpm")

# Given a list of files filter and transform it for entries that look like
# legitimate releases (may be empty in which case no filtering/transformation
Esempio n. 10
0
the filename, otherwise the filename is just filtered out); if "filter_exprs"
is not defined (or defined to be empty) then no filtering is performed

- an optional "trigger" instance of a trigger class; by default this is
initialized with trigger.trigger() but you can set it to another instance
(of your own site specific trigger class); even if you don't set it you
most certainly want to add a couple of actions to the trigger instance to
be executed for the new kernels (by default the list is empty and nothing
will happen with the new kernels other than being included in the known
kernels database so future lookups will not consider them new again)
"""
from autotest_lib.mirror import database, source as source_module
from autotest_lib.mirror import trigger as trigger_module

# create a database object where to store information about known files
db = database.dict_database('rsync.kernel.org.db')

# create a source object that will be used to fetch the list of new kernel
# files (this example uses rsync_source)
source = source_module.rsync_source(db,
    'rsync://rsync.kernel.org/pub/linux/kernel',
    excludes=('2.6.0-test*/', 'broken-out/', '*.sign', '*.gz'))
source.add_path('v2.6/patch-2.6.*.bz2', 'v2.6')
source.add_path('v2.6/linux-2.6.[0-9].tar.bz2', 'v2.6')
source.add_path('v2.6/linux-2.6.[0-9][0-9].tar.bz2', 'v2.6')
source.add_path('v2.6/testing/patch*.bz2', 'v2.6/testing')
source.add_path('v2.6/snapshots/*.bz2', 'v2.6/snapshots')
source.add_path('people/akpm/patches/2.6/*', 'akpm')

# Given a list of files filter and transform it for entries that look like
# legitimate releases (may be empty in which case no filtering/transformation