jepsen-io / maelstrom

A workbench for writing toy implementations of distributed systems.
Eclipse Public License 1.0
3.05k stars 189 forks source link

Running test yields `NoSuchFileException` #64

Closed Witcher01 closed 1 year ago

Witcher01 commented 1 year ago

I'm trying to package maelstrom for myself using Nix but using the packaged version always crashes with the following backtrace:

WARN [2023-04-14 10:39:06,433] jepsen test runner - jepsen.core Test crashed!
java.nio.file.NoSuchFileException: store/echo/20230414T103906.375+0200/test.jepsen
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:181)
        at java.base/java.nio.channels.FileChannel.open(FileChannel.java:298)
        at java.base/java.nio.channels.FileChannel.open(FileChannel.java:357)
        at jepsen.store.format$open.invokeStatic(format.clj:407)
        at jepsen.store.format$open.invoke(format.clj:402)
        at jepsen.core$run_BANG_.invokeStatic(core.clj:388)
        at jepsen.core$run_BANG_.invoke(core.clj:318)
        at jepsen.cli$single_test_cmd$fn__13951.invoke(cli.clj:396)
        at jepsen.cli$run_BANG_.invokeStatic(cli.clj:329)
        at jepsen.cli$run_BANG_.invoke(cli.clj:258)
        at maelstrom.core$_main.invokeStatic(core.clj:269)
        at maelstrom.core$_main.doInvoke(core.clj:267)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at maelstrom.core.main(Unknown Source)
ERROR [2023-04-14 10:39:06,434] main - jepsen.cli Oh jeez, I'm sorry, Jepsen broke. Here's why:
java.nio.file.NoSuchFileException: store/echo/20230414T103906.375+0200/test.jepsen
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:181)
        at java.base/java.nio.channels.FileChannel.open(FileChannel.java:298)
        at java.base/java.nio.channels.FileChannel.open(FileChannel.java:357)
        at jepsen.store.format$open.invokeStatic(format.clj:407)
        at jepsen.store.format$open.invoke(format.clj:402)
        at jepsen.core$run_BANG_.invokeStatic(core.clj:388)
        at jepsen.core$run_BANG_.invoke(core.clj:318)
        at jepsen.cli$single_test_cmd$fn__13951.invoke(cli.clj:396)
        at jepsen.cli$run_BANG_.invokeStatic(cli.clj:329)
        at jepsen.cli$run_BANG_.invoke(cli.clj:258)
        at maelstrom.core$_main.invokeStatic(core.clj:269)
        at maelstrom.core$_main.doInvoke(core.clj:267)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at maelstrom.core.main(Unknown Source)

I can't figure out what file is actually missing, nowhere can I find a reference to the given path and strace on a successful run doesn't mention it either.

Packaging maelstrom crates /bin/maelstrom with the following content (nix store paths have been minimsed to what matters):

#!/bin/bash

programDir="/lib"
cd "$programDir"
exec "/bin/java" -jar "$programDir/maelstrom.jar" "$@"

lib/maelstrom.jar is moved to /lib/maelstrom.jar.

Any ideas?

Witcher01 commented 1 year ago

Oh I see now: maelstrom seems to generate a store directory when running which holds testing data(?). That solves this issue :)

basbebe commented 1 year ago

@Witcher01 would you be willing to share your solution? I'm currently trying to create a flake for a dev environment including maelstrom…

Witcher01 commented 1 year ago

To be perfectly honest I gave up on creating the flake since I couldn't figure it out. Good luck, though!

basbebe commented 1 year ago

I now have a flake that seems to work:

{
  description = "A dev environment for Fly.io Gossip Glomers challenge";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem
      (system:
        let
          pkgs = import nixpkgs {
            inherit system;
          };

          maelstrom = pkgs.stdenv.mkDerivation rec{
            name = "Maelstrom";
            version = "0.2.3";

            src = builtins.fetchTarball {
              url = "https://github.com/jepsen-io/maelstrom/releases/download/v${version}/maelstrom.tar.bz2";
              sha256 = "sha256:1hkczlbgps3sl4mh6hk49jimp6wmks8hki0bqijxsqfbf0hcakwq";
            };

            # include upstream patch (not yet in 0.2.3)
            # https://github.com/jepsen-io/maelstrom/commit/f0ce6dbc60369ec85f8cd69aa5ac953806634260
            maelstromScriptPatch = pkgs.writeShellScript "maelstrom" ''
              # A small wrapper script for invoking the Maelstrom jar, with arguments.
              SCRIPT_DIR=$( cd -- "$( dirname "$(readlink -f "''${BASH_SOURCE[0]}")" )" &> /dev/null && pwd )
              exec java -Djava.awt.headless=true -jar "''${SCRIPT_DIR}/lib/maelstrom.jar" "$@"
            '';

            installPhase = ''
              mkdir -p $out/bin
              cp -r * $out/bin/
              cp $maelstromScriptPatch $out/bin/maelstrom
            '';

          };

        in
        {
          devShell = pkgs.mkShell {
            name = "Gossip Glomers env";

            buildInputs = with pkgs; [
              maelstrom
              jdk
              graphviz
              gnuplot

              # Golang
              go
              gopls
              delve
              golint
            ];

          };
        });
}

Within a nix shell (nix develop) or using direnv the following now works:

maelstrom test -w echo --bin $(which maelstrom-echo) --node-count 1 --time-limit 10

While I also get the following lines, the rest of the script seems to run just fine:

WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.core.matrix.impl.mathsops, being replaced by: #'clojure.core.matrix.impl.mathsops/abs
Warning: protocol #'clojure.core.matrix.protocols/PMathsFunctions is overwriting function abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.core.matrix.protocols, being replaced by: #'clojure.core.matrix.protocols/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.core.matrix, being replaced by: #'clojure.core.matrix/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.core.matrix.dataset, being replaced by: #'clojure.core.matrix/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: incanter.core, being replaced by: #'incanter.core/abs
INFO [2023-04-20 09:22:48,304] main - jepsen.cli Test options:
 {:args [],
[…]