OpenStack Database As A Service (Trove)
Go to file
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
api-ref/source Return 204 instead of 200 for root-disable API 2018-03-02 20:57:23 +08:00
apidocs/src/samples Fix backup of mysql variants on Centos 2016-12-13 16:29:41 +00:00
contrib Fixes hacking rules 2015-05-29 07:27:59 +00:00
devstack Remove use of unsupported TEMPEST_SERVICES variable 2018-01-23 16:27:42 +03:00
doc Merge "Add Database service user guide" 2018-01-14 02:45:42 +00:00
etc fix a typo in documentation 2018-03-23 08:08:18 +08:00
integration Merge "Fix incorrect usage of assertTrue" 2018-02-27 18:31:11 +00:00
playbooks/legacy Import experimental Zuul jobs 2018-01-13 07:28:27 +01:00
releasenotes Avoid diverged slave when migrating MariaDB master 2018-03-09 10:51:41 +08:00
tools Use RootHistory to check if root is ever enabled 2018-02-28 09:14:36 +08:00
trove Fix dict iteration in PropertiesCodec 2018-04-16 16:13:23 +08:00
.coveragerc Update some information 2016-10-24 04:12:55 +00:00
.gitignore Generate policy sample file automatically. 2018-02-12 18:11:22 +08:00
.gitreview Renamed repos to trove. 2013-06-14 18:25:42 -04:00
.stestr.conf Fix guestagent.test_operating_system for Python3 2018-03-01 10:52:26 +08:00
.zuul.yaml add lower-constraints job 2018-03-22 19:07:53 -04:00
babel.cfg Setup trove for translation 2014-03-19 15:06:23 +01:00
CONTRIBUTING.rst Update URLs in documents according to document migration 2017-11-03 17:17:01 +08:00
generate_examples.py Fixes hacking rules 2015-05-29 07:27:59 +00:00
HACKING.rst Remove log translations 2018-01-24 17:21:26 +00:00
LICENSE
lower-constraints.txt Fix lower-constraints and uncap eventlet 2018-04-12 19:20:02 +08:00
pylintrc initial chkin of pylint 2016-09-14 13:56:24 -04:00
README.rst Update URLs in documents according to document migration 2017-11-03 17:17:01 +08:00
requirements.txt Fix lower-constraints and uncap eventlet 2018-04-12 19:20:02 +08:00
run_tests.py secure oslo_messaging.rpc 2017-01-11 07:56:35 -05:00
run_tests.sh Remove extraneous vim configuration comments 2014-02-27 15:05:21 +08:00
setup.cfg Remove entry of policy.json from setup.cfg 2018-02-28 12:03:29 +05:30
setup.py Updated from global requirements 2017-03-02 11:57:16 +00:00
test-requirements.txt Mox removal for instances_resize API tests 2018-03-22 17:51:10 +08:00
tox.ini add lower-constraints job 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