NFIBrokerage / spear

A sharp EventStoreDB v20+ client backed by Mint :yum:
https://hex.pm/packages/spear
Apache License 2.0
85 stars 14 forks source link

Support for EventStore 24.2.0 #98

Closed pauldemarco closed 2 months ago

pauldemarco commented 2 months ago

Just noticing the tests fail when the esdb://localhost:2113 is of the newest EventStore version 24.2.0

pauldemarco commented 2 months ago

Update: After running the docker compose up -d for this project, and noticing it pull 24.4.0-prerelease, we have all tests passing.

I wonder why 24.2.0 would be failing a bunch, yet 24.4.0-prerelease passes all?

I can only assume the version of the github package is not respecting the semver from EventStoreDB, and that it is still some 23.X version.

the-mikedavis commented 2 months ago

Which tests fail and what is the failure message? Some cases flake fairly often so it might have been a transient failure.

pauldemarco commented 2 months ago

Using EventStoreDB version 24.2.0:

eventstore:
    image: eventstore/eventstore:24.2.0-jammy
    environment:
      - EVENTSTORE_START_STANDARD_PROJECTIONS=True
      - EVENTSTORE_RUN_PROJECTIONS=All
    volumes:
      - spear_eventstore:/var/lib/eventstore
      - ./eventstoredb:/etc/eventstore:ro
    # to run in insecure mode, which can be nice for debugging protobuf
    # messages via wireshark
    # command: "--insecure --run-projections=All"
    ports:
      - 2113:2113

With the .tool-versions:

elixir 1.16.2-otp-26
erlang 26.2

We get a single failed test (but this only happened once, subsequent runs passed 100%):

paul@paul-Ubuntu:~/spear$ EVENTSTORE_VERSION=24.2.0 mix test
Excluding tags: [:operations, :flaky, :version_incompatible]

...............................

  1) test given no prior state a subscription can pick up from where it left off with a Spear.Event (SpearTest)
     test/spear_test.exs:544
     ** (exit) exited in: :gen_server.call(#PID<0.326.0>, {:request, %Spear.Request{api: {Spear.Records.Streams, :Append}, service: :"event_store.client.streams.Streams", service_module: :event_store_db_gpb_protobufs_streams, rpc: %Spear.Rpc{request_type: :"event_store.client.streams.AppendReq", response_type: :"event_store.client.streams.AppendResp", request_stream?: true, response_stream?: false, path: "/event_store.client.streams.Streams/Append", name: :Append, service: :"event_store.client.streams.Streams", service_module: :event_store_db_gpb_protobufs_streams}, path: "/event_store.client.streams.Streams/Append", headers: [{"te", "trailers"}, {"content-type", "application/grpc+proto"}, {"grpc-encoding", "identity"}, {"grpc-accept-encoding", "identity,deflate,gzip"}, {"accept-encoding", "identity"}, {"user-agent", "grpc-elixir-spear/0.0.0 (mint 1.6.0; Elixir 1.16.2; OTP 26)"}], messages: #Stream<[enum: #Function<60.53678557/2 in Stream.transform/3>, funs: [#Function<48.53678557/1 in Stream.map/2>]]>, credentials: nil}}, 5000)
         ** (EXIT) time out
     code: :ok = Spear.append([next_event], c.conn, c.stream_name)
     stacktrace:
       (stdlib 5.2) gen_server.erl:419: :gen_server.call/3
       (spear 0.0.0) lib/spear.ex:1499: Spear.request/5
       (spear 0.0.0) lib/spear.ex:411: Spear.append/4
       test/spear_test.exs:563: (test)

.................................................................    warning: redefining module Spear.ConnectionTest.MfaTest (current version defined in memory)
    │
 97 │     defmodule MfaTest do
    │     ~~~~~~~~~~~~~~~~~~~~
    │
    └─ test/spear/connection_test.exs:97: Spear.ConnectionTest.MfaTest (module)

......
Finished in 20.5 seconds (19.9s async, 0.6s sync)
9 doctests, 102 tests, 1 failure, 8 excluded

I then ran docker compose down and docker compose up -d, and then re-ran the tests again and received another failure:

paul@paul-Ubuntu:~/spear$ EVENTSTORE_VERSION=24.2.0 mix test
Excluding tags: [:operations, :flaky, :version_incompatible]

.............................................................................

  1) test given no prior state a scavenge can be started, followed, and deleted (SpearTest)
     test/spear_test.exs:732
     Assertion failed, no matching message after 1000ms
     Showing 3 of 3 messages in the mailbox
     code: assert_receive %Spear.Event{type: "$scavengeCompleted"}
     mailbox:
       pattern: %Spear.Event{type: "$scavengeCompleted"}
       value:   {:caught_up, #Reference<0.1439662039.3285712898.211892>}

       pattern: %Spear.Event{type: "$scavengeCompleted"}
       value:   %Spear.Event{
                  type: "$scavengeChunksCompleted",
                  body: %{"chunkEndNumber" => 7, "chunkStartNumber" => 0, "errorMessage" => "", "nodeEndpoint" => "0.0.0.0:2113", "scavengeId" => "218cea7f-4a33-4b06-a848-9971f9bacfbd", "spaceSaved" => 4096, "timeTaken" => "00:00:00.1722573", "wasScavenged" => true},
                  id: "d101b149-f771-47eb-a3ff-708da47a7b2a",
                  link: nil,
                  metadata: %{stream_revision: 1, stream_name: "$scavenges-218cea7f-4a33-4b06-a848-9971f9bacfbd", subscription: #Reference<0.1439662039.3285712898.211892>, content_type: "application/json", custom_metadata: "", commit_position: 2415920442, prepare_position: 2415920442, created: ~U[2024-06-30 14:30:59.867631Z]}
                }

       pattern: %Spear.Event{type: "$scavengeCompleted"}
       value:   %Spear.Event{
                  type: "$scavengeChunksCompleted",
                  body: %{"chunkEndNumber" => 8, "chunkStartNumber" => 8, "errorMessage" => "", "nodeEndpoint" => "0.0.0.0:2113", "scavengeId" => "218cea7f-4a33-4b06-a848-9971f9bacfbd", "spaceSaved" => 8192, "timeTaken" => "00:00:00.0604131", "wasScavenged" => true},
                  id: "8ca868e4-5c48-45d7-b7ab-d8cd55c8ea88",
                  link: nil,
                  metadata: %{stream_revision: 2, stream_name: "$scavenges-218cea7f-4a33-4b06-a848-9971f9bacfbd", subscription: #Reference<0.1439662039.3285712898.211892>, content_type: "application/json", custom_metadata: "", commit_position: 2415920846, prepare_position: 2415920846, created: ~U[2024-06-30 14:30:59.932793Z]}
                }
     stacktrace:
       test/spear_test.exs:736: (test)

.................    warning: redefining module Spear.ConnectionTest.MfaTest (current version defined in memory)
    │
 80 │     defmodule MfaTest do
    │     ~~~~~~~~~~~~~~~~~~~~
    │
    └─ test/spear/connection_test.exs:80: Spear.ConnectionTest.MfaTest (module)

........
Finished in 15.9 seconds (15.3s async, 0.6s sync)
9 doctests, 102 tests, 1 failure, 8 excluded

Randomized with seed 641698

But then I ran them again and now we are passing everything. I even bumped the tool-versions to elixir 1.17.1-otp-27 and ran mix deps.update --all and we still pass everything.

We can close this.