Skip to content

Commit 88e5c40

Browse files
committed
Merge branch 'master' of github.com:elastic/elasticsearch-net
2 parents 725ea55 + 57539d1 commit 88e5c40

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

build/scripts/Commandline.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Execution hints can be provided anywhere on the command line
9393
NonInteractive: bool;
9494
SkipTests: bool;
9595
GenDocs: bool;
96-
Seed: string;
96+
Seed: int;
9797
RandomArguments: string list;
9898
DocsBranch: string;
9999
ReferenceBranch: string;
@@ -141,8 +141,8 @@ Execution hints can be provided anywhere on the command line
141141
GenDocs = not skipDocs && (args |> List.exists (fun x -> x = "gendocs") || target = "build")
142142
Seed =
143143
match args |> List.tryFind (fun x -> x.StartsWith("seed:")) with
144-
| Some t -> t.Replace("seed:", "")
145-
| _ -> ""
144+
| Some t -> Int32.Parse (t.Replace("seed:", ""))
145+
| _ -> Random().Next(1, 100_000)
146146
RandomArguments =
147147
args
148148
|> List.filter (fun x -> (x.StartsWith("random:")))

build/scripts/Targets.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ module Main =
3636

3737
let parsed = Commandline.parse (args |> Array.toList)
3838

39+
40+
let seed = parsed.Seed;
3941
let buildVersions = Versioning.BuildVersioning parsed
4042
let artifactsVersion = Versioning.ArtifactsVersion buildVersions
4143
Versioning.Validate parsed.Target buildVersions
@@ -69,7 +71,7 @@ module Main =
6971
target "test-nuget-package" <| fun _ ->
7072
// run release unit tests puts packages in the system cache prevent this from happening locally
7173
if not Commandline.runningOnCi then ignore ()
72-
else Tests.RunReleaseUnitTests artifactsVersion |> ignore
74+
else Tests.RunReleaseUnitTests artifactsVersion seed |> ignore
7375

7476
target "nuget-pack" <| fun _ -> Release.NugetPack artifactsVersion
7577

build/scripts/Testing.fs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace Scripts
22

33
open System
4+
open System.Globalization
5+
open Tooling
46
open Fake.Core
57
open System.IO
68
open Commandline
@@ -22,7 +24,8 @@ module Tests =
2224

2325
env "NEST_INTEGRATION_CLUSTER" clusterFilter
2426
env "NEST_TEST_FILTER" testFilter
25-
env "NEST_TEST_SEED" (Some <| args.Seed)
27+
let seed = Some <| args.Seed.ToString(CultureInfo.InvariantCulture)
28+
env "NEST_TEST_SEED" seed
2629

2730
for random in args.RandomArguments do
2831
let tokens = random.Split [|':'|]
@@ -33,17 +36,21 @@ module Tests =
3336
env key (Some <| value)
3437
ignore()
3538

36-
let private dotnetTest (target: Commandline.MultiTarget) =
39+
let private dotnetTest (target: Commandline.MultiTarget) seed =
3740
Directory.CreateDirectory Paths.BuildOutput |> ignore
3841
let command =
3942
let p = ["test"; "."; "-c"; "RELEASE"]
4043
//make sure we only test netcoreapp on linux or requested on the command line to only test-one
4144
match (target, Environment.isLinux) with
42-
| (_, true) -> ["--framework"; "netcoreapp3.0"] |> List.append p
45+
| (_, true) ->
46+
printfn "Running on linux defaulting tests to .NET Core only"
47+
["--framework"; "netcoreapp3.0"] |> List.append p
4348
| (Commandline.MultiTarget.One, _) ->
44-
let random = new Random()
49+
let random = Random(seed)
4550
let fw = DotNetFramework.AllTests |> List.sortBy (fun _ -> random.Next()) |> List.head
46-
["--framework"; fw.Identifier.MSBuild] |> List.append p
51+
let tfm = fw.Identifier.MSBuild
52+
printfn "Running on non linux system randomly selected '%s' for tests" tfm
53+
["--framework"; tfm] |> List.append p
4754
| _ -> p
4855
let commandWithCodeCoverage =
4956
// TODO /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
@@ -61,7 +68,7 @@ module Tests =
6168
else
6269
Tooling.DotNet.ExecInWithTimeout "src/Tests/Tests" commandWithCodeCoverage (TimeSpan.FromMinutes 30.)
6370

64-
let RunReleaseUnitTests (ArtifactsVersion(version)) =
71+
let RunReleaseUnitTests (ArtifactsVersion(version)) seed =
6572
//xUnit always does its own build, this env var is picked up by Tests.csproj
6673
//if its set it will include the local package source (build/output/_packages)
6774
//and references NEST and NEST.JsonNetSerializer by the current version
@@ -73,9 +80,9 @@ module Tests =
7380
Environment.setEnvironVar "TestPackageVersion" (version.Full.ToString())
7481
Tooling.DotNet.ExecIn "src/Tests/Tests" ["clean";] |> ignore
7582
Tooling.DotNet.ExecIn "src/Tests/Tests" ["restore";] |> ignore
76-
dotnetTest Commandline.MultiTarget.One
83+
dotnetTest Commandline.MultiTarget.One seed
7784

78-
let RunUnitTests args = dotnetTest args.MultiTarget
85+
let RunUnitTests args = dotnetTest args.MultiTarget args.Seed
7986

8087
let RunIntegrationTests args =
8188
let passedVersions = match args.CommandArguments with | Integration a -> Some a.ElasticsearchVersions | _ -> None
@@ -85,4 +92,4 @@ module Tests =
8592
for esVersion in esVersions do
8693
Environment.setEnvironVar "NEST_INTEGRATION_TEST" "1"
8794
Environment.setEnvironVar "NEST_INTEGRATION_VERSION" esVersion
88-
dotnetTest args.MultiTarget |> ignore
95+
dotnetTest args.MultiTarget args.Seed |> ignore

0 commit comments

Comments
 (0)