###############################################################################
#                                                                             #
#  TakTuk, a middleware for adaptive large scale parallel remote executions   #
#  deployment. Perl implementation, copyright(C) 2006 Guillaume Huard.        #
#                                                                             #
#  This program is free software; you can redistribute it and/or modify       #
#  it under the terms of the GNU General Public License as published by       #
#  the Free Software Foundation; either version 2 of the License, or          #
#  (at your option) any later version.                                        #
#                                                                             #
#  This program is distributed in the hope that it will be useful,            #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of             #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
#  GNU General Public License for more details.                               #
#                                                                             #
#  You should have received a copy of the GNU General Public License          #
#  along with this program; if not, write to the Free Software                #
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA #
#                                                                             #
#  Contact: Guillaume.Huard@imag.fr                                           #
#           ENSIMAG - Laboratoire ID                                          #
#           51 avenue Jean Kuntzmann                                          #
#           38330 Montbonnot Saint Martin                                     #
#                                                                             #
###############################################################################

0:TITLE:DATA TRANSFER TESTS

1:TITLE:RAW, Random data transfer using legacy commands set
1:RAW:echo "GENERATING DATA"
1:RAW:dd if=/dev/urandom of=/tmp/source.taktuk bs=1024 count=10000
1:RAW:echo "TRANSMITING"
1:CMD:$TAKTUK -m localhost broadcast exec [ "'cat >/tmp/destination.taktuk'" ], broadcast input file [ /tmp/source.taktuk ], broadcast input close
1:RAW:echo "VERIFYING"
1:RAW:ret=0
1:RAW:if diff /tmp/source.taktuk /tmp/destination.taktuk
1:RAW:then
1:RAW:  echo "OK"
1:RAW:else
1:RAW:     echo "CHECK FAILED"
1:RAW:  ret=1
1:RAW:fi
1:RAW:rm /tmp/source.taktuk /tmp/destination.taktuk
1:RAW:exit $ret

2:TITLE:CONNECTOR, File transfer at connection
2:RAW:echo "GENERATING DATA"
2:RAW:dd if=/dev/urandom of=/tmp/source.taktuk bs=1024 count=10000
2:RAW:chmod ug+x /tmp/source.taktuk
2:RAW:echo "TRANSMITING"
2:CMD:$TAKTUK -S /tmp/source.taktuk:/tmp/destination.taktuk -m localhost broadcast exec - ls -l '"/tmp/*.taktuk"' -
2:RAW:echo "VERIFYING"
2:RAW:ret=0
2:RAW:if diff /tmp/source.taktuk /tmp/destination.taktuk
2:RAW:then
2:RAW:  echo "OK"
2:RAW:else
2:RAW:     echo "CHECK FAILED"
2:RAW:  ret=1
2:RAW:fi
2:RAW:rm /tmp/source.taktuk /tmp/destination.taktuk
2:RAW:exit $ret

3:TITLE:PUT, Put of large random file only
3:RAW:echo "GENERATING DATA"
3:RAW:mkdir /tmp/src-taktuk
3:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/file1 bs=1024 count=10000
3:RAW:mkdir /tmp/dest-taktuk
3:RAW:echo "TRANSMITING"
3:CMD:$TAKTUK -m localhost 1 put - /tmp/src-taktuk/file1 - - /tmp/dest-taktuk -
3:RAW:echo "VERIFYING"
3:RAW:ret=0
3:RAW:if diff -r /tmp/src-taktuk /tmp/dest-taktuk
3:RAW:then
3:RAW:     echo "OK"
3:RAW:else
3:RAW:     echo "CHECK FAILED"
3:RAW:     ret=1
3:RAW:fi
3:RAW:rm -r /tmp/src-taktuk /tmp/dest-taktuk
3:RAW:exit $ret

4:TITLE:PUT, Put of large random file and directory
4:RAW:echo "GENERATING DATA"
4:RAW:mkdir /tmp/src-taktuk
4:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/file1 bs=1024 count=10000
4:RAW:mkdir /tmp/src-taktuk/dir
4:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/dir/file2 bs=1024 count=10000
4:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/dir/file3 bs=1024 count=10000
4:RAW:mkdir /tmp/dest-taktuk
4:RAW:echo "TRANSMITING"
4:CMD:$TAKTUK -m localhost broadcast put - /tmp/src-taktuk/file1 - - /tmp/dest-taktuk -, 1 put - /tmp/src-taktuk/dir - - /tmp/dest-taktuk -
4:RAW:echo "VERIFYING"
4:RAW:ret=0
4:RAW:if diff -r /tmp/src-taktuk /tmp/dest-taktuk
4:RAW:then
4:RAW:     echo "OK"
4:RAW:else
4:RAW:     echo "CHECK FAILED"
4:RAW:     ret=1
4:RAW:fi
4:RAW:rm -r /tmp/src-taktuk /tmp/dest-taktuk
4:RAW:exit $ret

5:TITLE:GET, Get of random file and directory
5:RAW:echo "GENERATING DATA"
5:RAW:mkdir /tmp/src-taktuk
5:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/file1 bs=1024 count=10000
5:RAW:mkdir /tmp/src-taktuk/dir
5:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/dir/file2 bs=1024 count=10000
5:RAW:dd if=/dev/urandom of=/tmp/src-taktuk/dir/file3 bs=1024 count=10000
5:RAW:mkdir /tmp/dest-taktuk-1
5:RAW:echo "TRANSMITING"
5:CMD:$TAKTUK -m localhost
 :RAW:    broadcast get - /tmp/src-taktuk/file1 - - /tmp/dest-taktuk-\$rank -, 1 get - /tmp/src-taktuk/dir - - /tmp/dest-taktuk-\$rank -
5:RAW:echo "VERIFYING"
5:RAW:ret=0
5:RAW:if diff -r /tmp/src-taktuk /tmp/dest-taktuk-1
5:RAW:then
5:RAW:     echo "OK"
5:RAW:else
5:RAW:     echo "CHECK FAILED"
5:RAW:     ret=1
5:RAW:fi
5:RAW:rm -r /tmp/src-taktuk /tmp/dest-taktuk-1
5:RAW:exit $ret

6:TITLE:RAW, Random data transfer using piped input
6:INC:echo_pipe_commands.sh
6:RAW:echo "GENERATING DATA"
6:RAW:dd if=/dev/urandom of=/tmp/source.taktuk bs=1024 count=10000
6:RAW:echo "TRANSMITING"
6:CMD:echo_pipe_commands '|' $TAKTUK -m localhost
 :RAW:    -o state='(($line > 9) and ($line < 13))?"TakTuk says > ".event_msg($line)."\n":""'
6:RAW:echo "VERIFYING"
6:RAW:ret=0
6:RAW:if diff /tmp/source.taktuk /tmp/destination.taktuk
6:RAW:then
6:RAW:  echo "OK"
6:RAW:else
6:RAW:     echo "CHECK FAILED"
6:RAW:  ret=1
6:RAW:fi
6:RAW:rm /tmp/source.taktuk /tmp/destination.taktuk
6:RAW:exit $ret
