fixed test scripts

This commit is contained in:
Serghey Rodin 2012-04-05 18:03:06 +03:00
parent 4b44937540
commit 719a38ca78
6 changed files with 78 additions and 19 deletions

View file

@ -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

View file

@ -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))

View file

@ -12,7 +12,7 @@
# Argument defenition
user=$1
job=$2
restart="$3"
restart="${3-yes}"
# Includes
source $VESTA/conf/vesta.conf

View file

@ -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

View file

@ -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"

View file

@ -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