diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 510378f..0adadc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,13 +27,13 @@ jobs: git tag --list # Install .NET version as mandated by global.json - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4.1.0 with: global-json-file: global.json env: NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - - run: ./build.sh build -s true + - run: ./build.sh test name: Build - run: ./build.sh generatepackages -s true name: Generate local nuget packages diff --git a/build/scripts/CommandLine.fs b/build/scripts/CommandLine.fs index a69c4f9..4672ec8 100644 --- a/build/scripts/CommandLine.fs +++ b/build/scripts/CommandLine.fs @@ -10,7 +10,8 @@ open Microsoft.FSharp.Reflection type Arguments = | [] Clean | [] Build - + | [] Test + | [] PristineCheck | [] GeneratePackages | [] ValidatePackages @@ -28,7 +29,8 @@ with member this.Usage = match this with | Clean -> "clean known output locations" - | Build -> "Run build and tests" + | Build -> "Run build" + | Test -> "Run build and tests" | Release -> "runs build, and create an validates the packages shy of publishing them" | Publish -> "Runs the full release" diff --git a/build/scripts/Targets.fs b/build/scripts/Targets.fs index 59ee764..14e13cb 100644 --- a/build/scripts/Targets.fs +++ b/build/scripts/Targets.fs @@ -14,9 +14,8 @@ open ProcNet let exec binary args = - let r = Proc.Exec (binary, args |> List.map (fun a -> sprintf "\"%s\"" a) |> List.toArray) - match r.HasValue with | true -> r.Value | false -> failwithf "invocation of `%s` timed out" binary - + Proc.Exec (binary, args |> List.toArray) + let private restoreTools = lazy(exec "dotnet" ["tool"; "restore"]) let private currentVersion = lazy( @@ -38,6 +37,9 @@ let private clean (arguments:ParseResults) = let private build (arguments:ParseResults) = exec "dotnet" ["build"; "-c"; "Release"] |> ignore +//let private test (arguments:ParseResults) = exec "dotnet" ["test"; "-c"; "Release"; "-f"; "net6.0"] |> ignore +let private test (arguments:ParseResults) = ignore() + let private pristineCheck (arguments:ParseResults) = match Information.isCleanWorkingCopy "." with | true -> printfn "The checkout folder does not have pending changes, proceeding" @@ -142,7 +144,8 @@ let Setup (parsed:ParseResults) (subCommand:Arguments) = step Clean.Name clean cmd Build.Name None (Some [Clean.Name]) <| fun _ -> build parsed - + cmd Test.Name None (Some [Build.Name]) <| fun _ -> test parsed + step PristineCheck.Name pristineCheck step GeneratePackages.Name generatePackages step ValidatePackages.Name validatePackages diff --git a/build/scripts/scripts.fsproj b/build/scripts/scripts.fsproj index 5220347..f2027b1 100644 --- a/build/scripts/scripts.fsproj +++ b/build/scripts/scripts.fsproj @@ -8,7 +8,7 @@ - + diff --git a/examples/ScratchPad/ScratchPad.csproj b/examples/ScratchPad/ScratchPad.csproj index cef057c..9810b28 100644 --- a/examples/ScratchPad/ScratchPad.csproj +++ b/examples/ScratchPad/ScratchPad.csproj @@ -5,7 +5,7 @@ False - + diff --git a/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj b/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj index 01c4de8..ad351d1 100644 --- a/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj +++ b/src/Elastic.Elasticsearch.Ephemeral/Elastic.Elasticsearch.Ephemeral.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net462 + netstandard2.0;netstandard2.1;net462 Provides an EphemeralCluster implementation that can download/bootstrap/run a throwaway customizable Elasticsearch cluster elastic,elasticsearch,cluster,ephemeral diff --git a/src/Elastic.Elasticsearch.Ephemeral/EphemeralFileSystem.cs b/src/Elastic.Elasticsearch.Ephemeral/EphemeralFileSystem.cs index 15acaa7..a1166ec 100644 --- a/src/Elastic.Elasticsearch.Ephemeral/EphemeralFileSystem.cs +++ b/src/Elastic.Elasticsearch.Ephemeral/EphemeralFileSystem.cs @@ -56,8 +56,9 @@ public EphemeralFileSystem(ElasticVersion version, string clusterName) : base(ve protected static string EphemeralHome(ElasticVersion version, string clusterName) { - var temp = Path.Combine(Path.GetTempPath(), SubFolder, - version.Artifact(Product.Elasticsearch).LocalFolderName, clusterName); + var artifact = version.Artifact(Product.Elasticsearch); + var localFolder = artifact.LocalFolderName; + var temp = Path.Combine(Path.GetTempPath(), SubFolder, localFolder, clusterName); return Path.Combine(temp, "home"); } } diff --git a/src/Elastic.Elasticsearch.Ephemeral/Tasks/IClusterComposeTask.cs b/src/Elastic.Elasticsearch.Ephemeral/Tasks/IClusterComposeTask.cs index 536c22d..c499064 100644 --- a/src/Elastic.Elasticsearch.Ephemeral/Tasks/IClusterComposeTask.cs +++ b/src/Elastic.Elasticsearch.Ephemeral/Tasks/IClusterComposeTask.cs @@ -148,14 +148,10 @@ protected static void WriteFileIfNotExist(string fileLocation, string contents) protected static void ExecuteBinary(EphemeralClusterConfiguration config, IConsoleLineHandler writer, string binary, string description, params string[] arguments) => - ExecuteBinaryInternal(config, writer, binary, description, null, arguments); - - protected static void ExecuteBinary(EphemeralClusterConfiguration config, IConsoleLineHandler writer, - string binary, string description, StartedHandler startedHandler, params string[] arguments) => - ExecuteBinaryInternal(config, writer, binary, description, startedHandler, arguments); + ExecuteBinaryInternal(config, writer, binary, description, arguments); private static void ExecuteBinaryInternal(EphemeralClusterConfiguration config, IConsoleLineHandler writer, - string binary, string description, StartedHandler startedHandler, params string[] arguments) + string binary, string description, params string[] arguments) { var command = $"{{{binary}}} {{{string.Join(" ", arguments)}}}"; writer?.WriteDiagnostic($"{{{nameof(ExecuteBinary)}}} starting process [{description}] {command}"); @@ -167,12 +163,14 @@ private static void ExecuteBinaryInternal(EphemeralClusterConfiguration config, { {config.FileSystem.ConfigEnvironmentVariableName, config.FileSystem.ConfigPath}, {"ES_HOME", config.FileSystem.ElasticsearchHome} - } + }, + Timeout = timeout, + ConsoleOutWriter = new ConsoleOutColorWriter(), }; - var result = startedHandler != null - ? Proc.Start(processStartArguments, timeout, new ConsoleOutColorWriter(), startedHandler) - : Proc.Start(processStartArguments, timeout, new ConsoleOutColorWriter()); + writer.WriteDiagnostic($"{binary} {string.Join(" ", arguments)}"); + + var result = Proc.Start(processStartArguments); if (!result.Completed) throw new Exception($"Timeout while executing {description} exceeded {timeout}"); diff --git a/src/Elastic.Elasticsearch.Managed/Configuration/NodeSettings.cs b/src/Elastic.Elasticsearch.Managed/Configuration/NodeSettings.cs index 714c625..1ddcaad 100644 --- a/src/Elastic.Elasticsearch.Managed/Configuration/NodeSettings.cs +++ b/src/Elastic.Elasticsearch.Managed/Configuration/NodeSettings.cs @@ -11,9 +11,6 @@ namespace Elastic.Elasticsearch.Managed.Configuration { public class NodeSettings : List { - private static readonly ElasticVersion - LastVersionWithoutPrefixForSettings = ElasticVersion.From("5.0.0-alpha2"); - public NodeSettings() { } @@ -37,8 +34,7 @@ public void Add(string key, string value, string versionRange) => public string[] ToCommandLineArguments(ElasticVersion version) { - var settingsPrefix = version > LastVersionWithoutPrefixForSettings ? "" : "es."; - var settingArgument = version.Major >= 5 ? "-E " : "-D"; + var settingArgument = "-E"; return this //if a node setting is only applicable for a certain version make sure its filtered out .Where(s => string.IsNullOrEmpty(s.VersionRange) || version.InRange(s.VersionRange)) @@ -47,7 +43,9 @@ public string[] ToCommandLineArguments(ElasticVersion version) //on the command with the latter taking precedence .GroupBy(setting => setting.Key) .Select(g => g.Last()) - .Select(s => s.Key.StartsWith(settingArgument) ? s.ToString() : $"{settingArgument}{settingsPrefix}{s}") + .SelectMany( + s => [settingArgument, $"{s}"] + ) .ToArray(); } } diff --git a/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj b/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj index 06f70f1..5ab042f 100644 --- a/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj +++ b/src/Elastic.Elasticsearch.Managed/Elastic.Elasticsearch.Managed.csproj @@ -1,17 +1,15 @@  - netstandard2.0;net462 + netstandard2.0;netstandard2.1;net462 Provides an observable ElasticsearchNode abstraction that can be used to wrap an elasticsearch process. Also ships with an cluster abstraction that can start one or more ElasticsearchNode's elastic,elasticsearch,cluster,observable,rx - - - + \ No newline at end of file diff --git a/src/Elastic.Elasticsearch.Managed/ElasticsearchNode.cs b/src/Elastic.Elasticsearch.Managed/ElasticsearchNode.cs index 57ee13e..8c2dae7 100644 --- a/src/Elastic.Elasticsearch.Managed/ElasticsearchNode.cs +++ b/src/Elastic.Elasticsearch.Managed/ElasticsearchNode.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Threading; using Elastic.Elasticsearch.Managed.Configuration; using Elastic.Elasticsearch.Managed.ConsoleWriters; @@ -116,12 +117,17 @@ public IDisposable SubscribeLines(IConsoleLineHandler writer, Action on var node = NodeConfiguration.DesiredNodeName; writer?.WriteDiagnostic($"Elasticsearch location: [{Binary}]", node); writer?.WriteDiagnostic($"Settings: {{{string.Join(" ", NodeConfiguration.CommandLineArguments)}}}", node); + writer?.WriteDiagnostic($"Environment: {{{string.Join(" ", StartArguments.Environment)}}}", node); + var envArgs = string.Join(" ", StartArguments.Environment.Select(kv => $"{kv.Key}={kv.Value}")); + writer?.WriteDiagnostic($"Full CMD: env {envArgs} {Binary} {string.Join(" ", NodeConfiguration.CommandLineArguments)} ", node); var envVarName = NodeConfiguration.Version.InRange("<7.12.0") ? "JAVA_HOME" : "ES_JAVA_HOME"; var javaHome = Environment.GetEnvironmentVariable(envVarName); - writer?.WriteDiagnostic($"{envVarName}: {{{javaHome}}}", node); - Process.StartInfo.Environment[envVarName] = javaHome; - + if (!string.IsNullOrWhiteSpace(javaHome)) + { + writer?.WriteDiagnostic($"{envVarName}: {{{javaHome}}}", node); + Process.StartInfo.Environment[envVarName] = javaHome; + } return SubscribeLines( l => { diff --git a/src/Elastic.Stack.ArtifactsApi/ElasticVersion.cs b/src/Elastic.Stack.ArtifactsApi/ElasticVersion.cs index 843bf66..b461d56 100644 --- a/src/Elastic.Stack.ArtifactsApi/ElasticVersion.cs +++ b/src/Elastic.Stack.ArtifactsApi/ElasticVersion.cs @@ -34,7 +34,7 @@ public int CompareTo(string other) public Artifact Artifact(Product product) { var cacheKey = product.ToString(); - if (_resolved.TryGetValue(cacheKey, out var artifact)) + if (_resolved.TryGetValue(cacheKey, out var artifact) && artifact != null) return artifact; switch (ArtifactBuildState) {