From 99488b0a388b3d7652af9203475ce248bd8ee738 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 6c2d85ce6890b..ddd309f581dec 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 1ac18406d2417..5bb2ad6da3e05 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -11,6 +11,7 @@ * Class Amazons3Test * * @group DB + * @group S3 * * @package OCA\Files_External\Tests\Storage */ @@ -23,7 +24,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 fd7fd9225c930..bcfdc19115410 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -12,6 +12,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 e79e1e2d958d84fadcdfe22355ad27e3e98aa843 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 ddd309f581dec..6a0690a9c28be 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 5bb2ad6da3e05..99acc5b4e9456 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -46,6 +46,10 @@ public function testStat(): void { } 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 bcfdc19115410..b28ff23b43eba 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -44,6 +44,9 @@ public function testStat(): void { } 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 9fa9ffd22971c3324209f95a899ed5e34c744237 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 6a0690a9c28be..6f0298a9c1210 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', '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 @@ -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 99acc5b4e9456..c268b58030199 100644 --- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php +++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php @@ -44,12 +44,4 @@ protected function tearDown(): void { 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 b28ff23b43eba..196f814ba6ca0 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -17,7 +17,7 @@ * @package OCA\Files_External\Tests\Storage */ class Amazons3Test extends \Test\Files\Storage\Storage { - private $config; + protected $config; /** @var AmazonS3 */ protected $instance; @@ -25,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); @@ -42,11 +42,4 @@ protected function tearDown(): void { 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 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(); + } }