Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / tests / ovs-xapi-sync.at
1 AT_BANNER([ovs-xapi-sync])
2
3 AT_SETUP([ovs-xapi-sync])
4 AT_SKIP_IF([test $HAVE_PYTHON = no])
5
6 # Mock up the XenAPI.
7 cp "$top_srcdir/tests/MockXenAPI.py" XenAPI.py
8 PYTHONPATH=`pwd`:$PYTHONPATH
9 export PYTHONPATH
10
11 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
12 OVS_DBDIR=`pwd`; export OVS_DBDIR
13 OVS_PKGDATADIR=`pwd`; export OVS_PKGDATADIR
14 cp "$top_srcdir/vswitchd/vswitch.ovsschema" .
15
16 cp "$top_srcdir/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync" \
17    ovs-xapi-sync
18
19 ON_EXIT([kill `cat pid ovs-xapi-sync.pid`])
20
21 mkdir var var/run
22 touch var/run/xapi_init_complete.cookie
23
24 ovs_vsctl () {
25     ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket "$@"
26 }
27
28 # Start ovsdb-server.
29 OVS_VSCTL_SETUP
30
31 # Start ovs-xapi-sync.
32 AT_CHECK([$PYTHON ./ovs-xapi-sync "--pidfile=`pwd`/ovs-xapi-sync.pid" \
33                   "--root-prefix=`pwd`" unix:socket >log 2>&1 &])
34 AT_CAPTURE_FILE([log])
35
36 # Add bridges and check ovs-xapi-sync's work.
37 AT_CHECK([ovs_vsctl -- add-br xenbr0 -- add-br xenbr1])
38 OVS_WAIT_UNTIL([test "X`ovs_vsctl get bridge xenbr0 fail-mode`" != "X[[]]"])
39 AT_CHECK([ovs_vsctl \
40                 -- get bridge xenbr0 fail-mode other-config external-ids \
41                 -- get bridge xenbr1 fail-mode other-config external-ids], [0],
42          [[secure
43 {}
44 {bridge-id="custom bridge ID"}
45 secure
46 {disable-in-band="true"}
47 {}
48 ]])
49
50 # Add vif and check daemon's work.
51 AT_CHECK([ovs_vsctl \
52                 -- add-port xenbr0 vif1.0 \
53                 -- set Interface vif1.0 'external-ids={attached-mac="00:11:22:33:44:55", xs-network-uuid="9b66c68b-a74e-4d34-89a5-20a8ab352d1e", xs-vif-uuid="6ab1b260-398e-49ba-827b-c7696108964c", xs-vm-uuid="fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8"'}])
54 OVS_WAIT_UNTIL([ovs_vsctl get interface vif1.0 external-ids:iface-id >/dev/null 2>&1])
55 AT_CHECK([ovs_vsctl get interface vif1.0 external-ids], [0],
56   [{attached-mac="00:11:22:33:44:55", iface-id="custom iface ID", iface-status=active, vm-id="custom vm ID", xs-network-uuid="9b66c68b-a74e-4d34-89a5-20a8ab352d1e", xs-vif-uuid="6ab1b260-398e-49ba-827b-c7696108964c", xs-vm-uuid="fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8"}
57 ])
58
59 # Add corresponding tap and check daemon's work.
60 AT_CHECK([ovs_vsctl add-port xenbr0 tap1.0])
61 OVS_WAIT_UNTIL([ovs_vsctl get interface tap1.0 external-ids:iface-id >/dev/null 2>&1])
62 AT_CHECK([ovs_vsctl \
63                 -- get interface vif1.0 external-ids \
64                 -- get interface tap1.0 external-ids], [0],
65   [{attached-mac="00:11:22:33:44:55", iface-id="custom iface ID", iface-status=inactive, vm-id="custom vm ID", xs-network-uuid="9b66c68b-a74e-4d34-89a5-20a8ab352d1e", xs-vif-uuid="6ab1b260-398e-49ba-827b-c7696108964c", xs-vm-uuid="fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8"}
66 {attached-mac="00:11:22:33:44:55", iface-id="custom iface ID", iface-status=active, vm-id="custom vm ID", xs-network-uuid="9b66c68b-a74e-4d34-89a5-20a8ab352d1e", xs-vif-uuid="6ab1b260-398e-49ba-827b-c7696108964c", xs-vm-uuid="fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8"}
67 ])
68
69 # Remove corresponding tap and check daemon's work.
70 AT_CHECK([ovs_vsctl del-port tap1.0])
71 OVS_WAIT_UNTIL([test `ovs_vsctl get interface vif1.0 external-ids:iface-status` = active])
72 AT_CHECK([ovs_vsctl get interface vif1.0 external-ids], [0],
73   [{attached-mac="00:11:22:33:44:55", iface-id="custom iface ID", iface-status=active, vm-id="custom vm ID", xs-network-uuid="9b66c68b-a74e-4d34-89a5-20a8ab352d1e", xs-vif-uuid="6ab1b260-398e-49ba-827b-c7696108964c", xs-vm-uuid="fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8"}
74 ])
75
76 OVSDB_SERVER_SHUTDOWN
77
78 AT_CLEANUP