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

Eliminate warnings, from mocking time, when running test scripts #616

Closed
bschmalhofer opened this issue Nov 4, 2020 · 4 comments
Closed
Labels
enhancement New feature or request
Milestone

Comments

@bschmalhofer
Copy link
Contributor

Running a simple
prove -I . -I Kernel/cpan-lib/ --verbose scripts/test/DynamicField/Driver/WebService/PossibleValuesGet.t
produces the following warnings:


 1 Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine new redefined at /opt/otobo/Kernel/System/DB.pm line 90.
  2 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Connect redefined at /opt/otobo/Kernel/System/DB.pm line 194.
  3 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Disconnect redefined at /opt/otobo/Kernel/System/DB.pm line 382.
  4 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Version redefined at /opt/otobo/Kernel/System/DB.pm line 417.
  5 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Quote redefined at /opt/otobo/Kernel/System/DB.pm line 452.
  6 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Error redefined at /opt/otobo/Kernel/System/DB.pm line 511.
  7 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Do redefined at /opt/otobo/Kernel/System/DB.pm line 537.
  8 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine _InitSlaveDB redefined at /opt/otobo/Kernel/System/DB.pm line 620.
  9 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Prepare redefined at /opt/otobo/Kernel/System/DB.pm line 715.
 10 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine FetchrowArray redefined at /opt/otobo/Kernel/System/DB.pm line 871.
 11 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine ListTables redefined at /opt/otobo/Kernel/System/DB.pm line 941.
 12 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine GetColumnNames redefined at /opt/otobo/Kernel/System/DB.pm line 982.
 13 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine SelectAll redefined at /opt/otobo/Kernel/System/DB.pm line 1018.
 14 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine GetDatabaseFunction redefined at /opt/otobo/Kernel/System/DB.pm line 1061.
 15 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine SQLProcessor redefined at /opt/otobo/Kernel/System/DB.pm line 1095.
 16 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine SQLProcessorPost redefined at /opt/otobo/Kernel/System/DB.pm line 1235.
 17 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine QueryCondition redefined at /opt/otobo/Kernel/System/DB.pm line 1303.
 18 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine QueryInCondition redefined at /opt/otobo/Kernel/System/DB.pm line 1760.
 19 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine QueryStringEscape redefined at /opt/otobo/Kernel/System/DB.pm line 1886.
 20 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Ping redefined at /opt/otobo/Kernel/System/DB.pm line 1920.
 21 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine BeginWork redefined at /opt/otobo/Kernel/System/DB.pm line 1950.
 22 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine Rollback redefined at /opt/otobo/Kernel/System/DB.pm line 1966.
 23 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine _Decrypt redefined at /opt/otobo/Kernel/System/DB.pm line 1979.
 24 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine _Encrypt redefined at /opt/otobo/Kernel/System/DB.pm line 1993.
 25 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine _TypeCheck redefined at /opt/otobo/Kernel/System/DB.pm line 2016.
 26 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine _NameCheck redefined at /opt/otobo/Kernel/System/DB.pm line 2033.
 27 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine _SpecialCharactersGet redefined at /opt/otobo/Kernel/System/DB.pm line 2046.
 28 [Wed Nov  4 10:29:45 2020] PossibleValuesGet.t: Subroutine DESTROY redefined at /opt/otobo/Kernel/System/DB.pm line 2059.

These warnings are likely harmless, but they are annoying.

@bschmalhofer bschmalhofer added the enhancement New feature or request label Nov 4, 2020
@bschmalhofer bschmalhofer added this to the OTOBO 10.1 milestone Nov 4, 2020
bschmalhofer added a commit that referenced this issue Nov 4, 2020
It only works when Module::Refresh was loaded when the other module was
initially loaded. But don't want to turn on the Debugger,
just for avoiding the silly warnings.
Try to go with a simple 'no warnings'.
@bschmalhofer
Copy link
Contributor Author

bschmalhofer commented Nov 4, 2020

These warnings come from Kernel::System::UnitTest::_MockPerlTimeHandling, specifically when reloading modules that use time. It is not trivial to avoid these messages. Let*s investigate whether reloading the modules is really necessary. The most simple solution should be using Test::MockTime .

Alternatively: don't use the object manager for Kernel::System::UnitTest::Helper.

bschmalhofer added a commit that referenced this issue Nov 5, 2020
bschmalhofer added a commit that referenced this issue Nov 5, 2020
bschmalhofer added a commit that referenced this issue Nov 5, 2020
bschmalhofer added a commit that referenced this issue Nov 5, 2020
and turn them into subtests
@bschmalhofer bschmalhofer modified the milestones: OTOBO 10.1, OTOBO 10.0.6 Nov 5, 2020
bschmalhofer added a commit that referenced this issue Nov 5, 2020
bschmalhofer added a commit that referenced this issue Nov 5, 2020
as it is currently not used
Tidying.
bschmalhofer added a commit that referenced this issue Nov 5, 2020
Issue #616: MockTime.pm does not have to be loaded
@bschmalhofer bschmalhofer changed the title Eliminate warnings when running test scripts Eliminate warnings, from mocking time, when running test scripts Nov 5, 2020
@bschmalhofer
Copy link
Contributor Author

Provided a Kernel::System::UnitTest::MockTime module for mocking time. This module can be loaded in the test scripts before the other OTOBO modules are loaded. The specific warnings seem to be gone. Shaving off about 14000 lines in the verbose test output.

@bschmalhofer
Copy link
Contributor Author

Tests look fine.Closing this issue again.

@bschmalhofer
Copy link
Contributor Author

The added testing module Kernel::UnitTest::MockTime overrides DateTime::_core_time() See https://metacpan.org/release/DROLSKY/DateTime-1.08/source/lib/DateTime.pm.

The intent of _ core_time()is indeed to allow easy overriding the way DateTime gets it's time.

1.08 2014-03-11

  • DateTime now calls DateTime->_core_time() instead of calling Perl's time()
    built-in directly. This makes it much easier to override the value of time()
    that DateTime sees. This may make it easier to write tests for code that
    uses DateTime .

But Kernel::UnitTest::MockTime already has overridden Core::GLOBAL::time(). This means that overriding DateTime::_core_time() is not necessary. Removing the override shouldn't change anything.

See also RotherOSS/FAQ#7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant