diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-07-04 09:57:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-04 09:57:12 +0200 |
commit | 8f42a1f1c2f4b88cc8694a489a722a66a79a3716 (patch) | |
tree | ae1b2b1cbba0e472df746de55efef4052e428839 | |
parent | dba072ef3ec7f56e9a9907393d9dfaf3fcf9ac59 (diff) | |
download | nextcloud-server-8f42a1f1c2f4b88cc8694a489a722a66a79a3716.tar.gz nextcloud-server-8f42a1f1c2f4b88cc8694a489a722a66a79a3716.zip |
[stable8] Use oracle docker for ci with stable8 (#24529)
* Use oracle docker for ci with stable8
* Fix failing unit test
-rwxr-xr-x | apps/files_encryption/tests/share.php | 11 | ||||
-rwxr-xr-x | autotest.sh | 82 |
2 files changed, 51 insertions, 42 deletions
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php index a59838ede1c..af8d93e16d9 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -21,6 +21,7 @@ */ namespace OCA\Files_Encryption\Tests; +use OC\HTTPHelper; /** * Class Share @@ -44,6 +45,9 @@ class Share extends TestCase { public $subfolder; public $subsubfolder; + /** @var HTTPHelper */ + private $oldHttpHelper; + public static function setUpBeforeClass() { parent::setUpBeforeClass(); @@ -123,17 +127,20 @@ class Share extends TestCase { $config = $this->getMockBuilder('\OCP\IConfig') ->disableOriginalConstructor()->getMock(); $certificateManager = $this->getMock('\OCP\ICertificateManager'); + /** @var HTTPHelper | \PHPUnit_Framework_MockObject_MockObject $httpHelperMock */ $httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper') ->setConstructorArgs(array($config, $certificateManager)) ->getMock(); - $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(array('success' => true, 'result' => "{'ocs' : { 'meta' : { 'statuscode' : 100 }}}"))); + $httpHelperMock->expects($this->any()) + ->method('post')->with($this->anything()) + ->will($this->returnValue(array('success' => true, 'result' => '{"ocs" : { "meta" : { "statuscode" : 100 }}}'))); $this->registerHttpHelper($httpHelperMock); } /** * Register an http helper mock for testing purposes. - * @param $httpHelper http helper mock + * @param HTTPHelper $httpHelper http helper mock */ private function registerHttpHelper($httpHelper) { $this->oldHttpHelper = \OC::$server->query('HTTPHelper'); diff --git a/autotest.sh b/autotest.sh index 7bb4c80cb9b..9bc1e7fc5be 100755 --- a/autotest.sh +++ b/autotest.sh @@ -66,6 +66,12 @@ if [ -f config/config.php ]; then fi function restore_config { + if [ ! -z "$DOCKER_CONTAINER_ID" ]; then + echo "Kill the docker $DOCKER_CONTAINER_ID" + docker stop "$DOCKER_CONTAINER_ID" + docker rm -f "$DOCKER_CONTAINER_ID" + fi + # Restore existing config if [ -f config/config-autotest-backup.php ]; then mv config/config-autotest-backup.php config/config.php @@ -73,7 +79,7 @@ function restore_config { } # restore config on exit, even when killed -trap restore_config SIGINT SIGTERM +trap restore_config EXIT # use tmpfs for datadir - should speedup unit test execution if [ -d /dev/shm ]; then @@ -129,22 +135,6 @@ cat > ./tests/autoconfig-pgsql.php <<DELIM ); DELIM -cat > ./tests/autoconfig-oci.php <<DELIM -<?php -\$AUTOCONFIG = array ( - 'installed' => false, - 'dbtype' => 'oci', - 'dbtableprefix' => 'oc_', - 'adminlogin' => '$ADMINLOGIN', - 'adminpass' => 'admin', - 'directory' => '$DATADIR', - 'dbuser' => '$DATABASENAME', - 'dbname' => 'XE', - 'dbhost' => 'localhost', - 'dbpass' => 'owncloud', -); -DELIM - function execute_tests { echo "Setup environment for $1 testing ..." # back to root folder @@ -169,28 +159,40 @@ function execute_tests { dropdb -U $DATABASEUSER $DATABASENAME || true fi if [ "$1" == "oci" ] ; then - echo "drop the database" - sqlplus -s -l / as sysdba <<EOF - drop user $DATABASENAME cascade; -EOF - - echo "create the database" - sqlplus -s -l / as sysdba <<EOF - create user $DATABASENAME identified by owncloud; - alter user $DATABASENAME default tablespace users - temporary tablespace temp - quota unlimited on users; - grant create session - , create table - , create procedure - , create sequence - , create trigger - , create view - , create synonym - , alter session - to $DATABASENAME; - exit; -EOF + echo "Fire up the oracle docker" + DOCKER_CONTAINER_ID=$(docker run -d deepdiver/docker-oracle-xe-11g) + DATABASEHOST=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$DOCKER_CONTAINER_ID") + + echo "Waiting for Oracle initialization ... " + + # Try to connect to the OCI host via sqlplus to ensure that the connection is already running + for i in {1..48} + do + if sqlplus "autotest/owncloud@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=$DATABASEHOST)(Port=1521))(CONNECT_DATA=(SID=XE)))" < /dev/null | grep 'Connected to'; then + break; + fi + sleep 5 + done + + DATABASEUSER=autotest + DATABASENAME='XE' + + cat > ./tests/autoconfig-oci.php <<DELIM +<?php +\$AUTOCONFIG = array ( + 'installed' => false, + 'dbtype' => 'oci', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASEUSER', + 'dbname' => '$DATABASENAME', + 'dbhost' => '$DATABASEHOST', + 'dbpass' => 'owncloud', +); +DELIM + fi # copy autoconfig @@ -236,7 +238,6 @@ fi cd "$BASEDIR" -restore_config # # NOTES on mysql: # - CREATE DATABASE oc_autotest; @@ -262,3 +263,4 @@ restore_config # - DON'T TRY THIS AT HOME! # - if you really need it: we feel sorry for you # + |