Skip to content

Commit

Permalink
Add new gateway url to servers (#879)
Browse files Browse the repository at this point in the history
* Rename central testing workflow

* Add new gateway_url field to servers

* Add new gateway_url field to html templates

* Rename wrongly named module migration

* Set gateway_url for existing servers

* Add gateway url to JSON encoder

* Fix configurator tests

* Fix seeds

* Add gateway url to controller test params

* Format elixir code

* fix tests once again

* Add gateway url to arena server's show

---------

Co-authored-by: tvillegas98 <[email protected]>
  • Loading branch information
Nico-Sanchez and tvillegas98 authored Aug 23, 2024
1 parent fa09285 commit df42baa
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/central-europe-testing-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[CENTRAL-EUROPE] Deploy to Europe Central testing"
name: "[CENTRAL-TESTING] Deploy to Europe Central testing"
on:
workflow_dispatch:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
<.input field={f[:name]} type="text" label="Name" />
<.input field={f[:ip]} type="text" label="Ip" />
<.input field={f[:url]} type="text" label="Url" />
<.input
field={f[:gateway_url]}
type="select"
label="Gateway Url"
prompt="Choose a value"
options={[
"https://central-europe-testing.championsofmirra.com",
"https://central-europe-staging.championsofmirra.com"
]}
/>
<.input
field={f[:status]}
type="select"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<:col :let={arena_server} label="Name"><%= arena_server.name %></:col>
<:col :let={arena_server} label="Ip"><%= arena_server.ip %></:col>
<:col :let={arena_server} label="Url"><%= arena_server.url %></:col>
<:col :let={arena_server} label="Gateway Url"><%= arena_server.gateway_url %></:col>
<:col :let={arena_server} label="Status"><%= arena_server.status %></:col>
<:col :let={arena_server} label="Environment"><%= arena_server.environment %></:col>
<:action :let={arena_server}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<:item title="Name"><%= @arena_server.name %></:item>
<:item title="Ip"><%= @arena_server.ip %></:item>
<:item title="Url"><%= @arena_server.url %></:item>
<:item title="Gateway Url"><%= @arena_server.gateway_url %></:item>
<:item title="Status"><%= @arena_server.status %></:item>
<:item title="Environment"><%= @arena_server.environment %></:item>
</.list>
Expand Down
9 changes: 8 additions & 1 deletion apps/configurator/test/configurator/configuration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ defmodule Configurator.ConfigurationTest do
end

test "create_arena_server/1 with valid data creates a arena_server" do
valid_attrs = %{name: "some name", ip: "some ip", url: "some url", status: :active, environment: :production}
valid_attrs = %{
name: "some name",
ip: "some ip",
url: "some url",
gateway_url: "some GATEWAY url",
status: :active,
environment: :production
}

assert {:ok, %ArenaServer{} = arena_server} = Configuration.create_arena_server(valid_attrs)
assert arena_server.name == "some name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ defmodule ConfiguratorWeb.ArenaServerControllerTest do

setup [:create_authenticated_conn]

@create_attrs %{name: "some name", ip: "some ip", url: "some url", status: :active, environment: :production}
@create_attrs %{
name: "some name",
ip: "some ip",
url: "some url",
gateway_url: "some gateway url",
status: :active,
environment: :production
}
@update_attrs %{
name: "some updated name",
ip: "some updated ip",
url: "some updated url",
gateway_url: "some updated GATEWAY url",
status: :inactive,
environment: :development
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ defmodule Configurator.ConfigurationFixtures do
ip: "some ip",
name: "some name",
url: "some url",
gateway_url: "some GATEWAY url",
status: :active,
environment: :production
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ defmodule GameBackend.ArenaServers.ArenaServer do
use GameBackend.Schema
import Ecto.Changeset

@derive {Jason.Encoder, only: [:name, :ip, :url, :status, :environment]}
@derive {Jason.Encoder, only: [:name, :ip, :url, :gateway_url, :status, :environment]}
schema "arena_servers" do
field(:name, :string)
field(:ip, :string)
field(:url, :string)
field(:gateway_url, :string)
field(:status, Ecto.Enum, values: [:active, :inactive])
field(:environment, Ecto.Enum, values: [:production, :development, :staging])

Expand All @@ -19,7 +20,7 @@ defmodule GameBackend.ArenaServers.ArenaServer do
@doc false
def changeset(arena_server, attrs) do
arena_server
|> cast(attrs, [:name, :ip, :url, :status, :environment])
|> validate_required([:name, :url, :status, :environment])
|> cast(attrs, [:name, :ip, :url, :status, :environment, :gateway_url])
|> validate_required([:name, :url, :status, :environment, :gateway_url])
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Configurator.Repo.Migrations.CreateArenaServers do
defmodule GameBackend.Repo.Migrations.CreateArenaServers do
use Ecto.Migration

def change do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule GameBackend.Repo.Migrations.AddGatewayUrlFieldToArenaServers do
use Ecto.Migration

def change do
alter table(:arena_servers) do
add :gateway_url, :string
end

execute("""
UPDATE arena_servers arena_server
SET gateway_url = 'https://central-europe-staging.championsofmirra.com';
""", "")
end
end
2 changes: 2 additions & 0 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3068,6 +3068,7 @@ brazil_arena_server =
name: "BRAZIL",
ip: "",
url: "arena-brazil-staging.championsofmirra.com",
gateway_url: "https://central-europe-staging.championsofmirra.com",
status: "active",
environment: "production"
}
Expand All @@ -3079,6 +3080,7 @@ europe_arena_server =
name: "EUROPE",
ip: "",
url: "arena-europe-testing.championsofmirra.com",
gateway_url: "https://central-europe-staging.championsofmirra.com",
status: "active",
environment: "production"
}
Expand Down

0 comments on commit df42baa

Please sign in to comment.