fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.05k stars 424 forks source link

Fix flaky tests #4270

Open michalnicp opened 2 years ago

michalnicp commented 2 years ago

Currently, there are a couple tests that are flaky and need to be fixed.

$ MYSQL_TEST=1 make test-go
...
--- FAIL: TestLocks (3.68s)
    --- FAIL: TestLocks/DBLocks (0.04s)
        locks_test.go:151:
                Error Trace:    locks_test.go:151
                                                        locks_test.go:24
                                                        locks_test.go:29
                Error:          "[%!s(*fleet.DBLock=&{1796455 157858 0xc00021aa20 421977504352184 157859 <nil>}) %!s(*fleet.DBLock=&{421977504350344 157861 0xc00021aa50 1796450 157852 0xc00021aa70}) %!s(*fleet.DBLock=&{421977504346664 157860 0xc00021aab0 1796450 157852 0xc00021aac0})]" should have 1 item(s), but has 3
                Test:           TestLocks/DBLocks
--- FAIL: TestHosts (9.92s)
    --- FAIL: TestHosts/HostsReadsLessRows (0.07s)
        hosts_test.go:2020: withExtraRowReads 6
        hosts_test.go:2021: withoutExtraRowReads 6
        assertion_compare.go:332:
                Error Trace:    hosts_test.go:2022
                                                        hosts_test.go:119
                Error:          "6" is not less than "6"
                Test:           TestHosts/HostsReadsLessRows
                Messages:       []
FAIL
mna commented 2 years ago

Another one I've noticed (also in CI failed runs):

--- FAIL: TestUp_20220208144831 (0.92s)
    20220208144831_AddSoftwareReleaseArchVendorColumns_test.go:15: 
            Error Trace:    20220208144831_AddSoftwareReleaseArchVendorColumns_test.go:15
            Error:          Received unexpected error:
                            Error 1054: Unknown column 'bundle_identifier' in 'field list'
            Test:           TestUp_20220208144831