Skip to content

testCheckUpdate fails on Owncloud external storage type #38731

Open

Description

@phil-davis

Steps to reproduce

See PR #38354

  1. run the apps/files_external/tests/Storage/OwncloudTest.php

Expected behaviour

Pass

Actual behaviour

https://drone.owncloud.com/owncloud/core/30016/35/10

PHPUnit 8.5.15 by Sebastian Bergmann and contributors.

Runtime:       PHPDBG 7.4.18
Configuration: /drone/src/tests/phpunit-autotest-external.xml

.............................................F................... 65 / 85 ( 76%)
....................                                              85 / 85 (100%)

Time: 2.23 minutes, Memory: 52.52 MB

There was 1 failure:

1) OCA\Files_External\Tests\Storage\OwncloudTest::testCheckUpdate
No update
Failed asserting that true is false.

/drone/src/tests/lib/Files/Storage/Storage.php:347

FAILURES!
Tests: 85, Assertions: 366, Failures: 1.

Server configuration

CI - see the PR for the configuration.

Activity

  1. phil-davis commented on May 13, 2021

    @phil-davis
    ContributorAuthor

    We are getting this running in CI again after a long time. See issue #34735
    It runs, but we get this 1 unit test failure. Maybe this is a real failure?
    The test is:

    	/**
    	 * Test whether checkUpdate properly returns false when there was
    	 * no change.
    	 */
    	public function testCheckUpdate() {
    		if ($this->instance instanceof \OC\Files\Storage\Wrapper\Wrapper) {
    			$this->markTestSkipped('Cannot test update check on wrappers');
    		}
    		$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
    		$watcher = $this->instance->getWatcher();
    		$watcher->setPolicy(Watcher::CHECK_ALWAYS);
    		$this->instance->file_put_contents('/lorem.txt', \file_get_contents($textFile));
    		$this->assertTrue($watcher->checkUpdate('/lorem.txt'), 'Update detected');
    		$this->assertFalse($watcher->checkUpdate('/lorem.txt'), 'No update');
    	}
    

    And it fails at the last assertFalse

    I will put in an appropriate markTestSkipped for now, so that the other tests can be run regularly in CI.

  2. github-actions commented on Nov 10, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

  3. github-actions commented on Nov 21, 2021

    @github-actions

    This issue has been automatically closed.

  4. phil-davis commented on Nov 21, 2021

    @phil-davis
    ContributorAuthor

    The test skip is commit d2230f9

  5. phil-davis commented on Nov 21, 2021

    @phil-davis
    ContributorAuthor

    I added the bug label so that the bot does not close this. Someone should investigate - it might just be a test issue, or there might be a real issue with the code-under-test.

  6. DeepDiver1975 commented on Jun 22, 2026

    @DeepDiver1975
    Contributor

    🤖 Automated issue triage by Claude Code review agent.

    I investigated this and the situation is still live: the test is skipped, not fixed. On the current default branch the skip is in the shared base test class, not in OwncloudTest:

    • tests/lib/Files/Storage/Storage.php:342-344 — testCheckUpdate() calls markTestSkipped('Skip testCheckUpdate on OwncloudTest see issue 38371') whenever $this instanceof \OCA\Files_External\Tests\Storage\OwncloudTest. (The 38371 in that message is a typo — it refers to this issue, testCheckUpdate fails on Owncloud external storage type #38731.)

    The skip was introduced in PR #38354 (commit d2230f9) to unblock CI for the rest of the suite. So the failure is masked, not resolved.

    Located root cause

    The failing assertion is the second checkUpdate:

    $this->assertTrue($watcher->checkUpdate('/lorem.txt'),  'Update detected'); // passes
    $this->assertFalse($watcher->checkUpdate('/lorem.txt'), 'No update');       // FAILS for OwncloudTest

    The OwnCloud external-storage backend is WebDAV-based — OCA\Files_External\Lib\Storage\OwnCloud extends \OC\Files\Storage\DAV (apps/files_external/lib/Lib/Storage/OwnCloud.php:34). With Watcher::CHECK_ALWAYS, every checkUpdate evaluates:

    • Watcher::needsUpdate() → storage->hasUpdated($path, $cachedData['storage_mtime']) (lib/private/Files/Cache/Watcher.php:122-130)
    • Common::hasUpdated() → return $this->filemtime($path) > $time; (lib/private/Files/Storage/Common.php:325)

    The mtime here comes from the remote DAV server's {DAV:}getlastmodified header, parsed via \strtotime(...) (lib/private/Files/Storage/DAV.php:481, :620, :836). That value has whole-second (HTTP-date) resolution and is produced by the remote server's clock/propagation, whereas storage_mtime cached after the upload is the value seen at write time.

    For native local backends filemtime and the cached storage_mtime agree exactly, so the second hasUpdated returns false → assertFalse passes. For the DAV/ownCloud backend the remote getlastmodified the second time can be strictly greater than the cached storage_mtime (second-rounding boundary + remote mtime not being byte-identical to the locally cached value), so filemtime() > $time is true → checkUpdate returns true → assertFalse(..., 'No update') fails with exactly the reported Failed asserting that true is false. at tests/lib/Files/Storage/Storage.php:347 (now :350).

    In short: this is a DAV-mtime-resolution / propagation interaction with CHECK_ALWAYS, not a regression in business logic. It is essentially a test that does not account for the second-granularity, server-authoritative mtime of WebDAV-backed storages.

    Suggested resolution

    Two reasonable paths (a maintainer call):

    1. Keep the skip but make it explicit and correct — move the skip into OwncloudTest itself (or DAV-based tests generally) with a comment explaining DAV second-resolution mtime, and fix the stale 38371 → 38731 reference.
    2. Make the test mtime-tolerant for DAV backends — e.g. allow a small mtime tolerance / re-stat-after-cache for storages whose mtime is second-granular, so the "no change" check is stable.

    Given the backend is still present and shipped, option 2 is the more correct fix, but it's a behavioral decision for the files_external owners.

  7. phil-davis commented on Jun 24, 2026

    @phil-davis
    ContributorAuthor

    Note: removing the test skip code at the moment does not really enable anything. Unit tests were run in drone with different backend storage in place (rather than just wrappers that simulate what storage "should" do). Those unit test pipelines for webdav, sftp, owncloud and samba have not yet been ported to GitHub workflows.

    After they are running in GitHub workflows, then we can try enabling this skipped test.

  8. DeepDiver1975 commented on Jun 24, 2026

    @DeepDiver1975
    Contributor

    🤖 Automated issue triage by Claude Code review agent.

    Thanks @phil-davis — that context changes the picture. Agreed: removing the markTestSkipped right now wouldn't actually exercise the ownCloud (DAV) backend, since testCheckUpdate currently runs only against wrapper storages that simulate expected behaviour. The real-backend unit-test pipelines (webdav, sftp, owncloud, samba) that used to run in Drone haven't been ported to GitHub workflows yet, so there's nothing to enable against.

    So this isn't actionable as a code fix today. The previously located root cause still appears to hold and is worth keeping on record for when the test is re-enabled:

    • The skip lives in the shared base class — tests/lib/Files/Storage/Storage.php testCheckUpdate() skips when $this instanceof \OCA\Files_External\Tests\Storage\OwncloudTest (the 38371 in the skip message is a typo for testCheckUpdate fails on Owncloud external storage type #38731).
    • The likely cause is the DAV backend's second-granularity, server-authoritative {DAV:}getlastmodified mtime interacting with Watcher::CHECK_ALWAYS: the second checkUpdate can see a remote mtime strictly greater than the cached storage_mtime, so Common::hasUpdated() (filemtime() > $time) re-fires and assertFalse(..., 'No update') fails.

    Recommended next step (no fix needed now): keep this open as a tracker, and once the backend-storage unit-test pipelines are running in GitHub Actions, un-skip testCheckUpdate for the ownCloud backend and confirm whether it's a genuine bug or a test that needs to tolerate second-resolution DAV mtimes. No further automated action on my side until then.

  9. dj4oC commented on Jul 8, 2026

    @dj4oC
    Contributor

    Before this can be acted on, the following needs to be resolved:

    • Not actionable yet: testCheckUpdate is currently skipped for the OwncloudTest (DAV-backed) storage test via tests/lib/Files/Storage/Storage.php, and per the maintainer's 2026-06-24 comment, the real-backend unit-test pipelines (webdav, sftp, owncloud, samba) needed to exercise this path haven't been ported from Drone to GitHub Actions yet — there is nothing to run a fix against right now.
    • Decision needed once that infra is ready: should the fix (a) make the base test's second checkUpdate assertion tolerant of the DAV backend's second-granularity, server-authoritative mtime, or (b) keep an explicit, correctly-referenced skip for DAV-backed storages? These are different changes to tests/lib/Files/Storage/Storage.php.
    • Blocked on: the webdav/sftp/owncloud/samba backend-storage unit-test pipelines landing in GitHub Actions CI.

    🤖 Automated by Claude Code


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions