diff --git a/src/KubernetesClient/Autorest/HttpOperationException.cs b/src/KubernetesClient/Autorest/HttpOperationException.cs
index ac4117f3..e5da8686 100644
--- a/src/KubernetesClient/Autorest/HttpOperationException.cs
+++ b/src/KubernetesClient/Autorest/HttpOperationException.cs
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
-using System.Runtime.Serialization;
-
namespace k8s.Autorest
{
///
/// Exception thrown for an invalid response with custom error information.
///
- [Serializable]
public class HttpOperationException : Exception
{
///
@@ -51,15 +48,5 @@ public HttpOperationException(string message, Exception innerException)
: base(message, innerException)
{
}
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Serialization info.
- /// Streaming context.
- protected HttpOperationException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
}
}
diff --git a/src/KubernetesClient/KubernetesException.cs b/src/KubernetesClient/KubernetesException.cs
index 0735b78f..7d5ab6fb 100644
--- a/src/KubernetesClient/KubernetesException.cs
+++ b/src/KubernetesClient/KubernetesException.cs
@@ -1,5 +1,3 @@
-using System.Runtime.Serialization;
-
namespace k8s
{
///
@@ -72,22 +70,6 @@ public KubernetesException(string message, Exception innerException)
{
}
- ///
- /// Initializes a new instance of the class with serialized data.
- ///
- ///
- /// The that holds the serialized
- /// object data about the exception being thrown.
- ///
- ///
- /// The that contains contextual information
- /// about the source or destination.
- ///
- protected KubernetesException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
-
///
/// Gets, when this exception was raised because of a Kubernetes status message, the underlying
/// Kubernetes status message.
diff --git a/src/KubernetesClient/LeaderElection/LeaderElector.cs b/src/KubernetesClient/LeaderElection/LeaderElector.cs
index dce925d5..eb96b48a 100644
--- a/src/KubernetesClient/LeaderElection/LeaderElector.cs
+++ b/src/KubernetesClient/LeaderElection/LeaderElector.cs
@@ -54,6 +54,7 @@ public string GetLeader()
/// Will complete the returned Task and not retry to acquire leadership again after leadership is lost once.
///
/// A token to cancel the operation.
+ /// A Task representing the asynchronous operation.
public async Task RunUntilLeadershipLostAsync(CancellationToken cancellationToken = default)
{
await AcquireAsync(cancellationToken).ConfigureAwait(false);
@@ -132,6 +133,7 @@ public async Task RunAndTryToHoldLeadershipForeverAsync(CancellationToken cancel
///
///
/// A token to cancel the operation.
+ /// A Task representing the asynchronous operation.
[Obsolete("Replaced by RunUntilLeadershipLostAsync to encode behavior in method name.")]
public Task RunAsync(CancellationToken cancellationToken = default)
{
diff --git a/tests/E2E.Tests/MinikubeTests.cs b/tests/E2E.Tests/MinikubeTests.cs
index 0ea8300b..fc5136d5 100644
--- a/tests/E2E.Tests/MinikubeTests.cs
+++ b/tests/E2E.Tests/MinikubeTests.cs
@@ -303,7 +303,7 @@ void DeleteEndpoints(string name)
le.OnStartedLeading += () => leader1acq.Set();
le.OnStoppedLeading += () => leader1lose.Set();
- tasks.Add(le.RunAsync(cts.Token));
+ tasks.Add(le.RunUntilLeadershipLostAsync(cts.Token));
}
// wait 1 become leader
@@ -325,7 +325,7 @@ void DeleteEndpoints(string name)
leader2init.Set();
};
- tasks.Add(le.RunAsync());
+ tasks.Add(le.RunUntilLeadershipLostAsync());
Assert.True(leader2init.WaitOne(TimeSpan.FromSeconds(30)));
Assert.Equal("leader1", le.GetLeader());
diff --git a/tests/KubernetesClient.Classic.Tests/SimpleTests.cs b/tests/KubernetesClient.Classic.Tests/SimpleTests.cs
index b03c936d..f0437def 100644
--- a/tests/KubernetesClient.Classic.Tests/SimpleTests.cs
+++ b/tests/KubernetesClient.Classic.Tests/SimpleTests.cs
@@ -52,6 +52,9 @@ public void Dispose()
{
running = false;
server.Stop();
+#if NET8_0_OR_GREATER
+ server.Dispose();
+#endif
loop.Wait();
loop.Dispose();
}
@@ -74,7 +77,7 @@ public async Task QueryPods()
});
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Addr });
- var pod = await client.CoreV1.ReadNamespacedPodAsync("pod", "default").ConfigureAwait(false);
+ var pod = await client.CoreV1.ReadNamespacedPodAsync("pod", "default").ConfigureAwait(true);
Assert.Equal("pod0", pod.Metadata.Name);
}
diff --git a/tests/KubernetesClient.Tests/AuthTests.cs b/tests/KubernetesClient.Tests/AuthTests.cs
index cd8777a7..3e9cf684 100644
--- a/tests/KubernetesClient.Tests/AuthTests.cs
+++ b/tests/KubernetesClient.Tests/AuthTests.cs
@@ -541,7 +541,7 @@ private X509Certificate2 OpenCertificateStore(Stream stream)
var store = new Pkcs12Store();
store.Load(stream, new char[] { });
- var keyAlias = store.Aliases.Cast().SingleOrDefault(a => store.IsKeyEntry(a));
+ var keyAlias = store.Aliases.Cast().SingleOrDefault(store.IsKeyEntry);
var key = (RsaPrivateCrtKeyParameters)store.GetKey(keyAlias).Key;
var bouncyCertificate = store.GetCertificate(keyAlias).Certificate;
diff --git a/tests/KubernetesClient.Tests/ByteBufferTests.cs b/tests/KubernetesClient.Tests/ByteBufferTests.cs
index 223382bf..9377b658 100644
--- a/tests/KubernetesClient.Tests/ByteBufferTests.cs
+++ b/tests/KubernetesClient.Tests/ByteBufferTests.cs
@@ -255,7 +255,7 @@ public async Task ReadBlocksUntilDataAvailableTest()
// Kick off a read operation
var readTask = Task.Run(() => read = buffer.Read(readData, 0, readData.Length));
- await Task.Delay(250).ConfigureAwait(false);
+ await Task.Delay(250).ConfigureAwait(true);
Assert.False(readTask.IsCompleted, "Read task completed before data was available.");
// Write data to the buffer
@@ -264,7 +264,7 @@ public async Task ReadBlocksUntilDataAvailableTest()
await TaskAssert.Completed(
readTask,
TimeSpan.FromMilliseconds(1000),
- "Timed out waiting for read task to complete.").ConfigureAwait(false);
+ "Timed out waiting for read task to complete.").ConfigureAwait(true);
Assert.Equal(3, read);
Assert.Equal(0xF0, readData[0]);
@@ -411,10 +411,10 @@ public async Task ReadFirstTest()
var output = new byte[buffer.Size + 1];
var readTask = Task.Run(() => buffer.Read(output, 0, output.Length));
- await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
+ await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(true);
buffer.Write(data, 0, data.Length);
- await readTask.ConfigureAwait(false);
+ await readTask.ConfigureAwait(true);
}
#if NETCOREAPP2_0
diff --git a/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs b/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
index 8f491a8e..a1239c9e 100644
--- a/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
+++ b/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
@@ -437,7 +437,7 @@ public async Task ContextWithClusterExtensions()
{
var path = Path.GetFullPath("assets/kubeconfig.cluster-extensions.yml");
- _ = await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(path)).ConfigureAwait(false);
+ _ = await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(path)).ConfigureAwait(true);
}
[Fact]
diff --git a/tests/KubernetesClient.Tests/KubernetesExecTests.cs b/tests/KubernetesClient.Tests/KubernetesExecTests.cs
index 1b7e3909..e0e0d593 100644
--- a/tests/KubernetesClient.Tests/KubernetesExecTests.cs
+++ b/tests/KubernetesClient.Tests/KubernetesExecTests.cs
@@ -51,7 +51,7 @@ public async Task WebSocketNamespacedPodExecAsync()
{
{ "X-My-Header", new List() { "myHeaderValue", "myHeaderValue2" } },
},
- cancellationToken: CancellationToken.None).ConfigureAwait(false);
+ cancellationToken: CancellationToken.None).ConfigureAwait(true);
var expectedHeaders = new Dictionary()
{
@@ -91,7 +91,7 @@ public async Task WebSocketNamespacedPodPortForwardAsync()
{
{ "X-My-Header", new List() { "myHeaderValue", "myHeaderValue2" } },
},
- cancellationToken: CancellationToken.None).ConfigureAwait(false);
+ cancellationToken: CancellationToken.None).ConfigureAwait(true);
var expectedHeaders = new Dictionary()
{
@@ -137,7 +137,7 @@ public async Task WebSocketNamespacedPodAttachAsync()
{
{ "X-My-Header", new List() { "myHeaderValue", "myHeaderValue2" } },
},
- cancellationToken: CancellationToken.None).ConfigureAwait(false);
+ cancellationToken: CancellationToken.None).ConfigureAwait(true);
var expectedHeaders = new Dictionary()
{
diff --git a/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs b/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs
index a616f26e..96561a50 100644
--- a/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs
+++ b/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs
@@ -35,7 +35,7 @@ public async Task NodesMetrics()
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var nodesMetricsList = await client.GetKubernetesNodesMetricsAsync().ConfigureAwait(false);
+ var nodesMetricsList = await client.GetKubernetesNodesMetricsAsync().ConfigureAwait(true);
Assert.Single(nodesMetricsList.Items);
@@ -56,7 +56,7 @@ public async Task NodesMetricsOptionalProperty()
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
// Should not throw with timespan optional property
- var exception = await Record.ExceptionAsync(async () => await client.GetKubernetesNodesMetricsAsync().ConfigureAwait(false)).ConfigureAwait(false);
+ var exception = await Record.ExceptionAsync(client.GetKubernetesNodesMetricsAsync).ConfigureAwait(true);
Assert.Null(exception);
}
@@ -69,7 +69,7 @@ public async Task PodsMetrics()
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var podsMetricsList = await client.GetKubernetesPodsMetricsAsync().ConfigureAwait(false);
+ var podsMetricsList = await client.GetKubernetesPodsMetricsAsync().ConfigureAwait(true);
Assert.Single(podsMetricsList.Items);
@@ -94,7 +94,7 @@ public async Task PodsMetricsOptionalProperty()
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
// Should not throw with timespan optional property
- var exception = await Record.ExceptionAsync(async () => await client.GetKubernetesPodsMetricsAsync().ConfigureAwait(false)).ConfigureAwait(false);
+ var exception = await Record.ExceptionAsync(client.GetKubernetesPodsMetricsAsync).ConfigureAwait(true);
Assert.Null(exception);
}
@@ -107,7 +107,7 @@ public async Task PodsMetricsEmptyResponse()
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var podsMetricsList = await client.GetKubernetesPodsMetricsByNamespaceAsync("empty").ConfigureAwait(false);
+ var podsMetricsList = await client.GetKubernetesPodsMetricsByNamespaceAsync("empty").ConfigureAwait(true);
Assert.Empty(podsMetricsList.Items);
}
@@ -122,7 +122,7 @@ public async Task PodsMetricsByNamespace()
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var podsMetricsList = await client.GetKubernetesPodsMetricsByNamespaceAsync(namespaceName).ConfigureAwait(false);
+ var podsMetricsList = await client.GetKubernetesPodsMetricsByNamespaceAsync(namespaceName).ConfigureAwait(true);
Assert.Single(podsMetricsList.Items);
@@ -147,7 +147,7 @@ public async Task PodsMetricsNonExistingNamespaceResponse()
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var podsMetricsList = await client.GetKubernetesPodsMetricsByNamespaceAsync("nonexisting").ConfigureAwait(false);
+ var podsMetricsList = await client.GetKubernetesPodsMetricsByNamespaceAsync("nonexisting").ConfigureAwait(true);
Assert.Empty(podsMetricsList.Items);
}
diff --git a/tests/KubernetesClient.Tests/KubernetesYamlTests.cs b/tests/KubernetesClient.Tests/KubernetesYamlTests.cs
index 9cd30e72..261e0819 100644
--- a/tests/KubernetesClient.Tests/KubernetesYamlTests.cs
+++ b/tests/KubernetesClient.Tests/KubernetesYamlTests.cs
@@ -136,9 +136,9 @@ public async Task LoadAllFromFile()
var tempFileName = Path.GetTempFileName();
try
{
- await File.WriteAllTextAsync(tempFileName, content).ConfigureAwait(false);
+ await File.WriteAllTextAsync(tempFileName, content).ConfigureAwait(true);
- var objs = await KubernetesYaml.LoadAllFromFileAsync(tempFileName).ConfigureAwait(false);
+ var objs = await KubernetesYaml.LoadAllFromFileAsync(tempFileName).ConfigureAwait(true);
Assert.Equal(2, objs.Count);
Assert.IsType(objs[0]);
Assert.IsType(objs[1]);
@@ -175,9 +175,9 @@ public async Task LoadAllFromFileWithTypes()
var tempFileName = Path.GetTempFileName();
try
{
- await File.WriteAllTextAsync(tempFileName, content).ConfigureAwait(false);
+ await File.WriteAllTextAsync(tempFileName, content).ConfigureAwait(true);
- var objs = await KubernetesYaml.LoadAllFromFileAsync(tempFileName, types).ConfigureAwait(false);
+ var objs = await KubernetesYaml.LoadAllFromFileAsync(tempFileName, types).ConfigureAwait(true);
Assert.Equal(2, objs.Count);
Assert.IsType(objs[0]);
Assert.IsType(objs[1]);
@@ -282,7 +282,7 @@ public void LoadPropertyNamedReadOnlyFromString()
}
[Fact]
- public void LoadFromStream()
+ public async Task LoadFromStream()
{
var content = @"apiVersion: v1
kind: Pod
@@ -292,7 +292,7 @@ public void LoadFromStream()
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
- var obj = KubernetesYaml.LoadFromStreamAsync(stream).Result;
+ var obj = await KubernetesYaml.LoadFromStreamAsync(stream).ConfigureAwait(true);
Assert.Equal("foo", obj.Metadata.Name);
}
@@ -309,9 +309,9 @@ public async Task LoadFromFile()
var tempFileName = Path.GetTempFileName();
try
{
- await File.WriteAllTextAsync(tempFileName, content).ConfigureAwait(false);
+ await File.WriteAllTextAsync(tempFileName, content).ConfigureAwait(true);
- var obj = await KubernetesYaml.LoadFromFileAsync(tempFileName).ConfigureAwait(false);
+ var obj = await KubernetesYaml.LoadFromFileAsync(tempFileName).ConfigureAwait(true);
Assert.Equal("foo", obj.Metadata.Name);
}
finally
diff --git a/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs b/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs
index 22cb1241..7422dd04 100644
--- a/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs
+++ b/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs
@@ -55,7 +55,7 @@ public void SimpleLeaderElection()
};
var countdown = new CountdownEvent(2);
- Task.Run(() =>
+ Task.Run(async () =>
{
var leaderElector = new LeaderElector(leaderElectionConfig);
@@ -71,7 +71,7 @@ public void SimpleLeaderElection()
countdown.Signal();
};
- leaderElector.RunUntilLeadershipLostAsync().Wait();
+ await leaderElector.RunUntilLeadershipLostAsync().ConfigureAwait(true);
});
countdown.Wait(TimeSpan.FromSeconds(10));
@@ -147,7 +147,7 @@ public void LeaderElection()
var lockAStopLeading = new ManualResetEvent(false);
var testLeaderElectionLatch = new CountdownEvent(4);
- Task.Run(() =>
+ Task.Run(async () =>
{
var leaderElector = new LeaderElector(leaderElectionConfigA);
@@ -164,13 +164,13 @@ public void LeaderElection()
lockAStopLeading.Set();
};
- leaderElector.RunUntilLeadershipLostAsync().Wait();
+ await leaderElector.RunUntilLeadershipLostAsync().ConfigureAwait(true);
});
lockAStopLeading.WaitOne(TimeSpan.FromSeconds(3));
- Task.Run(() =>
+ Task.Run(async () =>
{
var leaderElector = new LeaderElector(leaderElectionConfigB);
@@ -186,7 +186,7 @@ public void LeaderElection()
testLeaderElectionLatch.Signal();
};
- leaderElector.RunUntilLeadershipLostAsync().Wait();
+ await leaderElector.RunUntilLeadershipLostAsync().ConfigureAwait(true);
});
testLeaderElectionLatch.Wait(TimeSpan.FromSeconds(15));
@@ -256,7 +256,7 @@ public void LeaderElectionWithRenewDeadline()
};
var countdown = new CountdownEvent(2);
- Task.Run(() =>
+ Task.Run(async () =>
{
var leaderElector = new LeaderElector(leaderElectionConfig);
@@ -272,7 +272,7 @@ public void LeaderElectionWithRenewDeadline()
countdown.Signal();
};
- leaderElector.RunUntilLeadershipLostAsync().Wait();
+ await leaderElector.RunUntilLeadershipLostAsync().ConfigureAwait(true);
});
countdown.Wait(TimeSpan.FromSeconds(15));
@@ -290,7 +290,7 @@ public void LeaderElectionWithRenewDeadline()
}
[Fact]
- public void LeaderElectionThrowException()
+ public async Task LeaderElectionThrowException()
{
var l = new Mock();
l.Setup(obj => obj.GetAsync(CancellationToken.None))
@@ -305,11 +305,11 @@ public void LeaderElectionThrowException()
try
{
- leaderElector.RunUntilLeadershipLostAsync().Wait();
+ await leaderElector.RunUntilLeadershipLostAsync().ConfigureAwait(true);
}
catch (Exception e)
{
- Assert.Equal("noxu", e.InnerException?.Message);
+ Assert.Equal("noxu", e.Message);
return;
}
diff --git a/tests/KubernetesClient.Tests/OidcAuthTests.cs b/tests/KubernetesClient.Tests/OidcAuthTests.cs
index 8eccf475..23eb7292 100644
--- a/tests/KubernetesClient.Tests/OidcAuthTests.cs
+++ b/tests/KubernetesClient.Tests/OidcAuthTests.cs
@@ -21,7 +21,7 @@ public async Task TestOidcAuth()
// use unexpired id token as bearer, do not attempt to refresh
var auth = new OidcTokenProvider(clientId, clientSecret, idpIssuerUrl, unexpiredIdToken, refreshToken);
- var result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
+ var result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(true);
result.Scheme.Should().Be("Bearer");
result.Parameter.Should().Be(unexpiredIdToken);
@@ -29,7 +29,7 @@ public async Task TestOidcAuth()
{
// attempt to refresh id token when expired
auth = new OidcTokenProvider(clientId, clientSecret, idpIssuerUrl, expiredIdToken, refreshToken);
- result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
+ result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(true);
result.Scheme.Should().Be("Bearer");
result.Parameter.Should().Be(expiredIdToken);
Assert.Fail("should not be here");
@@ -43,7 +43,7 @@ public async Task TestOidcAuth()
{
// attempt to refresh id token when null
auth = new OidcTokenProvider(clientId, clientSecret, idpIssuerUrl, null, refreshToken);
- result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
+ result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(true);
result.Scheme.Should().Be("Bearer");
result.Parameter.Should().Be(expiredIdToken);
Assert.Fail("should not be here");
diff --git a/tests/KubernetesClient.Tests/PodExecTests.cs b/tests/KubernetesClient.Tests/PodExecTests.cs
index 067060c7..5a6276e8 100644
--- a/tests/KubernetesClient.Tests/PodExecTests.cs
+++ b/tests/KubernetesClient.Tests/PodExecTests.cs
@@ -52,7 +52,7 @@ public async Task ExecDefaultContainerStdOut()
TimeSpan.FromSeconds(5));
}
- await Host.StartAsync(TestCancellation).ConfigureAwait(false);
+ await Host.StartAsync(TestCancellation).ConfigureAwait(true);
using (Kubernetes client = CreateTestClient())
{
@@ -67,7 +67,7 @@ public async Task ExecDefaultContainerStdOut()
false,
true,
webSocketSubProtol: WebSocketProtocol.ChannelWebSocketProtocol,
- cancellationToken: TestCancellation).ConfigureAwait(false);
+ cancellationToken: TestCancellation).ConfigureAwait(true);
Assert.Equal(
WebSocketProtocol.ChannelWebSocketProtocol,
clientSocket.SubProtocol); // For WebSockets, the Kubernetes API defaults to the binary channel (v1) protocol.
@@ -82,10 +82,10 @@ public async Task ExecDefaultContainerStdOut()
const int STDOUT = 1;
const string expectedOutput = "This is text send to STDOUT.";
- int bytesSent = await SendMultiplexed(serverSocket, STDOUT, expectedOutput).ConfigureAwait(false);
+ int bytesSent = await SendMultiplexed(serverSocket, STDOUT, expectedOutput).ConfigureAwait(true);
testOutput.WriteLine($"Sent {bytesSent} bytes to server socket; receiving from client socket...");
- (string receivedText, byte streamIndex, int bytesReceived) = await ReceiveTextMultiplexed(clientSocket).ConfigureAwait(false);
+ (string receivedText, byte streamIndex, int bytesReceived) = await ReceiveTextMultiplexed(clientSocket).ConfigureAwait(true);
testOutput.WriteLine(
$"Received {bytesReceived} bytes from client socket ('{receivedText}', stream {streamIndex}).");
@@ -94,7 +94,7 @@ public async Task ExecDefaultContainerStdOut()
await Disconnect(clientSocket, serverSocket,
WebSocketCloseStatus.NormalClosure,
- "Normal Closure").ConfigureAwait(false);
+ "Normal Closure").ConfigureAwait(true);
WebSocketTestAdapter.CompleteTest();
}
@@ -204,8 +204,8 @@ public async Task NamespacedPodExecAsyncActionNull()
{
await Assert.ThrowsAsync(() => client.NamespacedPodExecAsync(
"pod-name",
- "pod-namespace", "my-container", command, false, null, CancellationToken.None))
- .ConfigureAwait(false);
+ "pod-namespace", "my-container", command, false, null, CancellationToken.None)).ConfigureAwait(true)
+;
}
}
}
@@ -229,8 +229,8 @@ public async Task NamespacedPodExecAsyncHttpExceptionWithStatus()
{
var ex = await Assert.ThrowsAsync(() => client.NamespacedPodExecAsync(
"pod-name",
- "pod-namespace", "my-container", command, false, handler, CancellationToken.None))
- .ConfigureAwait(false);
+ "pod-namespace", "my-container", command, false, handler, CancellationToken.None)).ConfigureAwait(true)
+;
Assert.Same(status, ex.Status);
}
}
@@ -254,7 +254,7 @@ public async Task NamespacedPodExecAsyncHttpExceptionNoStatus()
{
var ex = await Assert.ThrowsAsync(() =>
client.NamespacedPodExecAsync("pod-name", "pod-namespace", "my-container", command, false, handler,
- CancellationToken.None)).ConfigureAwait(false);
+ CancellationToken.None)).ConfigureAwait(true);
Assert.Same(exception, ex);
}
}
@@ -278,8 +278,8 @@ public async Task NamespacedPodExecAsyncGenericException()
{
var ex = await Assert.ThrowsAsync(() => client.NamespacedPodExecAsync(
"pod-name",
- "pod-namespace", "my-container", command, false, handler, CancellationToken.None))
- .ConfigureAwait(false);
+ "pod-namespace", "my-container", command, false, handler, CancellationToken.None)).ConfigureAwait(true)
+;
Assert.Same(exception, ex);
}
}
@@ -330,7 +330,7 @@ public async Task NamespacedPodExecAsyncExitCodeNonZero()
using (Kubernetes client = kubernetesMock.Object)
{
var exitCode = await client.NamespacedPodExecAsync("pod-name", "pod-namespace", "my-container",
- command, false, handler, CancellationToken.None).ConfigureAwait(false);
+ command, false, handler, CancellationToken.None).ConfigureAwait(true);
Assert.Equal(1, exitCode);
}
}
diff --git a/tests/KubernetesClient.Tests/SerializationTests.cs b/tests/KubernetesClient.Tests/SerializationTests.cs
index c6c95af3..b11cba31 100644
--- a/tests/KubernetesClient.Tests/SerializationTests.cs
+++ b/tests/KubernetesClient.Tests/SerializationTests.cs
@@ -38,8 +38,8 @@ public async Task SerializeEnumUsingPascalCase()
var customObject = Animals.Dog;
- var result = await client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(customObject, "TestGroup", "TestVersion", "TestNamespace", "TestPlural").ConfigureAwait(false);
- var content = await result.Request.Content.ReadAsStringAsync().ConfigureAwait(false);
+ var result = await client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(customObject, "TestGroup", "TestVersion", "TestNamespace", "TestPlural").ConfigureAwait(true);
+ var content = await result.Request.Content.ReadAsStringAsync().ConfigureAwait(true);
// Assert that the client serializes using the default options.
Assert.Equal(@"""Dog""", content);
@@ -65,8 +65,8 @@ public async Task SerializeEnumUsingCamelCase()
var customObject = Animals.Dog;
- var result = await client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(customObject, "TestGroup", "TestVersion", "TestNamespace", "TestPlural").ConfigureAwait(false);
- var content = await result.Request.Content.ReadAsStringAsync().ConfigureAwait(false);
+ var result = await client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(customObject, "TestGroup", "TestVersion", "TestNamespace", "TestPlural").ConfigureAwait(true);
+ var content = await result.Request.Content.ReadAsStringAsync().ConfigureAwait(true);
// Assert that the client serializes using the specified options.
Assert.Equal(@"""dog""", content);
diff --git a/tests/KubernetesClient.Tests/StreamDemuxerTests.cs b/tests/KubernetesClient.Tests/StreamDemuxerTests.cs
index 03d9981b..36593044 100644
--- a/tests/KubernetesClient.Tests/StreamDemuxerTests.cs
+++ b/tests/KubernetesClient.Tests/StreamDemuxerTests.cs
@@ -29,7 +29,7 @@ public async Task SendDataRemoteCommand()
// Send 100 bytes, expect 1 (channel index) + 100 (payload) = 101 bytes
Assert.True(
- await WaitForAsync(() => sentBuffer.Count == 101).ConfigureAwait(false),
+ await WaitForAsync(() => sentBuffer.Count == 101).ConfigureAwait(true),
$"Demuxer error: expect to send 101 bytes, but actually send {sentBuffer.Count} bytes.");
Assert.True(sentBuffer[0] == channelIndex, "The first sent byte is not channel index!");
Assert.True(sentBuffer[1] == 0xEF, "Incorrect payload!");
@@ -56,7 +56,7 @@ public async Task SendMultipleDataRemoteCommand()
// Send 300 bytes in 2 messages, expect 1 (channel index) * 2 + 300 (payload) = 302 bytes
Assert.True(
- await WaitForAsync(() => sentBuffer.Count == 302).ConfigureAwait(false),
+ await WaitForAsync(() => sentBuffer.Count == 302).ConfigureAwait(true),
$"Demuxer error: expect to send 302 bytes, but actually send {sentBuffer.Count} bytes.");
Assert.True(sentBuffer[0] == channelIndex, "The first sent byte is not channel index!");
Assert.True(sentBuffer[1] == 0xEF, "The first part of payload incorrect!");
@@ -84,21 +84,21 @@ public async Task ReceiveDataRemoteCommand()
{
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(100, channelIndex, 0xAA, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(200, channelIndex, 0xAB, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(300, channelIndex, 0xAC, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
- await WaitForAsync(() => receivedBuffer.Count == expectedCount).ConfigureAwait(false);
- await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(false);
+ await WaitForAsync(() => receivedBuffer.Count == expectedCount).ConfigureAwait(true);
+ await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(true);
});
var buffer = new byte[50];
while (true)
{
- var cRead = await stream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -110,7 +110,7 @@ await ws.InvokeReceiveAsync(
}
}
- await t.ConfigureAwait(false);
+ await t.ConfigureAwait(true);
Assert.True(
receivedBuffer.Count == expectedCount,
@@ -144,21 +144,21 @@ public async Task ReceiveDataPortForward()
{
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(100, channelIndex, 0xB1, true)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(200, channelIndex, 0xB2, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(300, channelIndex, 0xB3, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
- await WaitForAsync(() => receivedBuffer.Count == expectedCount).ConfigureAwait(false);
- await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(false);
+ await WaitForAsync(() => receivedBuffer.Count == expectedCount).ConfigureAwait(true);
+ await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(true);
});
var buffer = new byte[50];
while (true)
{
- var cRead = await stream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -170,7 +170,7 @@ await ws.InvokeReceiveAsync(
}
}
- await t.ConfigureAwait(false);
+ await t.ConfigureAwait(true);
Assert.True(
receivedBuffer.Count == expectedCount,
@@ -204,21 +204,21 @@ public async Task ReceiveDataPortForwardOneByteMessage()
{
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(2, channelIndex, 0xC1, true)),
- WebSocketMessageType.Binary, false).ConfigureAwait(false);
+ WebSocketMessageType.Binary, false).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(100, channelIndex, 0xC2, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(300, channelIndex, 0xC3, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
- await WaitForAsync(() => receivedBuffer.Count == expectedCount).ConfigureAwait(false);
- await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(false);
+ await WaitForAsync(() => receivedBuffer.Count == expectedCount).ConfigureAwait(true);
+ await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(true);
});
var buffer = new byte[50];
while (true)
{
- var cRead = await stream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -230,7 +230,7 @@ await ws.InvokeReceiveAsync(
}
}
- await t.ConfigureAwait(false);
+ await t.ConfigureAwait(true);
Assert.True(
receivedBuffer.Count == expectedCount,
@@ -268,24 +268,24 @@ public async Task ReceiveDataRemoteCommandMultipleStream()
// Simulate WebSocket received remote data to multiple streams
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(100, channelIndex1, 0xD1, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(200, channelIndex2, 0xD2, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(300, channelIndex1, 0xD3, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
- await WaitForAsync(() => receivedBuffer1.Count == expectedCount1).ConfigureAwait(false);
- await WaitForAsync(() => receivedBuffer2.Count == expectedCount2).ConfigureAwait(false);
- await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(false);
+ await WaitForAsync(() => receivedBuffer1.Count == expectedCount1).ConfigureAwait(true);
+ await WaitForAsync(() => receivedBuffer2.Count == expectedCount2).ConfigureAwait(true);
+ await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(true);
});
var t2 = Task.Run(async () =>
{
var buffer = new byte[50];
while (true)
{
- var cRead = await stream1.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream1.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -302,7 +302,7 @@ await ws.InvokeReceiveAsync(
var buffer = new byte[50];
while (true)
{
- var cRead = await stream2.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream2.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -314,7 +314,7 @@ await ws.InvokeReceiveAsync(
}
}
});
- await Task.WhenAll(t1, t2, t3).ConfigureAwait(false);
+ await Task.WhenAll(t1, t2, t3).ConfigureAwait(true);
Assert.True(
receivedBuffer1.Count == expectedCount1,
@@ -359,24 +359,24 @@ public async Task ReceiveDataPortForwardMultipleStream()
// Simulate WebSocket received remote data to multiple streams
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(100, channelIndex1, 0xE1, true)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(200, channelIndex2, 0xE2, true)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
await ws.InvokeReceiveAsync(
new ArraySegment(GenerateRandomBuffer(300, channelIndex1, 0xE3, false)),
- WebSocketMessageType.Binary, true).ConfigureAwait(false);
+ WebSocketMessageType.Binary, true).ConfigureAwait(true);
- await WaitForAsync(() => receivedBuffer1.Count == expectedCount1).ConfigureAwait(false);
- await WaitForAsync(() => receivedBuffer2.Count == expectedCount2).ConfigureAwait(false);
- await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(false);
+ await WaitForAsync(() => receivedBuffer1.Count == expectedCount1).ConfigureAwait(true);
+ await WaitForAsync(() => receivedBuffer2.Count == expectedCount2).ConfigureAwait(true);
+ await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal", CancellationToken.None).ConfigureAwait(true);
});
var t2 = Task.Run(async () =>
{
var buffer = new byte[50];
while (true)
{
- var cRead = await stream1.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream1.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -393,7 +393,7 @@ await ws.InvokeReceiveAsync(
var buffer = new byte[50];
while (true)
{
- var cRead = await stream2.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
+ var cRead = await stream2.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(true);
if (cRead == 0)
{
break;
@@ -405,7 +405,7 @@ await ws.InvokeReceiveAsync(
}
}
});
- await Task.WhenAll(t1, t2, t3).ConfigureAwait(false);
+ await Task.WhenAll(t1, t2, t3).ConfigureAwait(true);
Assert.True(
receivedBuffer1.Count == expectedCount1,
diff --git a/tests/KubernetesClient.Tests/TokenFileAuthTests.cs b/tests/KubernetesClient.Tests/TokenFileAuthTests.cs
index 9d3be6bf..5824917d 100644
--- a/tests/KubernetesClient.Tests/TokenFileAuthTests.cs
+++ b/tests/KubernetesClient.Tests/TokenFileAuthTests.cs
@@ -13,17 +13,17 @@ public class TokenFileAuthTests
public async Task TestToken()
{
var auth = new TokenFileAuth("assets/token1");
- var result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
+ var result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(true);
result.Scheme.Should().Be("Bearer");
result.Parameter.Should().Be("token1");
auth.TokenFile = "assets/token2";
- result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
+ result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(true);
result.Scheme.Should().Be("Bearer");
result.Parameter.Should().Be("token1");
auth.TokenExpiresAt = DateTime.UtcNow.AddSeconds(-1);
- result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
+ result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(true);
result.Scheme.Should().Be("Bearer");
result.Parameter.Should().Be("token2");
}
diff --git a/tests/KubernetesClient.Tests/WatchTests.cs b/tests/KubernetesClient.Tests/WatchTests.cs
index 3ddf6981..3b3a695d 100644
--- a/tests/KubernetesClient.Tests/WatchTests.cs
+++ b/tests/KubernetesClient.Tests/WatchTests.cs
@@ -59,7 +59,7 @@ public async Task CannotWatch()
using (listTask.Watch((type, item) => { }, e => { onErrorCalled = true; }))
{
- await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); // delay for onerror to be called
+ await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(true); // delay for onerror to be called
}
Assert.True(onErrorCalled);
@@ -72,7 +72,7 @@ await Assert.ThrowsAnyAsync(() =>
// this line did not throw
// listTask.Watch((type, item) => { });
- }).ConfigureAwait(false);
+ }).ConfigureAwait(true);
}
}
@@ -85,8 +85,8 @@ public async Task AsyncWatcher()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
// block until reponse watcher obj created
- await created.WaitAsync().ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
+ await created.WaitAsync().ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
return false;
}))
{
@@ -98,7 +98,7 @@ public async Task AsyncWatcher()
{
// here watcher is ready to use, but http server has not responsed yet.
created.Set();
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
}
Assert.True(eventsReceived.IsSet);
@@ -121,20 +121,20 @@ public async Task SurviveBadLine()
httpContext.Response.StatusCode = (int)HttpStatusCode.OK;
httpContext.Response.ContentLength = null;
- await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockBadStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockBadStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockBadStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockBadStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(true);
// make server alive, cannot set to int.max as of it would block response
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
var events = new HashSet();
var errors = 0;
@@ -157,7 +157,7 @@ public async Task SurviveBadLine()
connectionClosed.Set);
// wait server yields all events
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
@@ -173,7 +173,7 @@ public async Task SurviveBadLine()
// Let the server know it can initiate a shut down.
serverShutdown.Set();
- await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(connectionClosed.IsSet);
}
}
@@ -187,15 +187,15 @@ public async Task DisposeWatch()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
var events = new HashSet();
@@ -212,7 +212,7 @@ public async Task DisposeWatch()
onClosed: connectionClosed.Set);
// wait at least an event
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
"Timed out waiting for events.");
@@ -224,7 +224,7 @@ public async Task DisposeWatch()
events.Clear();
- await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.False(watcher.Watching);
Assert.True(connectionClosed.IsSet);
@@ -243,19 +243,19 @@ public async Task WatchAllEvents()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(true);
// make server alive, cannot set to int.max as of it would block response
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
var events = new HashSet();
var errors = 0;
@@ -278,7 +278,7 @@ public async Task WatchAllEvents()
waitForClosed.Set);
// wait server yields all events
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
@@ -295,7 +295,7 @@ public async Task WatchAllEvents()
serverShutdown.Set();
- await Task.WhenAny(waitForClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(waitForClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(waitForClosed.IsSet);
Assert.False(watcher.Watching);
}
@@ -310,21 +310,21 @@ public async Task WatchEventsWithTimeout()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(false);
- await Task.Delay(TimeSpan.FromSeconds(120)).ConfigureAwait(false); // The default timeout is 100 seconds
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(true);
+ await Task.Delay(TimeSpan.FromSeconds(120)).ConfigureAwait(true); // The default timeout is 100 seconds
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(true);
// make server alive, cannot set to int.max as of it would block response
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
var events = new HashSet();
var errors = 0;
@@ -347,7 +347,7 @@ public async Task WatchEventsWithTimeout()
connectionClosed.Set);
// wait server yields all events
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
@@ -364,7 +364,7 @@ public async Task WatchEventsWithTimeout()
serverShutdown.Set();
- await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(connectionClosed.IsSet);
}
}
@@ -379,14 +379,14 @@ public async Task WatchServerDisconnect()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(false);
- await waitForException.WaitAsync().ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(true);
+ await waitForException.WaitAsync().ConfigureAwait(true);
throw new IOException("server down");
}))
{
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() });
- var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
waitForException.Set();
Watcher watcher;
@@ -400,13 +400,13 @@ public async Task WatchServerDisconnect()
waitForClosed.Set);
// wait server down
- await Task.WhenAny(exceptionReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(exceptionReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
exceptionReceived.IsSet,
"Timed out waiting for exception");
- await Task.WhenAny(waitForClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(waitForClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(waitForClosed.IsSet);
Assert.False(watcher.Watching);
@@ -439,11 +439,11 @@ public async Task TestWatchWithHandlers()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
// make server alive, cannot set to int.max as of it would block response
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
@@ -456,7 +456,7 @@ public async Task TestWatchWithHandlers()
Assert.False(handler1.Called);
Assert.False(handler2.Called);
- var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ var listTask = await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
var events = new HashSet();
@@ -468,7 +468,7 @@ public async Task TestWatchWithHandlers()
});
// wait server yields all events
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
@@ -492,13 +492,13 @@ public async Task DirectWatchAllEvents()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(true);
// make server alive, cannot set to int.max as of it would block response
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
@@ -527,7 +527,7 @@ public async Task DirectWatchAllEvents()
onClosed: connectionClosed.Set);
// wait server yields all events
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
@@ -544,7 +544,7 @@ public async Task DirectWatchAllEvents()
serverShutdown.Set();
- await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(connectionClosed.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(connectionClosed.IsSet);
}
}
@@ -554,8 +554,8 @@ public async Task EnsureTimeoutWorks()
{
using var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await Task.Delay(TimeSpan.FromSeconds(120)).ConfigureAwait(false); // The default timeout is 100 seconds
- await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(false);
+ await Task.Delay(TimeSpan.FromSeconds(120)).ConfigureAwait(true); // The default timeout is 100 seconds
+ await WriteStreamLine(httpContext, MockKubeApiServer.MockPodResponse).ConfigureAwait(true);
return false;
});
@@ -568,8 +568,8 @@ await Assert.ThrowsAsync(async () =>
Host = server.Uri.ToString(),
HttpClientTimeout = TimeSpan.FromSeconds(5),
});
- await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default").ConfigureAwait(false);
- }).ConfigureAwait(false);
+ await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default").ConfigureAwait(true);
+ }).ConfigureAwait(true);
// cts
await Assert.ThrowsAsync(async () =>
@@ -580,8 +580,8 @@ await Assert.ThrowsAsync(async () =>
{
Host = server.Uri.ToString(),
});
- await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", cancellationToken: cts.Token).ConfigureAwait(false);
- }).ConfigureAwait(false);
+ await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", cancellationToken: cts.Token).ConfigureAwait(true);
+ }).ConfigureAwait(true);
}
[Fact]
@@ -592,14 +592,14 @@ public async Task DirectWatchEventsWithTimeout()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await Task.Delay(TimeSpan.FromSeconds(120)).ConfigureAwait(false); // The default timeout is 100 seconds
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(false);
- await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(false);
+ await Task.Delay(TimeSpan.FromSeconds(120)).ConfigureAwait(true); // The default timeout is 100 seconds
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockDeletedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockModifiedStreamLine).ConfigureAwait(true);
+ await WriteStreamLine(httpContext, MockErrorStreamLine).ConfigureAwait(true);
// make server alive, cannot set to int.max as of it would block response
- await serverShutdown.WaitAsync().ConfigureAwait(false);
+ await serverShutdown.WaitAsync().ConfigureAwait(true);
return false;
}))
{
@@ -627,7 +627,7 @@ public async Task DirectWatchEventsWithTimeout()
});
// wait server yields all events
- await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(false);
+ await Task.WhenAny(eventsReceived.WaitAsync(), Task.Delay(TestTimeout)).ConfigureAwait(true);
Assert.True(
eventsReceived.CurrentCount == 0,
@@ -654,8 +654,8 @@ public async Task WatchShouldCancelAfterRequested()
using (var server = new MockKubeApiServer(testOutput, async httpContext =>
{
httpContext.Response.StatusCode = 200;
- await httpContext.Response.Body.FlushAsync().ConfigureAwait(false);
- await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false); // The default timeout is 100 seconds
+ await httpContext.Response.Body.FlushAsync().ConfigureAwait(true);
+ await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(true); // The default timeout is 100 seconds
return true;
}, resp: ""))
@@ -668,8 +668,8 @@ public async Task WatchShouldCancelAfterRequested()
await Assert.ThrowsAnyAsync(async () =>
{
await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true,
- cancellationToken: cts.Token).ConfigureAwait(false);
- }).ConfigureAwait(false);
+ cancellationToken: cts.Token).ConfigureAwait(true);
+ }).ConfigureAwait(true);
}
}
@@ -733,7 +733,7 @@ public async Task MustHttp2VersionSet()
{
var server = new MockKubeApiServer(testOutput, async httpContext =>
{
- await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
+ await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(true);
return false;
});
@@ -742,7 +742,7 @@ public async Task MustHttp2VersionSet()
new KubernetesClientConfiguration { Host = server.Uri.ToString() }, handler);
Assert.Null(handler.Version);
- await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
+ await client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(true);
Assert.Equal(HttpVersion.Version20, handler.Version);
}
}