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

Test and warning fixes #244

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ runtime/
/source_deploy.tar.gz
central.tar.gz
/bin
.vscode/launch.json

# I'm storing server output here, don't want to push it to git
example_output
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/servers/client_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ defmodule Teiserver.Account.ClientServer do
end

def handle_cast({:merge_update_client, partial_client}, state) do
Logger.warn(":merge_update_client is still being used, instead use :update_values")
Logger.warning(":merge_update_client is still being used, instead use :update_values")
new_client = Map.merge(state.client, partial_client)

PubSub.broadcast(
Expand Down
20 changes: 10 additions & 10 deletions lib/teiserver/battle/servers/match_monitor_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ defmodule Teiserver.Battle.MatchMonitorServer do
Telemetry.log_simple_match_event(userid, match_id, event_type_name, game_time)
Logger.info("match-event: Stored <#{username}> <#{event_type_name}> <#{game_time}> userid #{userid} match_id #{match_id}")
else
Logger.warn("match-event: Cannot get match_id of userid of #{username}")
Logger.warning("match-event: Cannot get match_id of userid of #{username}")
end
else
Logger.warn("match-event: Cannot get userid of #{username} or is not a bot")
Logger.warning("match-event: Cannot get userid of #{username} or is not a bot")
end

_ ->
Expand Down Expand Up @@ -242,7 +242,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do
end

_ ->
Logger.warn("match-chat nomatch from: #{from_id}: match-chat #{data}")
Logger.warning("match-chat nomatch from: #{from_id}: match-chat #{data}")
end

{:noreply, state}
Expand Down Expand Up @@ -288,7 +288,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do
end

_ ->
Logger.warn("match-chat-name nomatch from: #{from_id}: match-chat [[#{data}]]")
Logger.warning("match-chat-name nomatch from: #{from_id}: match-chat [[#{data}]]")
end

{:noreply, state}
Expand All @@ -311,23 +311,23 @@ defmodule Teiserver.Battle.MatchMonitorServer do
handle_json_msg(data, from_id)

_ ->
Logger.warn("AHM DM no catch, no json-decode - '#{contents_string}'")
Logger.warning("AHM DM no catch, no json-decode - '#{contents_string}'")
end

_ ->
Logger.warn("AHM DM no catch, no decompress - '#{compressed_contents}'")
Logger.warning("AHM DM no catch, no decompress - '#{compressed_contents}'")
end

_ ->
Logger.warn("AHM DM no catch, no base64 - '#{message}'")
Logger.warning("AHM DM no catch, no base64 - '#{message}'")
end

{:noreply, state}
end

# Catchall handle_info
def handle_info(msg, state) do
Logger.warn(
Logger.warning(
"Match monitor Server handle_info error. No handler for msg of #{Kernel.inspect(msg)}"
)

Expand All @@ -337,7 +337,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do
defp handle_json_msg(%{"username" => username, "GPU" => _} = contents, from_id) do
case CacheUser.get_user_by_name(username) do
nil ->
Logger.warn("No username on handle_json_msg: #{username} - #{Kernel.inspect(contents)}")
Logger.warning("No username on handle_json_msg: #{username} - #{Kernel.inspect(contents)}")

:ok

Expand Down Expand Up @@ -367,7 +367,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do
end

defp handle_json_msg(contents, _from_id) do
Logger.warn("No catch on handle_json_msg: #{Kernel.inspect(contents)}")
Logger.warning("No catch on handle_json_msg: #{Kernel.inspect(contents)}")
:ok
end

Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/benchmark/stats_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Avg ping: #{round(average_ping * 100) / 100}ms, Pings: #{Enum.count(state.pings)
port: port
})

Logger.warn("Starting stats")
Logger.warning("Starting stats")
:timer.send_interval(@registration_interval, self(), :register)
send(self(), :register)

Expand Down
1 change: 0 additions & 1 deletion lib/teiserver/bridge/command_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule Teiserver.Bridge.CommandLib do
@moduledoc """

"""
alias Teiserver.Data.Types, as: T
require Logger

@spec handle_command(Nostrum.Struct.Interaction.t(), map()) :: map()
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/bridge/message_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Teiserver.Bridge.MessageCommands do
content: "$" <> content,
attachments: []
}) do
Logger.warn("1")
Logger.warning("1")

[cmd | remaining] = String.split(content, " ")
remaining = Enum.join(remaining, " ")
Expand Down Expand Up @@ -45,7 +45,7 @@ defmodule Teiserver.Bridge.MessageCommands do
end

def handle(_msg) do
# Logger.warn("2")
# Logger.warning("2")
# IO.inspect msg

:ok
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/coordinator/consul_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ defmodule Teiserver.Coordinator.ConsulServer do
# if existing.ready == false and new_client.ready == true and existing.unready_at != nil do
# time_elapsed = System.system_time(:millisecond) - existing.unready_at
# if time_elapsed < 1000 do
# Logger.warn("Ready up in #{time_elapsed}ms by #{existing.userid}/#{existing.name} using #{existing.lobby_client}")
# Logger.warning("Ready up in #{time_elapsed}ms by #{existing.userid}/#{existing.name} using #{existing.lobby_client}")
# end
# end

Expand Down Expand Up @@ -686,7 +686,7 @@ defmodule Teiserver.Coordinator.ConsulServer do

if player_count > 4 do
if user.hw_hash == nil do
Logger.warn("hw hash block for #{Account.get_username(userid)}")
Logger.warning("hw hash block for #{Account.get_username(userid)}")
%{new_client | player: false}
else
new_client
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/helpers/oban_logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Teiserver.Helper.ObanLogger do
require Logger

def handle_event([:oban, :job, :start], _measure, _meta, _) do
# Logger.warn("[Oban] :started #{meta.worker} at #{measure.system_time}")
# Logger.warning("[Oban] :started #{meta.worker} at #{measure.system_time}")
end

def handle_event([:oban, :job, :exception], _measure, meta, _) do
Expand Down
6 changes: 3 additions & 3 deletions lib/teiserver/lobby/libs/lobby_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ defmodule Teiserver.Lobby.LobbyLib do

@spec update_lobby(T.lobby(), nil | atom, any) :: T.lobby()
def update_lobby(%{id: lobby_id} = lobby, nil, :silent) do
Logger.warn("update_lobby is still being called for :silent")
Logger.warning("update_lobby is still being called for :silent")
cast_lobby(lobby_id, {:update_lobby, lobby})

lobby
end

def update_lobby(%{id: lobby_id} = lobby, nil, reason) do
Logger.warn("update_lobby (no data) is still being called, reason: #{reason}")
Logger.warning("update_lobby (no data) is still being called, reason: #{reason}")
cast_lobby(lobby_id, {:update_lobby, lobby})

PubSub.broadcast(
Expand All @@ -224,7 +224,7 @@ defmodule Teiserver.Lobby.LobbyLib do
end

def update_lobby(%{id: lobby_id} = lobby, data, reason) do
Logger.warn("update_lobby (with data) is still being called, reason: #{reason}")
Logger.warning("update_lobby (with data) is still being called, reason: #{reason}")
cast_lobby(lobby_id, {:update_lobby, lobby})

if Enum.member?([:update_battle_info], reason) do
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/protocols/spring/spring_in.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1408,11 +1408,11 @@ defmodule Teiserver.Protocols.SpringIn do

cond do
Enum.count(status_timestamps) > 10 ->
Logger.warn("status_flood_protection:10 - #{state.username}/#{state.userid}")
Logger.warning("status_flood_protection:10 - #{state.username}/#{state.userid}")
{true, %{state | status_timestamps: status_timestamps}}

Enum.count(recent_timestamps) > 3 ->
Logger.warn("status_flood_protection:3 - #{state.username}/#{state.userid}")
Logger.warning("status_flood_protection:3 - #{state.username}/#{state.userid}")
{true, %{state | status_timestamps: status_timestamps}}

true ->
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/protocols/spring/spring_out.ex
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ defmodule Teiserver.Protocols.SpringOut do
# I've made the mistake of forgetting it and wondering
# why stuff wasn't working so it's staying here
if not String.ends_with?(msg, "\n") do
Logger.warn("Attempting to send message without newline at the end - #{msg}")
Logger.warning("Attempting to send message without newline at the end - #{msg}")
end

msg =
Expand Down
2 changes: 0 additions & 2 deletions lib/teiserver/protocols/spring/spring_system_in.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
defmodule Teiserver.Protocols.Spring.SystemIn do
@moduledoc false

alias Teiserver.Account.LoginThrottleServer
alias Teiserver.Protocols.SpringIn
import Teiserver.Protocols.SpringOut, only: [reply: 5]
require Logger

@spec do_handle(String.t(), String.t(), String.t() | nil, Map.t()) :: Map.t()
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/protocols/spring/spring_telemetry_in.ex
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ defmodule Teiserver.Protocols.Spring.TelemetryIn do
defp do_live_client_event(data, state) do
if String.length(data) < 1024 do
case Regex.run(~r/(\S+) (\S+)/u, data) do
[_, event_name, value64] ->
[_, _event_name, value64] ->
case Spring.decode_value(value64) do
{:ok, value} ->
{:ok, _value} ->
if state.userid do
# TODO: Do stuff with live client events
# Telemetry.log_live_client_event(state.userid, event_name, value)
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/protocols/tachyon_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ defmodule Teiserver.Protocols.TachyonLib do
:error ->
# Previously got an error with data 'OK cmd=TACHYON' which suggests
# it was still in Spring mode
Logger.warn("Base64 error, given '#{data}'")
Logger.warning("Base64 error, given '#{data}'")
{:error, :base64_decode}

{:error, :gzip_decompress} ->
Logger.warn("Gzip error, given '#{data}'")
Logger.warning("Gzip error, given '#{data}'")
{:error, :gzip_decompress}

{:error, %Jason.DecodeError{}} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/protocols/tachyon_v1/communication_out.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Teiserver.Protocols.Tachyon.V1.CommunicationOut do
###########
# Direct messages
def do_reply(:direct_message, {sender_id, msg}) do
Logger.warn(
Logger.warning(
"Using :direct_message instead of :received_direct_message in V1.CommunicationOut"
)

Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/protocols/tachyon_v1/tachyon_out.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Teiserver.Protocols.Tachyon.V1.TachyonOut do
LobbyOut.do_reply(reply_cmd, data)

:battle ->
Logger.warn("Tachyon :battle namespace message #{reply_cmd}")
Logger.warning("Tachyon :battle namespace message #{reply_cmd}")
LobbyOut.do_reply(reply_cmd, data)

:matchmaking ->
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver_web/live/battles/lobbies/chat.ex
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ defmodule TeiserverWeb.Battle.LobbyLive.Chat do
end

def handle_info(msg, socket) do
Logger.warn("No handler in #{__MODULE__} for message #{Kernel.inspect(msg)}")
Logger.warning("No handler in #{__MODULE__} for message #{Kernel.inspect(msg)}")
{:noreply, socket}
end

Expand Down
1 change: 0 additions & 1 deletion lib/teiserver_web/live/microblog/admin/post/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.PostLive.Show do
@moduledoc false
use TeiserverWeb, :live_view
alias Teiserver.Microblog
import TeiserverWeb.MicroblogComponents

@impl true
def mount(_params, _session, socket) do
Expand Down
1 change: 0 additions & 1 deletion lib/teiserver_web/live/microblog/admin/tag/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.TagLive.Index do
@moduledoc false
use TeiserverWeb, :live_view
alias Teiserver.Microblog
import TeiserverWeb.MicroblogComponents

@impl true
def mount(_params, _session, socket) do
Expand Down
1 change: 0 additions & 1 deletion lib/teiserver_web/live/microblog/admin/tag/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.TagLive.Show do
@moduledoc false
use TeiserverWeb, :live_view
alias Teiserver.Microblog
import TeiserverWeb.MicroblogComponents

@impl true
def mount(_params, _session, socket) do
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver_web/live/queues/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ defmodule TeiserverWeb.Matchmaking.QueueLive.Index do
} = data,
socket
) do
Logger.warn("index.ex Match ready")
Logger.warning("index.ex Match ready")

{:noreply,
socket
Expand Down
7 changes: 0 additions & 7 deletions test/teiserver/account/account_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ defmodule Teiserver.AccountTest do
developer: "Normal"
]
)

# Order by
Account.list_users(order_by: [{:data, "field", :asc}])
Account.list_users(order_by: [{:data, "field", :desc}])

# Fallback
Account.list_users(order_by: [{:data, "field", :desc}])
end

test "get_user!/1 returns the user with given id" do
Expand Down
20 changes: 10 additions & 10 deletions test/teiserver/coordinator/consul_commands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
assert reply["message"] == "No command of name 'creativecommandname'"
end

test "non allowed command", %{lobby_id: lobby_id, psocket: psocket, player: player} do

Check failure on line 86 in test/teiserver/coordinator/consul_commands_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test non allowed command (Teiserver.Coordinator.ConsulCommandsTest)
Lobby.force_add_user_to_lobby(player.id, lobby_id)
player_client = Account.get_client_by_id(player.id)

Expand Down Expand Up @@ -456,13 +456,13 @@
# Minimum
assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 0

data = %{cmd: "c.lobby.message", message: "$minplaylevel 3"}
data = %{cmd: "c.lobby.message", message: "$minratinglevel 3"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 3

data = %{cmd: "c.lobby.message", message: "$minplaylevel Xy"}
data = %{cmd: "c.lobby.message", message: "$minratinglevel Xy"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

Expand All @@ -471,52 +471,52 @@
# Maximum
assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 1000

data = %{cmd: "c.lobby.message", message: "$maxplaylevel 13"}
data = %{cmd: "c.lobby.message", message: "$maxratinglevel 13"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13

data = %{cmd: "c.lobby.message", message: "$maxplaylevel Xy"}
data = %{cmd: "c.lobby.message", message: "$maxratinglevel Xy"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13

# Now try to set each the other side of the other
data = %{cmd: "c.lobby.message", message: "$maxplaylevel 1"}
data = %{cmd: "c.lobby.message", message: "$maxratinglevel 1"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 4

data = %{cmd: "c.lobby.message", message: "$maxplaylevel 16"}
data = %{cmd: "c.lobby.message", message: "$maxratinglevel 16"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 16

data = %{cmd: "c.lobby.message", message: "$minplaylevel 20"}
data = %{cmd: "c.lobby.message", message: "$minratinglevel 20"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 15

data = %{cmd: "c.lobby.message", message: "$setplaylevels 7 9"}
data = %{cmd: "c.lobby.message", message: "$setratinglevels 7 9"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 7
assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 9

data = %{cmd: "c.lobby.message", message: "$setplaylevels 50 33"}
data = %{cmd: "c.lobby.message", message: "$setratinglevels 50 33"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 33
assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 50

data = %{cmd: "c.lobby.message", message: "$resetplaylevels"}
data = %{cmd: "c.lobby.message", message: "$resetratinglevels"}
_tachyon_send(hsocket, data)
:timer.sleep(500)

Expand Down Expand Up @@ -644,7 +644,7 @@
assert bans == %{}
end

test "ban by name", %{host: host, player: player, hsocket: hsocket, lobby_id: lobby_id} do

Check failure on line 647 in test/teiserver/coordinator/consul_commands_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test ban by name (Teiserver.Coordinator.ConsulCommandsTest)
player_client = Account.get_client_by_id(player.id)
assert player_client.lobby_id == lobby_id

Expand Down Expand Up @@ -674,7 +674,7 @@
assert bans == %{player.id => %{by: host.id, level: :banned, reason: "Banned"}}
end

test "error with no name", %{player: player, hsocket: hsocket, lobby_id: lobby_id} do

Check failure on line 677 in test/teiserver/coordinator/consul_commands_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test error with no name (Teiserver.Coordinator.ConsulCommandsTest)
player_client = Account.get_client_by_id(player.id)
assert player_client.lobby_id == lobby_id

Expand All @@ -686,7 +686,7 @@
assert player_client.lobby_id == lobby_id
end

test "ban multiple", %{host: host, player: player1, hsocket: hsocket, lobby_id: lobby_id} do

Check failure on line 689 in test/teiserver/coordinator/consul_commands_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test ban multiple (Teiserver.Coordinator.ConsulCommandsTest)
%{user: player2} = tachyon_auth_setup()
%{user: player3} = tachyon_auth_setup()

Expand Down Expand Up @@ -1127,7 +1127,7 @@
assert queue == [player1.id]
end

test "shuffle", %{lobby_id: lobby_id, hsocket: hsocket, player: existing_player} do

Check failure on line 1130 in test/teiserver/coordinator/consul_commands_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test shuffle (Teiserver.Coordinator.ConsulCommandsTest)
# Limit player count to 4 (2v2)
_tachyon_send(hsocket, %{
cmd: "c.lobby_host.update_host_status",
Expand Down
Loading
Loading