4 # Copyright 2016 RIFT.IO Inc
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
32 gi
.require_version('CF', '1.0')
33 gi
.require_version('RwDts', '1.0')
34 gi
.require_version('RwMain', '1.0')
35 gi
.require_version('RwManifestYang', '1.0')
36 gi
.require_version('RwLaunchpadYang', '1.0')
37 gi
.require_version('RwcalYang', '1.0')
38 gi
.require_version('RwTypes', '1.0')
39 import gi
.repository
.CF
as cf
40 import gi
.repository
.RwDts
as rwdts
41 import gi
.repository
.RwMain
as rwmain
42 import gi
.repository
.RwManifestYang
as rwmanifest
43 import gi
.repository
.IetfL2TopologyYang
as l2Tl
44 import gi
.repository
.RwTopologyYang
as RwTl
45 import gi
.repository
.RwLaunchpadYang
as launchpadyang
46 from gi
.repository
import RwsdnalYang
47 from gi
.repository
.RwTypes
import RwStatus
49 from create_stackedl2topology
import MyL2Topology
50 from create_stackedProvNettopology
import MyProvTopology
51 from create_stackedVMNettopology
import MyVMTopology
52 from create_stackedSfctopology
import MySfcTopology
58 if sys
.version_info
< (3, 4, 4):
59 asyncio
.ensure_future
= asyncio
.async
62 class TopMgrTestCase(rift
.test
.dts
.AbstractDTSTest
):
65 def configure_suite(cls
, rwmain
):
66 vns_mgr_dir
= os
.environ
.get('VNS_MGR_DIR')
68 cls
.rwmain
.add_tasklet(vns_mgr_dir
, 'rwvnstasklet')
71 def configure_schema(cls
):
72 return RwTl
.get_schema()
75 def wait_tasklets(self
):
76 yield from asyncio
.sleep(1, loop
=self
.loop
)
79 def configure_timeout(cls
):
84 def configure_l2_network(self
, dts
):
85 nwtop
= RwTl
.YangData_IetfNetwork()
86 l2top
= MyL2Topology(nwtop
, self
.log
)
88 nw_xpath
= "C,/nd:network"
89 self
.log
.info("Configuring l2 network: %s",nwtop
)
90 yield from dts
.query_create(nw_xpath
,
91 rwdts
.XactFlag
.ADVISE
,
95 def configure_prov_network(self
, dts
):
96 nwtop
= RwTl
.YangData_IetfNetwork()
97 l2top
= MyL2Topology(nwtop
, self
.log
)
100 provtop
= MyProvTopology(nwtop
, l2top
, self
.log
)
102 nw_xpath
= "C,/nd:network"
103 self
.log
.info("Configuring provider network: %s",nwtop
)
104 yield from dts
.query_create(nw_xpath
,
105 rwdts
.XactFlag
.ADVISE
,
109 def configure_vm_network(self
, dts
):
110 nwtop
= RwTl
.YangData_IetfNetwork()
111 l2top
= MyL2Topology(nwtop
, self
.log
)
114 provtop
= MyProvTopology(nwtop
, l2top
, self
.log
)
117 vmtop
= MyVMTopology(nwtop
, l2top
, provtop
, self
.log
)
119 nw_xpath
= "C,/nd:network"
120 self
.log
.info("Configuring VM network: %s",nwtop
)
121 yield from dts
.query_create(nw_xpath
,
122 rwdts
.XactFlag
.ADVISE
,
126 def configure_sfc_network(self
, dts
):
127 nwtop
= RwTl
.YangData_IetfNetwork()
128 l2top
= MyL2Topology(nwtop
, self
.log
)
131 provtop
= MyProvTopology(nwtop
, l2top
, self
.log
)
134 vmtop
= MyVMTopology(nwtop
, l2top
, provtop
, self
.log
)
137 sfctop
= MySfcTopology(nwtop
, l2top
, provtop
, vmtop
, self
.log
)
140 nw_xpath
= "C,/nd:network"
141 self
.log
.info("Configuring SFC network: %s",nwtop
)
142 yield from dts
.query_create(nw_xpath
,
143 rwdts
.XactFlag
.ADVISE
,
147 #@unittest.skip("Skipping test_network_config")
148 def test_network_config(self
):
149 self
.log
.debug("STARTING - test_network_config")
150 tinfo
= self
.new_tinfo('static_network')
151 dts
= rift
.tasklets
.DTS(tinfo
, self
.schema
, self
.loop
)
158 yield from asyncio
.sleep(120, loop
=self
.loop
)
159 yield from self
.configure_l2_network(dts
)
160 yield from self
.configure_prov_network(dts
)
161 yield from self
.configure_vm_network(dts
)
162 yield from self
.configure_sfc_network(dts
)
164 future
= asyncio
.ensure_future(run_test(), loop
=self
.loop
)
165 self
.run_until(future
.done
)
166 if future
.exception() is not None:
167 self
.log
.error("Caught exception during test")
168 raise future
.exception()
170 self
.log
.debug("DONE - test_network_config")
173 plugin_dir
= os
.path
.join(os
.environ
["RIFT_INSTALL"], "usr/lib/rift/plugins")
175 if 'VNS_MGR_DIR' not in os
.environ
:
176 os
.environ
['VNS_MGR_DIR'] = os
.path
.join(plugin_dir
, 'rwvns')
178 if 'MESSAGE_BROKER_DIR' not in os
.environ
:
179 os
.environ
['MESSAGE_BROKER_DIR'] = os
.path
.join(plugin_dir
, 'rwmsgbroker-c')
181 if 'ROUTER_DIR' not in os
.environ
:
182 os
.environ
['ROUTER_DIR'] = os
.path
.join(plugin_dir
, 'rwdtsrouter-c')
184 runner
= xmlrunner
.XMLTestRunner(output
=os
.environ
["RIFT_MODULE_TEST"])
185 unittest
.main(testRunner
=runner
)
187 if __name__
== '__main__':