-
Notifications
You must be signed in to change notification settings - Fork 0
/
parallel_install_test.sh
executable file
·147 lines (120 loc) · 3.41 KB
/
parallel_install_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
set -x
set -e
set -o pipefail
function get_current_subpkgs {
NEW_RPMS=$1
RPMLIST=$(ls $NEW_RPMS)
SUBPKGS=""
for RPM in $RPMLIST; do
SUBPKGS+=$(echo $RPM | rev | cut -f 3- -d'-' | rev)
SUBPKGS+=","
done
echo $SUBPKGS
}
function get_set_version {
SET_DIR=$1
RPMLIST=($(ls $SET_DIR))
echo ${RPMLIST[1]} | rev | cut -f -2 -d'-' | rev
}
function clean_installed_java {
javas=`rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}\n" | grep -e "^java-[0-9]" -e "^java-gcj"`
sudo rpm -e --nodeps $javas
}
function run_parallel_test {
OLD_RPMS=$1
NEW_RPMS=$2
INSTALL_COMMAND=$3
if [[ "x$INSTALL_COMMAND" = "x" ]]; then
which dnf
if [ $? -eq 0 ] ; then
INSTALL_COMMAND="dnf -y install"
else
INSTALL_COMMAND="yum -y install"
fi
else
INSTALL_COMMAND="rpm -i"
fi
YUM_CONF="/etc/yum.conf"
sudo cp $YUM_CONF $YUM_CONF-copy
echo "installonlypkgs=$(get_current_subpkgs $NEW_RPMS)" | sudo tee -a $YUM_CONF
sudo $INSTALL_COMMAND $OLD_RPMS/*
RES1=$?
sudo $INSTALL_COMMAND $NEW_RPMS/*
RES2=$?
sudo rm $YUM_CONF
sudo mv $YUM_CONF-copy $YUM_CONF
clean_installed_java
if [ $RES1 -eq 0 ] && [ $RES2 -eq 0 ]; then
return 0
fi
return 1
}
RUNNING=false
if [[ ( x${BUILD_OS_NAME} == xel && ${BUILD_OS_VERSION} > 6 ) || x${BUILD_OS_NAME} == xf ]]; then
RUNNING=true
fi
FAILED=0
PASSED=0
IGNORED=0
BODY=""
if [ "x$RFaT" == "x" ]; then
readonly RFaT=`mktemp -d`
git clone https://github.com/rh-openjdk/run-folder-as-tests.git ${RFaT} 1>&2
ls -l ${RFaT} 1>&2
fi
source ${RFaT}/jtreg-shell-xml.sh
if [ "x$TMPRESULTS" == "x" ]; then
TMPRESULTS=`pwd`
fi
echo "" > $TMPRESULTS/parallel_install_log.txt
let "PASSED+=1"
echo "Appending dummy test, so there is at elast one test always running in suite" >> $TMPRESULTS/parallel_install_log.txt
TEST=$(printXmlTest "tps" "dummyTestToPrventTotalFailure" "0" "" "")
BODY+="$TEST
" # new line to improve clarity, also is used in TPS/tesultsToJtregs.sh
if [[ $(get_set_version $1) == $(get_set_version $2) ]]; then
echo "same versions of old and new rpms, skipping the test"
RUNNING=false
fi
set +e
clean_installed_java
set -e
for COMMANDSTRING in YumDnf "Rpm"; do
LOGFILE=$TMPRESULTS/parallel_install_log_$COMMANDSTRING.log
echo "" > $LOGFILE
if [ $RUNNING = false ]; then
let "IGNORED+=1"
echo "!skipped!" >> $LOGFILE
TEST=$(printXmlTest "tps" "install$COMMANDSTRING" "0" "$LOGFILE" "")
BODY+="$TEST
" # new line to improve clarity, also is used in TPS/tesultsToJtregs.sh
continue
fi
ARGUMENT=$COMMANDSTRING
if [[ "YumDnf" == $COMMANDSTRING ]]; then
ARGUMENT=""
fi
set +e
run_parallel_test $1 $2 $ARGUMENT >> $LOGFILE 2>&1
RES=$?
set -e
if [ $RES -eq 0 ]; then
let "PASSED+=1"
TEST=$(printXmlTest "tps" "install$COMMANDSTRING" "0")
BODY+="$TEST
" # new line to improve clarity, also is used in TPS/tesultsToJtregs.sh
echo "install$COMMANDSTRING PASSED\n"
else
let "FAILED+=1"
TEST=$(printXmlTest "tps" "install$COMMANDSTRING" "0" "$LOGFILE" "$LOGFILE")
BODY+="$TEST
" # new line to improve clarity, also is used in TPS/tesultsToJtregs.sh
echo "install$COMMANDSTRING FAILED\n"
fi
done
let "TESTS = $FAILED + $PASSED + $IGNORED"
XMLREPORT=$TMPRESULTS/parallel_install_log.jtr.xml
printXmlHeader $PASSED $FAILED $TESTS $IGNORED "parallelInstalls" > $XMLREPORT
echo "$BODY" >> $XMLREPORT
printXmlFooter >> $XMLREPORT