public YamlConfiguration(string configurationFile) { if (!File.Exists(configurationFile)) { return; } _config = File.ReadAllLines(configurationFile) .Where(l => !l.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(l)) .ToDictionary(ConfigName, ConfigValue); this.Mode = GetTestMode(_config["mode"]); this.ElasticsearchVersion = ElasticsearchVersion.Create(_config["elasticsearch_version"]); this.ForceReseed = BoolConfig("force_reseed", false); this.TestAgainstAlreadyRunningElasticsearch = BoolConfig("test_against_already_running_elasticsearch", false); this.ClusterFilter = _config.ContainsKey("cluster_filter") ? _config["cluster_filter"] : null; this.TestFilter = _config.ContainsKey("test_filter") ? _config["test_filter"] : null; this.Seed = _config.TryGetValue("seed", out var seed) ? int.Parse(seed) : 1337; Randomizer.Seed = new Random(this.Seed); var randomizer = new Randomizer(); this.Random = new RandomConfiguration { SourceSerializer = RandomBool("source_serializer", randomizer), TypedKeys = RandomBool("typed_keys", randomizer) }; }
public EnvironmentConfiguration() { //if env var NEST_INTEGRATION_VERSION is set assume integration mode //used by the build script FAKE var version = Environment.GetEnvironmentVariable("NEST_INTEGRATION_VERSION"); if (!string.IsNullOrEmpty(version)) { Mode = TestMode.Integration; } this.ElasticsearchVersion = ElasticsearchVersion.Create(string.IsNullOrWhiteSpace(version) ? DefaultVersion : version); this.ClusterFilter = Environment.GetEnvironmentVariable("NEST_INTEGRATION_CLUSTER"); this.TestFilter = Environment.GetEnvironmentVariable("NEST_TEST_FILTER"); var newRandom = new Random().Next(1, 100000); this.Seed = TryGetEnv("NEST_TEST_SEED", out var seed) ? int.Parse(seed) : newRandom; Randomizer.Seed = new Random(this.Seed); var randomizer = new Randomizer(); this.Random = new RandomConfiguration { SourceSerializer = RandomBoolConfig("SOURCESERIALIZER", randomizer), TypedKeys = RandomBoolConfig("TYPEDKEYS", randomizer), }; }
private void HandleConsoleMessage(ElasticsearchConsoleOut consoleOut, XplatManualResetEvent handle) { //no need to snoop for metadata if we already started if (!this._config.RunIntegrationTests || this.Started) { return; } //if we are running on CI and not started dump elasticsearch stdout/err //before the started notification to help debug failures to start if (this.RunningOnCI && !this.Started) { if (consoleOut.Error) { Console.Error.WriteLine(consoleOut.Data); } else { Console.WriteLine(consoleOut.Data); } } if (consoleOut.Error && !this.Started && !string.IsNullOrWhiteSpace(consoleOut.Data)) { throw new Exception(consoleOut.Data); } string version; int? pid; int port; if (this.ProcessId == null && consoleOut.TryParseNodeInfo(out version, out pid)) { var startedVersion = ElasticsearchVersion.Create(version); this.ProcessId = pid; if (this.Version != startedVersion) { throw new Exception($"Booted elasticsearch is version {startedVersion} but the test config dictates {this.Version}"); } } else if (consoleOut.TryGetPortNumber(out port)) { this.Port = port; } else if (consoleOut.TryGetStartedConfirmation()) { this.Started = true; handle.Set(); } }
public override void Validate(IElasticClient client, NodeConfiguration configuration) { if (!configuration.TestAgainstAlreadyRunningElasticsearch) { return; } var alreadyUp = client.RootNodeInfo(); if (!alreadyUp.IsValid) { return; } var v = configuration.ElasticsearchVersion; var alreadyUpVersion = ElasticsearchVersion.Create(alreadyUp.Version.Number); var alreadyUpSnapshotVersion = ElasticsearchVersion.Create(alreadyUp.Version.Number + "-SNAPSHOT"); if (v != alreadyUpVersion && v != alreadyUpSnapshotVersion) { throw new Exception($"running elasticsearch is version {alreadyUpVersion} but the test config dictates {v}"); } }
public ElasticsearchVersion Create(string version) => ElasticsearchVersion.Create(version, new MockElasticsearchVersionResolver());
public NodeConfiguration(ITestConfiguration configuration, ClusterBase cluster) { this._cluster = cluster; this.EnableSsl = cluster.EnableSsl; this.RequiredPlugins = ClusterRequiredPlugins(cluster); this.Mode = configuration.Mode; this.Random = configuration.Random; var v = configuration.ElasticsearchVersion; this.ElasticsearchVersion = v; this.ForceReseed = configuration.ForceReseed; this.TestAgainstAlreadyRunningElasticsearch = configuration.TestAgainstAlreadyRunningElasticsearch; this.RunIntegrationTests = configuration.RunIntegrationTests; this.RunUnitTests = configuration.RunUnitTests; this.ClusterFilter = configuration.ClusterFilter; this.TestFilter = configuration.TestFilter; this.Seed = configuration.Seed; this.FileSystem = new NodeFileSystem(configuration.ElasticsearchVersion, this.ClusterName, this.NodeName); this.DesiredPort = cluster.DesiredPort; var attr = v.Major >= 5 ? "attr." : ""; var indexedOrStored = v > ElasticsearchVersion.Create("5.0.0-alpha1") ? "stored" : "indexed"; var shieldOrSecurity = v > ElasticsearchVersion.Create("5.0.0-alpha1") ? "xpack.security" : "shield"; var es = v > ElasticsearchVersion.Create("5.0.0-alpha2") ? "" : "es."; var b = this.XPackEnabled.ToString().ToLowerInvariant(); var sslEnabled = this.EnableSsl.ToString().ToLowerInvariant(); this.DefaultNodeSettings = new List <string> { $"{es}cluster.name={this.ClusterName}", $"{es}node.name={this.NodeName}", $"{es}path.repo={this.FileSystem.RepositoryPath}", $"{es}path.data={this.FileSystem.DataPath}", $"{es}http.port={this.DesiredPort}", $"{es}node.{attr}testingcluster=true", $"{es}node.{attr}gateway=true", $"{es}{shieldOrSecurity}.enabled={b}", $"{es}{shieldOrSecurity}.http.ssl.enabled={sslEnabled}", $"{es}{shieldOrSecurity}.authc.realms.pki1.enabled={sslEnabled}", $"{es}search.remote.connect=true" }; //script.max_compilations_rate if (v < ElasticsearchVersion.Create("6.0.0-rc1")) { this.DefaultNodeSettings.Add($"{es}script.max_compilations_per_minute=10000"); } else { this.DefaultNodeSettings.Add($"{es}script.max_compilations_rate=10000/1m"); } if (v < ElasticsearchVersion.Create("5.5.0")) { this.DefaultNodeSettings.AddRange(new [] { $"{es}script.inline=true", $"{es}script.{indexedOrStored}=true", }); } else { this.DefaultNodeSettings.AddRange(new [] { $"script.allowed_types=inline,stored", }); } }