Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Fix data races in tests #484

Merged
merged 3 commits into from
Sep 7, 2020
Merged

Fix data races in tests #484

merged 3 commits into from
Sep 7, 2020

Commits on Sep 7, 2020

  1. Fix data races in tests

    While working on some other stuff locally and running the tests, I occasionally saw many data races. I think we've also seen these a few times on prow, so I figured I'd dig in. There were two separate data races:
    
    1. The DefaultOptions in migrations is a global mutable. Despite always setting the value to false (and the default being false), the race detector sees this as a data-write and barfs. I removed it, since it's the default value.
    
    2. In the event we failed to connect to the database, we were still registering the opencensus views. Furthermore, we could succeed connecting to the database, but fail to initialize gorm, which would trigger a re-connect. This separates the "connect to the database" and "connect to the database via gorm" steps into separate retries. It also moves the opencenusus and driver initialization into a package-level init.
    sethvargo committed Sep 7, 2020
    Configuration menu
    Copy the full SHA
    972d89f View commit details
    Browse the repository at this point in the history
  2. Create verification codes closer to their use

    Under heavy load, this causes a race where the struct is created (and thus the time is set), but the test might not run for a few more seconds. By switching this to a function, we ensure it's only called immediately before executing instead of during scheduling.
    sethvargo committed Sep 7, 2020
    Configuration menu
    Copy the full SHA
    4b1391f View commit details
    Browse the repository at this point in the history
  3. Mod

    sethvargo committed Sep 7, 2020
    Configuration menu
    Copy the full SHA
    f0d6f70 View commit details
    Browse the repository at this point in the history