Skip to content

Commit 1569bf2

Browse files
committed
Add username and password support for indexing benchmark results.
1 parent b119e99 commit 1569bf2

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

build/scripts/Benchmarking.fsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ module Benchmarker =
167167
if indexResponse.IsValid = false then
168168
raise (Exception("Unable to index report into Elasticsearch: " + indexResponse.ServerError.Error.ToString()))
169169

170-
let IndexResults url =
170+
let IndexResults (url, username, password) =
171171
if (String.IsNullOrEmpty url = false) then
172172
trace "Indexing benchmark results into Elasticsearch"
173173

@@ -179,7 +179,12 @@ module Benchmarker =
179179
|> Seq.toList
180180

181181
let uri = new Uri(url)
182-
let client = new ElasticClient(uri)
182+
let connectionSettings = new ConnectionSettings(uri);
183+
184+
if (String.IsNullOrEmpty username = false && String.IsNullOrEmpty password = false) then
185+
connectionSettings.BasicAuthentication(username, password) |> ignore
186+
187+
let client = new ElasticClient(connectionSettings)
183188

184189
let indexExists = client.IndexExists(Indices.op_Implicit(indexName)).Exists
185190

build/scripts/Commandline.fsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ module Commandline =
7777

7878
| ["test"; testFilter] -> setBuildParam "testfilter" testFilter
7979

80+
| ["benchmark"; IsUrl elasticsearch; username; password] ->
81+
setBuildParam "elasticsearch" elasticsearch
82+
setBuildParam "nonInteractive" "0"
83+
setBuildParam "username" username
84+
setBuildParam "password" password
85+
8086
| ["benchmark"; IsUrl elasticsearch] ->
8187
setBuildParam "elasticsearch" elasticsearch
8288
setBuildParam "nonInteractive" "0"

build/scripts/Targets.fsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ Target "Benchmark" <| fun _ ->
5252
let runInteractive = ((getBuildParam "nonInteractive") <> "1")
5353
Benchmarker.Run(runInteractive)
5454
let url = getBuildParam "elasticsearch"
55-
Benchmarker.IndexResults url
55+
let username = getBuildParam "username"
56+
let password = getBuildParam "password"
57+
Benchmarker.IndexResults (url, username, password)
5658

5759
Target "InheritDoc" InheritDoc.PatchInheritDocs
5860

0 commit comments

Comments
 (0)