From d409f739297c4ecbb06454601a5aab34221a5e04 Mon Sep 17 00:00:00 2001
From: MJB <mjb@it-innovation.soton.ac.uk>
Date: Wed, 14 Feb 2018 16:06:35 +0000
Subject: [PATCH] added streaming test to incrementally spawn vlc streams,
 jmeter fails to launch vlc from the command line so we'll go with bash for
 now

---
 Vagrantfile                                   |   3 +-
 infra/streaming/rspec.yml                     |  16 +--
 test/services/ffmpeg/install.sh               |   8 +-
 test/services/jmeter/install.sh               |  13 +-
 test/services/loadtest-streaming/install.sh   |  32 +++++
 .../loadtest-streaming/telegraf_template.conf | 112 ++++++++++++++++++
 test/services/vlc/install.sh                  |   4 +-
 test/streaming/run.sh                         |  47 ++++++++
 8 files changed, 215 insertions(+), 20 deletions(-)
 create mode 100644 test/services/loadtest-streaming/install.sh
 create mode 100644 test/services/loadtest-streaming/telegraf_template.conf
 create mode 100644 test/streaming/run.sh

diff --git a/Vagrantfile b/Vagrantfile
index d6485c9..af4f48e 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -90,7 +90,8 @@ Vagrant.configure("2") do |config|
           instance_config.vm.provision :shell, :path => "scripts/clmc-service/install.sh"
         else
           # specific service install
-          instance_config.vm.provision :shell, :path => "test/services/#{host["service_name"]}/install.sh"     
+          instance_config.vm.provision :shell, :path => "test/services/#{host["service_name"]}/install.sh", env: {"REPO_ROOT" => "/vagrant"}
+    
           # CLMC agent install
           instance_config.vm.provision :shell, :path => "scripts/clmc-agent/install.sh", :args => "/vagrant/test/services/#{host["service_name"]}/telegraf_template.conf #{host["location"]} #{host["sfc_id"]} #{host["sfc_id_instance"]} #{host["sf_id"]} #{host["sf_id_instance"]} #{host["ipendpoint_id"]} #{host["influxdb_url"]} #{host["database_name"]}"
       end
diff --git a/infra/streaming/rspec.yml b/infra/streaming/rspec.yml
index b2b15e4..8cbcda9 100644
--- a/infra/streaming/rspec.yml
+++ b/infra/streaming/rspec.yml
@@ -12,8 +12,8 @@ hosts:
         host: 9092
     ip_address: "192.168.50.10"
   - name: apache1
-    cpus: 1
-    memory: 2048
+    cpus: 2
+    memory: 4096
     disk: "10GB"
     service_name: "apache"
     forward_ports:
@@ -29,8 +29,8 @@ hosts:
     influxdb_url: "http://192.168.50.10:8086"
     database_name: "CLMCMetrics"
   - name: apache2
-    cpus: 1
-    memory: 2048
+    cpus: 2
+    memory: 4096
     disk: "10GB"
     service_name: "apache"
     forward_ports:
@@ -45,11 +45,11 @@ hosts:
     ipendpoint_id: "adaptive_streaming_I1_apache2"
     influxdb_url: "http://192.168.50.10:8086"
     database_name: "CLMCMetrics"
-  - name: vlc-client
-    cpus: 1
-    memory: 2048
+  - name: loadtest-streaming
+    cpus: 2
+    memory: 4096
     disk: "10GB"
-    service_name: "vlc"
+    service_name: "loadtest-streaming"
     forward_ports:
       - guest: 80
         host: 8083
diff --git a/test/services/ffmpeg/install.sh b/test/services/ffmpeg/install.sh
index 0f9a52b..02d6e1e 100644
--- a/test/services/ffmpeg/install.sh
+++ b/test/services/ffmpeg/install.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-sudo apt-get update
-sudo apt-get -y install zip python
+apt-get update
+apt-get -y install zip python
 
 wget http://zebulon.bok.net/Bento4/binaries/Bento4-SDK-1-5-1-621.x86_64-unknown-linux.zip
 unzip Bento4-SDK-1-5-1-621.x86_64-unknown-linux.zip
@@ -9,7 +9,7 @@ unzip Bento4-SDK-1-5-1-621.x86_64-unknown-linux.zip
 mv Bento4-SDK-1-5-1-621.x86_64-unknown-linux /opt/ 
 rm Bento4-SDK-1-5-1-621.x86_64-unknown-linux.zip
 
-sudo add-apt-repository ppa:jonathonf/ffmpeg-3
-sudo apt-get update && sudo apt -y install ffmpeg libav-tools x264 x265
+add-apt-repository -y ppa:jonathonf/ffmpeg-3
+apt-get update && apt -y install ffmpeg libav-tools x264 x265
 
 ffmpeg -version
diff --git a/test/services/jmeter/install.sh b/test/services/jmeter/install.sh
index 82bda7d..937af59 100644
--- a/test/services/jmeter/install.sh
+++ b/test/services/jmeter/install.sh
@@ -31,13 +31,16 @@ apt-get -y update
 # tell the oracle java installer the license has been read
 echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
 echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
-
 DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" oracle-java8-installer
 
 # install JMeter
-wget http://apache.mirrors.nublue.co.uk//jmeter/binaries/apache-jmeter-3.3.tgz -P /tmp
-tar -C /opt -xf /tmp/apache-jmeter-3.3.tgz
-rm -rf /tmp/apache-jmeter-3.3.tgz
+JMETER_VERSION="apache-jmeter-4.0"
+wget http://mirror.vorboss.net/apache//jmeter/binaries/$JMETER_VERSION.tgz -P /tmp
+tar -C /opt -xf /tmp/$JMETER_VERSION.tgz
+rm -rf /tmp/$JMETER_VERSION.tgz
 
 # Add jmeter to the path system wide
-echo 'PATH="'$PATH':/opt/apache-jmeter-3.3/bin"' > /etc/environment
+#echo 'PATH="'$PATH':/opt/'$JMETER_VERSION'/bin"' > /etc/environment
+
+echo 'PATH="'$PATH':/opt/apache-jmeter-4.0/bin"' > /etc/environment
+source /etc/environment
diff --git a/test/services/loadtest-streaming/install.sh b/test/services/loadtest-streaming/install.sh
new file mode 100644
index 0000000..8c1f2fb
--- /dev/null
+++ b/test/services/loadtest-streaming/install.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#/////////////////////////////////////////////////////////////////////////
+#//
+#// (c) University of Southampton IT Innovation Centre, 2017
+#//
+#// Copyright in this software belongs to University of Southampton
+#// IT Innovation Centre of Gamma House, Enterprise Road,
+#// Chilworth Science Park, Southampton, SO16 7NS, UK.
+#//
+#// This software may not be used, sold, licensed, transferred, copied
+#// or reproduced in whole or in part in any manner or form or in or
+#// on any media by any person other than in accordance with the terms
+#// of the Licence Agreement supplied with the software, or otherwise
+#// without the prior written consent of the copyright owners.
+#//
+#// This software is distributed WITHOUT ANY WARRANTY, without even the
+#// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#// PURPOSE, except where stated in the Licence Agreement supplied with
+#// the software.
+#//
+#//      Created By :            Michael Boniface
+#//      Created Date :          14/02/2018
+#//      Created for Project :   FLAME
+#//
+#/////////////////////////////////////////////////////////////////////////
+
+set -euo pipefail
+
+echo "REPO_ROOT:"$REPO_ROOT
+
+eval '$REPO_ROOT/test/services/vlc/install.sh'
+eval '$REPO_ROOT/test/services/jmeter/install.sh'
diff --git a/test/services/loadtest-streaming/telegraf_template.conf b/test/services/loadtest-streaming/telegraf_template.conf
new file mode 100644
index 0000000..3e30465
--- /dev/null
+++ b/test/services/loadtest-streaming/telegraf_template.conf
@@ -0,0 +1,112 @@
+# Telegraf configuration
+
+# Telegraf is entirely plugin driven. All metrics are gathered from the
+# declared inputs, and sent to the declared outputs.
+
+# Plugins must be declared in here to be active.
+# To deactivate a plugin, comment out the name and any variables.
+
+# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
+# file would generate.
+
+# Global tags can be specified here in key="value" format.
+[global_tags]
+  # location of the data centre
+  location="{{LOCATION}}"
+  # media service template id
+  sfc="{{SFC_ID}}"
+  # media service instance
+  sfc_i="{{SFC_ID_INSTANCE}}"
+  # service function type
+  sf="{{SF_ID}}"
+  # service function instance id
+  sf_i="{{SF_ID_INSTANCE}}"
+  # ipendpoint id aka surrogate instance
+  ipendpoint="{{IP_ENDPOINT_ID}}"
+
+# Configuration for telegraf agent
+[agent]
+  ## Default data collection interval for all inputs
+  interval = "10s"
+  ## Rounds collection interval to 'interval'
+  ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
+  round_interval = true
+
+  ## Telegraf will cache metric_buffer_limit metrics for each output, and will
+  ## flush this buffer on a successful write.
+  metric_buffer_limit = 1000
+  ## Flush the buffer whenever full, regardless of flush_interval.
+  flush_buffer_when_full = true
+
+  ## Collection jitter is used to jitter the collection by a random amount.
+  ## Each plugin will sleep for a random time within jitter before collecting.
+  ## This can be used to avoid many plugins querying things like sysfs at the
+  ## same time, which can have a measurable effect on the system.
+  collection_jitter = "0s"
+
+  ## Default flushing interval for all outputs. You shouldn't set this below
+  ## interval. Maximum flush_interval will be flush_interval + flush_jitter
+  flush_interval = "10s"
+  ## Jitter the flush interval by a random amount. This is primarily to avoid
+  ## large write spikes for users running a large number of telegraf instances.
+  ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
+  flush_jitter = "0s"
+
+  ## Logging configuration:
+  ## Run telegraf in debug mode
+  debug = false
+  ## Run telegraf in quiet mode
+  quiet = false
+  ## Specify the log file name. The empty string means to log to stdout.
+  logfile = "/var/log/telegraf/telegraf.log"
+
+  ## Override default hostname, if empty use os.Hostname()
+  hostname = ""
+
+
+###############################################################################
+#                                  OUTPUTS                                    #
+###############################################################################
+
+# Configuration for influxdb server to send metrics to
+[[outputs.influxdb]]
+  # The full HTTP or UDP endpoint URL for your InfluxDB instance.
+  # Multiple urls can be specified but it is assumed that they are part of the same
+  # cluster, this means that only ONE of the urls will be written to each interval.
+  # urls = ["udp://127.0.0.1:8089"] # UDP endpoint example
+  urls = ["{{INFLUXDB_URL}}"] # required
+  # The target database for metrics (telegraf will create it if not exists)
+  database = "{{DATABASE_NAME}}" # required
+  # Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h".
+  # note: using second precision greatly helps InfluxDB compression
+  precision = "s"
+
+  ## Write timeout (for the InfluxDB client), formatted as a string.
+  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
+  timeout = "5s"
+  # username = "telegraf"
+  # password = "metricsmetricsmetricsmetrics"
+  # Set the user agent for HTTP POSTs (can be useful for log differentiation)
+  # user_agent = "telegraf"
+  # Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
+  # udp_payload = 512
+
+
+###############################################################################
+#                                  INPUTS                                     #
+###############################################################################
+# # Influx HTTP write listener
+[[inputs.http_listener]]
+  ## Address and port to host HTTP listener on
+  service_address = ":8186"
+
+  ## timeouts
+  read_timeout = "10s"
+  write_timeout = "10s"
+
+  ## HTTPS
+  #tls_cert= "/etc/telegraf/cert.pem"
+  #tls_key = "/etc/telegraf/key.pem"
+
+  ## MTLS
+  #tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]
\ No newline at end of file
diff --git a/test/services/vlc/install.sh b/test/services/vlc/install.sh
index 149406d..02e3b8f 100644
--- a/test/services/vlc/install.sh
+++ b/test/services/vlc/install.sh
@@ -24,6 +24,6 @@
 #//
 #/////////////////////////////////////////////////////////////////////////
 
-sudo add-apt-repository ppa:videolan/master-daily
-sudo apt-get update
+add-apt-repository -y ppa:videolan/master-daily
+apt-get update
 apt-get -y install vlc
\ No newline at end of file
diff --git a/test/streaming/run.sh b/test/streaming/run.sh
new file mode 100644
index 0000000..b9f4999
--- /dev/null
+++ b/test/streaming/run.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#/////////////////////////////////////////////////////////////////////////
+#//
+#// (c) University of Southampton IT Innovation Centre, 2017
+#//
+#// Copyright in this software belongs to University of Southampton
+#// IT Innovation Centre of Gamma House, Enterprise Road,
+#// Chilworth Science Park, Southampton, SO16 7NS, UK.
+#//
+#// This software may not be used, sold, licensed, transferred, copied
+#// or reproduced in whole or in part in any manner or form or in or
+#// on any media by any person other than in accordance with the terms
+#// of the Licence Agreement supplied with the software, or otherwise
+#// without the prior written consent of the copyright owners.
+#//
+#// This software is distributed WITHOUT ANY WARRANTY, without even the
+#// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#// PURPOSE, except where stated in the Licence Agreement supplied with
+#// the software.
+#//
+#//      Created By :            Michael Boniface
+#//      Created Date :          13/12/2017
+#//      Created for Project :   FLAME
+#//
+#/////////////////////////////////////////////////////////////////////////
+
+# create test directories
+testfolder=$(date +%Y%m%d%H%M%S)
+testrundir="/vagrant/test/run"
+testdir=$testrundir"/streaming/"$testfolder
+echo "Test directory: "$testdir
+mkdir -p  "$testdir"
+
+# run testplan
+cd $testdir
+
+# jmeter -n -LDEBUG -t /vagrant/test/streaming/testplan.jmx -l results.jtx -j jmeter.log
+
+COUNTER=0
+while [  $COUNTER -lt 20 ]; do
+  cvlc -Vdummy --no-audio http://192.168.50.11/test_video/stream.mpd &
+  sleep 1
+  let COUNTER=COUNTER+1 
+done
+
+
+
-- 
GitLab