-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bugs in Proxy and Listener mappers, updated logging message, an…
…d enhanced file parsing in FileProxyP rovider (#29)
- Loading branch information
Showing
12 changed files
with
258 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
envoy/src/main/kotlin/ayansen/playground/envoy/entity/ProxyProviderConfigurations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
envoy/src/test/kotlin/ayansen/playground/envoy/Fixtures.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ayansen.playground.envoy | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory | ||
import com.fasterxml.jackson.module.kotlin.KotlinModule | ||
import java.io.File | ||
|
||
object Fixtures { | ||
|
||
val mapper: ObjectMapper = ObjectMapper(YAMLFactory()).apply { | ||
registerModule(KotlinModule.Builder().build()) | ||
} | ||
|
||
inline fun <reified T> parseYamlFile(file: File): T { | ||
return mapper.readValue(file, T::class.java) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
envoy/src/test/kotlin/ayansen/playground/envoy/entity/ListenersConfigurationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ayansen.playground.envoy.entity | ||
|
||
import ayansen.playground.envoy.Fixtures.parseYamlFile | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
import kotlin.test.assertEquals | ||
|
||
class ListenersConfigurationTest { | ||
|
||
@Test | ||
fun `toProtoListeners method returns a list of Listener protobuf objects when given a list of ListenerConfiguration objects`() { | ||
// Given | ||
val listeners: ListenersConfiguration = | ||
parseYamlFile(File("src/test/resources/listeners/multiple_http_listeners.yaml")) | ||
|
||
|
||
// When | ||
val result = listeners.toProtoListeners() | ||
|
||
// Then | ||
assertEquals(2, result.size) | ||
listeners.listeners.forEachIndexed { index, listener -> | ||
assertEquals(listener.name, result[index].name) | ||
assertEquals( | ||
listener.socketAddress.address, | ||
result[index].address.socketAddress.address | ||
) | ||
assertEquals(result[index].filterChainsCount, 1) | ||
assertEquals( | ||
listener.socketAddress.port, | ||
result[index].address.socketAddress.portValue | ||
) | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
envoy/src/test/kotlin/ayansen/playground/envoy/entity/ProxyTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package ayansen.playground.envoy.entity | ||
|
||
|
||
import ayansen.playground.envoy.Fixtures.parseYamlFile | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
import kotlin.test.assertNotNull | ||
|
||
class ProxyTest { | ||
|
||
@Test | ||
fun `generates a unique cluster for each route in the proxy`() { | ||
val proxy:Proxy = parseYamlFile(File("src/test/resources/proxies/proxy_with_multiple_routes.yaml")) | ||
val clusters = proxy.toProtoClusters() | ||
|
||
assert(clusters.size == 2) | ||
assert(clusters[0].name != clusters[1].name) | ||
} | ||
|
||
@Test | ||
fun `generates multiple endpoints with the right cluster name for each route in the proxy`() { | ||
val proxy:Proxy = parseYamlFile(File("src/test/resources/proxies/proxy_with_multiple_routes.yaml")) | ||
val clusters = proxy.toProtoClusters() | ||
val endpoints = proxy.toProtoEndpoints() | ||
|
||
assert(clusters.size == 2) | ||
assert(endpoints.size == 2) | ||
assert(clusters[0].name != clusters[1].name) | ||
assert(endpoints[0].clusterName == clusters[0].name) | ||
assert(endpoints[1].clusterName == clusters[1].name) | ||
} | ||
|
||
@Test | ||
fun `generates a single route configuration for a unique domain name`() { | ||
val proxy:Proxy = parseYamlFile(File("src/test/resources/proxies/proxy_with_multiple_routes.yaml")) | ||
|
||
val routeConfiguration = proxy.toProtoRoute() | ||
assertNotNull(routeConfiguration) | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
envoy/src/test/resources/listeners/multiple_http_listeners.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
listeners: | ||
- name: http | ||
socketAddress: | ||
address: 0.0.0.0 | ||
port: 10000 | ||
- name: http | ||
socketAddress: | ||
address: 0.0.0.0 | ||
port: 10001 |
Oops, something went wrong.