Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
otrack committed Apr 2, 2019
1 parent 0534231 commit 818926d
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 51 deletions.
8 changes: 4 additions & 4 deletions client/src/main/java/org/infinispan/creson/CyclicBarrier.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ public class CyclicBarrier {
public CyclicBarrier(){}

public CyclicBarrier(String name, int parties){
this.counter = new AtomicCounter(name,0);
this.generation = new AtomicCounter(name,0);
this.counter = new AtomicCounter(name+"-counter",0);
this.generation = new AtomicCounter(name+"generation",0);
this.parties = parties;
}

public int await(){
int previous = generation.tally();

int ret = counter.increment();
if (ret % parties == 0) {
counter.reset();
generation.increment();
}

int current = generation.tally();
int backoff = 2;
while (previous == current) {
current = generation.tally();
try {
Thread.sleep(100);
Thread.currentThread().sleep(backoff);
} catch (InterruptedException e) {
// ignore
}
Expand Down
8 changes: 2 additions & 6 deletions client/src/test/bin/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@ if [ -z "${DOCKER_USER}" ]; then
fi

DIR=$(dirname "$0")
IMAGE=${DOCKER_USER}/infinispan-creson-client-test:${TAG}
IMAGE=${DOCKER_USER}/infinispan-creson-client-tests:${TAG}
DOCKERFILE=${DIR}/../docker/Dockerfile

# package
mvn clean package -DskipTests

# last commit hash
# FIXME
# git log -1 --format="%H" >${DIR}/../../../version-hash

# build image
docker build \
--no-cache \
-t "${IMAGE}" -f "${DOCKERFILE}" .

# # push image
# push image
docker push "${IMAGE}"

2 changes: 1 addition & 1 deletion client/src/test/bin/k8s/exp.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud=k8s
context=creson
image=0track/infinispan-creson-server:latest
image-client=0track/infinispan-creson-client-test:latest
image-client=0track/infinispan-creson-client-tests:latest
pull-image=Always
nodes=1
verbose=1
28 changes: 28 additions & 0 deletions client/src/test/bin/k8s/templates/blob-test.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: batch/v1
kind: Job
metadata:
name: infinispan-creson-client-test
spec:
parallelism: 6
template:
spec:
restartPolicy: OnFailure
containers:
- name: infinispan-creson-client
image: %IMAGE%
resources:
requests:
cpu: 0.2
env:
- name: PROXY
value: "%PROXY%"
- name: CLIENTS
value: "1"
- name: INSTANCES
value: "10000"
- name: CALLS
value: "100000"
- name: CLASS
value: "org.infinispan.creson.Blob"
- name: EXTRA
value: "-parameters 10000"
26 changes: 26 additions & 0 deletions client/src/test/bin/k8s/templates/client-test.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: batch/v1
kind: Job
metadata:
name: infinispan-creson-client-test
spec:
parallelism: 1
template:
spec:
restartPolicy: OnFailure
containers:
- name: infinispan-creson-client-test
image: %IMAGE%
resources:
requests:
cpu: 0.2
env:
- name: PROXY
value: "%PROXY%"
- name: CLIENTS
value: "50"
- name: INSTANCES
value: "1000"
- name: CALLS
value: "1000"
- name: CLASS
value: "Counter"
26 changes: 26 additions & 0 deletions client/src/test/bin/k8s/templates/counter-test.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: batch/v1
kind: Job
metadata:
name: infinispan-creson-client
spec:
parallelism: 6
template:
spec:
restartPolicy: OnFailure
containers:
- name: infinispan-creson-client
image: %IMAGE%
resources:
requests:
cpu: 0.2
env:
- name: PROXY
value: "%PROXY%"
- name: CLIENTS
value: "1"
- name: INSTANCES
value: "10000"
- name: CALLS
value: "100000"
- name: CLASS
value: "org.infinispan.creson.AtomicCounter"
2 changes: 1 addition & 1 deletion client/src/test/bin/k8s/templates/replicaset.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: server
image: "0track/infinispan-creson-server"
image: %IMAGE%
imagePullPolicy: "Always"
resources:
requests:
Expand Down
42 changes: 26 additions & 16 deletions client/src/test/bin/k8s/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,46 @@ source ${DIR}/utils_benchmarks.sh

trap "pkill -KILL -P $$; exit 255" SIGINT SIGTERM

if [ $# -ne 1 ]; then
echo "usage: [-create, -delete, -counters]"
usage(){
echo "usage: -[create|delete|counters|blobs]"
exit -1
}

if [ $# -ne 1 ]; then
usage
fi

if [[ "$1" == "-create" ]]
then
# gsutil rm -r gs://$(config bucket)/* >&/dev/null # clean bucket
k8s_rs_create ${TMPLDIR}/replicaset.yaml.tmpl
k8s_rs_cp ${TMPLDIR}/replicaset.yaml.tmpl ${DIR}/../../../../target/infinispan-creson-client-9.4.1.Final.jar/ /tmp
# kubectl create -f ${TMPLDIR}/autoscaler.yaml
# kubectl autoscale replicaset infinispan-creson-server --cpu-percent=50 --min=3 --max=8 # FIXME
elif [[ "$1" == "-delete" ]]
then
k8s_rs_delete ${TMPLDIR}/replicaset.yaml.tmpl
kubectl delete hpa infinispan-creson-server
# kubectl delete hpa infinispan-creson-server
# gsutil rm -r gs://$(config bucket)/* >&/dev/null # clean bucket
elif [[ "$1" == "-counters" ]]
then
start_increment
start_monitor
wait_increment
# sleep 300
stop_monitor
compute_throughput
elif [[ "$1" == "-blobs" ]]
then
start_access
else
template=""
if [[ "$1" == "-counters" ]]
then
template=${TMPLDIR}/counter-test.yaml.tmpl
elif [[ "$1" == "-blobs" ]]
then
template=${TMPLDIR}/blobs-test.yaml.tmpl
elif [[ "$1" == "-barrier" ]]
then
template=${TMPLDIR}/barrier-test.yaml.tmpl
else
usage
fi
start_access ${template}
start_monitor
wait_access
wait_access ${template}
# sleep 300
stop_monitor
compute_throughput
fi


28 changes: 14 additions & 14 deletions client/src/test/bin/k8s/utils_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
DIR=$(dirname "${BASH_SOURCE[0]}")
source ${DIR}/utils_functions.sh

start_increment(){
k8s_create_job ${TMPLDIR}/counter-test.yaml.tmpl
}

wait_increment(){
k8s_wait_job ${TMPLDIR}/counter-test.yaml.tmpl
k8s_fetch_logs ${TMPLDIR}/counter-test.yaml.tmpl "^[0-9]*:[0-9]*$"
k8s_delete_job ${TMPLDIR}/counter-test.yaml.tmpl
}

start_access(){
k8s_create_job ${TMPLDIR}/blob-test.yaml.tmpl
if [ $# -ne 1 ]; then
echo "usage: start_access template.yaml"
exit -1
fi
local template=$1
k8s_create_job ${template}
}

wait_access(){
k8s_wait_job ${TMPLDIR}/blob-test.yaml.tmpl
k8s_fetch_logs ${TMPLDIR}/blob-test.yaml.tmpl "^[0-9]*:[0-9]*$"
k8s_delete_job ${TMPLDIR}/blob-test.yaml.tmpl
if [ $# -ne 1 ]; then
echo "usage: wait_access template.yaml"
exit -1
fi
local template=$1
k8s_wait_job ${template}
k8s_fetch_logs ${template} "^[0-9]*:[0-9]*$"
k8s_delete_job ${template}
}

# utils
Expand Down
58 changes: 56 additions & 2 deletions client/src/test/bin/k8s/utils_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DIR=$(dirname "${BASH_SOURCE[0]}")

TMPLDIR="${DIR}/../templates"
TMPLDIR="${DIR}/templates"
CONFIG_FILE="${DIR}/exp.config"
TMPDIR="/tmp"
LOGDIR="${TMPDIR}/log"
Expand Down Expand Up @@ -92,6 +92,18 @@ k8s_delete_pod() {
info "pod ${pod_name} deleted at ${context}"
}

k8s_pod_cp(){
if [ $# -ne 3 ]; then
echo "usage: k8s_pod_cp src pod dst"
exit -1
fi
local src=$1
local pod=$2
local dst=$2
kubectl cp $1 $2:$3

}

k8s_create_all_pods(){
local context=$(config context)
local service=$(cat ${CONFIG_FILE} | grep -ioh "/.*:" | sed s,[/:],,g)
Expand Down Expand Up @@ -159,8 +171,21 @@ k8s_rs_create() {
sed s,%CLOUD%,$(config cloud),g \
>${file}

# create rs
info $(kubectl --context="${context}" create -f ${file})

# wait until
started=0
while [ "${started}" != "1" ]; do
sleep 1
starting=$(kubectl --context="${context}" get pods 2>&1 |
grep $(k8s_name ${file}) |
grep -v "Running" |
wc -l)
if [ "${starting}" == "0" ]
then
started=1
fi
done
}

k8s_rs_delete() {
Expand All @@ -171,8 +196,18 @@ k8s_rs_delete() {
local template=$1
local context=$(config context)
local file=${template}-0
local image=$(k8s_name ${file})

info $(kubectl --context="${context}" delete -f ${file})

# wait until
running=1
while [ "${running}" != "0" ]; do
sleep 1
running=$(kubectl --context="${context}" get pods 2>&1 |
grep ${image} |
wc -l)
done
}

k8s_rs_count_pods() {
Expand All @@ -187,6 +222,25 @@ k8s_rs_count_pods() {
kubectl --context="${context}" get pod -l app=${name} | grep "Running" | wc -l
}

k8s_rs_cp(){
if [ $# -ne 3 ]; then
echo "usage: k8s_rs_cp template.yaml file dst"
exit -1
fi

local template=$1
local file=$2
local dst=$3
local context=$(config context)
local rs_name=$(k8s_name ${template})

for pod in $(kubectl --context=${context} get pods | grep ${rs_name} | awk '{print $1}');
do
info "copying ${file} to ${pod}:${dst} at ${context}"
k8s_pod_cp ${file} ${pod} ${dst}
done
}

k8s_clean_all(){
k8s_delete_all_pods $(config context) >&/dev/null
gsutil rm -r gs://$(config bucket)/* >&/dev/null
Expand Down
8 changes: 4 additions & 4 deletions client/src/test/bin/local/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
PROJDIR=`realpath $(dirname "${BASH_SOURCE[0]}")/../../../../`
TARGETDIR="${PROJDIR}/target"

NSERVERS=2
NSERVERS=3
NAME="infinispan-creson-server"
MAINTAINER="0track"
TAG="latest"
IMAGE="${MAINTAINER}/${NAME}:${TAG}"
IMAGE_ID=$(docker images | grep ${NAME} | head -n 1 | awk '{print $3}')

INSTANCES="1"
CLIENTS="16"
CLIENTS="100"
CALLS="1000"

CLIENT="infinispan-creson-client"
VERSION=$(cat ${PROJDIR}/pom.xml | grep version | head -n 1 | tr -d '[:blank:]' | sed s,\</*version\>,,g)

if [ $# -ne 1 ]; then
echo "usage: -[create|blobs|counters|delete]"
echo "usage: -[create|blobs|counters|countdownlatch|barrier|delete]"
exit -1
fi

Expand Down Expand Up @@ -75,4 +75,4 @@ else
ARGS="-ea -Dlog4j2.configuration=log4j.xml org.infinispan.creson.Benchmark -class ${CLASS} -instances ${INSTANCES} -clients ${CLIENTS} -calls ${CALLS} -verbose"
echo "java -cp ${CLASSPATH} ${ARGS} ${EXTRA}"
java -cp ${CLASSPATH} ${ARGS} ${EXTRA}
fi
fi
Loading

0 comments on commit 818926d

Please sign in to comment.