Skip to content

Commit 0bce481

Browse files
authored
Work around flake in the Couchbase 3 integration tests (#7357)
## Summary of changes Work around flake in the Couchbase 3 integration tests ## Reason for change In #7029 we added code to workaround infra flake in the couchbase tests by looking for `AuthenticationException`. However, in Couchbase 3, `AuthenticationFailureException` is thrown instead, so we should look for that too. Additionally, I noticed that if I just run the sample locally, with no couchbase running, a totally different issue arises. Working abound that by trying to explicitly connect, and timing out if that fails ## Implementation details Add `AuthenticationFailureException` and `UnambiguousTimeoutException` to the ignored list. Re-throwing (instead of swallowing) when an error occurs during auth (as we can't continue) ## Test coverage Tested locally, and confirmed we return the skip code.
1 parent 3dbdd98 commit 0bce481

File tree

1 file changed

+10
-11
lines changed
  • tracer/test/test-applications/integrations/Samples.Couchbase3

1 file changed

+10
-11
lines changed

tracer/test/test-applications/integrations/Samples.Couchbase3/Program.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
using System.Threading.Tasks;
66
using Couchbase;
77
using Couchbase.Core;
8+
using Couchbase.Core.Exceptions;
89

910
namespace Samples.Couchbase3
1011
{
1112
internal class Program
1213
{
13-
private static bool ContainsAuthenticationException(Exception ex) => ex switch
14+
private static bool ContainsIgnorableException(Exception ex) => ex switch
1415
{
15-
AuthenticationException => true,
16-
AggregateException aggEx => aggEx.InnerExceptions.Any(ContainsAuthenticationException),
17-
{ InnerException: { } inner } => ContainsAuthenticationException(inner),
16+
AuthenticationException or AuthenticationFailureException => true,
17+
UnambiguousTimeoutException => true,
18+
AggregateException aggEx => aggEx.InnerExceptions.Any(ContainsIgnorableException),
19+
{ InnerException: { } inner } => ContainsIgnorableException(inner),
1820
_ => false,
1921
};
2022

@@ -31,16 +33,13 @@ private static async Task<int> Main()
3133
try
3234
{
3335
cluster = await Cluster.ConnectAsync(options);
36+
await cluster.WaitUntilReadyAsync(TimeSpan.FromSeconds(15));
3437
}
35-
catch (Exception ex)
38+
catch (Exception ex) when (ContainsIgnorableException(ex))
3639
{
3740
Console.WriteLine("Exception during execution " + ex);
38-
39-
if (ContainsAuthenticationException(ex))
40-
{
41-
Console.WriteLine("Exiting with skip code (13)");
42-
return 13;
43-
}
41+
Console.WriteLine("Exiting with skip code (13)");
42+
return 13;
4443
}
4544

4645
// get a bucket reference

0 commit comments

Comments
 (0)