You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

autotest.sh 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #!/bin/bash
  2. #
  3. # ownCloud
  4. #
  5. # @author Thomas Müller
  6. # @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu
  7. #
  8. #$EXECUTOR_NUMBER is set by Jenkins and allows us to run autotest in parallel
  9. DATABASENAME=oc_autotest$EXECUTOR_NUMBER
  10. DATABASEUSER=oc_autotest$EXECUTOR_NUMBER
  11. ADMINLOGIN=admin$EXECUTOR_NUMBER
  12. BASEDIR=$PWD
  13. # use tmpfs for datadir - should speedup unit test execution
  14. if [ -d /dev/shm ]; then
  15. DATADIR=/dev/shm/data-autotest$EXECUTOR_NUMBER
  16. else
  17. DATADIR=$BASEDIR/data-autotest
  18. fi
  19. echo "Using database $DATABASENAME"
  20. # create autoconfig for sqlite, mysql and postgresql
  21. cat > ./tests/autoconfig-sqlite.php <<DELIM
  22. <?php
  23. \$AUTOCONFIG = array (
  24. 'installed' => false,
  25. 'dbtype' => 'sqlite',
  26. 'dbtableprefix' => 'oc_',
  27. 'adminlogin' => '$ADMINLOGIN',
  28. 'adminpass' => 'admin',
  29. 'directory' => '$DATADIR',
  30. );
  31. DELIM
  32. cat > ./tests/autoconfig-mysql.php <<DELIM
  33. <?php
  34. \$AUTOCONFIG = array (
  35. 'installed' => false,
  36. 'dbtype' => 'mysql',
  37. 'dbtableprefix' => 'oc_',
  38. 'adminlogin' => '$ADMINLOGIN',
  39. 'adminpass' => 'admin',
  40. 'directory' => '$DATADIR',
  41. 'dbuser' => '$DATABASEUSER',
  42. 'dbname' => '$DATABASENAME',
  43. 'dbhost' => 'localhost',
  44. 'dbpass' => 'owncloud',
  45. );
  46. DELIM
  47. cat > ./tests/autoconfig-pgsql.php <<DELIM
  48. <?php
  49. \$AUTOCONFIG = array (
  50. 'installed' => false,
  51. 'dbtype' => 'pgsql',
  52. 'dbtableprefix' => 'oc_',
  53. 'adminlogin' => '$ADMINLOGIN',
  54. 'adminpass' => 'admin',
  55. 'directory' => '$DATADIR',
  56. 'dbuser' => '$DATABASEUSER',
  57. 'dbname' => '$DATABASENAME',
  58. 'dbhost' => 'localhost',
  59. 'dbpass' => 'owncloud',
  60. );
  61. DELIM
  62. cat > ./tests/autoconfig-oci.php <<DELIM
  63. <?php
  64. \$AUTOCONFIG = array (
  65. 'installed' => false,
  66. 'dbtype' => 'oci',
  67. 'dbtableprefix' => 'oc_',
  68. 'adminlogin' => '$ADMINLOGIN',
  69. 'adminpass' => 'admin',
  70. 'directory' => '$DATADIR',
  71. 'dbuser' => '$DATABASENAME',
  72. 'dbname' => 'XE',
  73. 'dbhost' => 'localhost',
  74. 'dbpass' => 'owncloud',
  75. );
  76. DELIM
  77. function execute_tests {
  78. echo "Setup environment for $1 testing ..."
  79. # back to root folder
  80. cd $BASEDIR
  81. # revert changes to tests/data
  82. git checkout tests/data/*
  83. # reset data directory
  84. rm -rf $DATADIR
  85. mkdir $DATADIR
  86. # remove the old config file
  87. #rm -rf config/config.php
  88. cp tests/preseed-config.php config/config.php
  89. # drop database
  90. if [ "$1" == "mysql" ] ; then
  91. mysql -u $DATABASEUSER -powncloud -e "DROP DATABASE $DATABASENAME"
  92. fi
  93. if [ "$1" == "pgsql" ] ; then
  94. dropdb -U $DATABASEUSER $DATABASENAME
  95. fi
  96. if [ "$1" == "oci" ] ; then
  97. echo "drop the database"
  98. sqlplus -s -l / as sysdba <<EOF
  99. drop user $DATABASENAME cascade;
  100. EOF
  101. echo "create the database"
  102. sqlplus -s -l / as sysdba <<EOF
  103. create user $DATABASENAME identified by owncloud;
  104. alter user $DATABASENAME default tablespace users
  105. temporary tablespace temp
  106. quota unlimited on users;
  107. grant create session
  108. , create table
  109. , create procedure
  110. , create sequence
  111. , create trigger
  112. , create view
  113. , create synonym
  114. , alter session
  115. to $DATABASENAME;
  116. exit;
  117. EOF
  118. fi
  119. # copy autoconfig
  120. cp $BASEDIR/tests/autoconfig-$1.php $BASEDIR/config/autoconfig.php
  121. # trigger installation
  122. php -f index.php
  123. #test execution
  124. echo "Testing with $1 ..."
  125. cd tests
  126. rm -rf coverage-html-$1
  127. mkdir coverage-html-$1
  128. php -f enable_all.php
  129. if [ "$1" == "sqlite" ] ; then
  130. # coverage only with sqlite - causes segfault on ci.tmit.eu - reason unknown
  131. phpunit --configuration phpunit-autotest.xml --log-junit autotest-results-$1.xml --coverage-clover autotest-clover-$1.xml --coverage-html coverage-html-$1 $2 $3
  132. else
  133. phpunit --configuration phpunit-autotest.xml --log-junit autotest-results-$1.xml $2 $3
  134. fi
  135. }
  136. #
  137. # start test execution
  138. #
  139. if [ -z "$1" ]
  140. then
  141. execute_tests 'sqlite'
  142. execute_tests 'mysql'
  143. execute_tests 'pgsql'
  144. execute_tests 'oci'
  145. else
  146. execute_tests $1 $2 $3
  147. fi
  148. #
  149. # NOTES on mysql:
  150. # - CREATE DATABASE oc_autotest;
  151. # - CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'owncloud';
  152. # - grant all on oc_autotest.* to 'oc_autotest'@'localhost';
  153. #
  154. # - for parallel executor support with EXECUTOR_NUMBER=0:
  155. # - CREATE DATABASE oc_autotest0;
  156. # - CREATE USER 'oc_autotest0'@'localhost' IDENTIFIED BY 'owncloud';
  157. # - grant all on oc_autotest0.* to 'oc_autotest0'@'localhost';
  158. #
  159. # NOTES on pgsql:
  160. # - su - postgres
  161. # - createuser -P oc_autotest (enter password and enable superuser)
  162. # - to enable dropdb I decided to add following line to pg_hba.conf (this is not the safest way but I don't care for the testing machine):
  163. # local all all trust
  164. #
  165. # - for parallel executor support with EXECUTOR_NUMBER=0:
  166. # - createuser -P oc_autotest0 (enter password and enable superuser)
  167. #
  168. # NOTES on oci:
  169. # - it's a pure nightmare to install Oracle on a Linux-System
  170. # - DON'T TRY THIS AT HOME!
  171. # - if you really need it: we feel sorry for you
  172. #