55 lines
1.2 KiB
Bash
Executable File
55 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
JAVA=$1
|
|
JAVA_VER=$2
|
|
AGENT_VERSION="1.6.2"
|
|
dir=$(mktemp -d)
|
|
pushd $dir
|
|
cat > jolokia_config.properties <<EOF
|
|
port=7777
|
|
host=localhost
|
|
user=foo
|
|
password=bar
|
|
EOF
|
|
cat > HelloWait.java <<EOF
|
|
public class HelloWait {
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println("Hello World");
|
|
try {
|
|
while (true) {
|
|
Thread.sleep(200);
|
|
}
|
|
} catch (InterruptedException e) {
|
|
// ignore
|
|
}
|
|
}
|
|
|
|
}
|
|
EOF
|
|
javac HelloWait.java
|
|
$JAVA/bin/java -javaagent:/usr/share/java/jolokia-jvm-agent/jolokia-jvm.jar=config=jolokia_config.properties -cp . HelloWait > hello_wait.out 2>&1 &
|
|
num_tries=0
|
|
while [ $num_tries -lt 10 ] && ! grep -q 'Hello World' hello_wait.out; do
|
|
sleep 1
|
|
num_tries=$(($num_tries + 1))
|
|
done
|
|
echo
|
|
if [ $num_tries -eq 10 ]; then
|
|
echo "Time out reached waiting for HelloWait to come up"
|
|
exit 1
|
|
fi
|
|
curl -s --user foo:bar http://127.0.0.1:7777/jolokia/ 2>&1 | tee jolokia.out
|
|
echo
|
|
echo
|
|
grep -q "\"agent\":\"$AGENT_VERSION\"" jolokia.out
|
|
grep -q '"status":200' jolokia.out
|
|
popd
|
|
rm -rf $dir
|
|
|
|
# Cleanup HelloWait process
|
|
kill $(jps | grep HelloWait | awk '{ print $1 }')
|
|
|
|
echo "JDK $JAVA_VER: Tests PASSED!"
|