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