From f8f1de4b0be98dd6aaaeed5bba47a2011e35be20 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 | 21 +++++++++++-------- .../tests/Storage/Amazons3MultiPartTest.php | 3 ++- .../tests/Storage/Amazons3Test.php | 1 + .../tests/Storage/VersionedAmazonS3Test.php | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/files-external-s3.yml b/.github/workflows/files-external-s3.yml index 5d0711554236e..54fce452281dd 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -91,14 +91,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 \ - apps/files_external/tests/Storage/VersionedAmazonS3Test.php \ - ${{ 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 }} @@ -163,10 +164,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 \ - ${{ 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 fc3aeef35a337..e95c797a5787d 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -12,6 +12,7 @@ * Class Amazons3Test * * @group DB + * @group S3 * * @package OCA\Files_External\Tests\Storage */ @@ -24,7 +25,7 @@ protected function setUp(): void { 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 2e12b1b371ca0..fe9269a663212 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -13,6 +13,7 @@ * 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 4d9d1e3206758..89c601c6528d6 100644 --- a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php +++ b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php @@ -10,6 +10,7 @@ /** * @group DB + * @group S3 */ class VersionedAmazonS3Test extends Amazons3Test { protected function setUp(): void { From 8e54caa0528d5e6e103ff15b861957140949186f 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 ++-- .../tests/Storage/Amazons3MultiPartTest.php | 8 ++++++-- apps/files_external/tests/Storage/Amazons3Test.php | 7 +++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/files-external-s3.yml b/.github/workflows/files-external-s3.yml index 54fce452281dd..2c32d158feeb8 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -134,7 +134,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" @@ -161,7 +161,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 e95c797a5787d..7bafd75396e45 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -46,7 +46,11 @@ public function testStat() { $this->markTestSkipped('S3 doesn\'t update the parents folder mtime'); } - public function testHashInFileName() { - $this->markTestSkipped('Localstack has a bug with hashes in filename'); + 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 fe9269a663212..f5099885b1fc6 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -44,7 +44,10 @@ public function testStat() { $this->markTestSkipped('S3 doesn\'t update the parents folder mtime'); } - public function testHashInFileName() { - $this->markTestSkipped('Localstack has a bug with hashes in filename'); + public function testHashInFileName(): void { + if (isset($this->config['localstack'])) { + $this->markTestSkipped('Localstack has a bug with hashes in filename'); + } + parent::testHashInFileName(); } } From 2f56cc3950c02905fd340d74a75c374724178912 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 2c32d158feeb8..e3043737a7a2a 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -44,9 +44,9 @@ jobs: strategy: matrix: - php-versions: ['8.1', '8.2', '8.3'] + php-versions: ['8.1', '8.2'] include: - - php-versions: '8.2' + - php-versions: '8.3' coverage: ${{ github.event_name != 'pull_request' }} name: php${{ matrix.php-versions }}-s3 @@ -87,7 +87,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: | @@ -122,7 +122,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: true diff --git a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php index 7bafd75396e45..55b3efe482732 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -45,12 +45,4 @@ protected function tearDown(): void { public function testStat() { $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 f5099885b1fc6..2b66f3beb6ebb 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -18,7 +18,7 @@ * @package OCA\Files_External\Tests\Storage */ class Amazons3Test extends \Test\Files\Storage\Storage { - private $config; + protected $config; /** @var AmazonS3 */ protected $instance; @@ -26,7 +26,7 @@ protected function setUp(): void { 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); @@ -43,11 +43,4 @@ protected function tearDown(): void { public function testStat() { $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 89c601c6528d6..9d413620292bf 100644 --- a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php +++ b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php @@ -26,4 +26,12 @@ protected function setUp(): void { $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(); + } }