<commit_before>#!/usr/bin/env sh
# Script for running automated CBench regression tests
# TODO: Support latency and throughput modes
# TODO: Support for running against other controllers

# For remote runs, you must have .ssh/config setup such that `ssh $SSH_HOSTMANE` works w/o pw
# Example host setup in .ssh/config:
# Host cbench
#     Hostname 192.168.127.12
#     User fedora
#     IdentityFile /home/daniel/.ssh/id_rsa_nopass
#     StrictHostKeyChecking no

# Exit codes
EX_USAGE=64
EX_NOT_FOUND=65
EX_OK=0
EX_ERR=1

# Params for CBench test and ODL config
NUM_SWITCHES=256
NUM_MACS=100000
TESTS_PER_SWITCH=10  # Comment out to speed up testing of this script
#TESTS_PER_SWITCH=2  # ^^Then uncomment this one
MS_PER_TEST=10000
CBENCH_WARMUP=1
OSGI_PORT=2400
ODL_STARTUP_DELAY=90
ODL_RUNNING_STATUS=0
ODL_STOPPED_STATUS=255
ODL_BROKEN_STATUS=1
CONTROLLER="OpenDaylight"
CONTROLLER_IP="localhost"
#CONTROLLER_IP="172.18.14.26"
CONTROLLER_PORT=6633
SSH_HOSTNAME="cbenchc"

# Array that stores results in indexes defined by cols array
declare -a results

# The order of these array values determines column order in RESULTS_FILE
cols=(run_num cbench_avg start_time end_time controller_ip human_time
      num_switches num_macs tests_per_switch ms_per_test start_steal_time
      end_steal_time total_ram used_ram free_ram cpus one_min_load five_min_load
      fifteen_min_load controller start_iowait end_iowait)

# This two-stat-array system is needed until I find an answer to this question:
# http://goo.gl/e0M8Tp

# Associative array with stats-collecting commands for local system
declare -A local_stats_cmds
local_stats_cmds=([total_ram]="$(free -m | awk '/^Mem:/{print $2}')"
            [used_ram]="$(free -m | awk '/^Mem:/{print $3}')"
            [free_ram]="$(free -m | awk '/^Mem:/{print $4}')"
            [cpus]="`nproc`"
            [one_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $1}' | tr -d " "`"
            [five_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $2}' | tr -d " "`"
            [fifteen_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $3}' | tr -d " "`"
            [iowait]="`cat /proc/stat | awk 'NR==1 {print $6}'`"
            [steal_time]="`cat /proc/stat | awk 'NR==1 {print $9}'`")

# Associative array with stats-collecting commands for remote system
# See this for explanation of horrible-looking quoting: http://goo.gl/PMI5ag
declare -A remote_stats_cmds
remote_stats_cmds=([total_ram]='free -m | awk '"'"'/^Mem:/{print $2}'"'"''
            [used_ram]='free -m | awk '"'"'/^Mem:/{print $3}'"'"''
            [free_ram]='free -m | awk '"'"'/^Mem:/{print $4}'"'"''
            [cpus]='nproc'
            [one_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $1}'"'"' | tr -d " "'
            [five_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $2}'"'"' | tr -d " "'
            [fifteen_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $3}'"'"' | tr -d " "'
            [iowait]='cat /proc/stat | awk '"'"'NR==1 {print $6}'"'"''
            [steal_time]='cat /proc/stat | awk '"'"'NR==1 {print $9}'"'"'')

# Paths used in this script
BASE_DIR=$HOME
OF_DIR=$BASE_DIR/openflow
OFLOPS_DIR=$BASE_DIR/oflops
ODL_DIR=$BASE_DIR/opendaylight
ODL_ZIP="distributions-base-0.1.2-SNAPSHOT-osgipackage.zip"
ODL_ZIP_PATH=$BASE_DIR/$ODL_ZIP
PLUGIN_DIR=$ODL_DIR/plugins
RESULTS_FILE=$BASE_DIR/"results.csv"
CBENCH_LOG=$BASE_DIR/"cbench.log"
CBENCH_BIN="/usr/local/bin/cbench"
<commit_msg>Updated ODL zip URL, closes #27<commit_after>#!/usr/bin/env sh
# Script for running automated CBench regression tests
# TODO: Support latency and throughput modes
# TODO: Support for running against other controllers

# For remote runs, you must have .ssh/config setup such that `ssh $SSH_HOSTMANE` works w/o pw
# Example host setup in .ssh/config:
# Host cbench
#     Hostname 192.168.127.12
#     User fedora
#     IdentityFile /home/daniel/.ssh/id_rsa_nopass
#     StrictHostKeyChecking no

# Exit codes
EX_USAGE=64
EX_NOT_FOUND=65
EX_OK=0
EX_ERR=1

# Params for CBench test and ODL config
NUM_SWITCHES=256
NUM_MACS=100000
TESTS_PER_SWITCH=10  # Comment out to speed up testing of this script
#TESTS_PER_SWITCH=2  # ^^Then uncomment this one
MS_PER_TEST=10000
CBENCH_WARMUP=1
OSGI_PORT=2400
ODL_STARTUP_DELAY=90
ODL_RUNNING_STATUS=0
ODL_STOPPED_STATUS=255
ODL_BROKEN_STATUS=1
CONTROLLER="OpenDaylight"
CONTROLLER_IP="localhost"
#CONTROLLER_IP="172.18.14.26"
CONTROLLER_PORT=6633
SSH_HOSTNAME="cbenchc"

# Array that stores results in indexes defined by cols array
declare -a results

# The order of these array values determines column order in RESULTS_FILE
cols=(run_num cbench_avg start_time end_time controller_ip human_time
      num_switches num_macs tests_per_switch ms_per_test start_steal_time
      end_steal_time total_ram used_ram free_ram cpus one_min_load five_min_load
      fifteen_min_load controller start_iowait end_iowait)

# This two-stat-array system is needed until I find an answer to this question:
# http://goo.gl/e0M8Tp

# Associative array with stats-collecting commands for local system
declare -A local_stats_cmds
local_stats_cmds=([total_ram]="$(free -m | awk '/^Mem:/{print $2}')"
            [used_ram]="$(free -m | awk '/^Mem:/{print $3}')"
            [free_ram]="$(free -m | awk '/^Mem:/{print $4}')"
            [cpus]="`nproc`"
            [one_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $1}' | tr -d " "`"
            [five_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $2}' | tr -d " "`"
            [fifteen_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $3}' | tr -d " "`"
            [iowait]="`cat /proc/stat | awk 'NR==1 {print $6}'`"
            [steal_time]="`cat /proc/stat | awk 'NR==1 {print $9}'`")

# Associative array with stats-collecting commands for remote system
# See this for explanation of horrible-looking quoting: http://goo.gl/PMI5ag
declare -A remote_stats_cmds
remote_stats_cmds=([total_ram]='free -m | awk '"'"'/^Mem:/{print $2}'"'"''
            [used_ram]='free -m | awk '"'"'/^Mem:/{print $3}'"'"''
            [free_ram]='free -m | awk '"'"'/^Mem:/{print $4}'"'"''
            [cpus]='nproc'
            [one_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $1}'"'"' | tr -d " "'
            [five_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $2}'"'"' | tr -d " "'
            [fifteen_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $3}'"'"' | tr -d " "'
            [iowait]='cat /proc/stat | awk '"'"'NR==1 {print $6}'"'"''
            [steal_time]='cat /proc/stat | awk '"'"'NR==1 {print $9}'"'"'')

# Paths used in this script
BASE_DIR=$HOME
OF_DIR=$BASE_DIR/openflow
OFLOPS_DIR=$BASE_DIR/oflops
ODL_DIR=$BASE_DIR/opendaylight
ODL_ZIP="distributions-base-0.2.0-SNAPSHOT-osgipackage.zip"
ODL_ZIP_PATH=$BASE_DIR/$ODL_ZIP
PLUGIN_DIR=$ODL_DIR/plugins
RESULTS_FILE=$BASE_DIR/"results.csv"
CBENCH_LOG=$BASE_DIR/"cbench.log"
CBENCH_BIN="/usr/local/bin/cbench"

{'fraction_non_alphanumeric': 0.1803867403314917, 'fraction_numerical': 0.02541436464088398, 'mean_word_length': 3.9325613079019073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1582008', 'n_tokens_mistral': 2937, 'n_tokens_neox': 2798, 'n_words': 647}