Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit c990776

Browse files
authored
Merge pull request #295 from openweave/jexie/enable_serviceDir_lwip_tests
enable service-dir lwip tests
2 parents 7dad2fe + 6da2ca0 commit c990776

File tree

4 files changed

+50
-46
lines changed

4 files changed

+50
-46
lines changed

src/test-apps/happy/test-templates/WeaveServiceDir.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@ def __pre_check(self):
133133
self.client_ip = self.getNodeWeaveIPAddress(self.client)
134134

135135
# Check if all unknowns were found
136-
137-
if self.service_ip == None:
136+
# If device is tap device, IP will be assigned from lwip stack,
137+
# so no need to check IP here for tap devices
138+
if self.service_ip == None and not self.use_lwip:
138139
emsg = "Could not find IP address of the service."
139140
self.logger.error("[localhost] WeaveServiceDir: %s" % (emsg))
140141
self.exit()
141142

142-
if self.client_ip == None:
143+
if self.client_ip == None and not self.use_lwip:
143144
emsg = "Could not find IP address of the client."
144145
self.logger.error("[localhost] WeaveServiceDir: %s" % (emsg))
145146
self.exit()
@@ -197,8 +198,8 @@ def __start_client_side(self):
197198
if not cmd:
198199
return
199200

200-
cmd += " --node-addr " + self.client_ip
201-
cmd += " --service-dir-url " + self.service_ip
201+
self.client_weave_id = self.getWeaveNodeID(self.client)
202+
cmd += " --node-id " + str(self.client_weave_id)
202203
cmd += " --debug-resource-usage"
203204
cmd += " --print-fault-counters"
204205

@@ -207,16 +208,22 @@ def __start_client_side(self):
207208

208209
cmd += " --iterations " + str(self.iterations)
209210

210-
if self.tap:
211-
cmd += " --tap-device " + self.tap
211+
# if device is tap device, we need to provide tap interface and ipv4 gateway
212+
if self.use_lwip:
213+
cmd += " --tap-device " + self.client_tap
214+
cmd += " --ipv4-gateway " + self.client_ipv4_gateway
215+
cmd += " --node-addr " + self.client_node_addr
216+
cmd += " --service-dir-server " + self.service_node_addr
217+
else:
218+
cmd += " --node-addr " + self.client_ip
219+
cmd += " --service-dir-server " + self.service_ip
212220

213221
custom_env = {}
214222
if self.use_plaid:
215223
custom_env = self.plaid.getPlaidClientLibEnv(self.client)
216224

217225
self.start_weave_process(self.client, cmd, self.client_process_tag, strace=self.strace, env=custom_env)
218226

219-
220227
def __wait_for_client(self):
221228
self.wait_for_test_to_end(self.client, self.client_process_tag)
222229

@@ -243,8 +250,10 @@ def __start_service_side(self):
243250
cmd += " --node-id " + str(self.service_weave_id)
244251
cmd += " --fabric-id " + str(self.fabric_id)
245252

246-
if self.tap:
247-
cmd += " --tap-device " + self.tap
253+
if self.use_lwip:
254+
cmd += " --tap-device " + self.service_tap
255+
cmd += " --ipv4-gateway " + self.service_ipv4_gateway
256+
cmd += " --node-addr " + self.service_node_addr
248257

249258
if self.service_faults:
250259
cmd += " --faults " + self.service_faults

src/test-apps/happy/tests/standalone/servicedir/test_service_directory_01.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,36 @@
3636
import WeaveStateUnload
3737
import WeaveServiceDir
3838
import WeaveUtilities
39+
import subprocess
3940

4041
gFaultopts = WeaveUtilities.FaultInjectionOptions(nodes=["client", "service"])
4142
gOptions = { "fault-injection": False }
4243

4344
class test_service_directory_01(unittest.TestCase):
4445
def setUp(self):
45-
self.tap = None
46-
4746
if "WEAVE_SYSTEM_CONFIG_USE_LWIP" in os.environ.keys() and os.environ["WEAVE_SYSTEM_CONFIG_USE_LWIP"] == "1":
48-
self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \
49-
"/../../../topologies/standalone/thread_wifi_on_tap_ap_service.json"
50-
self.tap = "wpan0"
47+
self.use_lwip = True
48+
topology_shell_script = os.path.dirname(os.path.realpath(__file__)) + \
49+
"/../../../topologies/standalone/thread_wifi_on_tap_ap_service.sh"
50+
# tap interface, ipv4 gateway and node addr should be provided if device is tap device
51+
# both BorderRouter and cloud node are tap devices here
52+
self.BR_tap = "wlan0"
53+
self.BR_ipv4_gateway = "10.0.1.2"
54+
self.BR_node_addr = "10.0.1.3"
55+
self.cloud_tap = "eth0"
56+
self.cloud_ipv4_gateway = "192.168.100.2"
57+
self.cloud_node_addr = "192.168.100.3"
5158
else:
52-
self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \
53-
"/../../../topologies/standalone/thread_wifi_ap_service.json"
54-
55-
self.show_strace = False
56-
57-
# setting Mesh for thread test
58-
options = WeaveStateLoad.option()
59-
options["quiet"] = True
60-
options["json_file"] = self.topology_file
61-
62-
setup_network = WeaveStateLoad.WeaveStateLoad(options)
63-
ret = setup_network.run()
64-
59+
self.use_lwip = False
60+
topology_shell_script = os.path.dirname(os.path.realpath(__file__)) + \
61+
"/../../../topologies/standalone/thread_wifi_ap_service.sh"
62+
output = subprocess.call([topology_shell_script])
6563

6664
def tearDown(self):
6765
# cleaning up
68-
options = WeaveStateUnload.option()
69-
options["quiet"] = True
70-
options["json_file"] = self.topology_file
71-
72-
teardown_network = WeaveStateUnload.WeaveStateUnload(options)
73-
teardown_network.run()
74-
66+
subprocess.call(["happy-state-delete"])
7567

7668
def test_service_directory(self):
77-
# TODO: Once LwIP bugs are fix, enable this test on LwIP
78-
if "WEAVE_SYSTEM_CONFIG_USE_LWIP" in os.environ.keys() and os.environ["WEAVE_SYSTEM_CONFIG_USE_LWIP"] == "1":
79-
print hred("WARNING: Test skipped due to LwIP-based network cofiguration!")
80-
return
8169

8270
num_tests = 0
8371
num_failed_tests = 0
@@ -125,14 +113,20 @@ def __run_service_directory_test_between(self, nodeA, nodeB, num_iterations=1, f
125113
options["quiet"] = False
126114
options["client"] = nodeA
127115
options["service"] = nodeB
128-
options["tap"] = self.tap
116+
options["use_lwip"] = self.use_lwip
117+
if self.use_lwip:
118+
options["client_tap"] = self.BR_tap
119+
options["client_ipv4_gateway"] = self.BR_ipv4_gateway
120+
options["client_node_addr"] = self.BR_node_addr
121+
options["service_tap"] = self.cloud_tap
122+
options["service_ipv4_gateway"] = self.cloud_ipv4_gateway
123+
options["service_node_addr"] = self.cloud_node_addr
129124
options["client_faults"] = faults.get("client")
130125
options["service_faults"] = faults.get("service")
131126
options["iterations"] = num_iterations
132127
options["test_tag"] = test_tag
133128
options["plaid"] = "auto"
134129

135-
136130
service_dir = WeaveServiceDir.WeaveServiceDir(options)
137131
ret = service_dir.run()
138132

src/test-apps/happy/topologies/standalone/thread_wifi_ap_service.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# - one access-point router onhub
2424
# - one service node instance cloud
2525

26+
export PATH=$PATH:$(dirname $(readlink -f "$0"))/../../bin
2627
happy-network-add HomeThread thread
2728
happy-network-address HomeThread 2001:db8:111:1::
2829

src/test-apps/happy/topologies/standalone/thread_wifi_on_tap_ap_service.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
# - one access-point router onhub
2424
# - one service node instance cloud
2525

26+
# There is no need to set IP and Route for tap devices here, since it will be
27+
# assigned from lwip stack
28+
export PATH=$PATH:$(dirname $(readlink -f "$0"))/../../bin
2629
happy-network-add HomeThread thread
2730
happy-network-address HomeThread 2001:db8:111:1::
2831

@@ -45,13 +48,10 @@ happy-node-join onhub HomeWiFi
4548
happy-node-join onhub Internet
4649

4750
happy-node-add --service cloud
48-
happy-node-join cloud Internet
49-
50-
happy-network-route HomeThread BorderRouter
51-
happy-network-route --prefix 10.0.1.0 HomeWiFi onhub
51+
happy-node-join --tap cloud Internet
5252

5353
weave-fabric-add fab1
5454
weave-node-configure
5555
weave-network-gateway HomeThread BorderRouter
5656

57-
# happy-state -s thread_wifi_on_tap_ap_service.json
57+
# happy-state -s thread_wifi_on_tap_ap_service.json

0 commit comments

Comments
 (0)