Skip to content

Commit

Permalink
Back to no crap
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed May 16, 2021
1 parent fd913bd commit 77ce0a8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 88 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ jobs:
elixir: 1.11.2
coverage: true
lint: true
# - otp: 23.0
# elixir: 1.10.3
# - otp: 22.3
# elixir: 1.10.3
# - otp: 22.1
# elixir: 1.9.4
# - otp: 21.3
# elixir: 1.8.2
# - otp: 20.3.1
# elixir: 1.7.4
# - otp: 19.3
# elixir: 1.7.4
- otp: 23.0
elixir: 1.10.3
- otp: 22.3
elixir: 1.10.3
- otp: 22.1
elixir: 1.9.4
- otp: 21.3
elixir: 1.8.2
- otp: 20.3.1
elixir: 1.7.4
- otp: 19.3
elixir: 1.7.4
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
MIX_ENV: test
Expand Down Expand Up @@ -64,9 +64,9 @@ jobs:
if: ${{!matrix.coverage}}

- name: Run tests with coverage
run: mix coveralls.github test/redix/sentinel_test.exs
run: mix coveralls.github
if: ${{matrix.coverage}}

- name: Dump docker logs on failure
if: failure()
- name: Dump Docker logs on failure
uses: jwalton/gh-docker-logs@v1
if: failure()
94 changes: 44 additions & 50 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
version: '3'

services:
# base:
# image: "redis:alpine"
# ports:
# - "6379:6379"
# sysctls:
# net.core.somaxconn: 1024
base:
image: "redis:alpine"
ports:
- "6379:6379"
sysctls:
net.core.somaxconn: 1024

# pubsub:
# image: "redis:alpine"
# ports:
# - "6380:6379"
# sysctls:
# net.core.somaxconn: 1024
pubsub:
image: "redis:alpine"
ports:
- "6380:6379"
sysctls:
net.core.somaxconn: 1024

# base_with_auth:
# image: "redis:5-alpine"
# command: redis-server --requirepass some-password
# ports:
# - "16379:6379"
# sysctls:
# net.core.somaxconn: 1024
base_with_auth:
image: "redis:5-alpine"
command: redis-server --requirepass some-password
ports:
- "16379:6379"
sysctls:
net.core.somaxconn: 1024

# base_with_acl:
# build: ./test/docker/base_with_acl
# ports:
# - "6385:6379"
# sysctls:
# net.core.somaxconn: 1024
base_with_acl:
build: ./test/docker/base_with_acl
ports:
- "6385:6379"
sysctls:
net.core.somaxconn: 1024

sentinel:
build: ./test/docker/sentinel
Expand All @@ -38,32 +38,26 @@ services:
- "26379:26379"
- "26380:26380"
- "26381:26381"
expose:
- "6381"
- "6382"
- "26379"
- "26380"
- "26381"
sysctls:
net.core.somaxconn: 1024

# sentinel_with_auth:
# build: ./test/docker/sentinel_with_auth
# ports:
# - "6383:6383"
# - "26383:26383"
# sysctls:
# net.core.somaxconn: 1024
sentinel_with_auth:
build: ./test/docker/sentinel_with_auth
ports:
- "6383:6383"
- "26383:26383"
sysctls:
net.core.somaxconn: 1024

# base_with_stunnel:
# image: dweomer/stunnel
# environment:
# - STUNNEL_SERVICE=base
# - STUNNEL_ACCEPT=6384
# - STUNNEL_CONNECT=base:6379
# links:
# - base
# ports:
# - 6384:6384
# sysctls:
# net.core.somaxconn: 1024
base_with_stunnel:
image: dweomer/stunnel
environment:
- STUNNEL_SERVICE=base
- STUNNEL_ACCEPT=6384
- STUNNEL_CONNECT=base:6379
links:
- base
ports:
- 6384:6384
sysctls:
net.core.somaxconn: 1024
15 changes: 0 additions & 15 deletions lib/redix/connector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ defmodule Redix.Connector do
_ = Logger.debug(fn -> "Connected to sentinel #{inspect(sentinel)}" end)

with :ok <- maybe_auth(transport, sent_socket, sentinel, sentinel_opts[:timeout]),
_ = Logger.debug("Authenticated to sentinel #{inspect(sentinel)}"),
{:ok, {server_host, server_port}} <-
ask_sentinel_for_server(transport, sent_socket, sentinel_opts),
_ =
Expand All @@ -137,10 +136,6 @@ defmodule Redix.Connector do
String.to_integer(server_port),
opts
),
_ =
Logger.debug(fn ->
"Established connection to #{sentinel_opts[:role]} #{server_host}:#{server_port}"
end),
:ok <- verify_server_role(server_socket, opts, sentinel_opts) do
:ok = transport.close(sent_socket)
{:ok, server_socket, "#{server_host}:#{server_port}"}
Expand All @@ -153,21 +148,11 @@ defmodule Redix.Connector do
sentinel_address: format_host(sentinel)
})

_ =
Logger.debug(fn ->
"Failed to negotiate with sentinel #{inspect(sentinel)}: #{inspect(reason)}"
end)

:ok = transport.close(sent_socket)
connect_through_sentinel(rest, sentinel_opts, opts, transport, conn_pid)
end

{:error, reason} ->
_ =
Logger.debug(fn ->
"Failed to connect to sentinel #{inspect(sentinel)}: #{inspect(reason)}"
end)

:telemetry.execute([:redix, :failed_connection], %{}, %{
connection: conn_pid,
connection_name: opts[:name],
Expand Down
1 change: 0 additions & 1 deletion test/redix/sentinel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ defmodule Redix.SentinelTest do
assert %Redix.ConnectionError{reason: :no_viable_sentinel_connection} = error
end

@tag :skip
test "sentinel supports password", %{sentinel_config: sentinel_config} do
sentinel_config =
Keyword.merge(sentinel_config,
Expand Down
14 changes: 7 additions & 7 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ExUnit.start(assert_receive_timeout: 500)

Logger.configure(level: :debug)
Logger.configure(level: :info)

# case :gen_tcp.connect('localhost', 6379, []) do
# {:ok, socket} ->
# :ok = :gen_tcp.close(socket)
case :gen_tcp.connect('localhost', 6379, []) do
{:ok, socket} ->
:ok = :gen_tcp.close(socket)

# {:error, reason} ->
# Mix.raise("Cannot connect to Redis (http://localhost:6379): #{:inet.format_error(reason)}")
# end
{:error, reason} ->
Mix.raise("Cannot connect to Redis (http://localhost:6379): #{:inet.format_error(reason)}")
end

0 comments on commit 77ce0a8

Please sign in to comment.