diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 99f5aa7..0439938 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -4,16 +4,18 @@ jobs: build: runs-on: ubuntu-latest container: - image: lpgauth/erlang-cassandra:0.1.1 - + image: lpgauth/erlang-scylla:26.2.2-5.2-amd64 steps: - uses: actions/checkout@v1 - - name: Start Cassandra - run: cassandra -R + - name: Start Scylla + run: | + python3 /docker-entrypoint.py& + sleep 30 + - name: Set Path + run: | + echo "/usr/local/lib/erlang/bin" >> $GITHUB_PATH - name: Compile run: make compile - - name: Elvis rock - run: make elvis - name: Run xref run: make xref - name: Run eunit diff --git a/Dockerfile b/Dockerfile index 760ff56..60dbbfd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,28 @@ -FROM cassandra:3.11 +FROM scylladb/scylla:5.2 -ENV OTP_VERSION="24.1.2" \ - REBAR3_VERSION="3.17.0" +RUN apt-get update +RUN apt-get -y --no-install-recommends install \ + autoconf \ + dpkg-dev \ + gcc \ + g++ \ + make \ + libncurses-dev \ + unixodbc-dev \ + libssl-dev \ + libsctp-dev \ + wget \ + ca-certificates \ + pax-utils \ + git -RUN set -xe \ - && OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" \ - && OTP_DOWNLOAD_SHA256="c141a046bb7184a7bb5c3d6da2ed013e465d1fbe4ff5cd16e0fbb7a0e786a152" \ - && deps='dpkg-dev g++ gcc libncurses5-dev libssl-dev git-all' \ - && apt-get update \ - && apt-get install -y --no-install-recommends $deps \ - && curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \ - && echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \ - && export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \ - && mkdir -vp $ERL_TOP \ - && tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 \ - && rm otp-src.tar.gz \ - && ( cd $ERL_TOP \ - && gnuArch="$(dpkg-architecture --query DEB_HOST_GNU_TYPE)" \ - && ./configure --build="$gnuArch" \ - && make -j$(nproc) \ - && make -j$(nproc) docs DOC_TARGETS=chunks \ - && make install install-docs DOC_TARGETS=chunks ) \ - && find /usr/local -name examples | xargs rm -rf - -CMD ["erl"] - -RUN set -xe \ - && REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \ - && REBAR3_DOWNLOAD_SHA256="4c7f33a342bcab498f9bf53cc0ee5b698d9598b8fa9ef6a14bcdf44d21945c27" \ - && mkdir -p /usr/src/rebar3-src \ - && curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \ - && echo "$REBAR3_DOWNLOAD_SHA256 rebar3-src.tar.gz" | sha256sum -c - \ - && tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 \ - && rm rebar3-src.tar.gz \ - && cd /usr/src/rebar3-src \ - && HOME=$PWD ./bootstrap \ - && install -v ./rebar3 /usr/local/bin/ \ - && rm -rf /usr/src/rebar3-src +RUN mkdir -p /OTP/subdir +RUN wget -nv "https://github.com/erlang/otp/archive/OTP-26.2.3.tar.gz" && tar -zxf "OTP-26.2.3.tar.gz" -C /OTP/subdir --strip-components=1 +WORKDIR /OTP/subdir +RUN ./otp_build autoconf +RUN ./configure --with-ssl +RUN make -j$(getconf _NPROCESSORS_ONLN) +RUN make -j$(getconf _NPROCESSORS_ONLN) install +RUN find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|obj\|c_src\|emacs\|info\|examples\)' | xargs rm -rf +RUN find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true +RUN find /usr/local -name src | xargs -r find | xargs rmdir -vp || true diff --git a/LICENSE b/LICENSE index c9ff7cc..de4c3b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2017 Louis-Philippe Gauthier +Copyright (c) 2015-2024 Louis-Philippe Gauthier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/Makefile b/Makefile index f5cc653..6b3da98 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ CACHEGRIND=qcachegrind -ELVIS=./bin/elvis +REBAR3=$(shell which rebar3) +ifeq ($(REBAR3),) REBAR3=./bin/rebar3 +endif all: compile @@ -12,10 +14,6 @@ compile: @echo "Running rebar3 compile..." @$(REBAR3) as compile compile -coveralls: - @echo "Running rebar3 coveralls send..." - @$(REBAR3) as test coveralls send - dialyzer: @echo "Running rebar3 dialyze..." @$(REBAR3) dialyzer @@ -24,10 +22,6 @@ edoc: @echo "Running rebar3 edoc..." @$(REBAR3) as edoc edoc -elvis: - @echo "Running elvis rock..." - @$(ELVIS) rock - eunit: @echo "Running rebar3 eunit..." @$(REBAR3) do eunit -cv, cover -v @@ -43,10 +37,10 @@ profile: @_build/test/lib/fprofx/erlgrindx -p fprofx.analysis @$(CACHEGRIND) fprofx.cgrind -test: elvis xref eunit dialyzer +test: xref eunit dialyzer xref: @echo "Running rebar3 xref..." @$(REBAR3) xref -.PHONY: clean compile coveralls dialyzer edoc elvis eunit profile xref +.PHONY: clean compile dialyzer edoc eunit profile xref diff --git a/README.md b/README.md index 9ead5a4..64afbed 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # marina -High-Performance Erlang Cassandra CQL Client - -[![Build Status](https://travis-ci.org/lpgauth/marina.svg?branch=master)](https://travis-ci.org/lpgauth/marina) -[![Coverage Status](https://coveralls.io/repos/github/lpgauth/marina/badge.svg?branch=master)](https://coveralls.io/github/lpgauth/marina?branch=master) +High-Performance Erlang Cassandra / Scylla CQL Client ### Requirements @@ -170,7 +167,7 @@ make xref ```license The MIT License (MIT) -Copyright (c) 2015-2018 Louis-Philippe Gauthier +Copyright (c) 2015-2024 Louis-Philippe Gauthier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bin/elvis b/bin/elvis deleted file mode 100755 index ddb9fe7..0000000 Binary files a/bin/elvis and /dev/null differ diff --git a/elvis.config b/elvis.config deleted file mode 100644 index c3214fb..0000000 --- a/elvis.config +++ /dev/null @@ -1,35 +0,0 @@ -[{elvis, [ - {config, [ - #{dirs => ["src", "test"], - filter => "*.erl", - rules => [ - {elvis_style, dont_repeat_yourself, #{min_complexity => 10}}, - {elvis_style, god_modules, #{limit => 25}}, - {elvis_style, invalid_dynamic_call, #{ignore => []}}, - {elvis_style, line_length, #{limit => 80, skip_comments => false}}, - {elvis_style, macro_module_names}, - {elvis_style, macro_names}, - {elvis_style, module_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$", ignore => []}}, - {elvis_style, nesting_level, #{level => 4}}, - {elvis_style, no_behavior_info}, - {elvis_style, no_if_expression}, - {elvis_style, no_spec_with_records}, - {elvis_style, no_tabs}, - {elvis_style, no_trailing_whitespace}, - {elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}}, - {elvis_style, state_record_and_type}, - {elvis_style, used_ignored_variable} - ]}, - #{dirs => ["."], - filter => "rebar.config", - rules => [ - {elvis_project, no_deps_master_rebar, #{ignore => []}}, - {elvis_project, protocol_for_deps_rebar, #{ignore => []}} - ]}, - #{dirs => ["."], - filter => "elvis.config", - rules => [ - {elvis_project, old_configuration_format} - ]} - ]} -]}]. diff --git a/rebar.config b/rebar.config index bb2e64b..27cd9e0 100644 --- a/rebar.config +++ b/rebar.config @@ -7,13 +7,15 @@ {deps, [ {foil, ".*", - {git, "https://github.com/lpgauth/foil.git", {tag, "0.1.1"}}}, + {git, "https://github.com/lpgauth/foil.git", {tag, "0.1.3"}}}, + {granderl, ".*", + {git, "https://github.com/tokenrove/granderl.git", "ee3fac0a2ca1d460c90808537216707f82cc777f"}}, {lz4, ".*", {git, "https://github.com/lpgauth/erlang-lz4.git", {branch, "rebar3"}}}, {murmur, ".*", - {git, "https://github.com/lpgauth/murmur.git", {tag, "0.1.1"}}}, + {git, "https://github.com/lpgauth/murmur.git", {tag, "0.1.3"}}}, {shackle, ".*", - {git, "https://github.com/lpgauth/shackle.git", {tag, "0.6.14"}}} + {git, "https://github.com/lpgauth/shackle.git", {tag, "0.6.19"}}} ]}. {edoc_opts, [ diff --git a/rebar.config.script b/rebar.config.script deleted file mode 100644 index d829600..0000000 --- a/rebar.config.script +++ /dev/null @@ -1,7 +0,0 @@ -case os:getenv("TRAVIS") of - "true" -> - JobId = os:getenv("TRAVIS_JOB_ID"), - lists:keystore(coveralls_service_job_id, 1, CONFIG, {coveralls_service_job_id, JobId}); - _ -> - CONFIG -end. diff --git a/rebar.lock b/rebar.lock index d535e6f..dd359a2 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,24 +1,28 @@ -{"1.1.0", +{"1.2.0", [{<<"foil">>, {git,"https://github.com/lpgauth/foil.git", - {ref,"56440106cc70f45d53ae461e98a547b5cde63646"}}, + {ref,"e462829855a745d8f20fb0508ae3eb8e323b03bd"}}, + 0}, + {<<"granderl">>, + {git,"https://github.com/tokenrove/granderl.git", + {ref,"ee3fac0a2ca1d460c90808537216707f82cc777f"}}, 0}, - {<<"granderl">>,{pkg,<<"granderl">>,<<"0.1.5">>},1}, {<<"lz4">>, {git,"https://github.com/lpgauth/erlang-lz4.git", - {ref,"d52a642b9f6a4451a5f4ab7bc718d2fcfcf67f7f"}}, + {ref,"30ac242cf8f6ec9ef097f494ae87f6295039ffd4"}}, 0}, {<<"metal">>,{pkg,<<"metal">>,<<"0.1.1">>},1}, {<<"murmur">>, {git,"https://github.com/lpgauth/murmur.git", - {ref,"1ef5b3680c61498aa9f9c99aae6ea021d7844b71"}}, + {ref,"db2cd781c895d03561bc967ca75fe95e67a92dcf"}}, 0}, {<<"shackle">>, {git,"https://github.com/lpgauth/shackle.git", - {ref,"a498ef0fde4808fa71fd5fe1404543475aaf7043"}}, + {ref,"a4f7d82d10115cf0d676582b638a56260be685d5"}}, 0}]}. [ {pkg_hash,[ - {<<"granderl">>, <<"F20077A68BD80B8D8783BD15A052813C6483771DEC1A5B837D307CBE92F14122">>}, - {<<"metal">>, <<"5D3D1322DA7BCD34B94FED5486F577973685298883954F7A3E517EF5EF6953F5">>}]} + {<<"metal">>, <<"5D3D1322DA7BCD34B94FED5486F577973685298883954F7A3E517EF5EF6953F5">>}]}, +{pkg_hash_ext,[ + {<<"metal">>, <<"88B82B634998A1A768DEDCD372C2F7E657B19445325C0AF5CCBAC62C77210F1D">>}]} ]. diff --git a/src/marina.app.src b/src/marina.app.src index f82168e..01a2193 100644 --- a/src/marina.app.src +++ b/src/marina.app.src @@ -6,7 +6,12 @@ kernel, stdlib, shackle, - foil + foil, + murmur, + lz4, + metal, + syntax_tools, + compiler ]}, {mod, {marina_app, []}}, {env, []} diff --git a/src/marina_pool_server.erl b/src/marina_pool_server.erl index a8cca9d..8fd8a25 100644 --- a/src/marina_pool_server.erl +++ b/src/marina_pool_server.erl @@ -1,4 +1,6 @@ -module(marina_pool_server). +-compile({no_auto_import,[nodes/2]}). + -include("marina_internal.hrl"). -export([ diff --git a/src/marina_request.erl b/src/marina_request.erl index c522564..a466eea 100644 --- a/src/marina_request.erl +++ b/src/marina_request.erl @@ -93,7 +93,7 @@ startup(FrameFlags) -> marina_frame:encode(#frame { stream = ?DEFAULT_STREAM, opcode = ?OP_STARTUP, - flags = FrameFlags, + flags = 0, body = [marina_types:encode_string_map(Body)] }). diff --git a/src/marina_ring.erl b/src/marina_ring.erl index fdd9bdd..b370d53 100644 --- a/src/marina_ring.erl +++ b/src/marina_ring.erl @@ -5,6 +5,8 @@ {marina_ring_utils, lookup, 1} ]). +-dialyzer({nowarn_function, lookup/1}). + -export([ build/1, lookup/1 @@ -36,4 +38,4 @@ ranges([], LastToken, Acc) -> [{_Range, HostId} | _] = Ranges = lists:reverse(Acc), Ranges ++ [{{LastToken, undefined}, HostId}]; ranges([{Token, HostId} | T], LastToken, Acc) -> - ranges(T, Token, [{{LastToken, Token}, HostId} | Acc]). \ No newline at end of file + ranges(T, Token, [{{LastToken, Token}, HostId} | Acc]). diff --git a/src/marina_utils.erl b/src/marina_utils.erl index 44da63a..8c9c0ac 100644 --- a/src/marina_utils.erl +++ b/src/marina_utils.erl @@ -62,7 +62,8 @@ pack(Binary) -> {ok, term()} | {error, term()}. query(Socket, Query) -> - Msg = marina_request:query(0, 0, Query, #{skip_metadata => true}), + FrameFlags = frame_flags(), + Msg = marina_request:query(0, FrameFlags, Query, #{skip_metadata => true}), sync_msg(Socket, Msg). -spec query_opts(atom(), query_opts()) -> diff --git a/test/marina_tests.erl b/test/marina_tests.erl index fa6fc69..2456243 100644 --- a/test/marina_tests.erl +++ b/test/marina_tests.erl @@ -1,10 +1,13 @@ -module(marina_tests). -include("test.hrl"). +-define(IP, "172.18.0.2"). + %% runners marina_test_() -> {setup, fun () -> setup([ + {ip, ?IP}, {keyspace, <<"test">>}, {pool_size, 1} ]) end, @@ -27,6 +30,7 @@ marina_test_() -> marina_compression_test_() -> {setup, fun () -> setup([ + {ip, ?IP}, {compression, true}, {keyspace, <<"test">>} ]) end, @@ -214,6 +218,8 @@ tuples_subtest() -> %% utils bootstrap() -> + application:load(marina), + application:set_env(?APP, ip, ?IP), marina_app:start(), timer:sleep(500), query(<<"CREATE KEYSPACE test WITH REPLICATION = @@ -244,7 +250,8 @@ query(Query) -> }). setup(KeyVals) -> - error_logger:tty(false), + application:start(sasl), + % error_logger:tty(false), bootstrap(), application:load(marina), set_env(KeyVals),