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

maketest.sh: Add process cleanup for Windows at the end of testing #2059

Merged
merged 1 commit into from
Nov 18, 2020
Merged
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
33 changes: 33 additions & 0 deletions maketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ case `uname` in
;;
esac

if [ "$OSTYPE" = "cygwin" ]; then
karianna marked this conversation as resolved.
Show resolved Hide resolved
export JOBSTARTTIME=$(date -R)
echo PROCESSCATCH: Java processes which are currently on the machine:
powershell -c "Get-Process java | select id,processname,starttime"
fi

if [ "$#" -eq 1 ];then
cd $1/TKG
$MAKE compile
Expand All @@ -29,3 +35,30 @@ else
$MAKE $@
fi

# For now (while this code is being prototyped) I only want this to be
sxa marked this conversation as resolved.
Show resolved Hide resolved
# done while running in jenkins, to avoid a potentially destabilising
# change if people are running other java processes on their local system
karianna marked this conversation as resolved.
Show resolved Hide resolved
set -x
if [ ! -z "$EXECUTOR_NUMBER" ]; then
if [ "$OSTYPE" = "cygwin" ]; then
# Windows code based on https://github.com/AdoptOpenJDK/openjdk-infrastructure/issues/1669#issuecomment-727863096
echo PROCESSCATCH: Showing java processes - one will be the jenkins agent - removing any of these created since $JOBSTARTTIME:
powershell -c "Get-Process java"
C=`powershell -c "(Get-Process java | select id,processname,starttime | where {\\$_.StartTime -gt (Get-Date -Date \"$JOBSTARTTIME\")} | measure).count" | tr -d \\\\r`
if [ $C -ne 0 ]; then
echo PROCESSCATCH: Attempting to stop the following processes:
powershell -c "Get-Process java | select id,processname,starttime | where {\$_.StartTime -gt (Get-Date -Date \"$JOBSTARTTIME\")}"
powershell -c "Get-Process java | select id,processname,starttime | where {\$_.StartTime -gt (Get-Date -Date \"$JOBSTARTTIME\")} | stop-process"
echo PROCESSCATCH: Removed processes - here is what is remaining:
powershell -c "Get-Process java"
fi
else
# Non-Windows code from https://ci.adoptopenjdk.net/job/SXA-processCheck
echo PROCESSCATCH: Checking for any leftover java processes on the machine
if ps -fu $USER | grep java | egrep -v "remoting.jar|agent.jar|grep"; then
echo PROCESSCATCH: There are rogue processes still on the machine as per the list above
# TODO: We could kill them, but SXA-processCheck covers this in the adoptopenjdk jenkins
# And this is likely to be replaced as part of https://github.com/AdoptOpenJDK/TKG/issues/45
fi
fi
fi