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

feat(monitored deploy): add endpoint to get a list of deployment monitors #3138

Merged

Conversation

marchello2000
Copy link
Contributor

Returns the names and ids of registered deployment monitors.
This will be used in deck to let the user pick a monitor (also need to plumb through gate)

import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@ExtendWith(SpringExtension.class)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robzienert / @robfletcher I copied this pattern, but I question if we actually should test via the WebMvc? Perhaps it makes sense to validate that params are annotated correctly, but it seems like a big overhead (vs. testing the methods directly). It also makes the tests slower since a bunch of spring needs to be stood up for this style test
What are your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's a java file in src/test/groovy FWIW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

going to convert it to a simple non-mvc test

mvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andExpect(
content().json(format("[{'id':'%s','name':'%s'}]", def1.getId(), def1.getName())));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there has got to be a better way than format, feedback appreciated!

Copy link
Contributor

Choose a reason for hiding this comment

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

in pure Java I don't think so. But it seems like a job for def1's toString()

ArrayList<DeploymentMonitorDefinition> result = new ArrayList<>();

if (monitoredDeployConfigurationProperties != null) {
monitoredDeployConfigurationProperties
Copy link
Contributor

Choose a reason for hiding this comment

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

could streamline this with streams:

if (monitoredDeployConfigurationProperties == null) {
    return Collections.emptyList();
}

return monitoredDeployConfigurationProperties
    .getDeploymentMonitors()
    .stream()
    .map(dm -> result.add(new DeploymentMonitorDefinition(dm)))
    .collect(Collectors.toList());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, i like it (even though i am not a fan of java streams)

import lombok.Data;

@Data
public class DeploymentMonitorDefinition {
Copy link
Contributor

Choose a reason for hiding this comment

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

same class name but in a different package? This is triggering my anxiety

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the "model" for the API... should i call it something else - i don't want return all of the internal stuffs

…tors

Returns the names and ids of registered deployment monitors.
This will be used in `deck` to let the user pick a monitor (also need to plumb through `gate`)
@marchello2000 marchello2000 merged commit b867530 into spinnaker:master Sep 11, 2019
@marchello2000 marchello2000 deleted the mark/add_deploy_monitor_ep branch September 11, 2019 22:43
marchello2000 added a commit to marchello2000/gate that referenced this pull request Sep 12, 2019
marchello2000 added a commit to spinnaker/gate that referenced this pull request Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants