tripleo-common stable/queens tox -e py27 failing on fedora base system

Bug #1763779 reported by YaZug on 2018-04-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
High
Unassigned

Bug Description

I was testing out tripleo-common unittests on my local system fc27 and when I ran the tox unittests they failed, but they are passing in gates.

I ran:
tox -e py27

and it failed on my local system

I would expect it to pass

FAIL: tripleo_common.tests.utils.test_config.TestConfig.test_config_download

big difference was

'config': '"#!/bin/bash\\necho \\"A script\\"\\n"\n',

vs

'config': '#!/bin/bash\necho "A script"\n',

Note:

I verified that python virtual env was equivalent, and then also checked that a local spun up ubuntu env was passing

FAIL: tripleo_common.tests.utils.test_config.TestConfig.test_config_download
tags: worker-1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jschluet/distgit/tripleo-common/.tox/py27/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "tripleo_common/tests/utils/test_config.py", line 290, in test_config_download
    self._get_yaml_file(f))
  File "/home/jschluet/distgit/tripleo-common/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/home/jschluet/distgit/tripleo-common/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = {'ControllerHostEntryDeployment': {'config': '"#!/bin/bash\\necho \\"A script\\"\\n"\n',
                                   'creation_time': 'None',
                                   'deployment_name': 'ControllerHostEntryDeployment',
                                   'group': 'script',
                                   'id': '50fcb6ee-4ff2-4318-b734-d3a7b45a8d6d',
                                   'inputs': [{'description': 'None',
                                               'name': 'deploy_server_id',
                                               'type': 'None',
                                               'value': '00b3a5e1-5e8e-4b55-878b-2fa2271f15ad'}],
                                   'name': 'None',
                                   'options': 'None',
                                   'outputs': None},

...

actual = {'ControllerHostEntryDeployment': {'config': '#!/bin/bash\necho "A script"\n',
                                   'creation_time': 'None',
                                   'deployment_name': 'ControllerHostEntryDeployment',
                                   'group': 'script',
                                   'id': '50fcb6ee-4ff2-4318-b734-d3a7b45a8d6d',
                                   'inputs': [{'description': 'None',
                                               'name': 'deploy_server_id',
                                               'type': 'None',
                                               'value': '00b3a5e1-5e8e-4b55-878b-2fa2271f15ad'}],
                                   'name': 'None',
                                   'options': 'None',
                                   'outputs': None},

...

Alex Schultz (alex-schultz) wrote :

I traced this down to:

                # If the value is not a string already, pretty print it as a
                # string so it's rendered in a readable format.
                if not isinstance(data, six.text_type):
                    data = json.dumps(data, indent=2)
vs
                # If the value is not a string already, pretty print it as a
                # string so it's rendered in a readable format.
                if not (isinstance(data, six.text_type) or
                        isinstance(data, six.string_types)):
                    data = json.dumps(data, indent=2)

The tests are failing because we're json.dumps() on a string which is adding in additional escaping.

Changed in tripleo:
milestone: none → rocky-2
status: New → Triaged
importance: Undecided → High

Reviewed: https://review.openstack.org/564056
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=21a8c7f905915d2c92a9a96a0f393f945af128bc
Submitter: Zuul
Branch: stable/queens

commit 21a8c7f905915d2c92a9a96a0f393f945af128bc
Author: James Slagle <email address hidden>
Date: Fri Apr 6 17:24:08 2018 -0400

    Don't set deployments as hostvars

    This patch updates config-download to not create a vars file under
    group_vars for the server deployments. These variables end up as
    hostvars in Ansible, which has caused many escaping problems since
    hostvars are run through the templating engine.

    In combination with I06c9b3256567cc57d599bd4d9af617c718d2314f, these
    escaping problems should be eliminated.

    Additionally, by not using hostvars (set_fact), we can save memory since
    a hostvar is set on a host and persisted in memory. With many hosts and
    large deployments (such as all hiera data), this would have eventually
    been an issue.

    Instead, an Ansible lookup is used in deployments.yaml to read
    deployment data, which are now written to individual files by
    config-download. This also improves readability instead of having one
    big file of all deployment data.

    Change-Id: Ie09fc64cf85eb532f31684f1c9808b942672ff41
    Closes-Bug: #1760990
    Closes-Bug: #1763779
    (cherry picked from commit 60f25d2bcd08d58b3bbbe63a1c9b9e156c5ab5cc)

tags: added: in-stable-queens

This issue was fixed in the openstack/tripleo-common 8.6.2 release.

Changed in tripleo:
milestone: rocky-2 → rocky-3
Changed in tripleo:
milestone: rocky-3 → rocky-rc1
Changed in tripleo:
milestone: rocky-rc1 → stein-1
Changed in tripleo:
milestone: stein-1 → stein-2
Changed in tripleo:
milestone: stein-2 → stein-3
Changed in tripleo:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers