2 # Copyright (c) 2019 Erik Schilling
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 from emuvim
.api
.openstack
.openstack_api_endpoint
import OpenstackApiEndpoint
21 from emuvim
.api
.osm
.kafka
import Kafka
22 from emuvim
.api
.osm
.lcm
import LCM
23 from emuvim
.api
.osm
.mongo
import Mongo
24 from emuvim
.api
.osm
.mysql
import Mysql
25 from emuvim
.api
.osm
.nbi
import NBI
26 from emuvim
.api
.osm
.ro
import RO
27 from emuvim
.api
.osm
.zookeeper
import Zookeeper
28 from emuvim
.dcemulator
.net
import DCNetwork
29 from mininet
.link
import TCLink
30 from mininet
.log
import setLogLevel
38 class TimeoutException(Exception):
42 def timeout_handler(signum
, frame
):
43 raise TimeoutException
46 signal
.signal(signal
.SIGALRM
, timeout_handler
)
48 with
open('osm_component_increasing_delay_%d.csv' % time
.time(), 'w') as csvfile
:
49 fieldnames
= ['delay', 'startup', 'deployment', 'deletion', 'failed', 'other',
50 'zookeeper', 'kafka', 'mongo', 'nbi', 'ro_db', 'ro', 'lcm',
51 'rtt_ro_db_ms', 'rtt_db_ro_ms']
52 writer
= csv
.DictWriter(csvfile
, fieldnames
=fieldnames
)
55 for delay
in range(0, MAX_MS_DELAY
+ 1, STEP
):
57 net
= DCNetwork(monitor
=False, enable_learning
=True)
61 dc1
= net
.addDatacenter("dc1")
62 api
= OpenstackApiEndpoint("0.0.0.0", 6001)
63 api
.connect_datacenter(dc1
)
64 api
.connect_dc_network(net
)
66 s1
= net
.addSwitch('s1')
68 zookeeper_ip
= '10.0.0.96'
69 kafka_ip
= '10.0.0.97'
70 mongo_ip
= '10.0.0.98'
72 ro_db_ip
= '10.0.0.100'
76 d1
= net
.addDocker('d1', dimage
='ubuntu:trusty')
78 VERSION
= 'releasefive-daily'
80 zookeeper
= Zookeeper(net
, zookeeper_ip
)
81 kafka
= Kafka(net
, kafka_ip
, zookeeper_ip
)
82 mongo
= Mongo(net
, mongo_ip
)
83 nbi
= NBI(net
, nbi_ip
, mongo_ip
, kafka_ip
)
84 ro_db
= Mysql(net
, ro_db_ip
)
85 ro
= RO(net
, ro_ip
, ro_db_ip
, version
=VERSION
)
86 lcm
= LCM(net
, lcm_ip
, ro_ip
, mongo_ip
, kafka_ip
)
89 delay_string
= '%dms' % delay
90 net
.addLink(zookeeper
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
91 net
.addLink(kafka
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
92 net
.addLink(mongo
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
93 net
.addLink(nbi
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
94 net
.addLink(ro_db
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
95 net
.addLink(ro
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
96 net
.addLink(lcm
.instance
, s1
, cls
=TCLink
, delay
=delay_string
)
101 other_end
= time
.time()
103 zookeeper_started
= time
.time()
105 kafka_started
= time
.time()
107 mongo_started
= time
.time()
109 nbi_started
= time
.time()
111 ro_db_started
= time
.time()
113 ro_started
= time
.time()
115 lcm_started
= time
.time()
117 vim_id
= nbi
.register_emulated_api('vim-emu1', api
)
118 nbi
.onboard_vnfd('../vnfs/ping_vnf')
119 nbi
.onboard_vnfd('../vnfs/pong_vnf')
120 nsd_id
= nbi
.onboard_nsd('../services/pingpong_ns')
122 start_done
= time
.time()
125 result
= net
.pingFull(hosts
=[ro
.instance
, ro_db
.instance
])
126 rtt_ro_db
= result
[0][2][3]
127 rtt_db_ro
= result
[1][2][3]
129 deploy_start
= time
.time()
131 ns_id
= nbi
.ns_create('pingpong-test-%d' % delay
, nsd_id
, vim_id
)
133 _
, num_failed
= nbi
.ns_wait_until_all_in_status('running', 'failed')
135 deployment_done
= time
.time()
139 nbi
.ns_wait_until_all_in_status('terminated')
141 ns_delete_done
= time
.time()
145 'other': other_end
- start
,
146 'zookeeper': zookeeper_started
- other_end
,
147 'kafka': kafka_started
- zookeeper_started
,
148 'mongo': mongo_started
- kafka_started
,
149 'nbi': nbi_started
- mongo_started
,
150 'ro_db': ro_db_started
- nbi_started
,
151 'ro': ro_started
- ro_db_started
,
152 'lcm': lcm_started
- ro_started
,
153 'startup': start_done
- start
,
154 'deployment': deployment_done
- deploy_start
,
155 'deletion': ns_delete_done
- deployment_done
,
156 'failed': num_failed
,
157 'rtt_ro_db_ms': rtt_ro_db
,
158 'rtt_db_ro_ms': rtt_db_ro
,
161 except Exception as e
:
162 print('caught: %s' % e
)
177 'rtt_ro_db_ms': None,
178 'rtt_db_ro_ms': None,