From 719a38ca7814485c3933403884fe9070bd7c405c Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Thu, 5 Apr 2012 18:03:06 +0300 Subject: [PATCH] fixed test scripts --- bin/v_add_cron_job | 4 +-- bin/v_list_web_domain | 4 +-- bin/v_unsuspend_cron_job | 2 +- func/shared.sh | 4 +-- test/test_actions.sh | 71 +++++++++++++++++++++++++++++++++++---- test/test_json_listing.sh | 12 ++++--- 6 files changed, 78 insertions(+), 19 deletions(-) diff --git a/bin/v_add_cron_job b/bin/v_add_cron_job index ab785ef6..bb06fd46 100755 --- a/bin/v_add_cron_job +++ b/bin/v_add_cron_job @@ -46,8 +46,8 @@ is_object_free 'cron' 'JOB' "$job" # Concatenating cron string command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month WDAY='$wday'" -str="$v_str' CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" +str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" # Adding to crontab echo "$str" >> $VESTA/data/users/$user/cron.conf diff --git a/bin/v_list_web_domain b/bin/v_list_web_domain index ea58416d..018f9b81 100755 --- a/bin/v_list_web_domain +++ b/bin/v_list_web_domain @@ -31,9 +31,9 @@ json_list_domain() { echo -e "\t\"$value\": {" else if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"," - else echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," fi fi (( ++i)) diff --git a/bin/v_unsuspend_cron_job b/bin/v_unsuspend_cron_job index 1e22fbc6..49d1b557 100755 --- a/bin/v_unsuspend_cron_job +++ b/bin/v_unsuspend_cron_job @@ -12,7 +12,7 @@ # Argument defenition user=$1 job=$2 -restart="$3" +restart="${3-yes}" # Includes source $VESTA/conf/vesta.conf diff --git a/func/shared.sh b/func/shared.sh index 3d23c6c9..488a0b1e 100644 --- a/func/shared.sh +++ b/func/shared.sh @@ -426,9 +426,9 @@ sync_cron_jobs() { if [ "$CRON_REPORTS" = 'yes' ]; then echo "MAILTO=$CONTACT" > /var/spool/cron/$user fi - while read line ; do + while read line; do eval $line - if [ "$SUSPENDED" = 'no' ] ; then + if [ "$SUSPENDED" = 'no' ]; then echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\ sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" |\ >> /var/spool/cron/$user diff --git a/test/test_actions.sh b/test/test_actions.sh index c57df4fb..50159b50 100755 --- a/test/test_actions.sh +++ b/test/test_actions.sh @@ -36,7 +36,7 @@ echo_result() { } # Create random username -user="tmp_$(random 4)" +user="testu_$(random 4)" while [ ! -z "$(grep "^$user:" /etc/passwd)" ]; do user="tmp_$(random 4)" done @@ -45,18 +45,21 @@ done tmpfile=$(mktemp -p /tmp ) -# Add new user +# Add user cmd="v_add_user $user $user $user@vestacp.com default Super Test" $cmd > $tmpfile 2>> $tmpfile echo_result "Adding new user $user" "$?" "$tmpfile" "$cmd" +# Change user password +cmd="v_change_user_password $user t3st_p4ssw0rd" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Changing password" "$?" "$tmpfile" "$cmd" # Change system shell cmd="v_change_user_shell $user bash" $cmd > $tmpfile 2>> $tmpfile echo_result "Changing system shell to /bin/bash" "$?" "$tmpfile" "$cmd" - # Change name servers cmd="v_change_user_ns $user ns0.com ns1.com ns2.com ns3.com" $cmd > $tmpfile 2>> $tmpfile @@ -103,6 +106,15 @@ else fi echo_result "Dublicate cron job check" "$retval" "$tmpfile" "$cmd" +# Add second cron job +cmd="v_add_cron_job $user 2 2 2 2 2 echo 2" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding second cron job" "$?" "$tmpfile" "$cmd" + +# Rebuild cron jobs +cmd="v_rebuild_cron_jobs $user" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Rebuilding cron jobs" "$?" "$tmpfile" "$cmd" # List network interfaces cmd="v_list_sys_interfaces plain" @@ -113,21 +125,66 @@ else echo_result "Listing network interfaces" "0" "$tmpfile" "$cmd" fi - -# Add new ip address +# Add ip address cmd="v_add_sys_ip 198.18.0.123 255.255.255.255 $interface $user" $cmd > $tmpfile 2>> $tmpfile echo_result "Adding ip 198.18.0.123" "$?" "$tmpfile" "$cmd" - # Delete ip address cmd="v_delete_sys_ip 198.18.0.123" $cmd > $tmpfile 2>> $tmpfile echo_result "Deleting ip 198.18.0.123" "$?" "$tmpfile" "$cmd" +# Add ip address +cmd="v_add_sys_ip 198.18.0.125 255.255.255.255 $interface $user" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding ip 198.18.0.125" "$?" "$tmpfile" "$cmd" -# Delete new user +# Add web domain +domain="test-$(random 4).vestacp.com" +cmd="v_add_web_domain $user $domain 198.18.0.125" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding web domain $domain on 198.18.0.125" "$?" "$tmpfile" "$cmd" + +# Add web domain alias +cmd="v_add_web_domain_alias $user $domain v3.$domain" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding alias v3.$domain" "$?" "$tmpfile" "$cmd" + +# Add dns domain +cmd="v_add_dns_domain $user $domain 198.18.0.125" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding dns domain $domain" "$?" "$tmpfile" "$cmd" + +# Add mail domain +cmd="v_add_mail_domain $user $domain" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding mail domain $domain" "$?" "$tmpfile" "$cmd" + +# Add mysql database +database=d$(random 4) +cmd="v_add_database $user $database $database dbp4ssw0rd mysql" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding mysql database $database" "$?" "$tmpfile" "$cmd" + +# Add pgsql database +database=d$(random 4) +cmd="v_add_database $user $database $database dbp4ssw0rd pgsql" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Adding pgsql database $database" "$?" "$tmpfile" "$cmd" + +# Rebuild user configs +cmd="v_rebuild_user $user yes" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Rebuilding user config" "$?" "$tmpfile" "$cmd" + +# Delete user cmd="v_delete_user $user" $cmd > $tmpfile 2>> $tmpfile echo_result "Deleting user $user" "$?" "$tmpfile" "$cmd" +# Delete ip address +cmd="v_delete_sys_ip 198.18.0.125" +$cmd > $tmpfile 2>> $tmpfile +echo_result "Deleting ip 198.18.0.125" "$?" "$tmpfile" "$cmd" + diff --git a/test/test_json_listing.sh b/test/test_json_listing.sh index 8002037a..16d17564 100755 --- a/test/test_json_listing.sh +++ b/test/test_json_listing.sh @@ -6,18 +6,20 @@ V_BIN="$VESTA/bin" V_TEST="$VESTA/test" commands='v_list_cron_jobs admin json -v_list_db_bases admin json -v_list_db_base admin admin_read json -v_list_db_host mysql localhost json -v_list_db_hosts mysql json +v_list_databases admin json +v_list_database admin admin_vesta json +v_list_database_server mysql localhost json +v_list_database_servers mysql json v_list_dns_domains admin json +v_list_mail_domains admin json v_list_dns_templates json +v_list_mail_domains admin json v_list_sys_config json v_list_sys_interfaces json v_list_sys_ips json v_list_sys_rrd json v_list_user admin json -v_list_user_backups vesta json +v_list_user_backups admin json v_list_user_ips admin json v_list_user_ns admin json v_list_user_packages json