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

Add select host checks endpoint #1544

Merged
merged 3 commits into from
Jun 21, 2023
Merged

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Jun 19, 2023

Description

Exposes a POST /api/v1/hosts/:id/checks for host checks selection.

How was this tested?

Automated test.

@nelsonkopliku nelsonkopliku added enhancement New feature or request user story elixir Pull requests that update Elixir code labels Jun 19, 2023
@nelsonkopliku nelsonkopliku self-assigned this Jun 19, 2023
@nelsonkopliku nelsonkopliku force-pushed the add-select-host-checks-endpoint branch 2 times, most recently from f1c1c03 to 836e98c Compare June 19, 2023 14:22
responses: [
accepted: "The Selection has been successfully collected",
not_found: Schema.NotFound.response(),
bad_request: Schema.BadRequest.response(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a doubt on this. I am tempted to remove it. I couldn't make it respond a 400.

Copy link
Contributor

@arbulu89 arbulu89 Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we only have 404 and 422. Yes it looks correct.
PD: I guess the command dispatch command returns {:error, :host_not_registered}, right?

Copy link
Member Author

@nelsonkopliku nelsonkopliku Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took advantage by cleaning up also other controllers defining an unnecessary bad_request
We have bad_request also used in cluster controller and tags controller.
We might want to clean those up at a certain point, however that change is not backward compatible so we'd need to bump version. I would not touch them yet, and track the thing. wdty?

I guess the command dispatch command returns {:error, :host_not_registered}, right?

yes if the host is not registered yet. It might also return {:error, :host_rolling_up} if the aggregate is in the rollup process.

@nelsonkopliku nelsonkopliku force-pushed the add-select-host-checks-endpoint branch 2 times, most recently from 684c3dd to 91908df Compare June 20, 2023 07:40
@nelsonkopliku nelsonkopliku marked this pull request as ready for review June 20, 2023 07:40
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
PD: We will have fun with the conflicts at some point hehe

@@ -36,4 +40,16 @@ defmodule Trento.Hosts do
subscription_count
end
end

@spec select_checks(String.t(), [String.t()]) :: :ok | {:error, any}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More conflicts to come in this file most probably 🙈

responses: [
accepted: "The Selection has been successfully collected",
not_found: Schema.NotFound.response(),
bad_request: Schema.BadRequest.response(),
Copy link
Contributor

@arbulu89 arbulu89 Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we only have 404 and 422. Yes it looks correct.
PD: I guess the command dispatch command returns {:error, :host_not_registered}, right?

@nelsonkopliku nelsonkopliku force-pushed the add-select-host-checks-endpoint branch 5 times, most recently from cd967a8 to 064a6ec Compare June 20, 2023 11:02
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick but good job overall 👍

describe "Check Selection" do
test "should dispatch command on Check Selection" do
host_id = Faker.UUID.v4()
selected_checks = Enum.map(0..4, fn _ -> Faker.Cat.name() end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to use UUIDs here (file under the usual topic: not mandatorily a uuid, but still for the sake of uniqueness)

Copy link
Member Author

@nelsonkopliku nelsonkopliku Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uniqueness here is not strictly necessary, however I changed in favor of a uuid.
Hope it does not become uuid all the things 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well for tests I tend to prefer them because there's really no risk of collisions 😅

@nelsonkopliku nelsonkopliku force-pushed the add-select-host-checks-endpoint branch from 064a6ec to 023e3f3 Compare June 20, 2023 14:27
@nelsonkopliku nelsonkopliku merged commit d14a503 into main Jun 21, 2023
@nelsonkopliku nelsonkopliku deleted the add-select-host-checks-endpoint branch June 21, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elixir Pull requests that update Elixir code enhancement New feature or request user story
Development

Successfully merging this pull request may close these issues.

3 participants