public YamlConfiguration(string configurationFile) { if (!File.Exists(configurationFile)) { return; } _config = File.ReadAllLines(configurationFile) .Where(l => !l.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(l)) .ToDictionary(ConfigName, ConfigValue); Mode = GetTestMode(_config["mode"]); var version = _config["elasticsearch_version"]; ElasticsearchVersion = version; if (string.IsNullOrWhiteSpace(version)) { throw new Exception("No default version was set in test.yaml or test.default.yaml"); } ForceReseed = BoolConfig("force_reseed", false); TestOnlyOne = BoolConfig("test_only_one", false); TestAgainstAlreadyRunningElasticsearch = BoolConfig("test_against_already_running_elasticsearch", true); ClusterFilter = _config.ContainsKey("cluster_filter") ? _config["cluster_filter"] : null; TestFilter = _config.ContainsKey("test_filter") ? _config["test_filter"] : null; var externalSeed = _config.TryGetValue("seed", out var seed) ? int.Parse(seed) : (int?)null; SetExternalSeed(externalSeed, out var randomizer); Random = new RandomConfiguration { SourceSerializer = RandomBool("source_serializer", randomizer), TypedKeys = RandomBool("typed_keys", randomizer), HttpCompression = RandomBool("http_compression", randomizer), }; }
public YamlConfiguration(string configurationFile) { if (!File.Exists(configurationFile)) { return; } _config = File.ReadAllLines(configurationFile) .Where(l => !l.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(l)) .ToDictionary(ConfigName, ConfigValue); Mode = GetTestMode(_config["mode"]); var version = _config["elasticsearch_version"]; ElasticsearchVersion = string.IsNullOrWhiteSpace(version) ? DefaultVersion : version; ForceReseed = BoolConfig("force_reseed", false); TestAgainstAlreadyRunningElasticsearch = BoolConfig("test_against_already_running_elasticsearch", false); ShowElasticsearchOutputAfterStarted = BoolConfig("elasticsearch_out_after_started", false); ClusterFilter = _config.ContainsKey("cluster_filter") ? _config["cluster_filter"] : null; TestFilter = _config.ContainsKey("test_filter") ? _config["test_filter"] : null; var newRandom = new Random().Next(1, 100000); Seed = _config.TryGetValue("seed", out var seed) ? int.Parse(seed) : newRandom; var randomizer = new Random(Seed); Random = new RandomConfiguration { SourceSerializer = RandomBool("source_serializer", randomizer), TypedKeys = RandomBool("typed_keys", randomizer), }; }
public EnvironmentConfiguration(YamlConfiguration yamlConfiguration) { Mode = Environment.GetEnvironmentVariable("NEST_INTEGRATION_TEST") != null ? TestMode.Integration : TestMode.Unit; ClusterFilter = Environment.GetEnvironmentVariable("NEST_INTEGRATION_CLUSTER"); TestFilter = Environment.GetEnvironmentVariable("NEST_TEST_FILTER"); var version = Environment.GetEnvironmentVariable("NEST_INTEGRATION_VERSION"); ElasticsearchVersion = string.IsNullOrWhiteSpace(version) ? yamlConfiguration.ElasticsearchVersion : version; if (ElasticsearchVersion == null) { throw new Exception("Elasticsearch Version could not be determined from env var NEST_INTEGRATION_VERSION nor the test yaml configuration"); } var externalSeed = TryGetEnv("NEST_TEST_SEED", out var seed) ? int.Parse(seed) : yamlConfiguration.SeedProvidedExternally ? yamlConfiguration.Seed : (int?)null; SetExternalSeed(externalSeed, out var randomizer); TestOnlyOne = RandomBoolConfig("TEST_ONLY_ONE", randomizer, false); Random = new RandomConfiguration { SourceSerializer = RandomBoolConfig("SOURCESERIALIZER", randomizer), TypedKeys = RandomBoolConfig("TYPEDKEYS", randomizer), HttpCompression = RandomBoolConfig("HTTPCOMPRESSION", 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; } ElasticsearchVersion = string.IsNullOrWhiteSpace(version) ? DefaultVersion : version; ClusterFilter = Environment.GetEnvironmentVariable("NEST_INTEGRATION_CLUSTER"); ShowElasticsearchOutputAfterStarted = Environment.GetEnvironmentVariable("NEST_INTEGRATION_SHOW_OUTPUT_AFTER_START") == "1"; TestFilter = Environment.GetEnvironmentVariable("NEST_TEST_FILTER"); var newRandom = new Random().Next(1, 100000); Seed = TryGetEnv("NEST_TEST_SEED", out var seed) ? int.Parse(seed) : newRandom; var randomizer = new Random(Seed); Random = new RandomConfiguration { SourceSerializer = RandomBoolConfig("SOURCESERIALIZER", randomizer), TypedKeys = RandomBoolConfig("TYPEDKEYS", randomizer), }; }