Use the first enabled system repo for the test

(cherry picked from commit 3fd5e50c80)
This commit is contained in:
Brian C. Lane 2018-07-27 16:43:37 -07:00
parent 2a04eb88ad
commit 824c84ae2f

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import os import os
from ConfigParser import SafeConfigParser, NoOptionError
from glob import glob from glob import glob
import shutil import shutil
import tempfile import tempfile
@ -31,6 +32,26 @@ from pylorax.api.server import server, GitLock, DNFLock
from pylorax.api.dnfbase import get_base_object from pylorax.api.dnfbase import get_base_object
from pylorax.sysutils import joinpaths from pylorax.sysutils import joinpaths
def get_system_repo():
"""Get an enabled system repo from /etc/yum.repos.d/*repo
This will be used for test_projects_source_01_delete_system()
"""
# The sources delete test needs the name of a system repo, get it from /etc/yum.repos.d/
for sys_repo in sorted(glob("/etc/yum.repos.d/*repo")):
cfg = SafeConfigParser()
cfg.read(sys_repo)
for section in cfg.sections():
try:
if cfg.get(section, "enabled") == "1":
# The API only supports repo filenames, return that.
return os.path.basename(sys_repo)[:-5]
except NoOptionError:
pass
# Failed to find one, fall back to using base
return "base"
class ServerTestCase(unittest.TestCase): class ServerTestCase(unittest.TestCase):
@classmethod @classmethod
@ -85,6 +106,9 @@ class ServerTestCase(unittest.TestCase):
# Import the example blueprints # Import the example blueprints
commit_recipe_directory(server.config["GITLOCK"].repo, "master", self.examples_path) commit_recipe_directory(server.config["GITLOCK"].repo, "master", self.examples_path)
# The sources delete test needs the name of a system repo, get it from /etc/yum.repos.d/
self.system_repo = get_system_repo()
start_queue_monitor(server.config["COMPOSER_CFG"], 0, 0) start_queue_monitor(server.config["COMPOSER_CFG"], 0, 0)
@classmethod @classmethod