From patchwork Sat Apr 30 00:03:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aymerich, Edward" X-Patchwork-Id: 617005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3qxW4t74PGz9t6v for ; Sat, 30 Apr 2016 10:03:58 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 42E11102D5; Fri, 29 Apr 2016 17:03:58 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 0B86010170 for ; Fri, 29 Apr 2016 17:03:57 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 8D39342046B for ; Fri, 29 Apr 2016 18:03:56 -0600 (MDT) X-ASG-Debug-ID: 1461974635-09eadd135c692c0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar5.cudamail.com with ESMTP id dNxOFwM0Y0YBNMJG (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 29 Apr 2016 18:03:55 -0600 (MDT) X-Barracuda-Envelope-From: edward.aymerich@hpe.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO na01-by2-obe.outbound.protection.outlook.com) (207.46.100.106) by mx3-pf2.cudamail.com with ESMTPS (AES256-SHA encrypted); 30 Apr 2016 00:03:54 -0000 Received-SPF: none (mx3-pf2.cudamail.com: domain at hpe.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 207.46.100.106 X-Barracuda-RBL-IP: 207.46.100.106 Received: from TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM (10.162.187.148) by TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM (10.162.187.148) with Microsoft SMTP Server (TLS) id 15.1.477.8; Sat, 30 Apr 2016 00:03:52 +0000 Received: from TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM ([10.162.187.148]) by TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM ([10.162.187.148]) with mapi id 15.01.0477.014; Sat, 30 Apr 2016 00:03:52 +0000 X-CudaMail-Envelope-Sender: edward.aymerich@hpe.com From: "Aymerich, Edward" To: "' (dev@openvswitch.org)'" X-CudaMail-MID: CM-V2-428055455 X-CudaMail-DTE: 042916 X-CudaMail-Originating-IP: 207.46.100.106 Thread-Topic: [PATCH 3/3] tests: Add test for Partial Map Updates X-ASG-Orig-Subj: [##CM-V2-428055455##][PATCH 3/3] tests: Add test for Partial Map Updates Thread-Index: AdGic6Ff9YesR0I0TreLz6o00oSIRg== Date: Sat, 30 Apr 2016 00:03:52 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: openvswitch.org; dkim=none (message not signed) header.d=none; openvswitch.org; dmarc=none action=none header.from=hpe.com; x-originating-ip: [201.195.119.46] x-ms-office365-filtering-correlation-id: c75691dc-b147-4519-1226-08d3708aea11 x-microsoft-exchange-diagnostics: 1; TU4PR84MB0142; 5:1xmoqMt1XK6RoVRZo6v9BFMYCW0HDlnLohyeuwVg0N/9+WEygLxoDIUhy95To0yPkTfT82rWYe1af6EDCxRVKb7gUIjL+f/pZljmzI+PP+V6iPWTIJev2ZmxEs5tylnkYkwYAEVNvPlBjFfOcLdL9A==; 24:VJSKBBQXsAS58CnOU9fgAeGqVggZ86NpJSc3+hNln1xY+by+pjpKmQVNJNmQ+AX2grZRW1W1sejZ6EQfE55ubvyvUDHHQZ5gdbwuZoo+kJE=; 7:8rTeCM2oU1zrQ3U7L6aUttDZo0ViDZwqz8hZ7Zmx8RgBTc7wYWBZc1P80xBuUEqpCJzSWwvvbRlnoWbSLkzs1ZwKIHkDJ7qy4EyucrH8ZfyYmnIIJDzkTt1gMEKKVU/a2dYrrOFpMix9hBnJJLAtBXV1JvH2o11jMhBQFBWzAy78RfiVA1DFYTL3biXLEjek x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:TU4PR84MB0142; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(9101521072)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:TU4PR84MB0142; BCL:0; PCL:0; RULEID:; SRVR:TU4PR84MB0142; x-forefront-prvs: 0928072091 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(86362001)(54356999)(99286002)(15650500001)(189998001)(586003)(450100001)(9686002)(107886002)(110136002)(229853001)(33656002)(19580395003)(19580405001)(5008740100001)(1096002)(5002640100001)(1220700001)(50986999)(66066001)(3846002)(81166005)(5003600100002)(2906002)(5004730100002)(122556002)(102836003)(87936001)(15975445007)(92566002)(3660700001)(77096005)(551934003)(10400500002)(2900100001)(3280700002)(11100500001); DIR:OUT; SFP:1102; SCL:1; SRVR:TU4PR84MB0142; H:TU4PR84MB0142.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2016 00:03:52.2438 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR84MB0142 X-GBUdb-Analysis: 0, 207.46.100.106, Ugly c=0.308711 p=-0.4 Source Normal X-MessageSniffer-Rules: 0-0-0-25773-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1461974635 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.10 X-Barracuda-Spam-Status: No, SCORE=0.10 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.29166 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Subject: [ovs-dev] [PATCH 3/3] tests: Add test for Partial Map Updates X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" Insert basic functionality for testing partial update column and add a new test table named "simple2". Signed-off-by: Edward Aymerich Signed-off-by: Arnoldo Lutz Co-authored-by: Arnoldo Lutz --- The corresponding pull request is available here: https://github.com/openvswitch/ovs/pull/121 tests/idltest.ovsschema | 79 ++++++++++++++++++++++---------- tests/idltest2.ovsschema | 29 ++++++++++++ tests/ovsdb-idl.at | 33 ++++++++++++++ tests/test-ovsdb.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 231 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/tests/idltest.ovsschema b/tests/idltest.ovsschema index 1d073aa..5482234 100644 --- a/tests/idltest.ovsschema +++ b/tests/idltest.ovsschema @@ -6,7 +6,7 @@ "columns": { "i": { "type": "integer" - }, + }, "k": { "type": { "key": { @@ -14,17 +14,17 @@ "refTable": "link1" } } - }, + }, "ka": { "type": { "key": { "type": "uuid", "refTable": "link1" }, - "max": "unlimited", + "max": "unlimited", "min": 0 } - }, + }, "l2": { "type": { "key": { @@ -35,12 +35,12 @@ } } } - }, + }, "link2": { "columns": { "i": { "type": "integer" - }, + }, "l1": { "type": { "key": { @@ -51,60 +51,89 @@ } } } - }, + }, "simple": { "columns": { "b": { "type": "boolean" - }, + }, "ba": { "type": { - "key": "boolean", + "key": "boolean", "max": 1, "min": 0 } - }, + }, "i": { "type": "integer" - }, + }, "ia": { "type": { - "key": "integer", - "max": "unlimited", + "key": "integer", + "max": "unlimited", "min": 0 } - }, + }, "r": { "type": "real" - }, + }, "ra": { "type": { - "key": "real", - "max": "unlimited", + "key": "real", + "max": "unlimited", "min": 0 } - }, + }, "s": { "type": "string" - }, + }, "sa": { "type": { - "key": "string", - "max": "unlimited", + "key": "string", + "max": "unlimited", "min": 0 } - }, + }, "u": { "type": "uuid" - }, + }, "ua": { "type": { - "key": "uuid", - "max": "unlimited", + "key": "uuid", + "max": "unlimited", "min": 0 } } } + }, + "simple2" : { + "columns" : { + "name" : { + "type": "string" + }, + "smap" : { + "type": { + "key" : "string", + "value": "string", + "min": 0, + "max": "unlimited" + } + }, + "imap": { + "type" : { + "key": { + "type" : "integer", + "minInteger" : 0, + "maxInteger" : 4095 + }, + "value": { + "type" : "string" + }, + "min": 0, + "max": "unlimited" + } + } + } } } } diff --git a/tests/idltest2.ovsschema b/tests/idltest2.ovsschema index 312c9cc..5cf61d1 100644 --- a/tests/idltest2.ovsschema +++ b/tests/idltest2.ovsschema @@ -80,6 +80,35 @@ } } } + }, + "simple2" : { + "columns" : { + "name" : { + "type": "string" + }, + "smap" : { + "type": { + "key" : "string", + "value": "string", + "min": 0, + "max": "unlimited" + } + }, + "imap": { + "type" : { + "key": { + "type" : "integer", + "minInteger" : 0, + "maxInteger" : 4095 + }, + "value": { + "type" : "string" + }, + "min": 0, + "max": "unlimited" + } + } + } } } } diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index 33d508c..4683c4e 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -800,3 +800,36 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops], 014: updated columns: ba i ia r ra s 015: done ]]) + +m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN], + [AT_SETUP([$1 - C]) + AT_KEYWORDS([ovsdb server idl partial update map column positive $5]) + AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema], + [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + m4_if([$2], [], [], + [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])]) + AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3], + [0], [stdout], [ignore], [kill `cat pid`]) + AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + [0], [$4], [], [kill `cat pid`]) + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + +OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN([map, simple2 idl-partial-update-map-column, initially populated], +[['["idltest", {"op":"insert", "table":"simple2", + "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]'] +], +[], +[[000: Getting records +001: name=myString1 smap=[[key1 : value1],[key2 : value2]] imap=[] +002: After insert element +003: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]] +004: After insert duplicated element +005: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]] +006: After delete element +007: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]] +008: After trying to delete a deleted element +009: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]] +010: End test +]]) diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index dbb6897..dfa6e16 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -198,7 +198,11 @@ usage(void) " connect to SERVER and dump the contents of the database\n" " as seen initially by the IDL implementation and after\n" " executing each TRANSACTION. (Each TRANSACTION must modify\n" - " the database or this command will hang.)\n", + " the database or this command will hang.)\n" + " idl-partial-update-map-column SERVER \n" + " connect to SERVER and executes different operations to\n" + " test the capacity of updating elements inside a map column\n" + " displaying the table information after each operation.\n", program_name, program_name); vlog_usage(); printf("\nOther options:\n" @@ -2179,6 +2183,114 @@ do_idl(struct ovs_cmdl_context *ctx) printf("%03d: done\n", step); } +static void +print_idl_row_simple2(const struct idltest_simple2 *s, int step) +{ + size_t i; + const struct ovsdb_datum *smap, *imap; + + smap = idltest_simple2_get_smap(s, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING); + imap = idltest_simple2_get_imap(s, OVSDB_TYPE_INTEGER, OVSDB_TYPE_STRING); + printf("%03d: name=%s smap=[", + step, s->name); + for (i = 0; i < smap->n; i++) { + printf("[%s : %s]%s", smap->keys[i].string, smap->values[i].string, + i < smap->n-1? ",": ""); + } + printf("] imap=["); + for (i = 0; i < imap->n; i++) { + printf("[%"PRId64" : %s]%s", imap->keys[i].integer, imap->values[i].string, + i < imap->n-1? ",":""); + } + printf("]\n"); +} + +static void +dump_simple2(struct ovsdb_idl *idl, + const struct idltest_simple2 *myRow, + int step) +{ + IDLTEST_SIMPLE2_FOR_EACH(myRow, idl) { + print_idl_row_simple2(myRow, step); + } +} + + +static void +do_idl_partial_update_map_column(struct ovs_cmdl_context *ctx) +{ + struct ovsdb_idl *idl; + struct ovsdb_idl_txn *myTxn; + const struct idltest_simple2 *myRow; + const struct ovsdb_datum *smap, *imap OVS_UNUSED; + int step = 0; + char key_to_delete[100]; + + idltest_init(); + idl = ovsdb_idl_create(ctx->argv[1], &idltest_idl_class, false, true); + ovsdb_idl_add_table(idl, &idltest_table_simple2); + ovsdb_idl_add_column(idl, &idltest_simple2_col_name); + ovsdb_idl_add_column(idl, &idltest_simple2_col_smap); + ovsdb_idl_add_column(idl, &idltest_simple2_col_imap); + ovsdb_idl_get_initial_snapshot(idl); + setvbuf(stdout, NULL, _IONBF, 0); + ovsdb_idl_run(idl); + + /* Display original data in table */ + printf("%03d: Getting records\n", step++); + dump_simple2(idl, myRow, step++); + + /* Insert new elements in different map columns */ + myRow = idltest_simple2_first(idl); + myTxn = ovsdb_idl_txn_create(idl); + smap = idltest_simple2_get_smap(myRow, OVSDB_TYPE_STRING, + OVSDB_TYPE_STRING); + idltest_simple2_update_smap_setkey(myRow, "key1", "myList1"); + imap = idltest_simple2_get_imap(myRow, OVSDB_TYPE_INTEGER, + OVSDB_TYPE_STRING); + idltest_simple2_update_imap_setkey(myRow, 3, "myids2"); + idltest_simple2_set_name(myRow, "String2"); + ovsdb_idl_txn_commit_block(myTxn); + ovsdb_idl_txn_destroy(myTxn); + ovsdb_idl_get_initial_snapshot(idl); + printf("%03d: After insert element\n", step++); + dump_simple2(idl, myRow, step++); + + /* Insert duplicate element */ + myTxn = ovsdb_idl_txn_create(idl); + idltest_simple2_update_smap_setkey(myRow, "key1", "myList1"); + ovsdb_idl_txn_commit_block(myTxn); + ovsdb_idl_txn_destroy(myTxn); + ovsdb_idl_get_initial_snapshot(idl); + printf("%03d: After insert duplicated element\n", step++); + dump_simple2(idl, myRow, step++); + + /* deletes an element of a map column */ + myRow = idltest_simple2_first(idl); + myTxn = ovsdb_idl_txn_create(idl); + smap = idltest_simple2_get_smap(myRow, OVSDB_TYPE_STRING, + OVSDB_TYPE_STRING); + strcpy(key_to_delete, smap->keys[0].string); + idltest_simple2_update_smap_delkey(myRow, smap->keys[0].string); + ovsdb_idl_txn_commit_block(myTxn); + ovsdb_idl_txn_destroy(myTxn); + ovsdb_idl_get_initial_snapshot(idl); + printf("%03d: After delete element\n", step++); + dump_simple2(idl, myRow, step++); + + /* try to delete a deleted element of a map column */ + myTxn = ovsdb_idl_txn_create(idl); + idltest_simple2_update_smap_delkey(myRow, key_to_delete); + ovsdb_idl_txn_commit_block(myTxn); + ovsdb_idl_txn_destroy(myTxn); + ovsdb_idl_get_initial_snapshot(idl); + printf("%03d: After trying to delete a deleted element\n", step++); + dump_simple2(idl, myRow, step++); + + printf("%03d: End test\n", step); + return; +} + static struct ovs_cmdl_command all_commands[] = { { "log-io", NULL, 2, INT_MAX, do_log_io }, { "default-atoms", NULL, 0, 0, do_default_atoms }, @@ -2207,6 +2319,8 @@ static struct ovs_cmdl_command all_commands[] = { { "execute", NULL, 2, INT_MAX, do_execute }, { "trigger", NULL, 2, INT_MAX, do_trigger }, { "idl", NULL, 1, INT_MAX, do_idl }, + { "idl-partial-update-map-column", NULL, 1, INT_MAX, + do_idl_partial_update_map_column }, { "help", NULL, 0, INT_MAX, do_help }, { NULL, NULL, 0, 0, NULL }, };