Shermans's Notes
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

June 29th, 2022

    golang testing

    Finding flakey tests

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    
    Metrics: map[cont:2 data_race:2 fail:6 flaky:6 output:826 pass:159 run:165 slow:100]
    Elapsed: 7m5.169999999s
    Slow: 7m3.559999999s
    Test time distribution (seconds):
    [  min   max] cnt total%    sum (165 events)
    [ 0.00  0.00]  35 21.21%   0.00 .....................
    [ 0.01  0.03]  15  9.09%   0.26 .........
    [ 0.05  0.07]  10  6.06%   0.58 ......
    [ 0.15  0.17]   5  3.03%   0.77 ...
    [ 1.33  1.35]  10  6.06%  13.36 ......
    [ 2.28  3.08]  55 33.33% 140.53 .................................
    [ 3.75  4.00]  20 12.12%  77.48 ............
    [ 8.15  8.49]   5  3.03%  41.31 ...
    [12.22 12.74]   5  3.03%  61.86 ...
    [17.66 18.20]   5  3.03%  89.02 ...
    

    Race detection

    • Always test with -race
      • Found two issues using this on my tests
        • First, I was running go routines and appending a slice of errors without waiting for the routines to finish before returning.
        • Second, the slice was being appened to without synchronisation.