Repository: fedora-infra/bodhi

Issue:
Test failure during Rawhide rpmbuild
When attempting to build a 2.8.0 beta RPM, I got a traceback:

```
======================================================================                                                 
ERROR: Failure: ValueError (Invalid config values were set:             
        mash_dir: "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/../../masher/mash" does not exist.
        mash_stage_dir: "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/../../masher" does not exist.)
----------------------------------------------------------------------
Traceback (most recent call last):                                                
  File "/usr/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)                                        
  File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)                                                   
  File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)                            
  File "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/consumers/masher.py", line 71, in <module>
    class Masher(fedmsg.consumers.FedmsgConsumer):                                     
  File "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/consumers/masher.py", line 117, in Masher
    def __init__(self, hub, db_factory=None, mash_dir=config.get('mash_dir'),          
  File "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/config.py", line 562, in get
    self.load_config()                                                                                                                             
  File "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/config.py", line 590, in load_config                                                                                                            self._validate()                       
  File "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/config.py", line 608, in _validate
    'Invalid config values were set: \n{}'.format('\n'.join(errors)))
ValueError: Invalid config values were set:                                             
        mash_dir: "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/../../masher/mash" does not exist.
        mash_stage_dir: "/home/rbarlow/rpmbuild/BUILD/bodhi-fe7f50ca38dc2e838d3f587882daaac1da07a95b/bodhi/server/../../masher" does not exist.
```

Since a source checkout cannot reasonably have a place for mashing, I will probably just change the defaults for these two settings to ```None```. The defaults were kinda made up anyway.


Discussion:

Resolving patch:
diff --git a/bodhi/server/config.py b/bodhi/server/config.py
--- a/bodhi/server/config.py
+++ b/bodhi/server/config.py
@@ -435,11 +435,11 @@ class BodhiConfig(dict):
             'value': '/etc/mash/mash.conf',
             'validator': unicode},
         'mash_dir': {
-            'value': os.path.join(os.path.dirname(__file__), '..', '..', 'masher', 'mash'),
-            'validator': _validate_path},
+            'value': None,
+            'validator': _validate_none_or(_validate_path)},
         'mash_stage_dir': {
-            'value': os.path.join(os.path.dirname(__file__), '..', '..', 'masher'),
-            'validator': _validate_path},
+            'value': None,
+            'validator': _validate_none_or(_validate_path)},
         'max_update_length_for_ui': {
             'value': 30,
             'validator': int},


Test patch:
diff --git a/bodhi/tests/server/consumers/test_masher.py b/bodhi/tests/server/consumers/test_masher.py
--- a/bodhi/tests/server/consumers/test_masher.py
+++ b/bodhi/tests/server/consumers/test_masher.py
@@ -96,6 +96,13 @@ def makemsg(body=None):
 class TestMasher(unittest.TestCase):
 
     def setUp(self):
+        self._new_mash_stage_dir = tempfile.mkdtemp()
+        self._mash_stage_dir = config['mash_stage_dir']
+        self._mash_dir = config['mash_dir']
+        config['mash_stage_dir'] = self._new_mash_stage_dir
+        config['mash_dir'] = os.path.join(config['mash_stage_dir'], 'mash')
+        os.makedirs(config['mash_dir'])
+
         buildsys.setup_buildsystem({'buildsystem': 'dev'})
 
         fd, self.db_filename = tempfile.mkstemp(prefix='bodhi-testing-', suffix='.db')
@@ -138,6 +145,9 @@ def tearDown(self):
         except:
             pass
         buildsys.teardown_buildsystem()
+        config['mash_stage_dir'] = self._mash_stage_dir
+        config['mash_dir'] = self._mash_dir
+        shutil.rmtree(self._new_mash_stage_dir)
 
     def set_stable_request(self, title):
         with self.db_factory() as session:
diff --git a/bodhi/tests/server/test_metadata.py b/bodhi/tests/server/test_metadata.py
--- a/bodhi/tests/server/test_metadata.py
+++ b/bodhi/tests/server/test_metadata.py
@@ -118,16 +118,17 @@ def test_build_not_in_builds(self):
 
 class TestExtendedMetadata(unittest.TestCase):
 
-    def __init__(self, *args, **kw):
-        super(TestExtendedMetadata, self).__init__(*args, **kw)
-        repo_path = os.path.join(config.get('mash_dir'), 'f17-updates-testing')
-        if not os.path.exists(repo_path):
-            os.makedirs(repo_path)
-
     def setUp(self):
+        self._new_mash_stage_dir = tempfile.mkdtemp()
+        self._mash_stage_dir = config['mash_stage_dir']
+        self._mash_dir = config['mash_dir']
+        config['mash_stage_dir'] = self._new_mash_stage_dir
+        config['mash_dir'] = os.path.join(config['mash_stage_dir'], 'mash')
+        os.makedirs(os.path.join(config['mash_dir'], 'f17-updates-testing'))
+
         setup_buildsystem({'buildsystem': 'dev'})
-        config = {'sqlalchemy.url': DB_PATH}
-        engine = initialize_db(config)
+        app_config = {'sqlalchemy.url': DB_PATH}
+        engine = initialize_db(app_config)
         log.debug('Creating all models for %s' % engine)
         Base.metadata.bind = engine
         Base.metadata.create_all(engine)
@@ -160,6 +161,9 @@ def tearDown(self):
         get_session().clear()
         shutil.rmtree(self.tempdir)
         teardown_buildsystem()
+        config['mash_stage_dir'] = self._mash_stage_dir
+        config['mash_dir'] = self._mash_dir
+        shutil.rmtree(self._new_mash_stage_dir)
 
     def _verify_updateinfo(self, repodata):
         updateinfos = glob.glob(join(repodata, "*-updateinfo.xml*"))