From 5169ca61b215c062aae3a4c9d1cbfeaad99e13a7 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Fri, 23 Dec 2016 09:24:17 +0000 Subject: [PATCH 01/10] Added the option to run tests using md5 home --- build/integration/run.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build/integration/run.sh b/build/integration/run.sh index 8afbaa17bef3..d6efada4f427 100755 --- a/build/integration/run.sh +++ b/build/integration/run.sh @@ -8,6 +8,15 @@ OCC=${OC_PATH}occ SCENARIO_TO_RUN=$1 HIDE_OC_LOGS=$2 +function enableMD5HomeStorage { + $OCC app:enable testing + OUTPUT_ENABLING_ALT_USER_BACKEND=`$OCC config:app:set testing enable_alt_user_backend --value yes` +} + +function cleanupMD5HomeStorage { + $OCC app:disable testing +} + # avoid port collision on jenkins - use $EXECUTOR_NUMBER if [ -z "$EXECUTOR_NUMBER" ]; then EXECUTOR_NUMBER=0 @@ -37,6 +46,10 @@ ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | awk {'print $5'}` $OCC files_external:option $ID_STORAGE enable_sharing true +if test "$MD5_HOME_STORAGE" = "1"; then + enableMD5HomeStorage +fi + vendor/bin/behat --strict -f junit -f pretty $SCENARIO_TO_RUN RESULT=$? @@ -48,6 +61,10 @@ $OCC files_external:delete -y $ID_STORAGE #Disable external storage app $OCC app:disable files_external +if test "$MD5_HOME_STORAGE" = "1"; then + cleanupMD5HomeStorage +fi + if [ -z $HIDE_OC_LOGS ]; then tail "${OC_PATH}/data/owncloud.log" fi From 653e657a89f40ca1e1dd647815ccf37d5f4cd3ec Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Fri, 23 Dec 2016 09:39:17 +0000 Subject: [PATCH 02/10] Start using prefixes --- build/integration/run.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/integration/run.sh b/build/integration/run.sh index d6efada4f427..1c209061cc26 100755 --- a/build/integration/run.sh +++ b/build/integration/run.sh @@ -8,12 +8,12 @@ OCC=${OC_PATH}occ SCENARIO_TO_RUN=$1 HIDE_OC_LOGS=$2 -function enableMD5HomeStorage { +function env_alt_home_enable { $OCC app:enable testing - OUTPUT_ENABLING_ALT_USER_BACKEND=`$OCC config:app:set testing enable_alt_user_backend --value yes` + $OCC config:app:set testing enable_alt_user_backend --value yes } -function cleanupMD5HomeStorage { +function env_alt_home_clear { $OCC app:disable testing } @@ -46,8 +46,8 @@ ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | awk {'print $5'}` $OCC files_external:option $ID_STORAGE enable_sharing true -if test "$MD5_HOME_STORAGE" = "1"; then - enableMD5HomeStorage +if test "$OC_TEST_ALT_HOME" = "1"; then + env_althome_enable fi vendor/bin/behat --strict -f junit -f pretty $SCENARIO_TO_RUN @@ -61,8 +61,8 @@ $OCC files_external:delete -y $ID_STORAGE #Disable external storage app $OCC app:disable files_external -if test "$MD5_HOME_STORAGE" = "1"; then - cleanupMD5HomeStorage +if test "$OC_TEST_ALT_HOME" = "1"; then + env_althome_clear fi if [ -z $HIDE_OC_LOGS ]; then From 9c13b23182bee8f959cd60f772aaae3de7e7cc08 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Fri, 23 Dec 2016 10:04:10 +0000 Subject: [PATCH 03/10] Added alt home execution without makefiles for stable9.1 --- Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1f1362e7abcd..31d5be2174d7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -119,6 +119,18 @@ timestampedNode('SLAVE') { ./run.sh ''' } + + executeAndReport('build/integration/output/*.xml') { + sh '''phpenv local 7.0 + rm -rf config/config.php + ./occ maintenance:install --admin-pass=admin + rm -rf build/integration/output + rm -rf build/integration/vendor + rm -rf build/integration/composer.lock + cd build/integration + OC_TEST_ALT_HOME=1 ./run.sh + ''' + } } } From 2dcbb5ae1a52ad25986e4d99be56fe870b1e7d54 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 22 Dec 2016 10:07:01 +0000 Subject: [PATCH 04/10] Added support for homes which doesn't have user's name --- build/integration/features/bootstrap/Provisioning.php | 9 +++++++++ build/integration/features/bootstrap/WebDav.php | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index f4ac9f3346a3..b43d9d5f002e 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -637,6 +637,15 @@ public function userHasUnlimitedQuota($user) $this->userHasAQuotaOf($user, 'none'); } + public function getUserHome($user) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; + $client = new Client(); + $options = []; + $options['auth'] = $this->adminUser; + $this->response = $client->get($fullUrl, $options); + return $this->response->xml()->data[0]->home; + } + /** * @BeforeScenario * @AfterScenario diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 97aaf4fffabc..53534ba2590e 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -444,7 +444,8 @@ public function userAddsAFileTo($user, $bytes, $destination){ PHPUnit_Framework_Assert::assertEquals(1, file_exists("data/$filename")); $this->userUploadsAFileTo($user, "data/$filename", $destination); $this->removeFile("data/", $filename); - PHPUnit_Framework_Assert::assertEquals(1, file_exists("../../data/$user/files$destination")); + $userHome = $this->getUserHome($user); + PHPUnit_Framework_Assert::assertEquals(1, file_exists($userHome . "/files$destination")); } /** From 62081a30685247179130a71c42a468fa0da60721 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 22 Dec 2016 10:17:01 +0000 Subject: [PATCH 05/10] Changed data directory for work one --- build/integration/features/bootstrap/BasicStructure.php | 2 +- build/integration/features/bootstrap/WebDav.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index 5b245f33e230..a816c298449d 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -312,7 +312,7 @@ public function emptyTrashbin($user) { } public function createFileSpecificSize($name, $size){ - $file = fopen("data/" . "$name", 'w'); + $file = fopen("work/" . "$name", 'w'); fseek($file, $size - 1 ,SEEK_CUR); fwrite($file,'a'); // write a dummy char at SIZE position fclose($file); diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 53534ba2590e..8c6b7a092286 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -441,9 +441,9 @@ public function userUploadsAFileTo($user, $source, $destination) public function userAddsAFileTo($user, $bytes, $destination){ $filename = "filespecificSize.txt"; $this->createFileSpecificSize($filename, $bytes); - PHPUnit_Framework_Assert::assertEquals(1, file_exists("data/$filename")); - $this->userUploadsAFileTo($user, "data/$filename", $destination); - $this->removeFile("data/", $filename); + PHPUnit_Framework_Assert::assertEquals(1, file_exists("work/$filename")); + $this->userUploadsAFileTo($user, "work/$filename", $destination); + $this->removeFile("work/", $filename); $userHome = $this->getUserHome($user); PHPUnit_Framework_Assert::assertEquals(1, file_exists($userHome . "/files$destination")); } From 3a9110f3caa5f5d1c312148ffaf4a76dc51f31d5 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 22 Dec 2016 11:35:03 +0000 Subject: [PATCH 06/10] Using propfind instead of accessing the file system --- build/integration/features/bootstrap/WebDav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 8c6b7a092286..dd05a5551748 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -444,8 +444,8 @@ public function userAddsAFileTo($user, $bytes, $destination){ PHPUnit_Framework_Assert::assertEquals(1, file_exists("work/$filename")); $this->userUploadsAFileTo($user, "work/$filename", $destination); $this->removeFile("work/", $filename); - $userHome = $this->getUserHome($user); - PHPUnit_Framework_Assert::assertEquals(1, file_exists($userHome . "/files$destination")); + $expectedElements = new \Behat\Gherkin\Node\TableNode([["$destination"]]); + $this->checkElementList($user, $expectedElements); } /** From 05cc19764cb9f2aed21b67549be452242fb5eab0 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 22 Dec 2016 11:58:36 +0000 Subject: [PATCH 07/10] Added phpdoc for getUserHome --- build/integration/features/bootstrap/Provisioning.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index b43d9d5f002e..7e8509f95f31 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -637,6 +637,10 @@ public function userHasUnlimitedQuota($user) $this->userHasAQuotaOf($user, 'none'); } + /** + * Returns home path of the given user + * @param string $user + */ public function getUserHome($user) { $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; $client = new Client(); From 2135b297f5f7e7bf37d2eaedaaa8c47e06a8fa90 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 11 Jan 2017 09:03:49 +0000 Subject: [PATCH 08/10] fixed alt_home functions names --- build/integration/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integration/run.sh b/build/integration/run.sh index 1c209061cc26..51b8456b9db5 100755 --- a/build/integration/run.sh +++ b/build/integration/run.sh @@ -47,7 +47,7 @@ ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | awk {'print $5'}` $OCC files_external:option $ID_STORAGE enable_sharing true if test "$OC_TEST_ALT_HOME" = "1"; then - env_althome_enable + env_alt_home_enable fi vendor/bin/behat --strict -f junit -f pretty $SCENARIO_TO_RUN @@ -62,7 +62,7 @@ $OCC files_external:delete -y $ID_STORAGE $OCC app:disable files_external if test "$OC_TEST_ALT_HOME" = "1"; then - env_althome_clear + env_alt_home_clear fi if [ -z $HIDE_OC_LOGS ]; then From 395d726bcb03fa7b5597725ed5795a5c760bfed9 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 11 Jan 2017 09:51:44 +0000 Subject: [PATCH 09/10] Fixed federation tests --- build/integration/data/file_to_overwrite.txt | 1 + .../features/bootstrap/BasicStructure.php | 4 ++-- .../federation_features/federated.feature | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 build/integration/data/file_to_overwrite.txt diff --git a/build/integration/data/file_to_overwrite.txt b/build/integration/data/file_to_overwrite.txt new file mode 100644 index 000000000000..f45c3ef31ee5 --- /dev/null +++ b/build/integration/data/file_to_overwrite.txt @@ -0,0 +1 @@ +BLABLABLA diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index a816c298449d..215f089bd8c5 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -297,8 +297,8 @@ public static function removeFile($path, $filename){ * @param string $text */ public function modifyTextOfFile($user, $filename, $text) { - self::removeFile("../../data/$user/files", "$filename"); - file_put_contents("../../data/$user/files" . "$filename", "$text"); + self::removeFile($this->getUserHome($user) . "/files", "$filename"); + file_put_contents($this->getUserHome($user) . "/files" . "$filename", "$text"); } /** diff --git a/build/integration/federation_features/federated.feature b/build/integration/federation_features/federated.feature index 8bf8e921b0ff..70c4b10a106d 100644 --- a/build/integration/federation_features/federated.feature +++ b/build/integration/federation_features/federated.feature @@ -130,9 +130,10 @@ Feature: federated And User "user1" from server "REMOTE" accepts last pending share And Using server "REMOTE" And As an "user1" - And User "user1" modifies text of "/textfile0.txt" with text "BLABLABLA" - When User "user1" uploads file "../../data/user1/files/textfile0.txt" to "/textfile0 (2).txt" - And Downloading file "/textfile0 (2).txt" with range "bytes=0-8" + When User "user1" uploads file "data/file_to_overwrite.txt" to "/textfile0 (2).txt" + And Using server "LOCAL" + And As an "user0" + And Downloading file "/textfile0.txt" with range "bytes=0-8" Then Downloaded content should be "BLABLABLA" Scenario: Overwrite a federated shared folder as recipient @@ -145,9 +146,10 @@ Feature: federated And User "user1" from server "REMOTE" accepts last pending share And Using server "REMOTE" And As an "user1" - And User "user1" modifies text of "/textfile0.txt" with text "BLABLABLA" - When User "user1" uploads file "../../data/user1/files/textfile0.txt" to "/PARENT (2)/textfile0.txt" - And Downloading file "/PARENT (2)/textfile0.txt" with range "bytes=0-8" + When User "user1" uploads file "data/file_to_overwrite.txt" to "/PARENT (2)/textfile0.txt" + And Using server "LOCAL" + And As an "user0" + And Downloading file "/PARENT/textfile0.txt" with range "bytes=0-8" Then Downloaded content should be "BLABLABLA" Scenario: Overwrite a federated shared file as recipient using old chunking From f086279dabfcc0832f03e0da74586334d9780f89 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 11 Jan 2017 10:08:35 +0000 Subject: [PATCH 10/10] Do not take into account testing app in enabled apps scenario --- build/integration/features/bootstrap/Provisioning.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 7e8509f95f31..58ecd659674d 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -486,6 +486,9 @@ public function theAppsShouldBe($appList) { $apps = $appList->getRows(); $appsSimplified = $this->simplifyArray($apps); $respondedArray = $this->getArrayOfAppsResponded($this->response); + if(($key = array_search('testing', $respondedArray)) !== false) { + array_splice($respondedArray, $key, 1); + } PHPUnit_Framework_Assert::assertEquals($appsSimplified, $respondedArray, "", 0.0, 10, true); }