If dependency not in global reqs exit with a 1

Don't silently remove dependencies not in global reqs, instead let them
fail installation.

Note: this assumes that devstack will terminate if this fails.

Change-Id: I23be4c2084e07a6b60b64347af9b4c5338b06ada
This commit is contained in:
Joe Gordon 2014-03-14 13:20:48 -07:00
parent 297b22d03b
commit 1b725bd52e
3 changed files with 73 additions and 2 deletions

View File

@ -0,0 +1,45 @@
# The greenlet package must be compiled with gcc and needs
# the Python.h headers. Make sure you install the python-dev
# package to get the right headers...
greenlet>=0.3.1
# < 0.8.0/0.8 does not work, see https://bugs.launchpad.net/bugs/1153983
SQLAlchemy>=0.7.8,<=0.7.99
anyjson>=0.3.3
eventlet>=0.9.12
PasteDeploy
routes
WebOb>=1.2
wsgiref
argparse
boto
sqlalchemy-migrate>=0.7
httplib2
kombu>2.4.7
pycrypto>=2.1.0alpha1
iso8601>=0.1.4
oslo.config>=1.1.0
thisisnotarealdepedency
# For Swift storage backend.
python-swiftclient>=1.2,<2
# Note you will need gcc buildtools installed and must
# have installed libxml headers for lxml to be successfully
# installed using pip, therefore you will need to install the
# libxml2-dev and libxslt-dev Ubuntu packages.
lxml
# For paste.util.template used in keystone.common.template
Paste
passlib
jsonschema
python-cinderclient>=1.0.4
python-keystoneclient>=0.2.0
pyOpenSSL
# Required by openstack.common libraries
six

View File

@ -36,37 +36,51 @@ class UpdateTest(testtools.TestCase):
super(UpdateTest, self).setUp()
self.dir = tempfile.mkdtemp()
self.project_dir = os.path.join(self.dir, "project")
self.bad_project_dir = os.path.join(self.dir, "bad_project")
self.oslo_dir = os.path.join(self.dir, "project_with_oslo")
self.req_file = os.path.join(self.dir, "global-requirements.txt")
self.dev_req_file = os.path.join(self.dir, "dev-requirements.txt")
self.proj_file = os.path.join(self.project_dir, "requirements.txt")
self.oslo_file = os.path.join(self.oslo_dir, "requirements.txt")
self.bad_proj_file = os.path.join(self.bad_project_dir,
"requirements.txt")
self.proj_test_file = os.path.join(self.project_dir,
"test-requirements.txt")
self.setup_file = os.path.join(self.project_dir, "setup.py")
self.old_setup_file = os.path.join(self.oslo_dir, "setup.py")
self.bad_setup_file = os.path.join(self.bad_project_dir, "setup.py")
self.setup_cfg_file = os.path.join(self.project_dir, "setup.cfg")
self.bad_setup_cfg_file = os.path.join(self.bad_project_dir,
"setup.cfg")
self.oslo_setup_cfg_file = os.path.join(self.oslo_dir, "setup.cfg")
os.mkdir(self.project_dir)
os.mkdir(self.oslo_dir)
os.mkdir(self.bad_project_dir)
shutil.copy("tests/files/gr-base.txt", self.req_file)
shutil.copy("tests/files/dev-req.txt", self.dev_req_file)
shutil.copy("tests/files/project-with-oslo-tar.txt", self.oslo_file)
shutil.copy("tests/files/project.txt", self.proj_file)
shutil.copy("tests/files/project-with-bad-requirement.txt",
self.bad_proj_file)
shutil.copy("tests/files/test-project.txt", self.proj_test_file)
shutil.copy("tests/files/setup.py", self.setup_file)
shutil.copy("tests/files/setup.py", self.bad_setup_file)
shutil.copy("tests/files/old-setup.py", self.old_setup_file)
shutil.copy("tests/files/setup.cfg", self.setup_cfg_file)
shutil.copy("tests/files/setup.cfg", self.bad_setup_cfg_file)
shutil.copy("tests/files/setup.cfg", self.oslo_setup_cfg_file)
shutil.copy("update.py", os.path.join(self.dir, "update.py"))
# now go call update and see what happens
self.addCleanup(os.chdir, os.path.abspath(os.curdir))
os.chdir(self.dir)
subprocess.call([sys.executable, "update.py", "project"])
subprocess.call([sys.executable, "update.py", "project_with_oslo"])
returncode = subprocess.call([sys.executable, "update.py", "project"])
self.assertEqual(returncode, 0)
returncode = subprocess.call([sys.executable, "update.py",
"project_with_oslo"])
self.assertEqual(returncode, 0)
def test_requirements(self):
reqs = _file_to_list(self.req_file)
@ -104,3 +118,8 @@ class UpdateTest(testtools.TestCase):
self.assertNotIn(
"# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO"
" - DO NOT EDIT", setup_contents)
def test_requirment_not_in_global(self):
returncode = subprocess.call([sys.executable, "update.py",
"bad_project"])
self.assertEqual(returncode, 1)

View File

@ -134,6 +134,13 @@ def _sync_requirements_file(source_reqs, dev_reqs, dest_path, suffix):
new_reqs.write("%s\n" % dev_reqs[old_pip])
else:
new_reqs.write("%s\n" % source_reqs[old_pip])
else:
# Found a requirement that isn't in the global requirement file
# This is not supposed to happen, so exit with a failure.
print("'%s' is not a global requirement but it should be,"
"something went wrong" %
old_pip)
sys.exit(1)
def _copy_requires(suffix, dest_dir):