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

Re-register provider endpoints with admin interface after updates #572

Merged

Conversation

chrisgresty
Copy link
Contributor

See #555

Copy link
Contributor

@mikkokar mikkokar left a comment

Choose a reason for hiding this comment

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

To sum up:

  • Check my comments about Thread.sleep() in tests. This is why I'm setting the PR to Request Changes state.

  • Since this implemented feature is not specific to health check services alone, consider testing this with a mock service implementation. You could inject one via StyxServerComponents IIRC. This would avoid having to create mock origins and health checking them just for testing dynamic changes to admin interface providers.

  • Consider tweaking the URL router as per comments.

  • As a team we should consider to write all new code in Kotlin instead of Java. Now we are having a mixture of both. But this is a separate topic.

String providerName = entry.getKey();
entry.getValue().getStyxService().adminInterfaceHandlers(providerPath(providerName))
.forEach((relPath, handler) ->
routeBuilder.get(endpointPath(providerName, relPath), new HttpStreamer(MEGABYTE, handler))
Copy link
Contributor

Choose a reason for hiding this comment

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

We could simplify this code a bit by tweaking the UrlpatternRouter. So if UrlPatternRouter took a path prefix constructor argument, in this case /admin/providers, then all the subsequent calls to routeBuilder.get could simply pass in the relative path.

I think that would simplify this code a bit and we could possibly get rid of providerPath and endpointPath methods.

@@ -21,6 +21,7 @@ import io.kotlintest.Spec
import io.kotlintest.matchers.string.shouldContain
import io.kotlintest.matchers.string.shouldMatch
import io.kotlintest.specs.FeatureSpec
import java.io.File
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused import ^^^.

@@ -64,6 +65,7 @@ class AdminInterfaceSpec : FeatureSpec() {
.shouldMatch("\"[0-9]{1,2}d [0-9]{1,2}h [0-9]{1,2}m\"".toRegex())
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary change.

Thread.sleep(5000)
val response = styxServer.adminRequest("/admin/providers/appA-monitor/status")
response.status() shouldBe OK
response.header(HttpHeaderNames.CONTENT_TYPE).get().toLowerCase() shouldBe HttpHeaderValues.APPLICATION_JSON.toString().toLowerCase()
Copy link
Contributor

Choose a reason for hiding this comment

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

Use static Imports for HTTP header names.

}

scenario("The new endpoint returns status information after server restart") {
Thread.sleep(5000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the sleep here? Also 5 seconds is quite long. Is this justified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's not needed at all. It was left over from investigating something earlier in development.

scenario("The new endpoint returns status information without server restart") {
val response = styxServer.adminRequest("/admin/providers/appB-monitor/status")
response.status() shouldBe OK
response.header(HttpHeaderNames.CONTENT_TYPE).get().toLowerCase() shouldBe HttpHeaderValues.APPLICATION_JSON.toString().toLowerCase()
Copy link
Contributor

Choose a reason for hiding this comment

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

Use static imports.

Copy link
Contributor

@mikkokar mikkokar left a comment

Choose a reason for hiding this comment

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

Please remove the unnecessary comment blocks. Then proceed to merge.

scenario("Additional endpoints are listed on the Providers admin interface") {

// styxServer.components().servicesDatabase().insert("mockService",
// ProviderObjectRecord("MockService", setOf(), mockk(), MockService("mockService")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Some unnecessary comments here.


scenario("Endpoints for dynamically removed Styx services are not listed in the Admin interface") {

// styxServer.components().servicesDatabase().remove("mockService")
Copy link
Contributor

Choose a reason for hiding this comment

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

... and here.

@chrisgresty chrisgresty merged commit e4fb969 into ExpediaGroup:master Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants