mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
Merge pull request #7639 from jayunit100/e2e-k8bps
E2E: Soak test and Functional tests for K8Petstore
This commit is contained in:
@@ -16,16 +16,30 @@
|
||||
|
||||
echo "WRITING KUBE FILES , will overwrite the jsons, then testing pods. is kube clean ready to go?"
|
||||
|
||||
|
||||
#Args below can be overriden when calling from cmd line.
|
||||
#Just send all the args in order.
|
||||
#for dev/test you can use:
|
||||
#kubectl=$GOPATH/src/github.com/GoogleCloudPlatform/kubernetes/cluster/kubectl.sh"
|
||||
kubectl="kubectl"
|
||||
VERSION="r.2.8.19"
|
||||
PUBLIC_IP="10.1.4.89" # ip which we use to access the Web server.
|
||||
SECONDS=1000 # number of seconds to measure throughput.
|
||||
FE="1" # amount of Web server
|
||||
LG="1" # amount of load generators
|
||||
SLAVE="1" # amount of redis slaves
|
||||
TEST_SECONDS="1000" # 0 = Dont run tests, if > 0, run tests for n seconds.
|
||||
NS="k8petstore" # namespace
|
||||
|
||||
kubectl="${1:-$kubectl}"
|
||||
VERSION="${2:-$VERSION}"
|
||||
PUBLIC_IP="${3:-$PUBLIC_IP}"
|
||||
FE="${4:-$FE}"
|
||||
LG="${5:-$LG}"
|
||||
SLAVE="${6:-$SLAVE}"
|
||||
TEST_SECONDS="${7:-$TEST}"
|
||||
NS="${8:-$NS}"
|
||||
|
||||
echo "Running w/ args: kubectl $kubectl version $VERSION ip $PUBLIC_IP sec $_SECONDS fe $FE lg $LG slave $SLAVE test $TEST NAMESPACE $NS"
|
||||
function create {
|
||||
|
||||
cat << EOF > fe-rc.json
|
||||
@@ -188,53 +202,74 @@ cat << EOF > slave-rc.json
|
||||
"labels": {"name": "redisslave"}
|
||||
}
|
||||
EOF
|
||||
$kubectl create -f rm.json --api-version=v1beta1
|
||||
$kubectl create -f rm-s.json --api-version=v1beta1
|
||||
$kubectl create -f rm.json --api-version=v1beta1 --namespace=$NS
|
||||
$kubectl create -f rm-s.json --api-version=v1beta1 --namespace=$NS
|
||||
sleep 3 # precaution to prevent fe from spinning up too soon.
|
||||
$kubectl create -f slave-rc.json --api-version=v1beta1
|
||||
$kubectl create -f rs-s.json --api-version=v1beta1
|
||||
$kubectl create -f slave-rc.json --api-version=v1beta1 --namespace=$NS
|
||||
$kubectl create -f rs-s.json --api-version=v1beta1 --namespace=$NS
|
||||
sleep 3 # see above comment.
|
||||
$kubectl create -f fe-rc.json --api-version=v1beta1
|
||||
$kubectl create -f fe-s.json --api-version=v1beta1
|
||||
$kubectl create -f bps-load-gen-rc.json --api-version=v1beta1
|
||||
$kubectl create -f fe-rc.json --api-version=v1beta1 --namespace=$NS
|
||||
$kubectl create -f fe-s.json --api-version=v1beta1 --namespace=$NS
|
||||
$kubectl create -f bps-load-gen-rc.json --api-version=v1beta1 --namespace=$NS
|
||||
}
|
||||
|
||||
function test {
|
||||
function pollfor {
|
||||
pass_http=0
|
||||
|
||||
### Test HTTP Server comes up.
|
||||
for i in `seq 1 150`;
|
||||
do
|
||||
### Just testing that the front end comes up. Not sure how to test total entries etc... (yet)
|
||||
echo "Trying curl ... $i . expect a few failures while pulling images... "
|
||||
echo "Trying curl ... $PUBLIC_IP:3000 , attempt $i . expect a few failures while pulling images... "
|
||||
curl "$PUBLIC_IP:3000" > result
|
||||
cat result
|
||||
cat result | grep -q "k8-bps"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "TEST PASSED after $i tries !"
|
||||
i=1000
|
||||
break
|
||||
echo "TEST PASSED after $i tries !"
|
||||
i=1000
|
||||
break
|
||||
else
|
||||
echo "the above RESULT didn't contain target string for trial $i"
|
||||
fi
|
||||
sleep 5
|
||||
sleep 3
|
||||
done
|
||||
|
||||
if [ $i -eq 1000 ]; then
|
||||
pass_http=-1
|
||||
pass_http=1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function tests {
|
||||
pass_load=0
|
||||
|
||||
### Print statistics of db size, every second, until $SECONDS are up.
|
||||
for i in `seq 1 $SECONDS`;
|
||||
do
|
||||
echo "curl : $i"
|
||||
curl "$PUBLIC_IP:3000/llen" >> result
|
||||
for i in `seq 1 $TEST_SECONDS`;
|
||||
do
|
||||
echo "curl : $PUBLIC_IP:3000 , $i of $TEST_SECONDS"
|
||||
curr_cnt="`curl "$PUBLIC_IP:3000/llen"`"
|
||||
### Write CSV File of # of trials / total transcations.
|
||||
echo "$i $curr_cnt" >> result
|
||||
echo "total transactions so far : $curr_cnt"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
create
|
||||
|
||||
test
|
||||
pollfor
|
||||
|
||||
if [[ $pass_http -eq 1 ]]; then
|
||||
echo "Passed..."
|
||||
else
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ $TEST_SECONDS -eq 0 ]]; then
|
||||
echo "skipping tests, TEST_SECONDS value was 0"
|
||||
else
|
||||
echo "running polling tests now for $TEST_SECONDS"
|
||||
tests
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user