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

Use Kotlintest for unit-testing styx routing objects #394

Merged
merged 10 commits into from
Apr 5, 2019

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Apr 1, 2019

Summary

  • Replace Scala-based tests from styx-proxy project.
  • Add Kotlin-test framework to project and convert existing Scala-tests to Kotlin.

Rationale:

Routing object tests rely heavily on yaml configuration that require multi-line strings. Both Kotlin & Scala support multi-line strings and are handy for this domain. But Kotlin collections and SAM conversions interoperate better with existing Java code. Perhaps it is just my Scala knowledge (or lack of) but Kotlin seems more effortless for this purpose.

@mikkokar mikkokar requested review from kvosper and dvlato and removed request for kvosper April 1, 2019 08:06
assert(backendServices.toList().size == 2)
assert(backendServices.first() == backendServiceOne)

StyxFutures.await(registry.stop())
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to wait for the stop? I suppose that means we cannot run the tests in parallel, it would be nice to improve that...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I'll keep this in mind. This problem is inherited from the original Scala test. So it isn't introduced by this PR.

}

fun createOnMissing(path: String): String {
val absolutePath = Paths.get(javaClass.getResource("/").toURI()).resolve(path).toFile()
Copy link
Contributor

@dvlato dvlato Apr 1, 2019

Choose a reason for hiding this comment

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

Why are you using both java.nio and java.io here? is it because writeValue() above require a File?

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 also inherited from the original tests.

import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletableFuture.completedFuture

class BackendServiceProxyTest: StringSpec ({
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an space before the parenthesis, which is not consistent with the other tests.

(routingObjectDef as RouteHandlerDefinition).name() shouldBe("main-router")
routingObjectDef.type() shouldBe("ConditionRouter")

routingObjectDef.config().shouldBeInstanceOf<JsonNode>()
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we saw that in case of an assertion error this only prints the objects toString() and not the classname, we might want to somehow include a message with the actual class name .

mikkokar added 9 commits April 5, 2019 09:18
Disable NonSanitizingGraphiteSenderTest (uses java internal classes).
 - ConfigVersionResolverSpec
 - RouteHandlerFactorySpec
 - RoutingConfigParserSpec
 - RoutingConfigParserSpec
 - ConditionRouterConfigSpec
 - RewriteInterceptorSpec
 - ServerConfigSchemaSpec
 - StaticResponseHandlerSpec
 - ProxyToBackendSpec
 - HttpInterceptorPipelineSpec
 - BackendServiceProxySpec
 - FileBackkedBackendServicesRegistrySpec
@mikkokar mikkokar force-pushed the refactor-styx-routing branch from 7a274a0 to 7f418f3 Compare April 5, 2019 08:48
@mikkokar mikkokar merged commit cb50bf1 into ExpediaGroup:master Apr 5, 2019
@mikkokar mikkokar deleted the refactor-styx-routing branch April 5, 2019 09:58
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.

3 participants