Zhao Chao cfadd2bbe4 Fix dict iteration in PropertiesCodec
We're updating a dict while iterating in PropertiesCodec, this leads to
random failures of the py35 unittest gate job.

As the logs of a zuul gate job won't be permanent, I wrote a simple
script(though may be ugly) to testing this:

$ python --version
Python 3.5.2

$ cat /tmp/python35_dict_updating.py
data_dict = {}

def init_dict():
    global data_dict
    for x in range(11):
        key = 'key' + str(x+1)
        data_dict[key] = x * 10

def update_dict():
    global data_dict
    for k, v in data_dict.items():
        data_dict.update({k: v+1})

def checking_failed(round):
    global data_dict
    FAILED = False
    for x in range(11):
        key = 'key' + str(x+1)
        origin = x * 10
        current = data_dict[key]
        if (current - origin) != round:
            print('%s is %s, expecting %s' %
                  (key, current, origin + round))
            FAILED = True
            break
    return FAILED

TEST_TIMES=5

PASSED = True
for x in range(TEST_TIMES):
    init_dict()

    for round in range(1, 100):
        update_dict()
        if checking_failed(round):
            print("Failed at round %s" % round)
            PASSED = False
            break

if PASSED:
    print("No failures in 5 100-round tests")

$ python /tmp/python35_dict_updating.py
key9 is 82, expecting 81
Failed at round 1
$ python /tmp/python35_dict_updating.py
key2 is 12, expecting 11
Failed at round 1
$ python /tmp/python35_dict_updating.py
key9 is 82, expecting 81
Failed at round 1
$ python /tmp/python35_dict_updating.py
No failures in 5 100-round tests

From the above testing results, we could see it's quite often that one
of the item will be updated twice during the dict iteration. This is
the reason why test_properties_file_codec failed sometimes.

This fix is manually converting the result of dict.items to a list:

$ sed -i 's/data_dict.items()/list(data_dict.items())/' \
        /tmp/python35_dict_updating.py

$ python /tmp/python35_dict_updating.py
No failures in 5 100-round tests
$ python /tmp/python35_dict_updating.py
No failures in 5 100-round tests
$ python /tmp/python35_dict_updating.py
No failures in 5 100-round tests
$ python /tmp/python35_dict_updating.py
No failures in 5 100-round tests

Closes-Bug: #1764321
Change-Id: Ia9fcfc6519b29f1a9508b79614c5e81456ad57b6
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
2018-04-16 16:13:23 +08:00
2015-05-29 07:27:59 +00:00
2018-03-23 08:08:18 +08:00
2016-10-24 04:12:55 +00:00
2013-06-14 18:25:42 -04:00
2018-03-22 19:07:53 -04:00
2014-03-19 15:06:23 +01:00
2015-05-29 07:27:59 +00:00
2018-01-24 17:21:26 +00:00
2013-04-29 18:01:12 -04:00
2016-09-14 13:56:24 -04:00
2017-01-11 07:56:35 -05:00
2017-03-02 11:57:16 +00:00
2018-03-22 19:07:53 -04:00

Trove

image

Trove is Database as a Service for OpenStack.

Getting Started

If you'd like to run from the master branch, you can clone the git repo:

git clone https://github.com/openstack/trove

You can raise bugs here: https://bugs.launchpad.net/trove

Python client

https://git.openstack.org/cgit/openstack/python-troveclient

References

Description
OpenStack Database As A Service (Trove)
Readme 114 MiB
Languages
Python 95%
Shell 4.9%