Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): Fix tests when daytime saving time change happened recently #44612

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented Apr 2, 2024

Summary

Fix the quite corner case we are currently having in CI: recent daytime saving time change in Europe is making the share date expiration test fail.
Somehow the tests are also not correctly independent and having this one fail messed up 6 others, by leaving behind a hook expectation it seems.

The bug comes from the order of timezone change and day removal, if you change timezone first and remove 2 days after you do not get the same hours as if you do it the other way around.
Can be tested with this:

<?php

$timezone = new \DateTimeZone('Pacific/Auckland');
$nextWeek = new \DateTime('now', $timezone);
$nextWeek->add(new \DateInterval('P7D'));

$save = clone $nextWeek;
$save->setTime(0, 0);
$save->sub(new \DateInterval('P2D'));
$save->setTimezone(new \DateTimeZone(date_default_timezone_get()));

$save2 = clone $nextWeek;
$save2->setTime(0, 0);
$save2->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$save2->sub(new \DateInterval('P2D'));
		
var_dump(
    $nextWeek,
    $save,
    $save2,
);

Current output (on 2024-04-02):

object(DateTime)#2 (3) {
  ["date"]=>
  string(26) "2024-04-09 22:29:22.491335"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Pacific/Auckland"
}
object(DateTime)#3 (3) {
  ["date"]=>
  string(26) "2024-04-06 13:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}
object(DateTime)#4 (3) {
  ["date"]=>
  string(26) "2024-04-06 14:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}

Checklist

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc requested a review from Altahrim April 2, 2024 09:25
@come-nc come-nc self-assigned this Apr 2, 2024
@come-nc come-nc requested review from a team, ArtificialOwl, icewind1991 and sorbaugh and removed request for a team April 2, 2024 09:31
@come-nc come-nc added the 3. to review Waiting for reviews label Apr 2, 2024
@come-nc come-nc added this to the Nextcloud 30 milestone Apr 2, 2024
@come-nc come-nc added the tests Related to tests label Apr 2, 2024
@come-nc
Copy link
Contributor Author

come-nc commented Apr 2, 2024

/backport to stable29

@come-nc
Copy link
Contributor Author

come-nc commented Apr 2, 2024

/backport to stable28

@come-nc
Copy link
Contributor Author

come-nc commented Apr 2, 2024

/backport to stable27

@come-nc come-nc enabled auto-merge April 2, 2024 10:14
@come-nc come-nc merged commit e05ed23 into master Apr 2, 2024
167 checks passed
@come-nc come-nc deleted the fix/fix-share-manager-tests-near-daytime-change branch April 2, 2024 11:12
Copy link

backportbot bot commented Apr 2, 2024

The backport to stable29 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable29
git pull origin stable29

# Create the new backport branch
git checkout -b backport/44612/stable29

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick fda1c42a

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/44612/stable29

Error: Failed to push branch backport/44612/stable29: fatal: could not read Username for 'https://github.com': No such device or address


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@come-nc
Copy link
Contributor Author

come-nc commented Apr 2, 2024

/backport to stable29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews tests Related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants