feat: [OCISDEV-744] core-api-test

This commit is contained in:
Michal Klos
2026-03-30 14:10:06 +02:00
parent 5e87222571
commit 03e7194f91
3 changed files with 60 additions and 23 deletions

View File

@@ -218,10 +218,14 @@ jobs:
fail-fast: false
matrix:
suite:
- "coreApiAuth,coreApiCapabilities,coreApiFavorites,coreApiMain,coreApiVersions"
- "coreApiShareManagementBasicToShares,coreApiShareManagementToShares"
- "coreApiSharees,coreApiSharePublicLink2"
- "coreApiShareOperationsToShares1,coreApiShareOperationsToShares2,coreApiSharePublicLink1,coreApiShareCreateSpecialToShares1,coreApiShareCreateSpecialToShares2,coreApiShareUpdateToShares"
- "coreApiTrashbin,coreApiTrashbinRestore,coreApiWebdavEtagPropagation1,coreApiWebdavEtagPropagation2"
- "coreApiWebdavDelete,coreApiWebdavOperations,coreApiWebdavMove2"
- "coreApiWebdavProperties"
- "coreApiWebdavMove1,coreApiWebdavPreviews,coreApiWebdavUpload,coreApiWebdavUploadTUS"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
@@ -268,23 +272,16 @@ jobs:
run: >
BEHAT_SUITES="${{ matrix.suite }}"
ACCEPTANCE_TEST_TYPE=core-api
EXPECTED_FAILURES_FILE=tests/acceptance/expected-failures-API-on-OCIS-storage.md
WITH_REMOTE_PHP=true
python3 tests/acceptance/run-github.py
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs-${{ matrix.suite }}
path: tests/acceptance/output/
litmus:
name: litmus
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
@@ -296,8 +293,8 @@ jobs:
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
@@ -309,8 +306,8 @@ jobs:
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
@@ -322,8 +319,8 @@ jobs:
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true

View File

@@ -4063,10 +4063,46 @@ trait WebDav {
* @throws Exception
*/
public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename): void {
$expectedPreview = \file_get_contents(__DIR__ . "/../fixtures/" . $filename);
$fixturePath = __DIR__ . "/../fixtures/" . $filename;
$fixtureImg = \imagecreatefromstring(\file_get_contents($fixturePath));
Assert::assertNotFalse($fixtureImg, "Could not decode fixture image $filename");
$this->getResponse()->getBody()->rewind();
$responseBodyContent = $this->getResponse()->getBody()->getContents();
Assert::assertEquals($expectedPreview, $responseBodyContent);
$responseImg = \imagecreatefromstring($responseBodyContent);
Assert::assertNotFalse($responseImg, "Downloaded preview is not a valid image");
$w = \imagesx($fixtureImg);
$h = \imagesy($fixtureImg);
Assert::assertEquals($w, \imagesx($responseImg), "Image width mismatch for fixture $filename");
Assert::assertEquals($h, \imagesy($responseImg), "Image height mismatch for fixture $filename");
$tolerance = 12; // per-channel tolerance for libvips version differences
$maxDiff = 0;
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$fc = \imagecolorat($fixtureImg, $x, $y);
$rc = \imagecolorat($responseImg, $x, $y);
$maxDiff = \max(
$maxDiff,
\abs(($fc >> 16 & 0xFF) - ($rc >> 16 & 0xFF)),
\abs(($fc >> 8 & 0xFF) - ($rc >> 8 & 0xFF)),
\abs(($fc & 0xFF) - ($rc & 0xFF)),
);
}
}
$rw = \imagesx($responseImg);
$rh = \imagesy($responseImg);
echo " [preview-fixture] $filename: fixture={$w}x{$h} response={$rw}x{$rh} maxPixelDiff=$maxDiff\n";
Assert::assertLessThanOrEqual(
$tolerance,
$maxDiff,
"Preview pixel values differ by more than $tolerance from fixture $filename (max diff: $maxDiff)",
);
\imagedestroy($fixtureImg);
\imagedestroy($responseImg);
}
/**

View File

@@ -355,6 +355,8 @@ def main() -> int:
# generate IDP web assets (required for IDP service to start; matches drone ci-node-generate)
run(["make", "-C", str(repo_root / "services/idp"), "ci-node-generate"])
# download web UI assets (required for robots.txt and other static assets; no pnpm needed)
run(["make", "-C", str(repo_root / "services/web"), "ci-node-generate"])
# build (ENABLE_VIPS=true when libvips-dev is installed, matching drone)
build_env = {}
@@ -646,13 +648,15 @@ def main() -> int:
p = Path(ef_override)
base_failures = p if p.is_absolute() else repo_root / p
# merge expected-failures-without-remotephp.md (drone does this)
# merge expected-failures-without-remotephp.md only when not using remote.php
# (mirrors drone.star: "" if run_with_remote_php else "cat ...without-remotephp.md >> ...")
tmp = tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False)
tmp.write(base_failures.read_text())
without_rphp = repo_root / "tests/acceptance/expected-failures-without-remotephp.md"
if without_rphp.exists():
tmp.write("\n")
tmp.write(without_rphp.read_text())
if os.environ.get("WITH_REMOTE_PHP", "false").lower() != "true":
without_rphp = repo_root / "tests/acceptance/expected-failures-without-remotephp.md"
if without_rphp.exists():
tmp.write("\n")
tmp.write(without_rphp.read_text())
tmp.close()
# run tests