diff options
author | Han Zhou <zhouhan@gmail.com> | 2018-08-10 20:29:46 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-08-13 15:37:34 -0700 |
commit | d0bde28610dd59ffa3b8c5f11940e9efba636ded (patch) | |
tree | 0d98db958212d69743c217ff3a63d8a8f0adeb93 /tests | |
parent | acb511f91b6e2096fcef67341ec0ebb239d84da1 (diff) | |
download | openvswitch-d0bde28610dd59ffa3b8c5f11940e9efba636ded.tar.gz |
ovsdb-idl.c: Fix IDL index problem when rows are updated.
In current IDL index code it doesn't updated index when handling
"update2" messages, which is the default case. The consequence
is that when a row is updated, the index is not updated accordingly,
and even worse, it causes crash when calling ovsdb_idl_destroy().
It can be easily reproduced by the test cases added in this patch.
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ovsdb-idl.at | 34 | ||||
-rw-r--r-- | tests/test-ovsdb.c | 22 |
2 files changed, 44 insertions, 12 deletions
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index 014382850..8db6aa462 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -1509,16 +1509,21 @@ OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column te 006: i=19 006: i=20 006: i=54 -007: i=1 -007: i=1 -007: i=2 -007: i=2 -007: i=2 007: i=5 -007: i=10 007: i=19 007: i=20 +007: i=30 007: i=54 +008: i=1 +008: i=1 +008: i=2 +008: i=2 +008: i=2 +008: i=5 +008: i=19 +008: i=20 +008: i=30 +008: i=54 ], [002: i=1 s=List000 b=True r=101.000000 002: i=1 s=List001 b=False r=110.000000 @@ -1538,16 +1543,21 @@ OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column te 006: i=20 s=List020 b=True r=220.000000 006: i=5 s=List005 b=True r=130.000000 006: i=54 s=Lista054 b=False r=0.000000 -007: i=1 s=List000 b=True r=101.000000 -007: i=1 s=List001 b=False r=110.000000 -007: i=10 s=List000 b=True r=110.000000 007: i=19 s=List020 b=True r=219.000000 -007: i=2 s=List000 b=False r=102.000000 -007: i=2 s=List001 b=True r=120.000000 -007: i=2 s=List001 b=True r=122.000000 007: i=20 s=List020 b=True r=220.000000 +007: i=30 s=List000 b=True r=110.000000 007: i=5 s=List005 b=True r=130.000000 007: i=54 s=Lista054 b=False r=0.000000 +008: i=1 s=List000 b=True r=101.000000 +008: i=1 s=List001 b=False r=110.000000 +008: i=19 s=List020 b=True r=219.000000 +008: i=2 s=List000 b=False r=102.000000 +008: i=2 s=List001 b=True r=120.000000 +008: i=2 s=List001 b=True r=122.000000 +008: i=20 s=List020 b=True r=220.000000 +008: i=30 s=List000 b=True r=110.000000 +008: i=5 s=List005 b=True r=130.000000 +008: i=54 s=Lista054 b=False r=0.000000 ]) # Tests to verify the functionality of two column compound index. diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index e4e7d9035..793220400 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -2895,6 +2895,27 @@ test_idl_compound_index_single_column(struct ovsdb_idl *idl, myRow->s, myRow->b?"True":"False", myRow->r); } + /* Update record i=10 to i=30, make sure index is updated accordingly */ + ++step; + struct idltest_simple *toUpdate; + toUpdate = idltest_simple_index_init_row(i_index); + idltest_simple_index_set_i(toUpdate, 10); + ovs_assert(toUpdate->i == 10); + myRow = idltest_simple_index_find(i_index, toUpdate); + ovs_assert(myRow); + ovs_assert(myRow->i == 10); + txn = ovsdb_idl_txn_create(idl); + idltest_simple_set_i(myRow, 30); + ovsdb_idl_txn_commit_block(txn); + ovsdb_idl_txn_destroy(txn); + idltest_simple_index_set_i(to, 60); + printf("Expected 60, stored %"PRId64"\n", to->i); + ovs_assert(to->i == 60); + IDLTEST_SIMPLE_FOR_EACH_RANGE (myRow, from, to, i_index) { + printf("%03d: i=%"PRId64" s=%s b=%s r=%f\n", step, myRow->i, + myRow->s, myRow->b?"True":"False", myRow->r); + } + /* Test special-case range, "from" and "to" are both NULL, * which is interpreted as the range from -infinity to +infinity. */ ++step; @@ -2908,6 +2929,7 @@ test_idl_compound_index_single_column(struct ovsdb_idl *idl, idltest_simple_index_destroy_row(to); idltest_simple_index_destroy_row(equal); idltest_simple_index_destroy_row(toDelete); + idltest_simple_index_destroy_row(toUpdate); return step; } |