Skip to content

FS improvements for unit tests - #114026

Merged
Benjamin Pasero (bpasero) merged 7 commits into
masterfrom
alex/unit-tests-fs-improvements
Jan 8, 2021
Merged

Benjamin Pasero (bpasero) merged 7 commits into
masterfrom
alex/unit-tests-fs-improvements

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Jan 8, 2021 •

Copy link
Copy Markdown
Member

Towards fixing #114024

  • many teardown methods of our unit tests are using rimraf with the MOVE option.
  • this causes that the first error which occurs during moving is swallowed i.e. see the error being ignored here
    return rimrafUnlink(path); // if rename fails, delete without tmp dir
  • this most likely hides the fact that some tests continue writing to the fixture directory even after the test has signaled completion (this is the root problem here)
  • not waiting for unlinking and not using graceful-fs in our unit tests causes some tests which are unlucky and are not first in the mocha runner schedule to fail in their teardown hook
  • mocha does not recover from a failure in a teardown hook even if retry is used (i.e. even if the test is decorated with flakyTest)

This PR aims to expose the tests which write to the fixture directory even after the test has signaled completion. By using rimraf with the UNLINK option, any error will immediately become visible. I have already seen a ENOTEMPTY being thrown from the BackupTracker test. The best fix would be for the tests to be analyzed and repaired to stop writing to the fixture directory after they signal completion. The bandaid approach that I have started is to leave a TODO in the test and to use rimrafWithRetries especially in these tests where this ENOTEMPTY is observed.

@alexdima

Alexandru Dima (alexdima) commented Jan 8, 2021 •

Copy link
Copy Markdown
Member Author

Actually there is more to it. It looks like an EPERM can also be thrown when deleting a fixture directory which is still being written to:
https://github.com/microsoft/vscode/pull/114026/checks?check_run_id=1668335479#step:11:7692

  6406 passing (1m)
  38 pending
  1 failing

  1) BackupTracker
       "after each" hook for "should hot exit (reason: QUIT, windows: single, workspace)":
     Error: EPERM: operation not permitted, lstat 'C:\Users\RUNNER~1\AppData\Local\Temp\vsctests\backuprestorer\f1517443-8841-46bc-8cde-5c81baa87dca\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\3852fac775a9ca8e1002a47d2dc725cf'

Again it is the BackupTracker. This is definite proof that these tests continue writing to their fixture directories after signaling completion.

@alexdima

Alexandru Dima (alexdima) commented Jan 8, 2021 •

Copy link
Copy Markdown
Member Author

OK. This test is just really really annoying and I begin to understand how messy getting a good outcome is.

  6409 passing (2m)
  38 pending
  1 failing

  1) BackupTracker
       "after each" hook for "should hot exit (reason: QUIT, windows: multiple, empty workspace)":
     Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\65a65541-bb98-4208-a7f1-5c5d51fe7353\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\1b7340a36de1e1c3636b8291f12cf492'

Even retrying 5 times to delete the fixture directory fails sometimes -- https://dev.azure.com/monacotools/Monaco/_build/results?buildId=99749&view=logs&j=672276a2-8d3a-5fab-615d-090c51352f92&t=6ad30dce-518e-54c1-94da-00d19cce9354&l=7718:

2021-01-08T12:25:53.8249062Z �[0m    Hot Exit�[0m
2021-01-08T12:25:53.8251719Z �[0m      "onExit" setting�[0m
2021-01-08T12:25:53.8735822Z       �[32m  √�[0m�[90m should hot exit on non-Mac (reason: CLOSE, windows: single, workspace)�[0m�[33m (38ms)�[0m
2021-01-08T12:25:53.8905155Z [1772:0108/122553.889:INFO:CONSOLE(56)] "Ignoring error in retry 1 of 5:  Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\7d13d710-7fdf-42fb-98c6-46b2bafaa13a\Backups\2746e85e3aa3db1143f8b6945d3619a5\file'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:53.8920053Z [1772:0108/122553.890:INFO:CONSOLE(56)] "Ignoring error in retry 2 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\7d13d710-7fdf-42fb-98c6-46b2bafaa13a\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\dda638bb65409922442ccdd71cf1edb6'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:53.9465342Z       �[32m  √�[0m�[90m should hot exit on non-Mac (reason: CLOSE, windows: single, empty workspace)�[0m�[33m (39ms)�[0m
2021-01-08T12:25:53.9643588Z [1772:0108/122553.963:INFO:CONSOLE(56)] "Ignoring error in retry 1 of 5:  Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\0f247949-a849-4c66-acfe-5063b1c01aed\Backups\2746e85e3aa3db1143f8b6945d3619a5\file'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:53.9657238Z [1772:0108/122553.964:INFO:CONSOLE(56)] "Ignoring error in retry 2 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\0f247949-a849-4c66-acfe-5063b1c01aed\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\3a7efecfe644728728903fa292f0b5b2'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:53.9672344Z [1772:0108/122553.966:INFO:CONSOLE(56)] "Ignoring error in retry 3 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\0f247949-a849-4c66-acfe-5063b1c01aed\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\3a7efecfe644728728903fa292f0b5b2'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:53.9986223Z       �[32m  √�[0m�[90m should NOT hot exit (reason: CLOSE, windows: multiple, workspace)�[0m
2021-01-08T12:25:54.0210109Z       �[32m  √�[0m�[90m should NOT hot exit (reason: CLOSE, windows: multiple, empty workspace)�[0m
2021-01-08T12:25:54.0927763Z       �[32m  √�[0m�[90m should hot exit (reason: QUIT, windows: single, workspace)�[0m�[33m (46ms)�[0m
2021-01-08T12:25:54.1102831Z [1772:0108/122554.109:INFO:CONSOLE(56)] "Ignoring error in retry 1 of 5:  Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\728c6b3c-0705-49dc-9f82-c0d917c37550\Backups\2746e85e3aa3db1143f8b6945d3619a5\file'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.1114752Z [1772:0108/122554.110:INFO:CONSOLE(56)] "Ignoring error in retry 2 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\728c6b3c-0705-49dc-9f82-c0d917c37550\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\3852fac775a9ca8e1002a47d2dc725cf'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.1128861Z [1772:0108/122554.111:INFO:CONSOLE(56)] "Ignoring error in retry 3 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\728c6b3c-0705-49dc-9f82-c0d917c37550\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\3852fac775a9ca8e1002a47d2dc725cf'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.1144999Z [1772:0108/122554.113:INFO:CONSOLE(56)] "Ignoring error in retry 4 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\728c6b3c-0705-49dc-9f82-c0d917c37550\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\3852fac775a9ca8e1002a47d2dc725cf'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.1755928Z       �[32m  √�[0m�[90m should hot exit (reason: QUIT, windows: single, empty workspace)�[0m
2021-01-08T12:25:54.1932182Z [1772:0108/122554.192:INFO:CONSOLE(56)] "Ignoring error in retry 1 of 5:  Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\cb3e2d0f-52ec-4276-a19d-7f521f74e565\Backups\2746e85e3aa3db1143f8b6945d3619a5\file'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.2456466Z       �[32m  √�[0m�[90m should hot exit (reason: QUIT, windows: multiple, workspace)�[0m�[33m (39ms)�[0m
2021-01-08T12:25:54.2643971Z [1772:0108/122554.263:INFO:CONSOLE(56)] "Ignoring error in retry 1 of 5:  Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\19911ac7-5b01-4de2-95ca-c3d5aa51dec3\Backups\2746e85e3aa3db1143f8b6945d3619a5\file'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.2663334Z [1772:0108/122554.265:INFO:CONSOLE(56)] "Ignoring error in retry 2 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\19911ac7-5b01-4de2-95ca-c3d5aa51dec3\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\45f70f99ede8991195b760b6b84bbd67'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.3195077Z       �[32m  √�[0m�[90m should hot exit (reason: QUIT, windows: multiple, empty workspace)�[0m
2021-01-08T12:25:54.3355907Z [1772:0108/122554.334:INFO:CONSOLE(56)] "Ignoring error in retry 1 of 5:  Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\65a65541-bb98-4208-a7f1-5c5d51fe7353\Backups\2746e85e3aa3db1143f8b6945d3619a5\file'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.3369864Z [1772:0108/122554.336:INFO:CONSOLE(56)] "Ignoring error in retry 2 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\65a65541-bb98-4208-a7f1-5c5d51fe7353\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\1b7340a36de1e1c3636b8291f12cf492'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.3382834Z [1772:0108/122554.337:INFO:CONSOLE(56)] "Ignoring error in retry 3 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\65a65541-bb98-4208-a7f1-5c5d51fe7353\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\1b7340a36de1e1c3636b8291f12cf492'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)
2021-01-08T12:25:54.3395365Z [1772:0108/122554.338:INFO:CONSOLE(56)] "Ignoring error in retry 4 of 5:  Error: EPERM: operation not permitted, lstat 'C:\Users\VSSADM~1\AppData\Local\Temp\vsctests\backuprestorer\65a65541-bb98-4208-a7f1-5c5d51fe7353\Backups\2746e85e3aa3db1143f8b6945d3619a5\file\1b7340a36de1e1c3636b8291f12cf492'", source: file:///D:/a/1/s/out-build/vs/base/node/pfs.js (56)

@bpasero
Benjamin Pasero (bpasero) merged commit d6a63fc into master Jan 8, 2021
@bpasero
Benjamin Pasero (bpasero) deleted the alex/unit-tests-fs-improvements branch January 8, 2021 15:53
@bpasero

Benjamin Pasero (bpasero) commented Jan 8, 2021 •

Copy link
Copy Markdown
Contributor

I owe you a 🍺 for this one.

@github-actions github-actions Bot locked and limited conversation to collaborators Feb 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants