-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add installation_source field to the host telemetry (#728)
* Add installation_source field to the host telemetry * Set the installation_source in a fixed enum * Upcast version of the changed events * Add event upcasting tests * Remove not needed default values from commands ane events * Split the host event upcasting test to individual files
- Loading branch information
Showing
16 changed files
with
219 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
priv/repo/migrations/20220729073320_add_installation_source_host_telemetry_read_model.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule Trento.Repo.Migrations.AddInstallationSourceHostTelemetryReadModel do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:hosts_telemetry) do | ||
add :installation_source, :string | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
test/fixtures/discovery/host_discovery_with_installation_source.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"agent_id": "779cdd70-e9e2-58ca-b18a-bf3eb3f71244", | ||
"discovery_type": "host_discovery", | ||
"payload": { | ||
"ssh_address": "10.2.2.22", | ||
"os_version": "15-SP2", | ||
"ip_addresses": ["10.1.1.4", "10.1.1.5", "10.1.1.6"], | ||
"hostname": "suse", | ||
"cpu_count": 2, | ||
"socket_count": 1, | ||
"total_memory_mb": 4096, | ||
"agent_version": "0.1.0", | ||
"installation_source": "Community" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/trento/domain/host/events/host_details_updated_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule Trento.Domain.Events.HostDetailsUpdatedTest do | ||
use Trento.AggregateCase, aggregate: Trento.Domain.Host, async: true | ||
|
||
alias Trento.Domain.Events.HostDetailsUpdated | ||
|
||
describe "HostDetailsUpdated event upcasting" do | ||
test "should upcast HostDetailsUpdated event properly from version 1" do | ||
host_id = Faker.UUID.v4() | ||
hostname = Faker.StarWars.character() | ||
ip_addresses = [Faker.Internet.ip_v4_address()] | ||
ssh_address = Faker.Internet.ip_v4_address() | ||
agent_version = Faker.Internet.slug() | ||
cpu_count = Enum.random(1..16) | ||
total_memory_mb = Enum.random(1..128) | ||
socket_count = Enum.random(1..16) | ||
os_version = Faker.App.version() | ||
|
||
assert %HostDetailsUpdated{ | ||
version: 2, | ||
host_id: host_id, | ||
hostname: hostname, | ||
ip_addresses: ip_addresses, | ||
ssh_address: ssh_address, | ||
agent_version: agent_version, | ||
cpu_count: cpu_count, | ||
total_memory_mb: total_memory_mb, | ||
socket_count: socket_count, | ||
os_version: os_version, | ||
installation_source: :unknown | ||
} == | ||
%{ | ||
"host_id" => host_id, | ||
"hostname" => hostname, | ||
"ip_addresses" => ip_addresses, | ||
"ssh_address" => ssh_address, | ||
"agent_version" => agent_version, | ||
"cpu_count" => cpu_count, | ||
"total_memory_mb" => total_memory_mb, | ||
"socket_count" => socket_count, | ||
"os_version" => os_version | ||
} | ||
|> HostDetailsUpdated.upcast(%{}) | ||
|> HostDetailsUpdated.new!() | ||
end | ||
end | ||
end |
Oops, something went wrong.