Ejemplo n.º 1
0
    def test_update_harness_repos(self):
        """Test that the update_repo() call runs as expected.

        This checks that the harness repos that are supposed to be
        synced are actually synced.

        Does not check repo metadata.
        """
        if 'sqlite' in get_engine().name:
            raise unittest.SkipTest('SQL generated by lazy_create is not valid'
                ' in sqlite')
        base_path = mkdtemp()
        self.addCleanup(rmtree, base_path)
        faux_remote_harness1 = self._create_remote_harness(base_path, 'foobangmajor')
        faux_remote_harness2 = self._create_remote_harness(base_path, 'foobazmajor')
        faux_local_harness = mkdtemp('local_harness')
        self.addCleanup(rmtree, faux_local_harness)
        with session.begin():
            lab_controller = data_setup.create_labcontroller(fqdn=u'dummylab.example.invalid')
            distro_tree = data_setup.create_distro_tree(
                                osmajor=OSMajor.lazy_create(osmajor=u'foobangmajor'),
                                harness_dir=False,
                                lab_controllers=[lab_controller])
            distro_tree = data_setup.create_distro_tree(
                                osmajor=OSMajor.lazy_create(osmajor=u'foobazmajor'),
                                harness_dir=False,
                                lab_controllers=[lab_controller])
        # I'm not testing the config here, so just use createrepo
        update_repos('file://%s/' % base_path, faux_local_harness)
        self.assertTrue(os.path.exists(os.path.join(faux_local_harness, 'foobangmajor')))
        self.assertTrue(os.path.exists(os.path.join(faux_local_harness, 'foobazmajor')))
Ejemplo n.º 2
0
    def test_update_harness_repos(self):
        """Test that the update_repo() call runs as expected.

        This checks that the harness repos that are supposed to be
        synced are actually synced.

        Does not check repo metadata.
        """
        if 'sqlite' in get_engine().name:
            raise unittest.SkipTest('SQL generated by lazy_create is not valid'
                                    ' in sqlite')
        base_path = mkdtemp()
        self.addCleanup(rmtree, base_path)
        faux_remote_harness1 = self._create_remote_harness(
            base_path, 'foobangmajor')
        faux_remote_harness2 = self._create_remote_harness(
            base_path, 'foobazmajor')
        faux_local_harness = mkdtemp('local_harness')
        self.addCleanup(rmtree, faux_local_harness)
        with session.begin():
            OSMajor.lazy_create(osmajor=u'foobangmajor')
            OSMajor.lazy_create(osmajor=u'foobazmajor')
        # I'm not testing the config here, so just use createrepo
        update_repos('file://%s/' % base_path, faux_local_harness)
        self.assertTrue(
            os.path.exists(os.path.join(faux_local_harness, 'foobangmajor')))
        self.assertTrue(
            os.path.exists(os.path.join(faux_local_harness, 'foobazmajor')))
Ejemplo n.º 3
0
 def test_does_not_run_createrepo_unnecessarily(self):
     if 'sqlite' in get_engine().name:
         raise unittest.SkipTest('SQL generated by lazy_create is not valid'
                                 ' in sqlite')
     osmajor = u'GreenBeretLinux99'
     with session.begin():
         lab_controller = data_setup.create_labcontroller(
             fqdn=u'dummylab.example.invalid')
         distro_tree = data_setup.create_distro_tree(
             osmajor=OSMajor.lazy_create(osmajor=osmajor),
             harness_dir=False,
             lab_controllers=[lab_controller])
     remote_harness_dir = mkdtemp(suffix='remote')
     self.addCleanup(rmtree, remote_harness_dir)
     local_harness_dir = mkdtemp(suffix='local')
     self.addCleanup(rmtree, local_harness_dir)
     self._create_remote_harness(remote_harness_dir, osmajor)
     # run it once, repo is built
     update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
     repodata_dir = os.path.join(local_harness_dir, osmajor, 'repodata')
     mtime = os.path.getmtime(repodata_dir)
     # run it again, repo should not be rebuilt
     time.sleep(0.001)
     update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
     self.assertEquals(os.path.getmtime(repodata_dir), mtime)
Ejemplo n.º 4
0
 def test_exclude_nonexistent_osmajor(self):
     if 'sqlite' in get_engine().name:
         raise unittest.SkipTest('SQL generated by lazy_create is not valid'
             ' in sqlite')
     with session.begin():
         osmajor = OSMajor.lazy_create(osmajor="exist")
         lab_controller = data_setup.create_labcontroller(fqdn=u'dummylab.example.invalid')
         distro_tree = data_setup.create_distro_tree(osmajor=osmajor.osmajor,
                                                     harness_dir=False,
                                                     lab_controllers=[lab_controller])
         nonexistent_osmajor = OSMajor.lazy_create(osmajor=u'notexist')
     remote_harness_dir = mkdtemp(suffix='remote')
     self.addCleanup(rmtree, remote_harness_dir)
     local_harness_dir = mkdtemp(suffix='local')
     self.addCleanup(rmtree, local_harness_dir)
     self._create_remote_harness(remote_harness_dir, osmajor.osmajor)
     update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
     self.assertTrue(os.path.exists(os.path.join(local_harness_dir, osmajor.osmajor)))
     self.assertFalse(os.path.exists(os.path.join(local_harness_dir, nonexistent_osmajor.osmajor)))
Ejemplo n.º 5
0
 def test_does_not_run_createrepo_unnecessarily(self):
     if 'sqlite' in get_engine().name:
         raise unittest.SkipTest('SQL generated by lazy_create is not valid'
             ' in sqlite')
     osmajor = u'GreenBeretLinux99'
     with session.begin():
         OSMajor.lazy_create(osmajor=osmajor)
     remote_harness_dir = mkdtemp(suffix='remote')
     self.addCleanup(rmtree, remote_harness_dir)
     local_harness_dir = mkdtemp(suffix='local')
     self.addCleanup(rmtree, local_harness_dir)
     self._create_remote_harness(remote_harness_dir, osmajor)
     # run it once, repo is built
     update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
     repodata_dir = os.path.join(local_harness_dir, osmajor, 'repodata')
     mtime = os.path.getmtime(repodata_dir)
     # run it again, repo should not be rebuilt
     time.sleep(0.001)
     update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
     self.assertEquals(os.path.getmtime(repodata_dir), mtime)
Ejemplo n.º 6
0
 def test_exclude_nonexistent_osmajor(self):
     if 'sqlite' in get_engine().name:
         raise unittest.SkipTest('SQL generated by lazy_create is not valid'
                                 ' in sqlite')
     with session.begin():
         osmajor = OSMajor.lazy_create(osmajor="exist")
         lab_controller = data_setup.create_labcontroller(
             fqdn=u'dummylab.example.invalid')
         distro_tree = data_setup.create_distro_tree(
             osmajor=osmajor.osmajor,
             harness_dir=False,
             lab_controllers=[lab_controller])
         nonexistent_osmajor = OSMajor.lazy_create(osmajor=u'notexist')
     remote_harness_dir = mkdtemp(suffix='remote')
     self.addCleanup(rmtree, remote_harness_dir)
     local_harness_dir = mkdtemp(suffix='local')
     self.addCleanup(rmtree, local_harness_dir)
     self._create_remote_harness(remote_harness_dir, osmajor.osmajor)
     update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
     self.assertTrue(
         os.path.exists(os.path.join(local_harness_dir, osmajor.osmajor)))
     self.assertFalse(
         os.path.exists(
             os.path.join(local_harness_dir, nonexistent_osmajor.osmajor)))