blob: 13f276174008f8b62e31fd9909c85b87abad6a2d [file] [log] [blame]
Ashlesh Gawande6c86e302019-09-17 22:27:05 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
3# Copyright (C) 2015-2019, The University of Memphis,
4# Arizona Board of Regents,
5# Regents of the University of California.
6#
7# This file is part of Mini-NDN.
8# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
9#
10# Mini-NDN is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# Mini-NDN is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with Mini-NDN, e.g., in COPYING.md file.
22# If not, see <http://www.gnu.org/licenses/>.
23
24import time
25import sys
26
27from mininet.log import setLogLevel, info
28from mininet.topo import Topo
29
30from minindn.minindn import Minindn
31from minindn.apps.app_manager import AppManager
32from minindn.apps.nfd import Nfd
33
34if __name__ == '__main__':
35 setLogLevel('info')
36
37 topo = Topo()
38 topo.addHost('h1')
39
40 ndn = Minindn(topo=topo)
41 args = ndn.args
42
43 ndn.start()
44
45 nfds = AppManager(ndn, ndn.net.hosts, Nfd)
46
47 host1 = ndn.net.hosts[0]
48 host1.cmd('export NDN_LOG=examples.PartialSyncProducerApp=INFO')
49 host1.cmd('psync-producer /sync /{} 10 1 &> producer.log &'.format(host1.name))
50 time.sleep(1)
51
52 host1.cmd('export NDN_LOG=examples.PartialSyncConsumerApp=INFO:$NDN_LOG')
53 host1.cmd('psync-consumer /sync 5 &> consumer.log &')
54
55 info('Sleeping 90 seconds for convergence\n')
56 time.sleep(90)
57
58 consumerSubs = int(host1.cmd('cat consumer.log | grep -c Subscribing'))
59 consumerUpdates = int(host1.cmd('cat consumer.log | grep -c Update'))
60 producerPublish = int(host1.cmd('cat producer.log | grep -c Publish'))
61
62 if consumerSubs == 5 and consumerUpdates == 5 and producerPublish == 10:
63 info('PSync partial sync has successfully converged.\n')
64 else:
65 info('PSync partial sync convergence was not successful. Exiting...\n')
66 ndn.stop()
67 sys.exit(1)