deb-ceilometer/tools/make_test_data.sh
Doug Hellmann fbe59cfa34 Create tool for generating test meter data
This new command line tool creates meter events and writes
them directly to the database to make functional testing of
the API easier.

Change-Id: I23145da75dd6d671a36fa6cf8e5e613edabbb01e
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
2012-09-04 16:02:19 -04:00

71 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
bindir=$(dirname $0)
project_name="$1"
if [ -z "$project_name" ]
then
project_name=demo
fi
# Convert a possible project name to an id, if we have
# keystone installed.
if which keystone >/dev/null
then
project=$(keystone tenant-list | grep " $project_name " | cut -f2 -d'|' | cut -f2 -d' ')
else
# Assume they gave us the project id as argument.
project="$project_name"
fi
if [ -z "$project" ]
then
echo "Could not determine project id for \"$project_name\"" 1>&2
exit 1
fi
early1="2012-08-27T07:00:00"
early2="2012-08-27T17:00:00"
start="2012-08-28T00:00:00"
middle1="2012-08-28T08:00:00"
middle2="2012-08-28T18:00:00"
middle3="2012-08-29T09:00:00"
middle4="2012-08-29T19:00:00"
end="2012-08-31T23:59:00"
late1="2012-08-31T10:00:00"
late2="2012-08-31T20:00:00"
mkdata() {
${bindir}/make_test_data.py --project "$project" \
--start "$2" --end "$3" \
"$1" instance:m1.tiny 1
}
dates=(early1 early2 start middle1 middle2 middle3 middle4 end late1 late2)
echo $project
for i in $(seq 0 $((${#dates[@]} - 2)) )
do
iname=${dates[$i]}
eval "ivalue=\$$iname"
for j in $(seq $((i + 1)) $((${#dates[@]} - 1)) )
do
jname=${dates[$j]}
eval "jvalue=\$$jname"
resource_id="${project_name}-$iname-$jname"
echo "$resource_id"
mkdata "$resource_id" "$ivalue" "$jvalue"
[ $? -eq 0 ] || exit $?
done
echo
done