diff --git a/bft b/bft index 365acd0e..f87709fe 100755 --- a/bft +++ b/bft @@ -215,9 +215,9 @@ def main(): else: n = t.__class__.__name__ for k, v in t.logged.items(): - info_for_remote_log[n + '.' + k] = v + info_for_remote_log[n + '-' + k] = v if hasattr(t, 'result_grade'): - info_for_remote_log[n + ".result"] = t.result_grade + info_for_remote_log[n + "-result"] = t.result_grade try: if config.logging_server is not None: diff --git a/devices/openwrt_router.py b/devices/openwrt_router.py index a9a48401..04eb770b 100644 --- a/devices/openwrt_router.py +++ b/devices/openwrt_router.py @@ -92,9 +92,11 @@ def reset(self, break_into_uboot=False): self.expect('Hit any key ') self.sendline('\n\n\n\n\n\n\n') # try really hard self.expect(self.uprompt, timeout=4) + # Confirm we are in uboot by typing any command. + # If we weren't in uboot, we wouldn't see the command + # that we type. self.sendline('echo FOO') self.expect('echo FOO', timeout=4) - self.expect('FOO') self.expect(self.uprompt, timeout=4) return except Exception as e: diff --git a/docs/ELK_SETUP.md b/docs/ELK_SETUP.md new file mode 100644 index 00000000..e0664081 --- /dev/null +++ b/docs/ELK_SETUP.md @@ -0,0 +1,89 @@ +ELK Setup +========= + +ELK is the short term for a software compilation used by BoardFarm to store, process and visualize test results. +ELK consists of three tools: + +* Elasticsearch +* Logstash +* Kibana + +For this basic setup guide, we won't even need Logstash as the results are already stored in the correct format in the Elasticsearch database. + +Installation +------------ + +This guide was written for Ubuntu 16.04 LTS and the following versions of Elasticsearch and Kibana: + +* Elasticsearch 2.3.3 +* Kibana 4.5.1 + +If you follow this guide and you can't get it working with newer versions, you should try again with these versions. + +### Prerequisites + +Elasticsearch and Logstash require Java. Elasticsearch recommends Oracle Java 8 but I had no issues using OpenJDK 8. Use whatever you prefer, I'll use OpenJDK in this guide. + + apt-get install -y openjdk-8-jre openjdk-8-jdk + +Now that we've installed Java, we can go on with Elasticsearch. + +### Installing Elasticsearch + +We'll just download the Elasticsearch Debian package and install it: + + wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.3/elasticsearch-2.3.3.deb + dpkg -i ./elasticsearch-2.3.3.deb + +You probably want Elasticsearch to automatically start every time you reboot your machine: + + systemctl enable elasticsearch + +Now let's edit the Elasticsearch configuration to restrict access from anywhere except the host itself: + + nano /etc/elasticsearch/elasticsearch.yml + +Look for a line containing 'network.host' and uncomment it. Set the value to 'localhost': + + network.host: localhost + +This will only allow the machine itself to access Elasticsearch on port 9200. Otherwise, anyone with network access to the machine could access your stored data or shut down the Elasticsearch server. + +Finally, restart Elasticsearch to apply the changed settings: + + systemctl restart elasticsearch + +### Installing Kibana + +Kibana is available as a 32-bit package and a 64-bit package, I'm using the 64-bit package in this guide: + + wget https://download.elastic.co/kibana/kibana/kibana_4.5.1_amd64.deb + dpkg -i ./kibana_4.5.1_amd64.deb + +As we did with Elasticsearch, we'll make Kibana automatically start on bootup: + + systemctl enable kibana + +You should now be able to access the Kibana webinterface on port 5601. Before visiting the webinterface for the first time, we want to store some data in the Elasticsearch database so Kibana has something to work with when we start it for the first time. + +### Configuring BoardFarm + +We need to tell BoardFarm to store the data in the Elasticsearch database by specifying the server address in BoardFarm's `config.py`. In this guide, I'm running BoardFarm, Elasticsearch and Kibana on the same host, so I'll use 'localhost' as the server address: + + elasticsearch_server = 'localhost' + +You should then run a few BoardFarm tests to store some data in the Elasticsearch database. After running the tests, you should see something like this at the end of the output: + + Elasticsearch: Data stored at localhost boardfarm-2016.07.05/bft_run/AVW6ozxZoiJNDeD5bFyj + +Now, we have data to work with. + +### Specifying an index pattern in Kibana + +When visiting the Kibana webinterface for the first time, you'll have to specify an index pattern so Kibana knows which logfiles to analyze. BoardFarm stores its data in the format boardfarm-\, so we'll tell Kibana to use 'boardfarm-\*' as the index pattern. +Kibana should then automatically recognize your existing database entries and suggest '@timestamp' as the time-field name. +Click 'create' and you're good to go. You should now see a table with a number of fields, e.g. 'board_type' or 'tests_total'. + +*Note: If you now run other testcases with new field names, you'll have to click the 'refresh field list' button at the top of the page, otherwise the new fields won't be displayed.* + +You can now go to the 'Discover' page to see your log entries or to the 'Visualize' page to create new visualizations. diff --git a/tests/iperf_udp_test.py b/tests/iperf_udp_test.py index c5bd66e8..c8d2c6ba 100644 --- a/tests/iperf_udp_test.py +++ b/tests/iperf_udp_test.py @@ -76,7 +76,7 @@ def server_opts_reverse(self, node=lan): lan_priv_ip = node.get_interface_ipaddr("eth1") except: lan_priv_ip = node.get_interface_ipaddr("wlan0") - board.uci_forward_traffic_redirect("tcp", "5001", lan_priv_ip) + board.uci_forward_traffic_redirect("udp", "5001", lan_priv_ip) self.rip = board.get_interface_ipaddr(board.wan_iface) return "" @@ -167,10 +167,10 @@ def forward_ip(self): return "192.168.1.1" def runTest(self): - super(iPerfNonRoutedTest, self).runTest(client=lan, server=board) + super(iPerfUDPNonRoutedTest, self).runTest(client=lan, server=board) def recover(self): - super(iPerfNonRoutedTest, self).recover(client=lan, server=board) + super(iPerfUDPNonRoutedTest, self).recover(client=lan, server=board) class iPerfUDPReverseTest(iPerfUDPTest): '''iPerf from WAN to LAN''' @@ -228,7 +228,7 @@ def reverse_ip(self): return "4aaa::6" def server_opts_reverse(self, node): - board.uci_forward_traffic_rule("tcp", "5001", "4aaa::6") + board.uci_forward_traffic_rule("udp", "5001", "4aaa::6") return "-V -B %s" % self.reverse_ip() def client_opts(self): @@ -236,7 +236,7 @@ def client_opts(self): def runTest(self): ipv6_setup.Set_IPv6_Addresses.runTest(self) - iPerfReverseTest.runTest(self) + iPerfUDPReverseTest.runTest(self) class iPerfUDPBiDirTest(iPerfUDPTest): '''iPerf from LAN to/from WAN''' @@ -308,7 +308,7 @@ def server_opts_forward(self): return "-V -B %s" % self.forward_ip() def server_opts_reverse(self, node): - board.uci_forward_traffic_rule("tcp", "5001", "4aaa::6") + board.uci_forward_traffic_rule("udp", "5001", "4aaa::6") return "-V -B %s" % self.reverse_ip() def client_opts(self): @@ -316,4 +316,4 @@ def client_opts(self): def runTest(self): ipv6_setup.Set_IPv6_Addresses.runTest(self) - iPerfBiDirTest.runTest(self) + iPerfUDPBiDirTest.runTest(self)