uber-archive / makisu

Fast and flexible Docker image building tool, works in unprivileged containerized environments like Mesos and Kubernetes.
Apache License 2.0
2.41k stars 153 forks source link

Fix flaky unit tests #147

Closed yiranwang52 closed 5 years ago

yiranwang52 commented 5 years ago
--- FAIL: TestCreateLayerByScan (0.00s)
    --- FAIL: TestCreateLayerByScan/Simple (0.00s)
        require.go:1159: 
                Error Trace:    testutils_test.go:55
                                            mem_fs_test.go:602
                Error:          Should be true
                Test:           TestCreateLayerByScan/Simple
                Messages:       /test1/test2 headers not similar:
                                expected=&{Typeflag:53 Name:test1/test2/ Linkname: Size:0 Mode:493 Uid:0 Gid:0 Uname: Gname: ModTime:2019-01-09 04:56:00.997935188 +0000 UTC AccessTime:2019-01-09 04:56:00.997935188 +0000 UTC ChangeTime:2019-01-09 04:56:00.997935188 +0000 UTC Devmajor:0 Devminor:0 Xattrs:map[] PAXRecords:map[] Format:<unknown>}
                                actual=  &{Typeflag:53 Name:test1/test2/ Linkname: Size:0 Mode:493 Uid:0 Gid:0 Uname: Gname: ModTime:2019-01-09 04:56:01.001935272 +0000 UTC AccessTime:2019-01-09 04:56:00.997935188 +0000 UTC ChangeTime:2019-01-09 04:56:01.001935272 +0000 UTC Devmajor:0 Devminor:0 Xattrs:map[] PAXRecords:map[] Format:<unknown>}
yiranwang52 commented 5 years ago

This happens because the test create 2 directories test1 and test1/test2, and add headers to mock layer in the same order. However the when adding test1/test2, mod time of test1 was also updated.

We round the modtime to the nearest seconds before comparison. But if this test happens around second boundary, the modtime of test1 in mock layer and scanner layer will be seen as different.