New issue
Advanced search Search tips

Issue 658798 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug



Sign in to add a comment

RevisionGeneratorTest.GetNextRevisionCall is broken

Project Member Reported by xyzzyz@chromium.org, Oct 24 2016

Issue description

The tests depends on a specific global state, which it destroys. Because of this, if run twice in a row, it will fail the second time. Moreover, other tests also modify that global state (e.g. Lww tests), which also make it fail if run after these tests.
 

Comment 1 by xyzzyz@chromium.org, Oct 24 2016

For an easy repro, run

$ ./out/Default/blimp_unittests --single-process-tests

Comment 2 by scf@chromium.org, Oct 25 2016

Status: Fixed (was: Untriaged)
Project Member

Comment 3 by bugdroid1@chromium.org, Oct 25 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1ce5fa0395e29192dcefe6d3211d947b32968d40

commit 1ce5fa0395e29192dcefe6d3211d947b32968d40
Author: scf <scf@chromium.org>
Date: Tue Oct 25 17:16:00 2016

Helium: Fix flaky test

Unit test fixture was not using HeliumTest test fixture and thus not properly cleaning state.

BUG= 658798 

Review-Url: https://codereview.chromium.org/2444193002
Cr-Commit-Position: refs/heads/master@{#427387}

[modify] https://crrev.com/1ce5fa0395e29192dcefe6d3211d947b32968d40/blimp/helium/compound_syncable_unittest.cc

Comment 4 by xyzzyz@chromium.org, Oct 25 2016

Status: Assigned (was: Fixed)
The failure is now no longer reproducible with --single-process-tests, but I feel like the RevisionGeneratorTest.GetNextRevisionCall is still wrong -- it assumes that it's the first one in the whole binary to call GetNextRevision, which seems like a pretty brittle assumption -- if you add a second test, which is exactly the same, character for character, it will fail. Tests should be idempotent and isolated.

Also, I don't quite understand how the CL above fixes the failure -- could you explain to me how it works? From my brief glance, HeliumTest fixture doesn't seem to actually do anything...

Comment 5 by scf@chromium.org, Oct 25 2016

HeliumTest uses base::ShadowingAtExitManager which takes care of cleaning up the state from GetNextRevisionCall.

>if you add a second test, which is exactly the same, character for character, it will fail. Tests should be idempotent and isolated.
False. 
Gtest will create a fresh test fixture so that ensures ShadowingAtExitManager is destructed on every test (See https://github.com/google/googletest/blob/master/googletest/docs/Primer.md).

Comment 6 by xyzzyz@chromium.org, Oct 25 2016

Status: Fixed (was: Assigned)
Ah, I understand it now. ShadowingAtExitManager takes care of destroying the lazy instance keeping the global counter, so the test cleans up after itself, which is why running the same test twice in a row works correctly. If everything cleans up after using global GetNextRevision(), the test should continue working. I think it's still a bit brittle, but much less so than I though initially, and thus I'm not sure if it's worth spending any more time on this. Closing the issue.

Comment 7 by xyzzyz@chromium.org, Oct 28 2016

Cc: lethalantidote@chromium.org
Status: Available (was: Fixed)
And by the addition of OwnedRegisterTest, the GetNextRevision test is broken again. I think it proves that the current approach is brittle, and that it really requires fixing.

xyzzyz@xyzzyz:~/chromium/src$ out/Default/blimp_unittests --single-process-tests --gtest_filter=RevisionGeneratorTest.*:OwnedRegisterTest.*
Note: Google Test filter = RevisionGeneratorTest.*:OwnedRegisterTest.*
[==========] Running 8 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 5 tests from OwnedRegisterTest
[ RUN      ] OwnedRegisterTest.SetIncrementsLocalVersion
[       OK ] OwnedRegisterTest.SetIncrementsLocalVersion (0 ms)
[ RUN      ] OwnedRegisterTest.SyncSuccessfully
[       OK ] OwnedRegisterTest.SyncSuccessfully (0 ms)
[ RUN      ] OwnedRegisterTest.ChangesetIgnored
[       OK ] OwnedRegisterTest.ChangesetIgnored (0 ms)
[ RUN      ] OwnedRegisterTest.ChangesetsAppliedOutOfOrderFails
[       OK ] OwnedRegisterTest.ChangesetsAppliedOutOfOrderFails (0 ms)
[ RUN      ] OwnedRegisterTest.InvalidOperationForPeer
[       OK ] OwnedRegisterTest.InvalidOperationForPeer (0 ms)
[----------] 5 tests from OwnedRegisterTest (0 ms total)

[----------] 3 tests from RevisionGeneratorTest
[ RUN      ] RevisionGeneratorTest.CheckCurrentDoesntIncrease
[       OK ] RevisionGeneratorTest.CheckCurrentDoesntIncrease (0 ms)
[ RUN      ] RevisionGeneratorTest.MonotonicallyIncreasing
[       OK ] RevisionGeneratorTest.MonotonicallyIncreasing (0 ms)
[ RUN      ] RevisionGeneratorTest.GetNextRevisionCall
../../blimp/helium/revision_generator_unittest.cc:29: Failure
Value of: GetNextRevision()
  Actual: 5
Expected: 1UL
Which is: 1
../../blimp/helium/revision_generator_unittest.cc:30: Failure
Value of: GetNextRevision()
  Actual: 6
Expected: 2UL
Which is: 2
../../blimp/helium/revision_generator_unittest.cc:31: Failure
Value of: RevisionGenerator::GetInstance()->current()
  Actual: 6
Expected: 2UL
Which is: 2
[  FAILED  ] RevisionGeneratorTest.GetNextRevisionCall (1 ms)
[----------] 3 tests from RevisionGeneratorTest (1 ms total)

[----------] Global test environment tear-down
[==========] 8 tests from 2 test cases ran. (2 ms total)
[  PASSED  ] 7 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] RevisionGeneratorTest.GetNextRevisionCall

 1 FAILED TEST

Comment 8 by scf@chromium.org, Nov 1 2016

Thats because OwnedRegisterTest didn't extend HeliumTest. @lethalantidote do you mind taking care of this?

Comment 9 by scf@chromium.org, Nov 1 2016

Owner: lethalantidote@chromium.org
Status: Started (was: Available)
Feels like this is kind of a band-aid. Work is in progress, but the RevisionGeneratorTest should not be effected by other test classes like this. 
Yes, I agree with that. I think that test should make sure to set up the environment it expects itself, or be updated to deal with the environment it finds.
Status: Fixed (was: Started)
The issue was that tests were missing AtExitManager (didn't derive from HeliumTest).
Status: Started (was: Fixed)

Comment 15 by w...@chromium.org, Nov 15 2016

Labels: M-57
Project Member

Comment 16 by bugdroid1@chromium.org, Nov 18 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c69887e2547ece792256051d5fcce3f6d575b25d

commit c69887e2547ece792256051d5fcce3f6d575b25d
Author: lethalantidote <lethalantidote@chromium.org>
Date: Fri Nov 18 03:12:50 2016

OwnedRegisterTest now dervives from HeliumTest.

Updates test class to dervive from HeliumTest, which contributes
ShadowingAtExitManager.

BUG= 658798 

Review-Url: https://codereview.chromium.org/2470883002
Cr-Commit-Position: refs/heads/master@{#433046}

[modify] https://crrev.com/c69887e2547ece792256051d5fcce3f6d575b25d/blimp/helium/owned_register_unittest.cc

Status: Fixed (was: Started)
Labels: Archive-Blimp

Sign in to add a comment