[Ceph] Update helm tests.

The PS updates helm tests for Ceph-RGW and Ceph-provisioners:
- Checking several randomly generated objects instead of one static object.
- Improved the output of the tests.

Change-Id: I0733d7c47a2a8bdf30b0d6a97c1a0331eb5030c8
This commit is contained in:
Kabanov, Dmitrii 2019-10-01 16:25:49 -07:00
parent b401a2283b
commit 22ef25ab29
3 changed files with 127 additions and 73 deletions

View File

@ -28,6 +28,10 @@ function reset_test_env()
kubectl delete pod -n $pvc_namespace $pod_name kubectl delete pod -n $pvc_namespace $pod_name
fi fi
if kubectl get cm -n $pvc_namespace ${pod_name}-bin; then
kubectl delete cm -n $pvc_namespace ${pod_name}-bin
fi
if kubectl get pvc -n $pvc_namespace $pvc_name; then if kubectl get pvc -n $pvc_namespace $pvc_name; then
kubectl delete pvc -n $pvc_namespace $pvc_name; kubectl delete pvc -n $pvc_namespace $pvc_name;
fi fi
@ -78,6 +82,51 @@ EOF
tee <<EOF | kubectl apply --namespace $pvc_namespace -f - tee <<EOF | kubectl apply --namespace $pvc_namespace -f -
--- ---
kind: ConfigMap
apiVersion: v1
metadata:
name: ${pod_name}-bin
data:
test.sh: |
#!/bin/bash
tmpdir=\$(mktemp -d)
declare -a files_list
total_files=10
function check_result ()
{
red='\033[0;31m'
green='\033[0;32m'
bw='\033[0m'
if [ "\$1" -ne 0 ]; then
echo -e "\${red}\$2\${bw}"
exit 1
else
echo -e "\${green}\$3\${bw}"
fi
}
echo "Preparing \${total_objects} files for test"
for i in \$(seq \$total_files); do
files_list[\$i]="\$(mktemp -p "$tmpdir" -t XXXXXXXX)"
echo "Creating \${files_list[\$i]} file"
dd if=/dev/urandom of="\${files_list[\$i]}" bs=1M count=8
echo "Writing to /mnt/\${files_list[\$i]##*/}"
cp "\${files_list[\$i]}" "/mnt/\${files_list[\$i]##*/}"
check_result \$? "The action failed" "The action succeeded"
done
for i in \$(seq \$total_files); do
echo "Comparing files: \${files_list[\$i]} and /mnt/\${files_list[\$i]##*/}"
cmp "\${files_list[\$i]}" "/mnt/\${files_list[\$i]##*/}"
check_result \$? "The files are not equal" "The files are equal"
done
touch /mnt/SUCCESS && exit 0 || exit 1
---
kind: Pod kind: Pod
apiVersion: v1 apiVersion: v1
metadata: metadata:
@ -87,19 +136,25 @@ spec:
- name: task-pv-storage - name: task-pv-storage
image: {{ .Values.images.tags.ceph_config_helper }} image: {{ .Values.images.tags.ceph_config_helper }}
command: command:
- "/bin/sh" - /tmp/test.sh
args:
- "-c"
- "touch /mnt/SUCCESS && exit 0 || exit 1"
volumeMounts: volumeMounts:
- name: ceph-cm-test
mountPath: /tmp/test.sh
subPath: test.sh
readOnly: true
- name: pvc - name: pvc
mountPath: "/mnt" mountPath: "/mnt"
readOnly: false readOnly: false
restartPolicy: "Never" restartPolicy: "Never"
volumes: volumes:
- name: ceph-cm-test
configMap:
name: ${pod_name}-bin
defaultMode: 0555
- name: pvc - name: pvc
persistentVolumeClaim: persistentVolumeClaim:
claimName: $pvc_name claimName: $pvc_name
...
EOF EOF
# waiting for pod to get completed # waiting for pod to get completed
@ -107,12 +162,14 @@ EOF
while ! kubectl get pods -n $pvc_namespace $pod_name | grep -i Completed; do while ! kubectl get pods -n $pvc_namespace $pod_name | grep -i Completed; do
if [ "$(date +%s)" -gt "${end}" ]; then if [ "$(date +%s)" -gt "${end}" ]; then
kubectl get pods -n $pvc_namespace $pod_name kubectl get pods -n $pvc_namespace $pod_name
kubectl logs -n $pvc_namespace $pod_name
echo "Cannot create POD with rbd storage class $storageclass based PersistentVolumeClaim." echo "Cannot create POD with rbd storage class $storageclass based PersistentVolumeClaim."
exit 1 exit 1
fi fi
sleep 10 sleep 10
done done
kubectl logs -n $pvc_namespace $pod_name
} }

View File

@ -32,6 +32,8 @@ rules:
- persistentvolumeclaims - persistentvolumeclaims
- events - events
- pods - pods
- pods/log
- configmaps
verbs: verbs:
- create - create
- get - get

View File

@ -16,7 +16,11 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/}} */}}
set -ex set -e
tmpdir=$(mktemp -d)
declare -a objects_list
total_objects=10
#NOTE: This function tests keystone based auth. It uses ceph_config_helper #NOTE: This function tests keystone based auth. It uses ceph_config_helper
#container image that has openstack and ceph installed #container image that has openstack and ceph installed
@ -37,39 +41,28 @@ function rgw_keystone_bucket_validation ()
exit 1 exit 1
else else
echo "--> container openstack_test_container found" echo "--> container openstack_test_container found"
echo "Hello world!" | tee /tmp/hello.txt
echo "--> file uploaded to openstack_test_container container" for i in $(seq $total_objects); do
openstack object create --name hello openstack_test_container /tmp/hello.txt openstack object create --name "${objects_list[$i]}" openstack_test_container "${objects_list[$i]}"
echo "--> file ${objects_list[$i]} uploaded to openstack_test_container container"
done
echo "--> list contents of openstack_test_container container" echo "--> list contents of openstack_test_container container"
openstack object list openstack_test_container openstack object list openstack_test_container
echo "--> download object from openstack_test_container container" for i in $(seq $total_objects); do
openstack object save --file /tmp/output.txt openstack_test_container hello echo "--> downloading ${objects_list[$i]} object from openstack_test_container container to ${objects_list[$i]}_object${i} file"
if [ $? -ne 0 ]; then openstack object save --file "${objects_list[$i]}_object${i}" openstack_test_container "${objects_list[$i]}"
echo "Error during openstack CLI execution" check_result $? "Error during openstack CLI execution" "The object downloaded successfully"
exit 1
else
echo "File downloaded from container"
fi
content=$(cat /tmp/output.txt) echo "--> comparing files: ${objects_list[$i]} and ${objects_list[$i]}_object${i}"
if [ "Hello world!" == "${content}" ]; then cmp "${objects_list[$i]}" "${objects_list[$i]}_object${i}"
echo "Content matches from downloaded file using openstack CLI" check_result $? "The files are not equal" "The files are equal"
else
echo "Content is mismatched from downloaded file using openstack CLI"
exit 1
fi
echo "--> deleting object from openstack_test_container container" echo "--> deleting ${objects_list[$i]} object from openstack_test_container container"
openstack object delete openstack_test_container hello openstack object delete openstack_test_container "${objects_list[$i]}"
if [ $? -ne 0 ]; then check_result $? "Error during openstack CLI execution" "The object deleted successfully"
echo "Error during openstack CLI execution" done
exit 1
else
echo "File from container is deleted"
fi
echo "--> deleting openstack_test_container container" echo "--> deleting openstack_test_container container"
openstack container delete openstack_test_container openstack container delete openstack_test_container
@ -86,57 +79,34 @@ function rgw_s3_bucket_validation ()
echo "function: rgw_s3_bucket_validation" echo "function: rgw_s3_bucket_validation"
bucket=s3://rgw-test-bucket bucket=s3://rgw-test-bucket
create_bucket_output=$(s3cmd mb $bucket --host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl) params="--host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl"
s3cmd mb $bucket $params
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Bucket $bucket created" echo "Bucket $bucket created"
echo "Hello world!" | tee /tmp/hello.txt
s3cmd put /tmp/hello.txt $bucket --host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl for i in $(seq $total_objects); do
if [ $? -ne 0 ]; then s3cmd put "${objects_list[$i]}" $bucket $params
echo "Error during s3cmd execution" check_result $? "Error during s3cmd execution" "File ${objects_list[$i]##*/} uploaded to bucket"
exit 1 done
else
echo "File uploaded to bucket"
fi
s3cmd get s3://rgw-test-bucket/hello.txt -> /tmp/output.txt --host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl s3cmd ls $bucket $params
if [ $? -ne 0 ]; then check_result $? "Error during s3cmd execution" "Got list of objects"
echo "Error during s3cmd execution"
exit 1
else
echo "File downloaded from bucket"
fi
content=$(cat /tmp/output.txt) for i in $(seq $total_objects); do
if [ "Hello world!" == "${content}" ]; then s3cmd get "${bucket}/${objects_list[$i]##*/}" -> "${objects_list[$i]}_s3_object${i}" $params
echo "Content matches from downloaded file using s3cmd" check_result $? "Error during s3cmd execution" "File ${objects_list[$i]##*/} downloaded from bucket"
else
echo "Content is mismatched from downloaded file using s3cmd"
exit 1
fi
s3cmd ls $bucket --host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl echo "Comparing files: ${objects_list[$i]} and ${objects_list[$i]}_s3_object${i}"
if [ $? -ne 0 ]; then cmp "${objects_list[$i]}" "${objects_list[$i]}_s3_object${i}"
echo "Error during s3cmd execution" check_result $? "The files are not equal" "The files are equal"
exit 1
fi
s3cmd del s3://rgw-test-bucket/hello.txt --host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl s3cmd del "${bucket}/${objects_list[$i]##*/}" $params
if [ $? -ne 0 ]; then check_result $? "Error during s3cmd execution" "File from bucket is deleted"
echo "Error during s3cmd execution" done
exit 1
else
echo "File from bucket is deleted"
fi
s3cmd del --recursive --force $bucket --host=$RGW_HOST --host-bucket=$RGW_HOST --access_key=$S3_ADMIN_ACCESS_KEY --secret_key=$S3_ADMIN_SECRET_KEY --no-ssl s3cmd del --recursive --force $bucket $params
if [ $? -ne 0 ]; then check_result $? "Error during s3cmd execution" "Bucket is deleted"
echo "Error during s3cmd execution"
exit 1
else
echo "Bucket is deleted"
fi
else else
echo "Error during s3cmd execution" echo "Error during s3cmd execution"
@ -144,6 +114,31 @@ function rgw_s3_bucket_validation ()
fi fi
} }
function check_result ()
{
red='\033[0;31m'
green='\033[0;32m'
bw='\033[0m'
if [ "$1" -ne 0 ]; then
echo -e "${red}$2${bw}"
exit 1
else
echo -e "${green}$3${bw}"
fi
}
function prepare_objects ()
{
echo "Preparing ${total_objects} files for test"
for i in $(seq $total_objects); do
objects_list[$i]="$(mktemp -p "$tmpdir")"
echo "${objects_list[$i]}"
dd if=/dev/urandom of="${objects_list[$i]}" bs=1M count=8
done
}
prepare_objects
if [ "$RGW_TEST_TYPE" == RGW_KS ]; if [ "$RGW_TEST_TYPE" == RGW_KS ];
then then
echo "--> Keystone is enabled. Calling function to test keystone based auth " echo "--> Keystone is enabled. Calling function to test keystone based auth "