diff --git a/tools/cooja/contiki_tests/rest_rpl_coap.csc b/tools/cooja/contiki_tests/rest_rpl_coap.csc new file mode 100644 index 000000000..434809f6a --- /dev/null +++ b/tools/cooja/contiki_tests/rest_rpl_coap.csc @@ -0,0 +1,222 @@ + + + + REST with RPL router + -2147483648 + generated + 1000000 + + se.sics.cooja.radiomediums.UDGM + 50.0 + 50.0 + 1.0 + 1.0 + + + 40000 + + + se.sics.cooja.mspmote.SkyMoteType + rplroot + Sky RPL Root + [CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.c + make border-router.sky TARGET=sky DEFINES=NETSTACK_MAC=nullmac_driver,NETSTACK_RDC=nullrdc_driver,NULLRDC_CONF_802154_AUTOACK=0,CC2420_CONF_AUTOACK=0,ENERGEST_CONF_ON=0,PROCESS_CONF_NO_PROCESS_NAMES=1 + [CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.sky + se.sics.cooja.interfaces.Position + se.sics.cooja.interfaces.RimeAddress + se.sics.cooja.interfaces.IPAddress + se.sics.cooja.interfaces.Mote2MoteRelations + se.sics.cooja.interfaces.MoteAttributes + se.sics.cooja.mspmote.interfaces.MspClock + se.sics.cooja.mspmote.interfaces.MspMoteID + se.sics.cooja.mspmote.interfaces.SkyButton + se.sics.cooja.mspmote.interfaces.SkyFlash + se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem + se.sics.cooja.mspmote.interfaces.SkyByteRadio + se.sics.cooja.mspmote.interfaces.MspSerial + se.sics.cooja.mspmote.interfaces.SkyLED + se.sics.cooja.mspmote.interfaces.MspDebugOutput + se.sics.cooja.mspmote.interfaces.SkyTemperature + + + se.sics.cooja.mspmote.SkyMoteType + skyweb + Rest + [CONTIKI_DIR]/examples/er-rest-example/rest-server-example.c + make rest-server-example.sky TARGET=sky DEFINES=NETSTACK_MAC=nullmac_driver,NETSTACK_RDC=nullrdc_driver,NULLRDC_CONF_802154_AUTOACK=0,CC2420_CONF_AUTOACK=0,ENERGEST_CONF_ON=0,PROCESS_CONF_NO_PROCESS_NAMES=1 + [CONTIKI_DIR]/examples/er-rest-example/rest-server-example.sky + se.sics.cooja.interfaces.Position + se.sics.cooja.interfaces.RimeAddress + se.sics.cooja.interfaces.IPAddress + se.sics.cooja.interfaces.Mote2MoteRelations + se.sics.cooja.interfaces.MoteAttributes + se.sics.cooja.mspmote.interfaces.MspClock + se.sics.cooja.mspmote.interfaces.MspMoteID + se.sics.cooja.mspmote.interfaces.SkyButton + se.sics.cooja.mspmote.interfaces.SkyFlash + se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem + se.sics.cooja.mspmote.interfaces.SkyByteRadio + se.sics.cooja.mspmote.interfaces.MspSerial + se.sics.cooja.mspmote.interfaces.SkyLED + se.sics.cooja.mspmote.interfaces.MspDebugOutput + se.sics.cooja.mspmote.interfaces.SkyTemperature + + + + + se.sics.cooja.interfaces.Position + 33.260163187353555 + 30.643217359962595 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 1 + + rplroot + + + + + se.sics.cooja.interfaces.Position + 35.100895239785295 + 39.70574552287428 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 2 + + skyweb + + + + se.sics.cooja.plugins.SimControl + 259 + 6 + 179 + 0 + 0 + + + se.sics.cooja.plugins.Visualizer + + se.sics.cooja.plugins.skins.IDVisualizerSkin + se.sics.cooja.plugins.skins.UDGMVisualizerSkin + se.sics.cooja.plugins.skins.MoteTypeVisualizerSkin + se.sics.cooja.plugins.skins.AttributeVisualizerSkin + se.sics.cooja.plugins.skins.AddressVisualizerSkin + se.sics.cooja.plugins.skins.GridVisualizerSkin + 3.3323852179491644 0.0 0.0 3.3323852179491644 -30.392247168885415 -60.79227000363299 + + 176 + 5 + 173 + 259 + 3 + + + se.sics.cooja.plugins.LogListener + + + + + 582 + 2 + 393 + 6 + 259 + + + se.sics.cooja.plugins.RadioLogger + + 114 + + + 574 + -1 + 471 + 412 + 190 + true + + + SerialSocketServer + 0 + 428 + 4 + 74 + 7 + 181 + + + se.sics.cooja.plugins.TimeLine + + 0 + 1 + + + 23 + 24060.2737326431 + + 579 + 3 + 152 + 13 + 655 + + + se.sics.cooja.plugins.Notes + + Nightly test based on simulation in examples/er-rest-example/rest-server-example.csc: +* One REST server, and one RPL border router w. corresponding tun0 netif +* ContikiMAC is disabled to make firmwares fit on Tmote Sky nodes. +* Additional compile-time DEFINES used in this simulation: +NETSTACK_MAC=nullmac_driver +NETSTACK_RDC=nullrdc_driver +NULLRDC_CONF_802154_AUTOACK=0 +CC2420_CONF_AUTOACK=0 +ENERGEST_CONF_ON=0 +PROCESS_CONF_NO_PROCESS_NAMES=1 + +The test script communicates with the REST server via the RPL border router using external commands. +(* $ make connect-router-cooja) +* $ ping6 -c 10 -I tun0 aaaa::212:7401:1:101 +* $ ping6 -c 10 -I tun0 aaaa::212:7402:2:202 +* $ wget -t 1 -T 10 -O - http://[aaaa::212:7402:2:202] + +The final test uses CoAP to talk to the server, and requires an external Java library: +See: https://github.com/dapaulid/JCoAP +To download jar-file: $ wget --no-check-certificate http://github.com/dapaulid/JCoAP/raw/master/run/SampleClient.jar + + true + + 751 + 1 + 252 + 439 + 3 + + + se.sics.cooja.plugins.ScriptRunner + + [CONFIG_DIR]/rest_rpl_coap.js + true + + 600 + 0 + 584 + 592 + 260 + + + PowerTracker + 400 + -1 + 155 + 132 + 152 + true + + + diff --git a/tools/cooja/contiki_tests/rest_rpl_coap.js b/tools/cooja/contiki_tests/rest_rpl_coap.js new file mode 100644 index 000000000..75f6284ea --- /dev/null +++ b/tools/cooja/contiki_tests/rest_rpl_coap.js @@ -0,0 +1,155 @@ +TIMEOUT(300000); + +/* conf */ +ADDRESS_ROUTER = "aaaa::212:7401:1:101"; +ADDRESS_SERVER = "aaaa::212:7402:2:202"; +NR_PINGS = 10; +CMD_PING_PREFIX = "ping6 -c " + NR_PINGS + " -I tun0 "; +CMD_TUNNEL = "./tunslip6 -a 127.0.0.1 aaaa::1/64"; // "make connect-router-cooja"; +CMD_WGET_ROUTER = "wget -t 1 -T 10 -O - http:\/\/[" + ADDRESS_ROUTER + "]"; +CMD_WGET_SERVER = "wget -t 1 -T 10 -O - http:\/\/[" + ADDRESS_SERVER + "]"; +COAP_SAMPLECLIENT_JAR = "/home/user/JCoAP/SampleClient.jar"; + +/* delay */ +msg = ""; +GENERATE_MSG(5000, "continue"); +WAIT_UNTIL(msg.equals("continue")); + +/* override simulation delay to realtime */ +sim.setDelayTime(java.lang.Integer.MIN_VALUE); + +/* create tunnel interface */ +log.log("create tunnel interface\n"); +launcher = new java.lang.ProcessBuilder["(java.lang.String[])"](['sh','-c',CMD_TUNNEL]); +launcher.directory(new java.io.File("../../../tools")); +launcher.redirectErrorStream(true); +tunProcess = launcher.start(); +tunRunnable = new Object(); +tunRunnable.run = function() { + var stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(tunProcess.getInputStream())); + while ((line = stdIn.readLine()) != null) { + if (line != null && !line.trim().equals("")) { + log.log("TUN> " + line + "\n"); + } + } + tunProcess.destroy(); +} +new java.lang.Thread(new java.lang.Runnable(tunRunnable)).start(); + + +/* delay */ +msg = ""; +GENERATE_MSG(5000, "continue"); +WAIT_UNTIL(msg.equals("continue")); + + +/* help function for executing commands */ +processOutput = ""; +executeAndWait = function(cmd) { + log.log("EXEC>> " + cmd + "\n"); + + launcher = new java.lang.ProcessBuilder["(java.lang.String[])"](['sh','-c',cmd]); + launcher.redirectErrorStream(true); + process = launcher.start(); + runnable = new Object(); + runnable.run = function() { + var stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream())); + while ((line = stdIn.readLine()) != null) { + if (line != null && !line.trim().equals("")) { + log.log("PROCESS> " + line + "\n"); + processOutput += line + "\n"; + } + } + process.destroy(); + } + t = new java.lang.Thread(new java.lang.Runnable(runnable)); + t.start(); + + while (t.isAlive()) { + msg = ""; + GENERATE_MSG(1000, "continue"); + WAIT_UNTIL(msg.equals("continue")); + } +} + +/* PERFORM TESTS */ +testSummary = ""; +testFailed = false; + +/* ping tests */ +testname = "ping border router"; +log.log(testname + "\n"); +testSummary += testname; +processOutput = ""; +executeAndWait(CMD_PING_PREFIX + ADDRESS_ROUTER); +if (processOutput.indexOf("64 bytes from") != -1) { + testSummary += ": OK\n"; +} else { + testSummary += ": FAILED\n"; + testFailed = true; +} + +testname = "ping rest router"; +log.log(testname + "\n"); +testSummary += testname; +processOutput = ""; +executeAndWait(CMD_PING_PREFIX + ADDRESS_SERVER); +if (processOutput.indexOf("64 bytes from") != -1) { + testSummary += ": OK\n"; +} else { + testSummary += ": FAILED\n"; + testFailed = true; +} + + + +/* wget tests */ +testname = "wget border router"; +log.log(testname + "\n"); +testSummary += testname; +processOutput = ""; +executeAndWait(CMD_WGET_ROUTER); +if (processOutput.indexOf("ContikiRPL") != -1) { + testSummary += ": OK\n"; +} else { + testSummary += ": FAILED\n"; + testFailed = true; +} + + +/* coap tests: uses pre-downloaded dapaulid/JCoAP project's SampleClient.jar */ +testname = "coap discovery"; +log.log(testname + "\n"); +testSummary += testname; +processOutput = ""; +executeAndWait("java -jar " + COAP_SAMPLECLIENT_JAR + " DISCOVER coap:\/\/[" + ADDRESS_SERVER + "]"); +if (processOutput.indexOf("+[.well-known]") != -1) { + testSummary += ": OK\n"; +} else { + testSummary += ": FAILED\n"; + testFailed = true; +} + +testname = "coap get hello"; +log.log(testname + "\n"); +testSummary += testname; +processOutput = ""; +executeAndWait("java -jar " + COAP_SAMPLECLIENT_JAR + " GET coap:\/\/[" + ADDRESS_SERVER + "]/hello"); +if (processOutput.indexOf("Hello World!") != -1) { + testSummary += ": OK\n"; +} else { + testSummary += ": FAILED\n"; + testFailed = true; +} + + +log.log("\n\nTest finished. Summary:\n"); +log.log(testSummary + "\n"); + +tunProcess.destroy(); +if (testFailed) { + log.testFailed(); +} else { + log.testOK(); +} +