Exemple #1
0
def check_fixed_in(fixed_in, version_series):
    # used to check if the bug belongs to that series
    if fixed_in is None:
        return True
    if not isinstance(fixed_in, Version):
        fixed_in = Version(fixed_in)
    return fixed_in.is_in_series(version_series)
Exemple #2
0
def check_fixed_in(fixed_in, version_series):
    # used to check if the bug belongs to that series
    if fixed_in is None:
        return False
    if not isinstance(fixed_in, Version):
        fixed_in = Version(fixed_in)
    return fixed_in.is_in_series(version_series)
Exemple #3
0
 def upstream_version(self):
     if self.default_product is not None:
         return self.default_product.latest_version
     else:
         return Version(
             self.__config_options.get("upstream_version",
                                       Version.latest().vstring))
def get_product_version(ver):
    """Return product version for given Version obj or version string
    """
    ver = Version(ver)
    if ver.product_version() is not None:
        return ver.product_version()
    else:
        raise LookupError("no matching product version found for version {}".format(ver))
def get_stream(ver):
    """Return a stream name for given Version obj or version string
    """
    ver = Version(ver)
    if ver.stream() is not None:
        return ver.stream()
    else:
        raise LookupError("no matching stream found for version {}".format(ver))
Exemple #6
0
def test_version(v1, op, v2):
    v1 = Version(v1)
    v2 = Version(v2)
    if op == GT:
        assert v1 > v2
        # exercise
        assert v1 >= v2
    elif op == LT:
        assert v1 < v2
        # exercise
        assert v1 <= v2
    elif op == EQ:
        assert v1 == v2
        # to exercise all
        assert v1 <= v2
        assert v1 >= v2
Exemple #7
0
    def __getattr__(self, attr):
        """This proxies the attribute queries to the Bug object and modifies its result.

        If the field looked up is specified as loose field, it will be converted to Version.
        If the field is string and it has zero length, or the value is specified as "not specified",
        it will return None.
        """
        value = getattr(self._bug, attr)
        if attr in self.loose:
            if isinstance(value, Sequence) and not isinstance(value, six.string_types):
                value = value[0]
            value = value.strip()
            if not value:
                return None
            if value.lower() in NONE_FIELDS:
                return None
            # We have to strip any leading non-number characters to correctly match
            value = re.sub(r"^[^0-9]+", "", value)
            if not value:
                return None
            return Version(value)
        if isinstance(value, six.string_types):
            if len(value.strip()) == 0:
                return None
            else:
                return value
        else:
            return value
Exemple #8
0
def appliance_set_ansible_url(self, appliance_id):
    try:
        appliance = Appliance.objects.get(id=appliance_id)
    except ObjectDoesNotExist as e:
        self.logger.error("It seems such appliance %s doesn't exist: %s",
                          appliance_id, str(e))
        return False
    if appliance.is_openshift and Version(appliance.version) >= '5.10':
        appliance.cfme.set_ansible_url()
Exemple #9
0
def prepare_template_verify_version(self, template_id):
    template = Template.objects.get(id=template_id)
    template.set_status("Verifying version.")
    appliance = CFMEAppliance.from_provider(template.provider_name,
                                            template.name,
                                            container=template.container)
    appliance.ipapp.wait_for_ssh()
    try:
        true_version = appliance.version
    except Exception as e:
        template.set_status(
            "Some SSH error happened during appliance version check.")
        self.retry(args=(template_id, ), exc=e, countdown=20, max_retries=5)
    supposed_version = Version(template.version)
    if true_version is None or true_version.vstring == 'master':
        return
    if true_version != supposed_version:
        # Check if the difference is not just in the suffixes, which can be the case ...
        t = str(true_version)
        s = str(supposed_version)
        if supposed_version.version == true_version.version or t.startswith(s):
            # The two have same version but different suffixes, apply the suffix to the template obj
            # OR also a case - when the supposed version is incomplete so we will use the detected
            # version.
            with transaction.atomic():
                template.version = t
                template.save(update_fields=['version'])
                if template.parent_template is not None:
                    # In case we have a parent template, update the version there too.
                    if template.version != template.parent_template.version:
                        pt = template.parent_template
                        pt.version = template.version
                        pt.save(update_fields=['version'])
            return  # no need to continue with spamming process
        # SPAM SPAM SPAM!
        with transaction.atomic():
            mismatch_in_db = MismatchVersionMailer.objects.filter(
                provider=template.provider,
                template_name=template.original_name,
                supposed_version=supposed_version,
                actual_version=true_version)
            if not mismatch_in_db:
                mismatch = MismatchVersionMailer(
                    provider=template.provider,
                    template_name=template.original_name,
                    supposed_version=supposed_version,
                    actual_version=true_version)
                mismatch.save()
        # Run the task to mail the problem
        from .maintainance import mailer_version_mismatch
        mailer_version_mismatch.delay()
        raise Exception("Detected version mismatch!")
    template.set_status("Version verification is over")
Exemple #10
0
def _is_a_lvs(x, y):
    return mm.is_a(x, Version(y))
Exemple #11
0
def _is_a_slv(x, y):
    return mm.is_a(Version(x), y)
Exemple #12
0
 def versions(self):
     return sorted(
         Version(version["name"])
         for version in self._data["versions"]
         if version["name"] not in NONE_FIELDS
     )
Exemple #13
0
 def default_release(self):
     return Version(self._data["default_release"])
Exemple #14
0
 def upstream_version(self):
     if self.default_product is not None:
         return self.default_product.latest_version
     else:
         return Version(cfme_data.get("bugzilla", {}).get("upstream_version", "9.9"))
Exemple #15
0
def populate(
    template,
    output,
    credentials_key,
    vstring,
    polarion_project_id,
    polarion_url,
    template_format,
):
    with open(template, 'r') as template_file:
        input_yaml, indent, block_indent = load_yaml_guess_indent(template_file)

    # first update credentials fields
    input_yaml['username'] = credentials[credentials_key]['username']
    input_yaml['password'] = credentials[credentials_key]['password']

    version = Version(vstring)
    replacement = None  # avoid UnboundLocal below
    # First handle xunit import nested values
    if XUNIT_HEADER not in input_yaml:
        logger.info('Skipping [%s] in polarion_tools.local.yaml template, missing',
                    XUNIT_HEADER)
    else:
        for KEY in [TEMPLATE_ID, GROUP_ID, TESTRUN_TITLE, TESTRUN_ID]:
            # replacement is different for each field
            if KEY == TEMPLATE_ID:
                # There's no error if the template_format doesn't have {}
                replacement = template_format.format(version.series().replace('.', ''))
            elif KEY in [TESTRUN_TITLE, TESTRUN_ID]:
                replacement = vstring.replace('.', '_')  # stupid polarion not allowing .
            elif KEY == GROUP_ID:
                # z-stream for group ID
                replacement = version.series(n=3)
            # now apply the replacement
            if input_yaml[XUNIT_HEADER].get(KEY, None) not in ['', None]:
                # Only set empty values, if the template has a value don't change it
                logger.info('SKIP [%s][%s] in polarion_tools.local.yaml template, already set',
                            XUNIT_HEADER, KEY)
            else:
                input_yaml[XUNIT_HEADER][KEY] = replacement
                logger.info('Setting key [%s] in polarion_tools.local.yaml template, to %s',
                        KEY, replacement)

    # top level keys not in xunit
    for KEY in [POLARION_URL, POLARION_PROJECT_ID]:
        if KEY == POLARION_PROJECT_ID:
            replacement = polarion_project_id
        elif KEY == POLARION_URL:
            replacement = polarion_url
        # check replacement and current value
        if replacement is None:
            logger.info('SKIP [%s] in polarion_tools.local.yaml template, no value passed', KEY)
            continue
        elif input_yaml.get(KEY, None) is not None:
            logger.info('SKIP [%s] in polarion_tools.local.yaml template, value already set', KEY)
            continue
        else:
            logger.info('Setting key [%s] in polarion_tools.local.yaml template', KEY)
            input_yaml[KEY] = replacement

    with open(output, 'w') as output_file:
        ruamel.yaml.round_trip_dump(input_yaml,
                                    output_file,
                                    indent=indent,
                                    block_seq_indent=block_indent)
    return 0
Exemple #16
0
# -*- coding: utf-8 -*-
import pytest

from miq_version import Version

version_list = [
    Version('5.7.0.0'),
    Version('5.7.0.11-rc1'),
    Version('5.7.0.5-alpha2'),
    Version('5.7.0.17-nightly'),
    Version('5.7.0.6-alpha3'),
    Version('5.7.0.12-rc2'),
    Version('5.7.0.1'),
    Version('5.7.0.6'),
    Version('5.7.0.5'),
    Version('5.7.0.4'),
    Version('5.7.0.9'),
    Version('5.7.0.2'),
    Version('5.7.0.10-beta3'),
    Version('5.7.0.13-rc3'),
    Version('5.7.0.3'),
    Version('5.7.0.7-beta1'),
    Version('5.7.1.3'),
    Version('5.7.1.0'),
    Version('5.7.1.1'),
    Version('5.7.4.3'),
    Version('5.7.4.2'),
    Version('5.7.4.1'),
    Version('5.7.4.0'),
    Version('5.7.2.1'),
    Version('5.7.2.0'),
Exemple #17
0
def populate(
    template,
    output,
    credentials_key,
    vstring,
    polarion_project_id,
    polarion_url,
    template_format,
):
    with open(template, 'r') as template_file:
        input_yaml, indent, block_indent = load_yaml_guess_indent(
            template_file)

    # first update credentials fields
    input_yaml['username'] = credentials[credentials_key]['username']
    input_yaml['password'] = credentials[credentials_key]['password']

    version = Version(vstring)
    replacement = None  # avoid UnboundLocal below
    # First handle xunit import nested values
    if XUNIT_HEADER not in input_yaml:
        logger.info(
            'Skipping [%s] in polarion_tools.local.yaml template, missing',
            XUNIT_HEADER)
    else:
        for KEY in [TEMPLATE_ID, GROUP_ID, TESTRUN_TITLE, TESTRUN_ID]:
            # replacement is different for each field
            if KEY == TEMPLATE_ID:
                # There's no error if the template_format doesn't have {}
                replacement = template_format.format(version.series().replace(
                    '.', ''))
            elif KEY in [TESTRUN_TITLE, TESTRUN_ID]:
                replacement = vstring.replace(
                    '.', '_')  # stupid polarion not allowing .
            elif KEY == GROUP_ID:
                # z-stream for group ID
                replacement = version.series(n=3)
            # now apply the replacement
            if input_yaml[XUNIT_HEADER].get(KEY, None) not in ['', None]:
                # Only set empty values, if the template has a value don't change it
                logger.info(
                    'SKIP [%s][%s] in polarion_tools.local.yaml template, already set',
                    XUNIT_HEADER, KEY)
            else:
                input_yaml[XUNIT_HEADER][KEY] = replacement
                logger.info(
                    'Setting key [%s] in polarion_tools.local.yaml template, to %s',
                    KEY, replacement)

    # top level keys not in xunit
    for KEY in [POLARION_URL, POLARION_PROJECT_ID]:
        if KEY == POLARION_PROJECT_ID:
            replacement = polarion_project_id
        elif KEY == POLARION_URL:
            replacement = polarion_url
        # check replacement and current value
        if replacement is None:
            logger.info(
                'SKIP [%s] in polarion_tools.local.yaml template, no value passed',
                KEY)
            continue
        elif input_yaml.get(KEY, None) is not None:
            logger.info(
                'SKIP [%s] in polarion_tools.local.yaml template, value already set',
                KEY)
            continue
        else:
            logger.info(
                'Setting key [%s] in polarion_tools.local.yaml template', KEY)
            input_yaml[KEY] = replacement

    with open(output, 'w') as output_file:
        ruamel.yaml.round_trip_dump(input_yaml,
                                    output_file,
                                    indent=indent,
                                    block_seq_indent=block_indent)
    return 0
Exemple #18
0
 def upstream_version(self):
     if self.default_product is not None:
         return self.default_product.latest_version
     else:
         return Version(self.__config_options.get("upstream_version", Version.latest().vstring))