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

Allow other location account #104

Merged
merged 7 commits into from
Jan 28, 2020
Merged
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,55 @@ has an "object-oriented" parser - the only inherited parameter is the --tool par
run_snafu.py uses the tool parameter to determine which wrapper to invoke, and
The remaining parameters are defined and parsed by the workload-specific wrapper.


## how do I run my snafu wrapper in CI?

add the ci_test.sh script to your wrapper directory - the SNAFU CI (Continuous Integration) test harness
will automatically find it and run it. This assumes that your wrapper supports ripsaw, for now.
At present, the CI does not test SNAFU on baremetal but this may be added in the future.

every ci_test.sh script makes use of environment variables defined in ci/common.sh :

* RIPSAW_CI_IMAGE_LOCATION - defaults to quay.io
* RIPSAW_CI_IMAGE_ACCOUNT - defaults to rht_perf_ci
* SNAFU_IMAGE_TAG (defaults to snafu_ci)
* SNAFU_IMAGE_BUILDER (defaults to podman, can be set to docker)

You, the wrapper developer, can override these variables to use any container image repository
supported by ripsaw (quay.io is at present the only location tested).

NOTE: at present, you need to force these images to be public images so that minikube can
load them. A better method is needed.

In your CI script, ci_test.sh, you can make use of these 2 environment variables:

* SNAFU_IMAGE_TAG (defaults to snafu_ci)
* SNAFU_WRAPPER_IMAGE_PREFIX - just concatenation of location and account

And here is a simple example of a ci_test.sh (they all look very similar):

```
#!/bin/bash
source ci/common.sh
default_image_spec="quay.io/cloud-bulldozer/your_wrapper:master"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/your_wrapper:$SNAFU_IMAGE_TAG
build_and_push your_wrapper/Dockerfile $image_spec

cd ripsaw
sed -i "s#$default_image_spec#$image_spec#" roles/your_wrapper_in_ripsaw/templates/*

# Build new ripsaw image
update_operator_image

# run the ripsaw CI for your wrapper in tests/ and get resulting UUID
get_uuid test_your_wrapper.sh
uuid=`cat uuid`

cd ..

# Define index (there can be more than 1)
index="ripsaw-your-wrapper-results"

check_es $uuid $index
exit $?
```
52 changes: 36 additions & 16 deletions ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,43 @@

es_server="marquez.perf.lab.eng.rdu2.redhat.com"
es_port=9200
default_operator_image="quay.io/benchmark-operator/benchmark-operator:master"

image_location=${RIPSAW_CI_IMAGE_LOCATION:-quay.io}
image_account=${RIPSAW_CI_IMAGE_ACCOUNT:-rht_perf_ci}
export SNAFU_IMAGE_TAG=${SNAFU_IMAGE_TAG:-snafu_ci}
export SNAFU_WRAPPER_IMAGE_PREFIX="$image_location/$image_account"
echo "posting container images to $image_location with account $image_account"
export image_builder=${SNAFU_IMAGE_BUILDER:-podman}
if [ "$USER" != "root" ] ; then
SUDO=sudo
fi
NOTOK=1

# see kubernetes initialization on last line of this script
# which will be the first thing the wrapper ci_test.sh does to it

function update_operator_image() {
tag_name=$1
operator-sdk build quay.io/rht_perf_ci/benchmark-operator:$tag_name --image-builder podman
image_spec=$image_location/$image_account/benchmark-operator:$SNAFU_IMAGE_TAG
$SUDO operator-sdk build $image_spec --image-builder $image_builder

# In case we have issues uploading to quay we will retry a few times
try_count=0
while [ $try_count -le 2 ]
do
if podman push quay.io/rht_perf_ci/benchmark-operator:$tag_name
if $SUDO $image_builder push $image_spec
then
try_count=2
elif [[ $try_count -eq 2 ]]
then
echo "Could not upload image to quay. Exiting"
exit 1
echo "Could not upload image to $image_location. Exiting"
exit $NOTOK
fi
((try_count++))
done
sed -i "s| image: quay.io/benchmark-operator/benchmark-operator:master*| image: quay.io/rht_perf_ci/benchmark-operator:$tag_name # |" resources/operator.yaml
sed -i \
"s| image: $default_operator_image| image: $image_spec # |" \
resources/operator.yaml
}

function wait_clean {
Expand All @@ -33,9 +50,11 @@ function wait_clean {
break
fi
done
kubectl delete namespace my-ripsaw
kubectl create namespace my-ripsaw || exit $NOTOK
}

# Takes 2 arguements. $1 is the uuid and $2 is a space seperated list of indexs to check
# Takes 2 arguments. $1 is the uuid and $2 is a space-separated list of indexes to check
# Returns 0 if ALL indexes are found
function check_es() {
uuid=$1
Expand All @@ -44,14 +63,9 @@ function check_es() {
rc=0
for my_index in $index
do
python3 ci/check_es.py -s $es_server -p $es_port -u $uuid -i $my_index
ec=$?
if [[ $ec -ne 0 ]]
then
exit 1
fi
python3 ci/check_es.py -s $es_server -p $es_port -u $uuid -i $my_index \
|| exit $NOTOK
done
exit 0
}

# Takes test script as parameter and returns the uuid
Expand All @@ -67,22 +81,28 @@ function get_uuid() {
# Get UUID
uuid=`kubectl -n my-ripsaw get benchmarks -o jsonpath='{.items[0].status.uuid}'`

# while we're here, let's verify that right image location and account got used

kubectl -n my-ripsaw describe pods | grep -i pulled

finish
echo $uuid > uuid
)
}

# Takes 2 argumentes. $1 is the Dockerfile path and $2 is the image name
function build_and_push() {
if ! podman build --no-cache --tag=${2} -f ${1} . ; then
if ! $SUDO podman build --no-cache --tag=${2} -f ${1} . ; then
echo "Image building error. Exiting"
exit 1
fi
for i in {1..3}; do
podman push ${2} && break
$SUDO podman push ${2} && break
if [[ ${i} == 3 ]]; then
echo "Could not upload image to registry. Exiting"
exit 1
fi
done
}

wait_clean
10 changes: 6 additions & 4 deletions fio_wrapper/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push fio_wrapper/Dockerfile quay.io/cloud-bulldozer/fio:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/fio:latest"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/fio:$SNAFU_IMAGE_TAG
build_and_push fio_wrapper/Dockerfile $image_spec

cd ripsaw

sed -i 's/fio:latest/fio:snafu_ci/g' roles/fio-distributed/templates/*
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/fio-distributed/templates/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_fiod.sh
uuid=`cat uuid`
Expand All @@ -24,3 +25,4 @@ index="ripsaw-fio-results ripsaw-fio-log ripsaw-fio-analyzed-result"

check_es $uuid $index
exit $?

8 changes: 5 additions & 3 deletions fs_drift_wrapper/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push fs_drift_wrapper/Dockerfile quay.io/cloud-bulldozer/fs-drift:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/fs-drift:master"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/fs-drift:$SNAFU_IMAGE_TAG
build_and_push fs_drift_wrapper/Dockerfile $image_spec

cd ripsaw

sed -i 's/fs-drift:master/fs-drift:snafu_ci/g' roles/fs-drift/templates/*
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/fs-drift/templates/* roles/fs-drift/tasks/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_fs_drift.sh
uuid=`cat uuid`
Expand Down
8 changes: 5 additions & 3 deletions hammerdb/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push hammerdb/Dockerfile quay.io/cloud-bulldozer/hammerdb:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/hammerdb:latest"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/hammerdb:$SNAFU_IMAGE_TAG
build_and_push hammerdb/Dockerfile $image_spec

cd ripsaw

sed -i 's/hammerdb:latest/hammerdb:snafu_ci/g' roles/hammerdb/templates/*
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/hammerdb/templates/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_hammerdb.sh
uuid=`cat uuid`
Expand Down
9 changes: 6 additions & 3 deletions iperf/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push iperf/Dockerfile quay.io/cloud-bulldozer/iperf:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/iperf3:latest"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/iperf3:$SNAFU_IMAGE_TAG
build_and_push iperf/Dockerfile $image_spec

cd ripsaw

sed -i 's/iperf:latest/iperf:snafu_ci/g' roles/iperf3-bench/templates/*
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/iperf3-bench/templates/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

# iperf does not utilize a wrapper from snafu, only the Dockerfile
# We will confirm that the test_iperf passes only
bash tests/test_iperf3.sh

10 changes: 7 additions & 3 deletions pgbench-wrapper/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push pgbench-wrapper/Dockerfile quay.io/cloud-bulldozer/pgbench:snafu_ci
default_ripsaw_image="quay.io/cloud-bulldozer/pgbench"
default_ripsaw_tag="latest"
image=$SNAFU_WRAPPER_IMAGE_PREFIX/pgbench
build_and_push pgbench-wrapper/Dockerfile $image:snafu_ci

cd ripsaw

sed -i 's/latest/snafu_ci/g' roles/pgbench/defaults/main.yml
sed -i "s#$default_ripsaw_image#$image#" roles/pgbench/defaults/main.yml
sed -i "s#$default_ripsaw_tag#$SNAFU_IMAGE_TAG#" roles/pgbench/defaults/main.yml

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_pgbench.sh
uuid=`cat uuid`
Expand Down
9 changes: 6 additions & 3 deletions smallfile_wrapper/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push smallfile_wrapper/Dockerfile quay.io/cloud-bulldozer/smallfile:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/smallfile:master"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/smallfile:$SNAFU_IMAGE_TAG
build_and_push smallfile_wrapper/Dockerfile $image_spec

cd ripsaw

sed -i 's/smallfile:master/smallfile:snafu_ci/g' roles/smallfile-bench/templates/*
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/smallfile-bench/templates/* roles/smallfile-bench/tasks/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_smallfile.sh
uuid=`cat uuid`
Expand All @@ -23,3 +25,4 @@ index="ripsaw-smallfile-results ripsaw-smallfile-rsptimes"

check_es $uuid $index
exit $?

8 changes: 5 additions & 3 deletions sysbench/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push sysbench/Dockerfile quay.io/cloud-bulldozer/sysbench:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/sysbench:latest"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/sysbench:$SNAFU_IMAGE_TAG
build_and_push sysbench/Dockerfile $image_spec

cd ripsaw

sed -i 's/sysbench:latest/sysbench:snafu_ci/g' roles/sysbench/templates/*
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/sysbench/templates/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

# sysbench does not utilize a wrapper from snafu, only the Dockerfile
# We will confirm that the test_sysbench passes only
Expand Down
10 changes: 6 additions & 4 deletions uperf-wrapper/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ set -x

source ci/common.sh

# Build uperf image for ci
build_and_push uperf-wrapper/Dockerfile quay.io/cloud-bulldozer/uperf:snafu_ci
# Build image for ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/uperf:latest"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/uperf:$SNAFU_IMAGE_TAG
build_and_push uperf-wrapper/Dockerfile $image_spec

cd ripsaw

sed -i 's/uperf:latest/uperf:snafu_ci/g' roles/uperf-bench/templates/*
sed -si "s#$default_ripsaw_image_spec#$image_spec#g" roles/uperf-bench/templates/*

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_uperf.sh
uuid=`cat uuid`
Expand Down
8 changes: 5 additions & 3 deletions ycsb-wrapper/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ set -x
source ci/common.sh

# Build image for ci
build_and_push ycsb-wrapper/Dockerfile quay.io/cloud-bulldozer/ycsb-server:snafu_ci
default_ripsaw_image_spec="quay.io/cloud-bulldozer/ycsb-server:latest"
image_spec=$SNAFU_WRAPPER_IMAGE_PREFIX/ycsb-server:$SNAFU_IMAGE_TAG
build_and_push ycsb-wrapper/Dockerfile $image_spec

cd ripsaw

sed -i 's/ycsb-server:latest/ycsb-server:snafu_ci/g' roles/load-ycsb/tasks/main.yml
sed -i "s#$default_ripsaw_image_spec#$image_spec#g" roles/load-ycsb/tasks/main.yml

# Build new ripsaw image
update_operator_image snafu_ci
update_operator_image

get_uuid test_ycsb.sh
uuid=`cat uuid`
Expand Down