def check_version(config_section): """ Simple version check that config version == library version *Note:* Ignores REVIS, only MAJOR/MINOR compared. :raise DockerVersionError: if Major/Minor don't match """ config_version = config_section.get('config_version', NOVERSIONCHECK) if config_version == NOVERSIONCHECK: logging.warning("Could not check configuration version matches subtest" " API version. No 'config_version' option specified " "in configuration") else: try: if compare(config_version, STRING) != 0: raise xceptions.DockerVersionError(STRING, config_version) except xceptions.DockerVersionError: # it's a ValueError subclass raise except (ValueError, TypeError): raise xceptions.DockerVersionError(STRING, '<not set for test>') except AssertionError: raise xceptions.DockerValueError( "Internal version comparison " "problem comparing '%s' to '%s'." % (str(config_version), str(STRING)))
def check_doc_version(): """ Compare Dockertest API version to documentation version, fail if greater """ doc_version = get_doc_version() msg = ("Dockertest API version %s is greater than " "documentation version %s" % (STRING, doc_version)) # OK if docs are later version than API if compare(STRING, doc_version) < 0: raise xceptions.DockerVersionError(msg)
def check_autotest_version(config_section, installed_version): """ Raise exception if configured ``autotest_version`` < installed_version """ cfg_version_string = config_section.get('autotest_version', '0.15.0') if cfg_version_string == NOVERSIONCHECK: return cfg_version = LooseVersion(cfg_version_string) inst_version = LooseVersion(installed_version) if inst_version < cfg_version: raise xceptions.DockerVersionError(str(inst_version), str(cfg_version))