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

System test test_GetCounters_ShouldOnlyReturnResultsOfLastMinutes sometimes fail #7165

Closed
mattab opened this issue Feb 10, 2015 · 11 comments
Closed
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. worksforme The issue cannot be reproduced and things work as intended.

Comments

@mattab
Copy link
Member

mattab commented Feb 10, 2015

The goal of this issue is to investigate the system test test_GetCounters_ShouldOnlyReturnResultsOfLastMinutes which randomly fails the build (maybe depending on the speed of running the ci build? or the time? not sure)

Examples where the test failed the CI jobs:

1) Piwik\Plugins\Live\tests\Integration\APITest::test_GetCounters_ShouldOnlyReturnResultsOfLastMinutes

Failed asserting that two arrays are equal.

--- Expected

+++ Actual

@@ @@

Array (

0 => Array (

- 'visits' => 24

+ 'visits' => 30

'actions' => 60

'visitors' => 20

'visitsConverted' => 40

)

)


1) Piwik\Plugins\Live\tests\Integration\APITest::test_GetCounters_ShouldOnlyReturnResultsOfLastMinutes

Failed asserting that two arrays are equal.

--- Expected

+++ Actual

@@ @@

Array (

0 => Array (

- 'visits' => 24

- 'actions' => 60

- 'visitors' => 20

- 'visitsConverted' => 40

+ 'visits' => '28'

+ 'actions' => '60'

+ 'visitors' => '20'

+ 'visitsConverted' => '40'

)

)
@mattab mattab added Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. labels Feb 10, 2015
@mattab mattab added this to the Short term milestone Feb 10, 2015
@tsteur
Copy link
Member

tsteur commented Feb 10, 2015

I think it uses the current timestamp so in case around midnight it might create some users for the previous day etc.

@mnapoli
Copy link
Contributor

mnapoli commented Mar 23, 2015

It has been some time that system tests have not been failing randomly from what I've seen, maybe we can close this one? (or maybe I've just missed those random failures?)

@mattab mattab closed this as completed Mar 23, 2015
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 23, 2015
@tsteur
Copy link
Member

tsteur commented Mar 23, 2015

It is still happening all the time see eg yesterday https://travis-ci.org/piwik/piwik/jobs/55422165#L1021

It just depends on the time see my previous comment. It uses the current timestamp so it cannot work.

Unless there was a change?

@tsteur tsteur reopened this Mar 23, 2015
@diosmosis
Copy link
Member

If this is still broken, here's an idea to fix: move Date::factory to class called DateFactory. Then access the class through StaticContainer, then override in test DI Config with a mock factory that lets us override the date. What do you think?

@diosmosis
Copy link
Member

Override the now/today date*

@mnapoli
Copy link
Contributor

mnapoli commented Mar 23, 2015

Override the now/today date*

I've seen this needed in many places, done through private methods overridden using reflection in tests for example. So maybe that could be worth the trouble.

@mattab
Copy link
Member Author

mattab commented Sep 11, 2015

Still happening https://travis-ci.org/piwik/piwik/jobs/79763078 - somehow we need to fix this random test, or skip it around midnight - in this build the bug only appeared on the MYSQLI and not on PDO

@mattab mattab modified the milestones: 2.15.1, Short term Sep 11, 2015
@tsteur
Copy link
Member

tsteur commented Sep 11, 2015

The method to fetch counter actually uses time() and not Date::now() but Date::now() uses time() as well.

Maybe we could use time via DI where needed so it returns current time but one can override it to a fixed time. Did something similar in another plugin just recently:

    'MyPlugin.currentTime' => DI\factory(function () {
        return time();
    }),

It's just important that this one is by default not cached (in my case I needed it only once anyway). Of course we could also create a class etc to get current time() and others and replace that class if needed. Just went with above solution for simplicity

@mattab
Copy link
Member Author

mattab commented Sep 14, 2015

Maybe we could use time via DI where needed so it returns current time but one can override it to a fixed time.

+1

@mattab mattab modified the milestones: 2.16.1, 2.16.0 Jan 10, 2016
@mattab mattab modified the milestones: 2.16.1, 3.0.0 Feb 3, 2016
@mattab mattab removed the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Dec 5, 2016
@sgiehl
Copy link
Member

sgiehl commented Nov 25, 2017

Haven't seen it failing in the last months. Did anyone else? Otherwise guess we could close it now

@sgiehl
Copy link
Member

sgiehl commented Aug 24, 2023

Seems to work meanwhile

@sgiehl sgiehl closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
@sgiehl sgiehl added the worksforme The issue cannot be reproduced and things work as intended. label Aug 24, 2023
@mattab mattab removed this from the Priority Backlog (Help wanted) milestone Dec 10, 2023
@mattab mattab added this to the Backlog (Help wanted) milestone Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

5 participants