From de338d9d9f3b838b3d774adf728c7785f46edfb7 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 6 Jun 2025 14:06:57 +0200 Subject: [PATCH 1/3] test: fix s3 external storage tests to run all storages on ci Signed-off-by: Ferdinand Thiessen --- .github/workflows/files-external-s3.yml | 27 ++++++++++++------- .../tests/Storage/Amazons3MultiPartTest.php | 3 ++- .../tests/Storage/Amazons3Test.php | 1 + .../tests/Storage/VersionedAmazonS3Test.php | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/files-external-s3.yml b/.github/workflows/files-external-s3.yml index 5148ef07902..4e685989d73 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -92,14 +92,15 @@ jobs: - name: Wait for S3 run: | - sleep 10 curl -f -m 1 --retry-connrefused --retry 10 --retry-delay 10 http://localhost:9000/minio/health/ready - name: PHPUnit - run: composer run test:files_external -- \ - apps/files_external/tests/Storage/Amazons3Test.php \ - --log-junit junit.xml \ - ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }} + run: | + composer run test:files_external -- \ + --group S3 \ + --log-junit junit.xml \ + apps/files_external/tests/Storage \ + ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }} - name: Upload code coverage if: ${{ !cancelled() && matrix.coverage }} @@ -114,6 +115,11 @@ jobs: with: flags: phpunit-files-external-s3 + - name: Nextcloud logs + if: always() + run: | + cat data/nextcloud.log + - name: S3 logs if: always() run: | @@ -170,11 +176,12 @@ jobs: echo " true,'hostname' => 'localhost','key' => 'ignored','secret' => 'ignored', 'bucket' => 'bucket', 'port' => 4566, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php - name: PHPUnit - run: composer run test:files_external -- \ - apps/files_external/tests/Storage/Amazons3Test.php \ - apps/files_external/tests/Storage/VersionedAmazonS3Test.php \ - --log-junit junit.xml \ - ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }} + run: | + composer run test:files_external -- \ + --group S3 \ + --log-junit junit.xml \ + apps/files_external/tests/Storage \ + ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }} - name: Upload code coverage if: ${{ !cancelled() && matrix.coverage }} diff --git a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php index 93f2d7bf66e..b0b9743dc31 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -13,6 +13,7 @@ use OCA\Files_External\Lib\Storage\AmazonS3; * Class Amazons3Test * * @group DB + * @group S3 * * @package OCA\Files_External\Tests\Storage */ @@ -25,7 +26,7 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage { parent::setUp(); $this->config = include('files_external/tests/config.amazons3.php'); - if (! is_array($this->config) or ! $this->config['run']) { + if (!is_array($this->config) || !$this->config['run']) { $this->markTestSkipped('AmazonS3 backend not configured'); } $this->instance = new AmazonS3($this->config + [ diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php index 6d27b0b3253..2148bdd5c5f 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -14,6 +14,7 @@ use OCA\Files_External\Lib\Storage\AmazonS3; * Class Amazons3Test * * @group DB + * @group S3 * * @package OCA\Files_External\Tests\Storage */ diff --git a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php index 4d9d1e32067..89c601c6528 100644 --- a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php +++ b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php @@ -10,6 +10,7 @@ namespace OCA\Files_External\Tests\Storage; /** * @group DB + * @group S3 */ class VersionedAmazonS3Test extends Amazons3Test { protected function setUp(): void { From 22b9d912b1dd571a30eb40a19f8b9107adbaec94 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 6 Jun 2025 19:13:48 +0200 Subject: [PATCH 2/3] test: only skip tests failing on localstack for localstack Signed-off-by: Ferdinand Thiessen --- .github/workflows/files-external-s3.yml | 4 ++-- apps/files_external/tests/Storage/Amazons3MultiPartTest.php | 6 +++++- apps/files_external/tests/Storage/Amazons3Test.php | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/files-external-s3.yml b/.github/workflows/files-external-s3.yml index 4e685989d73..3c76185aa48 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -146,7 +146,7 @@ jobs: env: SERVICES: s3 DEBUG: 1 - image: localstack/localstack@sha256:b52c16663c70b7234f217cb993a339b46686e30a1a5d9279cb5feeb2202f837c # v4.4.0 + image: localstack/localstack@sha256:9d4253786e0effe974d77fe3c390358391a56090a4fff83b4600d8a64404d95d # v4.5.0 ports: - "4566:4566" @@ -173,7 +173,7 @@ jobs: composer install ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password ./occ app:enable --force files_external - echo " true,'hostname' => 'localhost','key' => 'ignored','secret' => 'ignored', 'bucket' => 'bucket', 'port' => 4566, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php + echo " true, 'localstack' => true, 'hostname' => 'localhost','key' => 'ignored','secret' => 'ignored', 'bucket' => 'bucket', 'port' => 4566, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php - name: PHPUnit run: | diff --git a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php index b0b9743dc31..05d59c520a0 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -48,6 +48,10 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage { } public function testHashInFileName(): void { - $this->markTestSkipped('Localstack has a bug with hashes in filename'); + if (isset($this->config['localstack'])) { + $this->markTestSkipped('Localstack has a bug with hashes in filename'); + } + + parent::testHashInFileName(); } } diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php index 2148bdd5c5f..f9cf97e0d02 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -46,6 +46,9 @@ class Amazons3Test extends \Test\Files\Storage\Storage { } public function testHashInFileName(): void { - $this->markTestSkipped('Localstack has a bug with hashes in filename'); + if (isset($this->config['localstack'])) { + $this->markTestSkipped('Localstack has a bug with hashes in filename'); + } + parent::testHashInFileName(); } } From 5f200c776529d1763c0854c35f00aff33f3fc869 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 7 Jun 2025 16:35:46 +0200 Subject: [PATCH 3/3] test: reenable localstack tests (bug fixed) but disable MinIO versioned copy test Signed-off-by: Ferdinand Thiessen --- .github/workflows/files-external-s3.yml | 8 ++++---- .../tests/Storage/Amazons3MultiPartTest.php | 8 -------- apps/files_external/tests/Storage/Amazons3Test.php | 11 ++--------- .../tests/Storage/VersionedAmazonS3Test.php | 8 ++++++++ 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.github/workflows/files-external-s3.yml b/.github/workflows/files-external-s3.yml index 3c76185aa48..89ddc2e508e 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -45,9 +45,9 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.1', '8.2', '8.3', '8.4'] + php-versions: ['8.1', '8.2', '8.4'] include: - - php-versions: '8.2' + - php-versions: '8.3' coverage: ${{ github.event_name != 'pull_request' }} name: php${{ matrix.php-versions }}-s3-minio @@ -88,7 +88,7 @@ jobs: composer install ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password ./occ app:enable --force files_external - echo " true, 'secret' => 'actually-not-secret', 'passwordsalt' => 'actually-not-secret', 'hostname' => 'localhost','key' => '$OBJECT_STORE_KEY','secret' => '$OBJECT_STORE_SECRET', 'bucket' => 'bucket', 'port' => 9000, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php + echo " true, 'minio' => true, 'secret' => 'actually-not-secret', 'passwordsalt' => 'actually-not-secret', 'hostname' => 'localhost','key' => '$OBJECT_STORE_KEY','secret' => '$OBJECT_STORE_SECRET', 'bucket' => 'bucket', 'port' => 9000, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php - name: Wait for S3 run: | @@ -134,7 +134,7 @@ jobs: strategy: matrix: - php-versions: ['8.1', '8.2', '8.3'] + php-versions: ['8.1', '8.2', '8.4'] include: - php-versions: '8.3' coverage: ${{ github.event_name != 'pull_request' }} diff --git a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php index 05d59c520a0..aa3925899f3 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -46,12 +46,4 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage { public function testStat(): void { $this->markTestSkipped('S3 doesn\'t update the parents folder mtime'); } - - public function testHashInFileName(): void { - if (isset($this->config['localstack'])) { - $this->markTestSkipped('Localstack has a bug with hashes in filename'); - } - - parent::testHashInFileName(); - } } diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php index f9cf97e0d02..d02dec0230c 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -19,7 +19,7 @@ use OCA\Files_External\Lib\Storage\AmazonS3; * @package OCA\Files_External\Tests\Storage */ class Amazons3Test extends \Test\Files\Storage\Storage { - private $config; + protected $config; /** @var AmazonS3 */ protected $instance; @@ -27,7 +27,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage { parent::setUp(); $this->config = include('files_external/tests/config.amazons3.php'); - if (! is_array($this->config) or ! $this->config['run']) { + if (!is_array($this->config) || !$this->config['run']) { $this->markTestSkipped('AmazonS3 backend not configured'); } $this->instance = new AmazonS3($this->config); @@ -44,11 +44,4 @@ class Amazons3Test extends \Test\Files\Storage\Storage { public function testStat(): void { $this->markTestSkipped('S3 doesn\'t update the parents folder mtime'); } - - public function testHashInFileName(): void { - if (isset($this->config['localstack'])) { - $this->markTestSkipped('Localstack has a bug with hashes in filename'); - } - parent::testHashInFileName(); - } } diff --git a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php index 89c601c6528..9d413620292 100644 --- a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php +++ b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php @@ -26,4 +26,12 @@ class VersionedAmazonS3Test extends Amazons3Test { $this->markTestSkipped("s3 backend doesn't seem to support versioning"); } } + + public function testCopyOverWriteDirectory(): void { + if (isset($this->config['minio'])) { + $this->markTestSkipped('MinIO has a bug with batch deletion on versioned storages, see https://github.com/minio/minio/issues/21366'); + } + + parent::testCopyOverWriteDirectory(); + } }