Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with interrupting Plutip tests with Ctrl+C #1580

Open
mikekeke opened this issue Dec 18, 2023 · 1 comment
Open

Issues with interrupting Plutip tests with Ctrl+C #1580

mikekeke opened this issue Dec 18, 2023 · 1 comment

Comments

@mikekeke
Copy link

I'm experiencing the following issue (at least up to the v6.0.0 release) when interrupting Plutip tests: after pressing Ctrl+C I see this error in the terminal

node:internal/fs/utils:350
    throw err;
    ^

Error: ENOENT: no such file or directory, lstat '/tmp/nix-shell.Od5tH5/kupo-db'
    at Object.lstatSync (node:fs:1668:3)
    at __node_internal_ (node:internal/fs/utils:825:8)
    at Object.rmSync (node:fs:1275:13)
    at /home/mike/dev/mlabs/clarity-project/my-ctl-fork/output/Ctl.Internal.Plutip.Spawn/foreign.js:9:39
    at ChildProcess.<anonymous> (/home/mike/dev/mlabs/clarity-project/my-ctl-fork/output/Node.ChildProcess/foreign.js:88:40)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12) {
  errno: -2,
  syscall: 'lstat',
  code: 'ENOENT',
  path: '/tmp/nix-shell.XXX/kupo-db'
}

It seems like this is caused by Kupo having two handlers that attempt to delete test directory: one on SIGINT and one on exit. In the case of pressing Ctrl+C, kupo-db is deleted by the on-SIGINT handler, and then the onexit handler fails to delete the nonexistent directory.

Some other consequences I've noticed besides error in the terminal: sometimes I see that directory of test cluster was not deleted from temp directory.

Although, after fixing this issue in some simplest way (e.g. adding try to directory deletion in onexit handler) I'm facing another issue: after pressing Ctrl+C process detaches instead of exiting and test suite runs till completion. I was testing with suite like this

suite :: TestPlanM (Aff Unit) Unit
suite = do
  test
    "interruption test-1" $ do
    withPlutipContractEnv ctcPlutipConfig testDistribution
      \env wallet -> do
        do
          runContractInEnv env $ withKeyWallet wallet do
            logInfo' "starting delay 10s - press CTRL + C"
            liftAff $ delay (Milliseconds (10000.0 :: Number))
            logInfo' "delay end"
            logInfo' "test end"
  test
    "interruption test -2" $ do
    withPlutipContractEnv ctcPlutipConfig testDistribution
      \env wallet -> do
        do
          runContractInEnv env $ withKeyWallet wallet do
            logInfo' "second test"

and if I press Ctrl+C after "starting delay 10s - press CTRL + C" log message, when delay is over I still see
"delay end" and "test end" messages, as well as execution of "interruption test -2"

@Renegatto
Copy link
Collaborator

Note, that many cleanups may be performed on the single cleanup handler (since it is not restricted), so you could call cleanup accidentally many times in tests.
However this should not be an issue if cleanup errors are catched well. So my opinion is that here are two issues:

  • Some errors are killing the cleaner thread before cleanup is completed (which prevents full cleanup)
  • Tests keep running after SIGINT

First issue can be solved by preventing CTL cleanups from throwing async exceptions.
For instance the one you have experienced: #1619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants