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

explicit start #4

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
inputs: ["{mix,.formatter}.exs", "{lib,test}/**/*.{ex,exs}"]
]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- make Hammer startup explicit

## 6.2.1 - 2024-02-23

- Fix issue in OTP 26 and Elixir 1.15 by not using to_existing_atom in configuration
Expand Down
12 changes: 0 additions & 12 deletions config/config.exs

This file was deleted.

68 changes: 0 additions & 68 deletions lib/hammer/application.ex

This file was deleted.

58 changes: 55 additions & 3 deletions lib/hammer/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,65 @@ defmodule Hammer.Supervisor do

Starts a set of poolboy pools based on provided configuration,
which are latter called to by the `Hammer` module.
See the Application module for configuration examples.

Configured with the `:hammer` environment key:

- `:backend`, Either a tuple of `{module, config}`, or a keyword-list
of separate, named backends. Examples:
`{Hammer.Backend.ETS, []}`, `[ets: {Hammer.Backend.ETS, []}, ...]`
- `:suppress_logs`, if set to `true`, stops all log messages from Hammer

### General Backend Options

Different backends take different options, but all will accept the following
options, and with the same effect:

- `:expiry_ms` (int): expiry time in milliseconds, after which a bucket will
be deleted. The exact mechanism for cleanup will vary by backend. This configuration
option is mandatory
- `:pool_size` (int): size of the backend worker pool (default=2)
- `:pool_max_overflow` int(): number of extra workers the pool is permitted
to spawn when under pressure. The worker pool (managed by the poolboy library)
will automatically create and destroy workers up to the max-overflow limit
(default=0)

Example of a single backend:

children = [
{Hammer.Supervisor, backend: {Hammer.Backend.ETS, [expiry_ms: 60_000 * 60 * 2]}}
]

Example of config for multiple-backends:

children = [
{Hammer.Supervisor,
backend: [
ets: {
Hammer.Backend.ETS,
[
ets_table_name: :hammer_backend_ets_buckets,
expiry_ms: 60_000 * 60 * 2,
cleanup_interval_ms: 60_000 * 2
]
},
redis: {
Hammer.Backend.Redis,
[
expiry_ms: 60_000 * 60 * 2,
redix_config: [host: "localhost", port: 6379],
pool_size: 4
]
}
]}
]

"""

use Supervisor

def start_link(config, opts) do
Supervisor.start_link(__MODULE__, config, opts)
def start_link(config) do
backend = Keyword.fetch!(config, :backend)
Supervisor.start_link(__MODULE__, backend, name: Hammer.Supervisor)
end

# Single backend
Expand Down
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ defmodule Hammer.Mixfile do
end

def application do
# Specify extra applications you'll use from Erlang/Elixir
[mod: {Hammer.Application, []}, extra_applications: [:logger, :runtime_tools]]
[extra_applications: []]
end

defp deps do
Expand Down
2 changes: 1 addition & 1 deletion test/hammer_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule HammerTest do
use ExUnit.Case, async: false
use ExUnit.Case

setup _context do
pool = Hammer.Utils.pool_name()
Expand Down Expand Up @@ -41,7 +41,7 @@
}
end

test "make_rate_checker" do

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test make_rate_checker (HammerTest)

Check failure on line 44 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test make_rate_checker (HammerTest)
check = Hammer.make_rate_checker("some-prefix:", 10_000, 2)
assert {:allow, 1} = check.("aaa")
assert {:allow, 2} = check.("aaa")
Expand All @@ -53,25 +53,25 @@
assert {:deny, 2} = check.("bbb")
end

test "returns {:ok, 1} tuple on first access", %{bucket: bucket} do

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test returns {:ok, 1} tuple on first access (HammerTest)

Check failure on line 56 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test returns {:ok, 1} tuple on first access (HammerTest)
assert {:allow, 1} = Hammer.check_rate(bucket, 10_000, 10)
end

test "returns {:ok, 4} tuple on in-limit checks", %{bucket: bucket} do

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)

Check failure on line 60 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test returns {:ok, 4} tuple on in-limit checks (HammerTest)
assert {:allow, 1} = Hammer.check_rate(bucket, 10_000, 10)
assert {:allow, 2} = Hammer.check_rate(bucket, 10_000, 10)
assert {:allow, 3} = Hammer.check_rate(bucket, 10_000, 10)
assert {:allow, 4} = Hammer.check_rate(bucket, 10_000, 10)
end

test "returns expected tuples on mix of in-limit and out-of-limit checks", %{bucket: bucket} do

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)

Check failure on line 67 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test returns expected tuples on mix of in-limit and out-of-limit checks (HammerTest)
assert {:allow, 1} = Hammer.check_rate(bucket, 10_000, 2)
assert {:allow, 2} = Hammer.check_rate(bucket, 10_000, 2)
assert {:deny, 2} = Hammer.check_rate(bucket, 10_000, 2)
assert {:deny, 2} = Hammer.check_rate(bucket, 10_000, 2)
end

test "returns expected tuples on 1000ms bucket check with a sleep in the middle", %{

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)

Check failure on line 74 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test returns expected tuples on 1000ms bucket check with a sleep in the middle (HammerTest)
bucket: bucket
} do
assert {:allow, 1} = Hammer.check_rate(bucket, 1000, 2)
Expand All @@ -83,7 +83,7 @@
assert {:deny, 2} = Hammer.check_rate(bucket, 1000, 2)
end

test "returns expected tuples on inspect_bucket" do

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test returns expected tuples on inspect_bucket (HammerTest)

Check failure on line 86 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test returns expected tuples on inspect_bucket (HammerTest)
assert {:ok, {0, 2, _, nil, nil}} = Hammer.inspect_bucket("inspect_bucket11", 1000, 2)
assert {:allow, 1} = Hammer.check_rate("inspect_bucket11", 1000, 2)
assert {:ok, {1, 1, _, _, _}} = Hammer.inspect_bucket("inspect_bucket11", 1000, 2)
Expand All @@ -98,7 +98,7 @@
assert ms_to_next_bucket < 1000
end

test "returns expected tuples on delete_buckets" do

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test returns expected tuples on delete_buckets (HammerTest)

Check failure on line 101 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test returns expected tuples on delete_buckets (HammerTest)
assert {:allow, 1} = Hammer.check_rate("my-bucket1", 1000, 2)
assert {:allow, 2} = Hammer.check_rate("my-bucket1", 1000, 2)
assert {:deny, 2} = Hammer.check_rate("my-bucket1", 1000, 2)
Expand All @@ -112,13 +112,13 @@
assert {:ok, 0} = Hammer.delete_buckets("unknown-bucket")
end

test "count_hit_inc" do

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test count_hit_inc (HammerTest)

Check failure on line 115 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test count_hit_inc (HammerTest)
assert {:allow, 4} = Hammer.check_rate_inc("cost-bucket1", 1000, 10, 4)
assert {:allow, 9} = Hammer.check_rate_inc("cost-bucket1", 1000, 10, 5)
assert {:deny, 10} = Hammer.check_rate_inc("cost-bucket1", 1000, 10, 3)
end

test "mixing count_hit with count_hit_inc" do

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test mixing count_hit with count_hit_inc (HammerTest)

Check failure on line 121 in test/hammer_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test mixing count_hit with count_hit_inc (HammerTest)
assert {:allow, 3} = Hammer.check_rate_inc("cost-bucket2", 1000, 10, 3)
assert {:allow, 4} = Hammer.check_rate("cost-bucket2", 1000, 10)
assert {:allow, 5} = Hammer.check_rate("cost-bucket2", 1000, 10)
Expand Down
15 changes: 15 additions & 0 deletions test/hammer_util_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
defmodule UtilsTest do
use ExUnit.Case

setup do
start_supervised!(
{Hammer.Supervisor,
backend: [
ets:
{Hammer.Backend.ETS,
ets_table_name: :utils_test,
expiry_ms: 60_000 * 60 * 2,
cleanup_interval_ms: 60_000 * 2}
]}
)

:ok
end

test "timestamp" do
assert is_integer(Hammer.Utils.timestamp())
end
Expand All @@ -15,7 +30,7 @@
assert b_id == id
end

test "get_backend_module" do

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 26)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 26)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.14, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.14, 26)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.16, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.13, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.13, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-20.04, 1.15, 26)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 26)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.15, 24)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 25)

test get_backend_module (UtilsTest)

Check failure on line 33 in test/hammer_util_test.exs

View workflow job for this annotation

GitHub Actions / setup (ubuntu-22.04, 1.16, 26)

test get_backend_module (UtilsTest)
# With :single and default backend config
assert Hammer.Utils.get_backend_module(:single) == Hammer.Backend.ETS

Expand Down
Loading