9
SWIFT_CONTAINER_NAME=""
13
a=`md5sum $1 | awk {'print \$1'}`
14
b=`md5sum $2 | awk {'print \$1'}`
18
echo "md5-sums of files $1 and $2 are equal"
20
echo -e "\nUpload file to Swift: $1 \n"
21
echo -e "Download file from Swift: $2 \n"
22
echo -e "md5-sums of files $1 and $2 are not equal \n"
23
echo "$1 != $2" && exit 1
27
check_return_code_after_command_execution() {
37
if [ "$1" = "-clean_hdfs" ]
41
sudo -u $HADOOP_USER bash -lc "hadoop dfs -rmr /swift-test" && exit 1
46
check_swift_availability() {
48
dd if=/dev/urandom of=/tmp/test-file bs=1048576 count=1
50
sudo -u $HADOOP_USER bash -lc "hadoop dfs -mkdir /swift-test"
51
check_return_code_after_command_execution -exit `echo "$?"`
53
sudo -u $HADOOP_USER bash -lc "hadoop dfs -copyFromLocal /tmp/test-file /swift-test/"
54
check_return_code_after_command_execution -clean_hdfs `echo "$?"`
56
sudo -u $HADOOP_USER bash -lc "hadoop distcp -D fs.swift.service.sahara.username=$OS_USERNAME -D fs.swift.service.sahara.tenant=$OS_TENANT_NAME -D fs.swift.service.sahara.password=$OS_PASSWORD /swift-test/test-file swift://$SWIFT_CONTAINER_NAME.sahara/"
57
check_return_code_after_command_execution -clean_hdfs `echo "$?"`
59
sudo -u $HADOOP_USER bash -lc "hadoop distcp -D fs.swift.service.sahara.username=$OS_USERNAME -D fs.swift.service.sahara.tenant=$OS_TENANT_NAME -D fs.swift.service.sahara.password=$OS_PASSWORD swift://$SWIFT_CONTAINER_NAME.sahara/test-file /swift-test/swift-test-file"
60
check_return_code_after_command_execution -clean_hdfs `echo "$?"`
62
sudo -u $HADOOP_USER bash -lc "hadoop dfs -copyToLocal /swift-test/swift-test-file /tmp/swift-test-file"
63
check_return_code_after_command_execution -clean_hdfs `echo "$?"`
65
sudo -u $HADOOP_USER bash -lc "hadoop dfs -rmr /swift-test"
67
compare_files /tmp/test-file /tmp/swift-test-file
69
sudo rm /tmp/test-file /tmp/swift-test-file
72
check_swift_availability