Skip to content

Commit

Permalink
Clean up some Toxiproxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Oct 20, 2023
1 parent 07800f3 commit 459592f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 40 deletions.
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ services:

toxiproxy:
image: ghcr.io/shopify/toxiproxy:2.6.0
command: -config=/config/toxiproxy.json -host 0.0.0.0
command: -host 0.0.0.0
volumes:
- ./test/toxiproxy_config.json:/config/toxiproxy.json
ports:
- "8474:8474"
- "19052:9042"
- "19152:9043"
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule Xandra.Mixfile do
{:mox, "~> 1.0", only: :test},
{:stream_data, "~> 0.6.0", only: [:dev, :test]},
{:nimble_lz4, "~> 0.1.3", only: [:dev, :test]},
{:toxiproxy_ex, "~> 1.1", only: :test}
{:toxiproxy_ex, github: "whatyouhide/toxiproxy_ex", only: :test}
]
end
end
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{
"castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"},
"castore": {:hex, :castore, "1.0.4", "ff4d0fb2e6411c0479b1d965a814ea6d00e51eb2f58697446e9c41a97d940b28", [:mix], [], "hexpm", "9418c1b8144e11656f0be99943db4caf04612e3eaecefb5dae9a2a87565584f8"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"dialyxir": {:hex, :dialyxir, "1.4.1", "a22ed1e7bd3a3e3f197b68d806ef66acb61ee8f57b3ac85fc5d57354c5482a93", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "84b795d6d7796297cca5a3118444b80c7d94f7ce247d49886e7c291e1ae49801"},
"earmark_parser": {:hex, :earmark_parser, "1.4.35", "437773ca9384edf69830e26e9e7b2e0d22d2596c4a6b17094a3b29f01ea65bb8", [:mix], [], "hexpm", "8652ba3cb85608d0d7aa2d21b45c6fad4ddc9a1f9a1f1b30ca3a246f0acc33f6"},
Expand All @@ -23,5 +23,5 @@
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"tesla": {:hex, :tesla, "1.7.0", "a62dda2f80d4f8a925eb7b8c5b78c461e0eb996672719fe1a63b26321a5f8b4e", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.13", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:msgpax, "~> 2.3", [hex: :msgpax, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "2e64f01ebfdb026209b47bc651a0e65203fcff4ae79c11efb73c4852b00dc313"},
"toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"},
"toxiproxy_ex": {:hex, :toxiproxy_ex, "1.1.1", "af605b9f54a4508e2c8987764301609f457076cafc472ba83beaec93e2796e99", [:mix], [{:castore, "~> 1.0.3", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: false]}, {:tesla, "~> 1.7.0", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "826c415c6e8ec1708894a86091afd0674f0a4115ed09ac6604088ef916226fe7"},
"toxiproxy_ex": {:git, "https://github.com/whatyouhide/toxiproxy_ex.git", "f77d7371bd0d58c3c6206589fba8c419e331113e", []},
}
9 changes: 9 additions & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ end

Logger.configure(level: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")))

ToxiproxyEx.populate!([
%{
name: "xandra_test_cassandra",
listen: "[::]:9042",
upstream: "cassandra:9042",
enabled: true
}
])

excluded =
case XandraTest.IntegrationCase.protocol_version() do
:v3 -> [:skip_for_native_protocol_v3]
Expand Down
14 changes: 0 additions & 14 deletions test/toxiproxy_config.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/xandra/cluster_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,6 @@ defmodule Xandra.ClusterTest do
end
end

@tag :tmp
@tag :toxiproxy
test "[tmp] Toxiproxy goes through", %{base_options: opts} do
opts = Keyword.merge(opts, sync_connect: 1000, nodes: ["127.0.0.1:19052"])
assert {:ok, _pid} = start_supervised({Cluster, opts})
end

defp get_state(cluster) do
assert {_state, data} = :sys.get_state(cluster)
data
Expand Down
16 changes: 2 additions & 14 deletions test/xandra_toxiproxy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ defmodule XandraToxiproxyTest do

test "execute/3,4 supports a network that slices packets",
%{start_options: opts, keyspace: keyspace} do
ToxiproxyEx.get!(:xandra_test_cassandra_sliced)
ToxiproxyEx.get!(:xandra_test_cassandra)
|> ToxiproxyEx.toxic(:slicer, average_size: 50, size_variation: 25, delay: _microsec = 50)
|> ToxiproxyEx.apply!(fn ->
opts = Keyword.merge(opts, nodes: ["127.0.0.1:19152"], keyspace: keyspace)
opts = Keyword.merge(opts, nodes: ["127.0.0.1:19052"], keyspace: keyspace)
conn = start_supervised!({Xandra, opts})
assert {:ok, prepared} = Xandra.prepare(conn, "SELECT * FROM system.local WHERE key = ?")
assert {:ok, page} = Xandra.execute(conn, prepared, ["local"])
Expand All @@ -30,18 +30,6 @@ defmodule XandraToxiproxyTest do
end)
end

test "prepare/3 when the connection goes down mid request", %{start_options: opts} do
opts = Keyword.merge(opts, nodes: ["127.0.0.1:19052"])
conn = start_supervised!({Xandra, opts})

ToxiproxyEx.get!(:xandra_test_cassandra)
|> ToxiproxyEx.toxic(:limit_data, bytes: 500)
|> ToxiproxyEx.apply!(fn ->
assert {:error, %ConnectionError{reason: :disconnected}} =
Xandra.prepare(conn, "SELECT * FROM system.local")
end)
end

test "start_link/1 supports the :connect_timeout option", %{start_options: opts} do
opts =
Keyword.merge(opts,
Expand Down

0 comments on commit 459592f

Please sign in to comment.