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

Remove DiscoverSoftwareUpdates command #2560

Merged
merged 1 commit into from
Apr 29, 2024
Merged
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
13 changes: 0 additions & 13 deletions lib/trento/hosts/commands/discover_software_updates.ex

This file was deleted.

20 changes: 0 additions & 20 deletions lib/trento/hosts/host.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ defmodule Trento.Hosts.Host do
CompleteHostChecksExecution,
CompleteSoftwareUpdatesDiscovery,
DeregisterHost,
DiscoverSoftwareUpdates,
RegisterHost,
RequestHostDeregistration,
RollUpHost,
Expand Down Expand Up @@ -551,25 +550,6 @@ defmodule Trento.Hosts.Host do

# Software Updates Discovery

def execute(
%Host{fully_qualified_domain_name: nil},
%DiscoverSoftwareUpdates{}
),
do: []

def execute(
%Host{
host_id: host_id,
fully_qualified_domain_name: fully_qualified_domain_name
},
%DiscoverSoftwareUpdates{}
) do
%SoftwareUpdatesDiscoveryRequested{
host_id: host_id,
fully_qualified_domain_name: fully_qualified_domain_name
}
end

def execute(
%Host{
host_id: host_id,
Expand Down
2 changes: 0 additions & 2 deletions lib/trento/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ defmodule Trento.Router do
CompleteHostChecksExecution,
CompleteSoftwareUpdatesDiscovery,
DeregisterHost,
DiscoverSoftwareUpdates,
RegisterHost,
RequestHostDeregistration,
RollUpHost,
Expand Down Expand Up @@ -64,7 +63,6 @@ defmodule Trento.Router do
RequestHostDeregistration,
DeregisterHost,
CompleteHostChecksExecution,
DiscoverSoftwareUpdates,
CompleteSoftwareUpdatesDiscovery,
ClearSoftwareUpdatesDiscovery
],
Expand Down
62 changes: 0 additions & 62 deletions test/trento/hosts/host_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule Trento.Hosts.HostTest do
CompleteHostChecksExecution,
CompleteSoftwareUpdatesDiscovery,
DeregisterHost,
DiscoverSoftwareUpdates,
RegisterHost,
RequestHostDeregistration,
RollUpHost,
Expand Down Expand Up @@ -1597,7 +1596,6 @@ defmodule Trento.Hosts.HostTest do
describe "software updates discovery" do
test "should not accept software updates discovery commands if a host is not registered yet" do
commands = [
%DiscoverSoftwareUpdates{host_id: Faker.UUID.v4()},
%CompleteSoftwareUpdatesDiscovery{host_id: Faker.UUID.v4()},
%ClearSoftwareUpdatesDiscovery{host_id: Faker.UUID.v4()}
]
Expand All @@ -1607,64 +1605,6 @@ defmodule Trento.Hosts.HostTest do
end
end

test "should not trigger the software updates discovery process without a valid FQDN" do
host_id = Faker.UUID.v4()

initial_events = [
build(:host_registered_event,
host_id: host_id,
fully_qualified_domain_name: nil
),
build(:heartbeat_succeded, host_id: host_id)
]

assert_events_and_state(
initial_events,
DiscoverSoftwareUpdates.new!(%{
host_id: host_id
}),
[],
fn host ->
assert %Host{
host_id: ^host_id,
fully_qualified_domain_name: nil,
heartbeat: Health.passing()
} = host
end
)
end

test "should trigger the software updates discovery process" do
host_id = Faker.UUID.v4()
fully_qualified_domain_name = Faker.Internet.domain_name()

initial_events = [
build(:host_registered_event,
host_id: host_id,
fully_qualified_domain_name: fully_qualified_domain_name
),
build(:heartbeat_succeded, host_id: host_id)
]

assert_events_and_state(
initial_events,
DiscoverSoftwareUpdates.new!(%{
host_id: host_id
}),
%SoftwareUpdatesDiscoveryRequested{
host_id: host_id,
fully_qualified_domain_name: fully_qualified_domain_name
},
fn host ->
assert %Host{
host_id: ^host_id,
fully_qualified_domain_name: ^fully_qualified_domain_name,
heartbeat: Health.passing()
} = host
end
)
end

defp get_host_health_changed_event(host_id, scenario) do
case Map.get(scenario, :expect_host_health_changed, true) do
true ->
Expand Down Expand Up @@ -1972,7 +1912,6 @@ defmodule Trento.Hosts.HostTest do
vpc_id: "vpc-12345"
}
}),
DiscoverSoftwareUpdates.new!(%{host_id: host_id}),
RollUpHost.new!(%{
host_id: host_id
})
Expand Down Expand Up @@ -2315,7 +2254,6 @@ defmodule Trento.Hosts.HostTest do
%UpdateHeartbeat{host_id: host_id},
%UpdateProvider{host_id: host_id},
%UpdateSlesSubscriptions{host_id: host_id},
%DiscoverSoftwareUpdates{host_id: host_id},
%CompleteSoftwareUpdatesDiscovery{host_id: host_id},
%ClearSoftwareUpdatesDiscovery{host_id: host_id},
%SelectHostChecks{host_id: host_id}
Expand Down