summaryrefslogtreecommitdiff
path: root/automated/linux/nginx-server/odp-dpdk.sh
diff options
context:
space:
mode:
authorJosep Puigdemont <josep.puigdemont@linaro.org>2017-03-17 10:01:49 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-04-19 09:02:32 +0000
commit6cdfbb5fcf3d939d11661bc5bf4aa3c496beb898 (patch)
treeb0a04269b01b8103d8aeac9ac312f59dd5e76114 /automated/linux/nginx-server/odp-dpdk.sh
parentea26a7cc5ddd2a7b01b1f96f4876c1fdb7783e5f (diff)
downloadtest-definitions-pipe-6cdfbb5fcf3d939d11661bc5bf4aa3c496beb898.tar.gz
nginx-server: use configuration files and callbaks
NGiNX can be installed in different places, and can be implemented using different IP stacks (Linux IP stack, OFP, ANS...). The nginx-server.sh script was meant to be used independently of he NGiNX version in use. Due to this it contains several initialization and configuration functions for each of the currently supported implementations. This could grow a bit too large for one single file, so we've opted for creating files with a set of required functions for each implementation. The file is sourced and it should define some functions used for the tests. The name of the file should be that of the CONFIG_TYPE defined for the test definition, plus the .sh suffix. The functions required to be implemented in the files are: - do_configure_system(): used to initialize the tests. Here any configuration required for the test, like NIC configuration, kernel module loading, etc, should be done. It is called once before any test starts. - do_start_nginx(): this function is used to start NGiNX. - do_stop_nginx(): this function is used to stop NGiNX. It may be called even if NGiNX is not running. - do_write_nginx_config(): this function is called before starting NGiNX, and it is meant to write a proper nginx.conf file for the current number of cores. - do_pre_test_cb(): this function is called before starting NGiNX, it can be used for anything deemed appropriate. - do_post_test_cb(): this function is called right after the test has finished, and before NGiNX is stopped. It can be used for anything deemed appropriate. All functions are called with the following parameters in this order: - cores: number of cores of the current test. For configure_sytem, this is the total number of physical cores available. - interface: this is the interface that NGiNX is expected to use. - IP: the IP that the web server is expected to use. The return value of the functions is not checked. Change-Id: I0321697509f9ac628e705c69285a7478dd993ace Signed-off-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Diffstat (limited to 'automated/linux/nginx-server/odp-dpdk.sh')
-rw-r--r--automated/linux/nginx-server/odp-dpdk.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/automated/linux/nginx-server/odp-dpdk.sh b/automated/linux/nginx-server/odp-dpdk.sh
new file mode 100644
index 0000000..f078e05
--- /dev/null
+++ b/automated/linux/nginx-server/odp-dpdk.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+exit_error() {
+ echo "-- SERVER ERROR"
+ journalctl -u nginx
+ lava-test-case server_up --status fail
+}
+trap exit_error ERR
+
+do_configure_system() {
+ local cores=$1
+ local vland_iface=$2
+ local server_ip=$3
+ local driver=${DPDK_DRIVER:-igb_uio}
+ local pci_dev=
+
+ pci_dev=$(basename "$(readlink -f "/sys/class/net/${vland_iface}/device")")
+
+ if ! which dpdk-devbind &>/dev/null; then
+ echo "ERROR: dpdk not installed"
+ exit 1
+ fi
+
+ modprobe "$driver"
+
+ dpdk-devbind -u "$pci_dev"
+ dpdk-devbind -b "$driver" "$pci_dev"
+ dpdk-devbind -s
+
+ apt-get install -y nginx
+ systemctl stop nginx
+
+ # when using write_config, we need to have /www mounted
+ configure_ramdisk
+
+ WRITE_CONFIG_CORE=""
+ WRITE_CONFIG_EVENTS="use select;"
+ WRITE_CONFIG_LISTEN="listen $server_ip:80 default_server so_keepalive=off;"
+
+ # FIXME: for now NGiNX for OFP only supports one core worker
+ echo "-- NOTICE: setting MAX_CORES to 1"
+ MAX_CORES=1
+
+ echo <<-EOF
+ WRITE_CONFIG_CORE=$WRITE_CONFIG_CORE
+ WRITE_CONFIG_EVENTS=$WRITE_CONFIG_EVENTS
+ WRITE_CONFIG_LISTEN=$WRITE_CONFIG_LISTEN
+ MAX_CORES=$MAX_CORES
+ EOF
+
+}
+
+do_stop_nginx() {
+ systemctl stop nginx
+}
+
+do_start_nginx() {
+ systemctl start nginx
+}
+
+do_write_nginx_config() {
+ local cores=$1
+ local vland_iface=$2
+ local server_ip=$3
+
+ # when using write_config, we need to have /www mounted
+ write_config "$cores" /etc/nginx/nginx.conf
+}
+
+do_pre_test_cb() {
+ local cores=$1
+ local vland_iface=$2
+ local server_ip=$3
+
+ rm -rf /dev/hugepages/*
+}
+
+do_post_test_cb() {
+ local cores=$1
+ local vland_iface=$2
+ local server_ip=$3
+ local pid
+
+ systemctl status nginx
+ echo "-- AFFINITY $cores"
+ for pid in $(pgrep nginx); do
+ taskset -p "$pid"
+ done
+}
+
+echo "-- odp-dpdk NGiNX initialized" >&2