Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation suite updated to support Jenkins and 'Single host to multi… #46

Merged
merged 1 commit into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def build_each_tool(dirname, section_name, des_build_file, arch='x86_86'):
FOLDER.caliper_log_file), shell=True)
result = subprocess.call("%s %s %s %s %s >> %s 2>&1"
% (des_build_file, arch,
CALIPER_DIR, TMP_DIR, "/".join(WS_GEN_DIR.split('/')[4:]), log_file),
CALIPER_DIR, TMP_DIR, "/".join(WS_GEN_DIR.split('/')[-2:]), log_file),
shell=True)
except Exception:
logging.info('There is exception when building the benchmarks')
Expand Down
2 changes: 1 addition & 1 deletion server/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ build_prepare() {

caliper_exists=$(which caliper)
if [ "$caliper_exists"x != ""x ]; then
INSTALL_DIR="/home/$(whoami)/caliper_output/$OBJPATH"
INSTALL_DIR="$HOME/caliper_output/$OBJPATH"
BENCH_PATH=$TMP_DIR/$BENCH_PATH
CURRENT_PATH=""
else
Expand Down
39 changes: 21 additions & 18 deletions server/run/write_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,26 @@ def round_perf(score):

def write_yaml_perf(yaml_file, tmp, result, kind=1):
flag = 0
if not os.path.exists(yaml_file):
os.mknod(yaml_file)
if yaml_file.endswith("_score.yaml"):
file_name = yaml_file.split('/')[-1]
file_name = file_name.split("_score")[0] + ".yaml"
abs_path = yaml_file.split('/')
abs_path[-1] = file_name
file_name = "/".join(abs_path)
with open(yaml_file,'w') as fp:
tp = open(file_name)
dic = yaml.load(tp)
dic_new = {}
dic_new['Configuration'] = {}
dic_new['Configuration'] = dic['Configuration']
dic_new['name'] = {}
dic_new['name'] = dic['name']
fp.write(yaml.dump(dic_new,default_flow_style=False))
try:
if not os.path.exists(yaml_file):
os.mknod(yaml_file)
if yaml_file.endswith("_score.yaml"):
file_name = yaml_file.split('/')[-1]
file_name = file_name.split("_score")[0] + ".yaml"
abs_path = yaml_file.split('/')
abs_path[-1] = file_name
file_name = "/".join(abs_path)
with open(yaml_file,'w') as fp:
tp = open(file_name)
dic = yaml.load(tp)
dic_new = {}
dic_new['Configuration'] = {}
dic_new['Configuration'] = dic['Configuration']
dic_new['name'] = {}
dic_new['name'] = dic['name']
fp.write(yaml.dump(dic_new,default_flow_style=False))
except:
pass
fp = open(yaml_file)
result = round_perf(result)
x = yaml.load(fp)
Expand Down Expand Up @@ -483,4 +486,4 @@ def normalize_score(results):
if total_str not in test_point_dic:
test_point_dic[total_str] = {}
test_point_dic[total_str] = round(total_sub_items_result, 2)
return results
return results
19 changes: 19 additions & 0 deletions utils/automation_scripts/.automationconfig/automation_X.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[SERVER]
ip =
user =
password =

[HOST]
ip =
user =
password =

[CLIENT]
Platform_name =
ip =
user =
password =
autoSetupSystem =
checkDependency =
caliper_option =
mount_point =
Binary file added utils/automation_scripts/Automation_UserDoc.docx
Binary file not shown.
6 changes: 6 additions & 0 deletions utils/automation_scripts/Database_cfg/Database_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[DATABASE]
ip =
user =
password =
folder =

6 changes: 6 additions & 0 deletions utils/automation_scripts/Database_cfg/Database_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[DATABASE]
ip =
user =
password =
folder =

6 changes: 6 additions & 0 deletions utils/automation_scripts/Database_cfg/Database_3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[DATABASE]
ip =
user =
password =
folder =

6 changes: 6 additions & 0 deletions utils/automation_scripts/Database_cfg/Database_template.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[DATABASE]
ip =
user =
password =
folder =

Binary file added utils/automation_scripts/Jenkins_Setup.docx
Binary file not shown.
28 changes: 0 additions & 28 deletions utils/automation_scripts/Readme.txt

This file was deleted.

216 changes: 216 additions & 0 deletions utils/automation_scripts/Scripts/automation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#!/bin/bash
# -*- coding:utf-8 -*-
#################################################
# #
# Author : Dikshit N #
# E-mail : dikshit.n@huawei.com #
# Date : 22/04/16 #
# #
#################################################

automationFile="../.automationconfig/automation_$1.cfg"
testFile="../testlist/testlist_$1"
copycfg="../Database_cfg/Database_$1"
server_def="/server_cases_def.cfg"
client_def="/common_cases_def.cfg"
wspath="$HOME/caliper_output/"
workspace=""
foldername=""
folder=""
checkDependency='y'
copy=0

source helper_functions.sh

# read the options
if [ -f "$automationFile" ]
then
autoSetupSystem=$( ini_get $automationFile CLIENT autoSetupSystem )
checkDependency=$( ini_get $automationFile CLIENT checkDependency )
Platform_name=$( ini_get $automationFile CLIENT Platform_name )
client_ip=$( ini_get $automationFile CLIENT ip )
server_ip=$( ini_get $automationFile SERVER ip )
host_ip=$( ini_get $automationFile HOST ip )
client_passwd=$( ini_get $automationFile CLIENT password )
server_passwd=$( ini_get $automationFile SERVER password )
host_passwd=$( ini_get $automationFile HOST password )
client_user=$( ini_get $automationFile CLIENT user )
server_user=$( ini_get $automationFile SERVER user )
host_user=$( ini_get $automationFile HOST user )
caliper_option=$( ini_get $automationFile CLIENT caliper_option )
mount_point=$( ini_get $automationFile CLIENT mount_point )
else
echo "$automationFile Does Not Exist"
exit 1
fi

autoSSH $client_user $client_ip $client_passwd
autoSSH $server_user $server_ip $server_passwd

echo -e " AutoSetupSystem=$autoSetupSystem\n checkDependency=$checkDependency \n Platform_name = $Platform_name \n server_user=$server_user\n server_ip=$server_ip\n server_passwd=$server_passwd\n client_user=$client_user\n client_ip=$client_ip\n client_passwd=$client_passwd\n caliper_option=$caliper_option\n Testlist = $testFile\n mount_point = $mount_point\n"

TEMP=`getopt -o o:dDcCh --long caliper_option:,check,dontcheck,copy,dontcopy,help -n 'automation.sh' -- "$@"`
if [ $? -ne 0 ]
then
cat help.txt
exit
fi

eval set -- "$TEMP"

# extract options and their arguments into variables.
while true ; do
case "$1" in
-o|--caliper_option)
caliper_option=$2
lineNum=`cat $automationFile | grep "caliper_option" `
sed -i "s/$lineNum/caliper_option\ =\ $caliper_option/g" $automationFile
shift 2 ;;
-d|--check)
checkDependency="y" ; shift;;
-D|--dontcheck)
checkDependency="n" ; shift;;
-c|--copy)
copy=1 ; shift;;
-C|--dontcopy)
copy=0 ; shift;;
-h|--help)
cat help.txt; shift; exit 1;;
--) shift; break;;
*) echo "Internal error!"; cat help.txt; exit 1 ;;
esac
done

#checking all the test to be conducted

# writing into files automation
check_f_option=`echo $caliper_option | awk -F ' ' '{print $1}' | grep -c 'f'`
if [ $check_f_option -ne 0 ]
then
list=(${caliper_option// / })
folder=${list[1]}
fi

if [ -z $folder ]
then
target_host=`ssh $client_user@$client_ip "hostname"`
sleep 2
TimeStamp=$(date "+%y-%m-%d_%H-%M-%S")
foldername=$(echo $target_host"_WS_"$TimeStamp )
workspace=$wspath$target_host"_WS_"$TimeStamp

else
workspace=$wspath$folder
echo $workspace
foldername=$folder
fi

if [[ ! -e $workspace ]]
then
mkdir $workspace
elif [[ ! -d $workspace ]]
then
echo "$workspace already exists but is not a directory" 1>&2
fi
`cp -r "$HOME/caliper_output/configuration/config" $workspace`
`cp -r "$HOME/caliper_output/configuration/test_cases_cfg" $workspace`

path="$workspace/test_cases_cfg"
server_def="$path$server_def"
client_def="$path$client_def"


if [ -f "$testFile" ]
then
while read testline
do
if [ ${testline:0:1} != '#' -a -n $testline ]
then
uncomment $server_def $client_def $testline
elif [ ${testline:0:1} == '#' ]
then
comment $server_def $client_def ${testline:1}
fi
done<$testFile
else
echo "Error: $testfile File Does Not Exist. Check readme.txt for more information"
exit 1
fi

path_config="$workspace/config/client_config.cfg"
./modify.py "$path_config" "$client_ip" "$server_ip"
if [ $? -ne 0 ]
then
echo "FAILED TO MODIFY $path_config"
cat $path_config
exit 1
fi

if [ -z $folder ]
then
caliper_option=$(echo $caliper_option"f $foldername")
fi


#Comparing the tool chain
target_arch=`ssh $client_user@$client_ip "uname -a"`
target_arch=`echo $target_arch | awk -F ' ' '{print $12}'`
host_arch=`uname -a | awk -F ' ' '{print $12}'`


#Exporting the Tool chain
echo "Target arch = $target_arch"
echo "Host arch = $host_arch"

if [ $target_arch != $host_arch ]
then

target_arch=`ssh $client_user@$client_ip "uname -a"`
target_arch=`echo $target_arch | awk -F ' ' '{print $13}'`

checkCrossCompilation $target_arch $autoSetupSystem

if [ $? -ne 0 ]
then
exit 1
fi
echo "exporting $files_toolchain done"
fi

if [ "$checkDependency" == 'y' ]
then
./server_dependency.exp "$autoSetupSystem" "$server_user" "$server_ip" "$server_passwd"
if [ $? -eq 0 ]
then
echo " SERVER SUCESSFULL "
else
echo " SERVER FAILED "
fi

./host_dependency.exp "$autoSetupSystem" "$host_passwd"
if [ $? -eq 0 ]
then
echo " HOST SUCESSFULL "
else
echo " HOST FAILED "
fi

./target_dependency.exp "$autoSetupSystem" "$client_user" "$client_ip" "$client_passwd" "$mount_point"
fi

if [ $? -eq 0 ]
then
echo -e "\n********************************* Caliper is excuting ***********************************\n"
caliper $caliper_option
wait
echo -e "\n ********************************** caliper completed *****************************************\n"

else
echo "Failed in Depenency"
exit 1
fi

if [ $copy -eq 1 ]
then
./copy.sh "$copycfg" "$foldername"
fi
27 changes: 27 additions & 0 deletions utils/automation_scripts/Scripts/client_automation_template.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[HOST]
ip = 192.168.40.89
user = caliper
password = dik123

[SERVER]
ip = 192.168.40.89
user = caliper
password = dik123

[CLIENT]
Platform_name = Testing_2
ip = 192.168.40.9
user = root
password = root123
autoSetupSystem = y
checkDependency = y
caliper_option = -bRPSf testing_RH2288
mount_point = /dev/sdb

[BMCER]
command =
host =
port =
user =
password =

Loading