@@ -39,6 +39,8 @@ let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults"
39
39
let outputPerfTests = __ SOURCE_ DIRECTORY__ @@ " PerfResults"
40
40
let outputNuGet = output @@ " nuget"
41
41
42
+ exception ConnectionFailure of string
43
+
42
44
Target " Clean" ( fun _ ->
43
45
ActivateFinalTarget " KillCreatedProcesses"
44
46
@@ -128,6 +130,76 @@ Target "NBench" <| fun _ ->
128
130
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
129
131
130
132
projects |> Seq.iter runSingleProject
133
+
134
+ Target " RunTestsOnRuntimes" ( fun _ ->
135
+
136
+ let LighthouseConnectTimeout = 20.0 // in seconds
137
+
138
+ let dockerFileForTest =
139
+ match ( isWindows) with
140
+ | true -> " src/Lighthouse/Dockerfile-windows"
141
+ | _ -> " src/Lighthouse/Dockerfile-linux"
142
+
143
+ let installPbm () =
144
+ // Install pbm client to test connections
145
+ ExecProcess( fun info ->
146
+ info.FileName <- " dotnet"
147
+ info.Arguments <- " tool install --global pbm" ) ( TimeSpan.FromMinutes 5.0 ) |> ignore // this is fine if tool is already installed
148
+
149
+ let startLighthouseDocker dockerFile =
150
+ printfn " Starting Lighthouse..."
151
+ let runArgs = " run -d --name lighthouse --hostname lighthouse1 -p 4053:4053 -p 9110:9110 --env CLUSTER_IP=127.0.0.1 --env CLUSTER_SEEDS=akka.tcp://some@lighthouse1:4053 --env CLUSTER_PORT=4053 lighthouse:latest"
152
+ let runResult = ExecProcess( fun info ->
153
+ info.FileName <- " docker"
154
+ info.WorkingDirectory <- ( Directory.GetParent dockerFile) .FullName
155
+ info.Arguments <- runArgs) ( System.TimeSpan.FromMinutes 5.0 )
156
+ if runResult <> 0 then failwith " Unable to start Lighthouse in Docker"
157
+
158
+ let stopLighthouseDocker dockerFile =
159
+ printfn " Stopping Lighthouse..."
160
+ ExecProcess( fun info ->
161
+ info.FileName <- " docker"
162
+ info.WorkingDirectory <- ( Directory.GetParent dockerFile) .FullName
163
+ info.Arguments <- " rm -f lighthouse" ) ( System.TimeSpan.FromMinutes 5.0 ) |> ignore // cleanup failure should not fail the test
164
+
165
+ let startLighhouseLocally exePath =
166
+ printfn " Starting Lighthouse locally..."
167
+ try
168
+ let runResult = ExecProcess( fun info ->
169
+ info.FileName <- exePath) ( System.TimeSpan.FromSeconds LighthouseConnectTimeout)
170
+ if runResult <> 0 then failwithf " Unable to start Lighthouse from %s " exePath
171
+ with
172
+ | _ -> () // Local instance process should just timeout, this is fine
173
+
174
+ let connectLighthouse () =
175
+ printfn " Connecting Lighthouse..."
176
+ try
177
+ ExecProcess( fun info ->
178
+ info.FileName <- " pbm" ) ( System.TimeSpan.FromSeconds LighthouseConnectTimeout) |> ignore
179
+ // If process returned, this means that pbm failed to connect
180
+ raise ( ConnectionFailure " Failed to connect Lighthouse from pbm" )
181
+ with
182
+ | ConnectionFailure( str) -> reraise()
183
+ // If timed out, Lighthouse was connected successfully
184
+ | _ -> printfn " Lighthouse was connected successfully"
185
+
186
+ installPbm()
187
+ startLighthouseDocker dockerFileForTest
188
+ try
189
+ connectLighthouse()
190
+ finally
191
+ stopLighthouseDocker dockerFileForTest
192
+
193
+ // Test Full .NET Framework version under windows only
194
+ // TODO: To make this work, need to start lighthouse and pbm as two parallel processes
195
+ (*
196
+ match (isWindows) with
197
+ | true ->
198
+ startLighhouseLocally "src/Lighthouse/bin/Release/net461/Lighthouse.exe"
199
+ connectLighthouse()
200
+ | _ -> ()
201
+ *)
202
+ )
131
203
132
204
133
205
//--------------------------------------------------------------------------------
@@ -254,6 +326,12 @@ let mapDockerImageName (projectName:string) =
254
326
| " Lighthouse" -> Some( " lighthouse" )
255
327
| _ -> None
256
328
329
+ let composedGetDirName ( p : string ) =
330
+ System.IO.Path.GetDirectoryName p
331
+
332
+ let composedGetFileNameWithoutExtension ( p : string ) =
333
+ System.IO.Path.GetFileNameWithoutExtension p
334
+
257
335
Target " BuildDockerImages" ( fun _ ->
258
336
let projects = !! " src/**/*.csproj"
259
337
-- " src/**/*Tests.csproj" // Don't publish unit tests
@@ -304,11 +382,11 @@ Target "BuildDockerImages" (fun _ ->
304
382
305
383
ExecProcess( fun info ->
306
384
info.FileName <- " docker"
307
- info.WorkingDirectory <- Path.GetDirectoryName projectPath
385
+ info.WorkingDirectory <- composedGetDirName projectPath
308
386
info.Arguments <- args) ( System.TimeSpan.FromMinutes 5.0 ) (* Reasonably long-running task. *)
309
387
310
388
let runSingleProject project =
311
- let projectName = Path.GetFileNameWithoutExtension project
389
+ let projectName = composedGetFileNameWithoutExtension project
312
390
let imageName = mapDockerImageName projectName
313
391
let result = match imageName with
314
392
| None -> 0
@@ -382,6 +460,7 @@ Target "Nuget" DoNothing
382
460
383
461
// tests dependencies
384
462
" Build" ==> " RunTests"
463
+ " PublishCode" ==> " BuildDockerImages" ==> " RunTestsOnRuntimes"
385
464
386
465
// nuget dependencies
387
466
" Clean" ==> " Build" ==> " CreateNuget"
@@ -391,7 +470,7 @@ Target "Nuget" DoNothing
391
470
" Clean" ==> " BuildRelease" ==> " Docfx"
392
471
393
472
// Docker
394
- " BuildRelease " ==> " PublishCode" ==> " BuildDockerImages" ==> " Docker"
473
+ " PublishCode" ==> " BuildDockerImages" ==> " Docker"
395
474
396
475
// all
397
476
" BuildRelease" ==> " All"
0 commit comments