1#!/bin/sh 2 3# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 4# Copyright (c) International Business Machines Corp., 2005 5# 6# This program is free software; you can redistribute it and/or 7# modify it under the terms of the GNU General Public License as 8# published by the Free Software Foundation; either version 2 of 9# the License, or (at your option) any later version. 10# 11# This program is distributed in the hope that it would be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write the Free Software Foundation, 18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19# 20# Author: Mitsuru Chinen <[email protected]> 21 22TCID=ftp-upload-stress 23TST_TOTAL=2 24TST_CLEANUP="cleanup" 25 26TST_USE_LEGACY_API=1 27 28# Big file size to upload (byte) 29UPLOAD_BIGFILESIZE=${UPLOAD_BIGFILESIZE:-2147483647} # 2GB - 1 30# Regular file size to upload(byte) 31UPLOAD_REGFILESIZE=${UPLOAD_REGFILESIZE:-1024} # 1K byte 32 33cleanup() 34{ 35 rm -f $FTP_UPLOAD_DIR/ftp_file* 36 rm -f $FTP_UPLOAD_DIR/ftp_reg_file* 37 tst_rmdir 38 pkill vsftpd 39} 40 41setup() 42{ 43 tst_require_root 44 tst_require_cmds pkill vsftpd 45 tst_tmpdir 46 47 tst_resm TINFO "run FTP over IPv$TST_IPVER" 48 49 trap "tst_brkm TBROK 'test interrupted'" INT 50 51 [ -d "$FTP_UPLOAD_DIR" ] || \ 52 tst_brkm TCONF "Start ftp server and set FTP_UPLOAD_DIR var" 53 54 chmod o+w $FTP_UPLOAD_DIR 55 56 getenforce 2> /dev/null | grep -q Enforcing 57 if [ $? -eq 0 ]; then 58 tst_resm TINFO "configuring SELinux FTP parameters" 59 tst_require_cmds chcon setsebool 60 setsebool allow_ftpd_anon_write 1 || \ 61 tst_brkm TBROK "Failed to allow ftpd anonymous write" 62 chcon -R -t public_content_rw_t $FTP_UPLOAD_DIR || \ 63 tst_brkm TBROK "Failed to apply public_content_rw_t" 64 fi 65 66 tst_resm TINFO "restart vsftpd with custom options" 67 pkill vsftpd 68 touch vsftpd.conf 69 70 local ip_opt="-olisten=YES -olisten_ipv6=NO" 71 [ $TST_IPV6 ] && ip_opt="-olisten=NO -olisten_ipv6=YES" 72 73 upload_opt="-owrite_enable=YES -oanon_upload_enable=YES" 74 75 vsftpd $ip_opt $upload_opt -oanonymous_enable=YES vsftpd.conf 76} 77 78test01() 79{ 80 tst_resm TINFO "upload file with size '$UPLOAD_BIGFILESIZE'" 81 82 # Run the script at the remote host 83 tst_rhost_run -s -c "ftp-upload-stress01-rmt.sh $(tst_ipaddr) \ 84 $FTP_UPLOAD_URLDIR ftp_file $UPLOAD_BIGFILESIZE" 85 86 tst_resm TPASS "Test is finished successfully" 87} 88 89test02() 90{ 91 tst_resm TINFO "Upload data asynchronously in $NS_DURATION sec" 92 93 tst_rhost_run -s -c "ftp-upload-stress02-rmt.sh \ 94 $(tst_ipaddr) $FTP_UPLOAD_URLDIR ftp_reg_file \ 95 $UPLOAD_REGFILESIZE $NS_DURATION $CONNECTION_TOTAL" 96 97 tst_resm TPASS "Test is finished successfully" 98} 99 100. tst_net.sh 101setup 102test01 103test02 104tst_exit 105