[ovs-dev] [vsctl prereqs 5/5] ovsdb-idl: Test prerequisite checking.
Justin Pettit
jpettit at nicira.com
Fri Oct 22 21:44:36 UTC 2010
Assuming it runs and doesn't blow up, then awesome!
--Justin
On Oct 22, 2010, at 12:55 PM, Ben Pfaff wrote:
> ---
> tests/ovsdb-idl.at | 35 +++++++++++++++++++++++++++++++++--
> tests/test-ovsdb.c | 29 ++++++++++++++++++++++++++++-
> 2 files changed, 61 insertions(+), 3 deletions(-)
>
> diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
> index b184e9d..3b4cfc8 100644
> --- a/tests/ovsdb-idl.at
> +++ b/tests/ovsdb-idl.at
> @@ -165,8 +165,8 @@ OVSDB_CHECK_IDL([simple idl, writing via IDL],
> {"op": "insert",
> "table": "simple",
> "row": {}}]']],
> - [['set 0 b 1, set 1 r 3.5' \
> - 'insert 2, delete 1']],
> + [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
> + 'insert 2, verify 2 i, verify 1 b, delete 1']],
> [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
> 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<3> <4>] uuid=<5>
> 001: commit, status=success
> @@ -178,6 +178,37 @@ OVSDB_CHECK_IDL([simple idl, writing via IDL],
> 005: done
> ]])
>
> +OVSDB_CHECK_IDL([simple idl, handling verification failure],
> + [['["idltest",
> + {"op": "insert",
> + "table": "simple",
> + "row": {"i": 1,
> + "r": 2.0}},
> + {"op": "insert",
> + "table": "simple",
> + "row": {}}]']],
> + [['set 0 b 1' \
> + '+["idltest",
> + {"op": "update",
> + "table": "simple",
> + "where": [["i", "==", 1]],
> + "row": {"r": 5.0}}]' \
> + '+verify 1 r, set 1 r 3' \
> + 'verify 1 r, set 1 r 3' \
> + ]],
> + [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
> +000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
> +001: commit, status=success
> +002: {"error":null,"result":[{"count":1}]}
> +003: commit, status=try again
> +004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
> +004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
> +005: commit, status=success
> +006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
> +006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
> +007: done
> +]])
> +
> OVSDB_CHECK_IDL([simple idl, increment operation],
> [['["idltest",
> {"op": "insert",
> diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
> index cdc939b..5a5a908 100644
> --- a/tests/test-ovsdb.c
> +++ b/tests/test-ovsdb.c
> @@ -1779,9 +1779,36 @@ idl_set(struct ovsdb_idl *idl, char *commands, int step)
> "i=%d", atoi(arg1));
> }
> idltest_simple_delete(s);
> + } else if (!strcmp(name, "verify")) {
> + const struct idltest_simple *s;
> +
> + if (!arg2 || arg3) {
> + ovs_fatal(0, "\"verify\" command requires 2 arguments");
> + }
> +
> + s = idltest_find_simple(idl, atoi(arg1));
> + if (!s) {
> + ovs_fatal(0, "\"verify\" command asks for nonexistent "
> + "i=%d", atoi(arg1));
> + }
> +
> + if (!strcmp(arg2, "i")) {
> + idltest_simple_verify_i(s);
> + } else if (!strcmp(arg2, "b")) {
> + idltest_simple_verify_b(s);
> + } else if (!strcmp(arg2, "s")) {
> + idltest_simple_verify_s(s);
> + } else if (!strcmp(arg2, "u")) {
> + idltest_simple_verify_s(s);
> + } else if (!strcmp(arg2, "r")) {
> + idltest_simple_verify_r(s);
> + } else {
> + ovs_fatal(0, "\"verify\" command asks for unknown column %s",
> + arg2);
> + }
> } else if (!strcmp(name, "increment")) {
> if (!arg2 || arg3) {
> - ovs_fatal(0, "\"set\" command requires 2 arguments");
> + ovs_fatal(0, "\"increment\" command requires 2 arguments");
> }
> ovsdb_idl_txn_increment(txn, arg1, arg2, NULL);
> increment = true;
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
More information about the dev
mailing list