-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix elastic transports * add tests * update readme skip ci
- Loading branch information
Showing
3 changed files
with
30 additions
and
3 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
27 changes: 27 additions & 0 deletions
27
src/test/scala/io/epiphanous/flinkrunner/model/ElasticsearchSinkConfigSpec.scala
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,27 @@ | ||
package io.epiphanous.flinkrunner.model | ||
|
||
import java.net.URL | ||
import java.util.Properties | ||
|
||
import io.epiphanous.flinkrunner.BasePropSpec | ||
import org.apache.http.HttpHost | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
class ElasticsearchSinkConfigSpec extends BasePropSpec { | ||
def getHosts(transports:List[String]) = transports | ||
.map(s => { | ||
val url = new URL(if (s.startsWith("http")) s else s"http://${s}") | ||
val hostname = url.getHost | ||
val port = if (url.getPort < 0) 9200 else url.getPort | ||
new HttpHost(hostname, port, url.getProtocol) | ||
}) | ||
.asJava | ||
|
||
property("transports config with protocol") { | ||
println(getHosts(List("https://elastic:9200"))) | ||
} | ||
property("transports config without protocol") { | ||
println(getHosts(List("elastic:9200"))) | ||
} | ||
} |