[ovs-dev,1/3] tests: Refactor macros so OVN databases can be initialized individually.
diff mbox

Message ID 1444251436-26967-1-git-send-email-blp@nicira.com
State Accepted
Headers show

Commit Message

Ben Pfaff Oct. 7, 2015, 8:57 p.m. UTC
I want to write a test for ovn-controller without ovn-northd getting
involved.

Signed-off-by: Ben Pfaff <blp@nicira.com>
---
 tests/ofproto-macros.at | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

Comments

Justin Pettit Oct. 7, 2015, 9 p.m. UTC | #1
Acked-by: Justin Pettit <jpettit@nicira.com>

--Justin


> On Oct 7, 2015, at 1:57 PM, Ben Pfaff <blp@nicira.com> wrote:
> 
> I want to write a test for ovn-controller without ovn-northd getting
> involved.
> 
> Signed-off-by: Ben Pfaff <blp@nicira.com>
> ---
> tests/ofproto-macros.at | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
> index 260dca4..a5aee3a 100644
> --- a/tests/ofproto-macros.at
> +++ b/tests/ofproto-macros.at
> @@ -108,19 +108,28 @@ as() {
>     fi
> }
> 
> +# ovn_init_db DATABASE
> +#
> +# Creates and initializes the given DATABASE (one of "ovn-sb" or "ovn-nb")
> +# and starts its ovsdb-server instance.
> +#
> +# Usually invoked from ovn_start.
> +ovn_init_db () {
> +    echo "creating $1 database"
> +    local d=$ovs_base/$1
> +    mkdir "$d" || return 1
> +    : > "$d"/.$1.db.~lock~
> +    as $1 ovsdb-tool create "$d"/$1.db "$abs_top_srcdir"/ovn/$1.ovsschema
> +    as $1 start_daemon ovsdb-server --remote=punix:"$d"/$1.sock "$d"/$1.db
> +}
> +
> # ovn_start
> #
> # Creates and initializes ovn-sb and ovn-nb databases and starts their
> # ovsdb-server instance, and starts ovn-northd running against them.
> ovn_start () {
> -    for db in ovn-sb ovn-nb; do
> -        echo "creating $db database"
> -        d=$ovs_base/$db
> -        mkdir "$d" || return 1
> -        : > "$d"/.$db.db.~lock~
> -        as $db ovsdb-tool create "$d"/$db.db "$abs_top_srcdir"/ovn/$db.ovsschema
> -        as $db start_daemon ovsdb-server --remote=punix:"$d"/$db.sock "$d"/$db.db
> -    done
> +    ovn_init_db ovn-sb
> +    ovn_init_db ovn-nb
> 
>     OVN_NB_DB=unix:$ovs_base/ovn-nb/ovn-nb.sock; export OVN_NB_DB
> 
> -- 
> 2.1.3
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev

Patch
diff mbox

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 260dca4..a5aee3a 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -108,19 +108,28 @@  as() {
     fi
 }
 
+# ovn_init_db DATABASE
+#
+# Creates and initializes the given DATABASE (one of "ovn-sb" or "ovn-nb")
+# and starts its ovsdb-server instance.
+#
+# Usually invoked from ovn_start.
+ovn_init_db () {
+    echo "creating $1 database"
+    local d=$ovs_base/$1
+    mkdir "$d" || return 1
+    : > "$d"/.$1.db.~lock~
+    as $1 ovsdb-tool create "$d"/$1.db "$abs_top_srcdir"/ovn/$1.ovsschema
+    as $1 start_daemon ovsdb-server --remote=punix:"$d"/$1.sock "$d"/$1.db
+}
+
 # ovn_start
 #
 # Creates and initializes ovn-sb and ovn-nb databases and starts their
 # ovsdb-server instance, and starts ovn-northd running against them.
 ovn_start () {
-    for db in ovn-sb ovn-nb; do
-        echo "creating $db database"
-        d=$ovs_base/$db
-        mkdir "$d" || return 1
-        : > "$d"/.$db.db.~lock~
-        as $db ovsdb-tool create "$d"/$db.db "$abs_top_srcdir"/ovn/$db.ovsschema
-        as $db start_daemon ovsdb-server --remote=punix:"$d"/$db.sock "$d"/$db.db
-    done
+    ovn_init_db ovn-sb
+    ovn_init_db ovn-nb
 
     OVN_NB_DB=unix:$ovs_base/ovn-nb/ovn-nb.sock; export OVN_NB_DB