Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public RequestDataContent(RequestData requestData)

Task OnStreamAvailable(PostData data, Stream stream, HttpContent content, TransportContext context)
{
if (_requestData.HttpCompression)
stream = new GZipStream(stream, CompressionMode.Compress, false);
using(stream)
data.Write(stream, requestData.ConnectionSettings);
return Task.CompletedTask;
Expand All @@ -52,6 +54,8 @@ public RequestDataContent(RequestData requestData, CancellationToken token)

async Task OnStreamAvailable(PostData data, Stream stream, HttpContent content, TransportContext context)
{
if (_requestData.HttpCompression)
stream = new GZipStream(stream, CompressionMode.Compress, false);
using (stream)
await data.WriteAsync(stream, requestData.ConnectionSettings, token).ConfigureAwait(false);
}
Expand All @@ -75,8 +79,6 @@ protected override async Task SerializeToStreamAsync(Stream stream, TransportCon

var serializeToStreamTask = new TaskCompletionSource<bool>();

if (_requestData.HttpCompression)
stream = new GZipStream(stream, CompressionMode.Compress, false);
var wrappedStream = new CompleteTaskOnCloseStream(stream, serializeToStreamTask);
await _onStreamAvailable(data, wrappedStream, this, context).ConfigureAwait(false);
await serializeToStreamTask.Task.ConfigureAwait(false);
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Tests.Configuration/EnvironmentConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public EnvironmentConfiguration(YamlConfiguration yamlConfiguration)
{
SourceSerializer = RandomBoolConfig("SOURCESERIALIZER", randomizer),
TypedKeys = RandomBoolConfig("TYPEDKEYS", randomizer),
HttpCompression = RandomBoolConfig("HTTPCOMPRESSION", randomizer),
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/Tests/Tests.Configuration/TestConfigurationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,8 @@ public class RandomConfiguration

/// <summary> Randomly enable typed keys on searches (defaults to true) on NEST search requests</summary>
public bool TypedKeys { get; set; }

/// <summary> Randomly enable compression on the http requests</summary>
public bool HttpCompression { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static void DumpConfiguration(this TestConfigurationBase config)
Console.WriteLine($" - Random:");
Console.WriteLine($" \t- {nameof(config.Random.SourceSerializer)}: {config.Random.SourceSerializer}");
Console.WriteLine($" \t- {nameof(config.Random.TypedKeys)}: {config.Random.TypedKeys}");
Console.WriteLine($" \t- {nameof(config.Random.HttpCompression)}: {config.Random.HttpCompression}");
Console.WriteLine(new string('-', 20));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Tests.Configuration/YamlConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public YamlConfiguration(string configurationFile)
{
SourceSerializer = RandomBool("source_serializer", randomizer),
TypedKeys = RandomBool("typed_keys", randomizer),
HttpCompression = RandomBool("http_compression", randomizer),
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/Tests/Tests.Configuration/tests.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ test_against_already_running_elasticsearch: true

#random_source_serializer: true
#random_old_connection: true
seed: 74337
#random_http_compresssion: true
#seed: 74337

# Can be helpful to speed up tests runs as setting this to true only randomly tests a single overload of the api rather than all 4.
# Can also help keep the noise down in case of test failures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public TestConnectionSettings(
private void ApplyTestSettings() =>
RerouteToProxyIfNeeded()
.EnableDebugMode()
//TODO make this random
//.EnableHttpCompression()
.EnableHttpCompression(TestConfiguration.Instance.Random.HttpCompression)
#if DEBUG
.EnableDebugMode()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something to address in this PR, but this #if preprocessor directive to enable debug mode looks superfluous, because it's enabled already on line 45.

#endif
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Tests.Core/Xunit/NestXunitRunOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ bool runningIntegrations

AppendExplictConfig(nameof(RandomConfiguration.SourceSerializer), sb);
AppendExplictConfig(nameof(RandomConfiguration.TypedKeys), sb);
AppendExplictConfig(nameof(RandomConfiguration.HttpCompression), sb);

if (runningIntegrations)
sb.Append("integrate ")
Expand Down