Skip to content

Commit bef281e

Browse files
committed
Fix Concourse CI
Fix required due to the changes in this PR: rabbitmq/tls-gen#37 Ensure that RMQ is always restarted
1 parent 93921e6 commit bef281e

File tree

6 files changed

+97
-82
lines changed

6 files changed

+97
-82
lines changed

_site

Submodule _site updated 152 files

projects/Unit/TestBasicPublish.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace RabbitMQ.Client.Unit
1010
{
11-
1211
public class TestBasicPublish
1312
{
1413
[Fact]

projects/Unit/TestConnectionRecovery.cs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,22 @@ public void TestBasicConnectionRecoveryStopsAfterManualClose()
236236
AutorecoveringConnection c = CreateAutorecoveringConnection();
237237
var latch = new AutoResetEvent(false);
238238
c.ConnectionRecoveryError += (o, args) => latch.Set();
239-
StopRabbitMQ();
240-
latch.WaitOne(30000); // we got the failed reconnection event.
241-
bool triedRecoveryAfterClose = false;
242-
c.Close();
243-
Thread.Sleep(5000);
244-
c.ConnectionRecoveryError += (o, args) => triedRecoveryAfterClose = true;
245-
Thread.Sleep(10000);
246-
Assert.False(triedRecoveryAfterClose);
247-
StartRabbitMQ();
239+
240+
try
241+
{
242+
StopRabbitMQ();
243+
latch.WaitOne(30000); // we got the failed reconnection event.
244+
bool triedRecoveryAfterClose = false;
245+
c.Close();
246+
Thread.Sleep(5000);
247+
c.ConnectionRecoveryError += (o, args) => triedRecoveryAfterClose = true;
248+
Thread.Sleep(10000);
249+
Assert.False(triedRecoveryAfterClose);
250+
}
251+
finally
252+
{
253+
StartRabbitMQ();
254+
}
248255
}
249256

250257
[Fact]
@@ -775,14 +782,21 @@ public void TestShutdownEventHandlersRecoveryOnConnectionAfterDelayedServerResta
775782
ManualResetEventSlim recoveryLatch = PrepareForRecovery((AutorecoveringConnection)_conn);
776783

777784
Assert.True(_conn.IsOpen);
778-
StopRabbitMQ();
779-
Console.WriteLine("Stopped RabbitMQ. About to sleep for multiple recovery intervals...");
780-
Thread.Sleep(7000);
781-
StartRabbitMQ();
785+
786+
try
787+
{
788+
StopRabbitMQ();
789+
Console.WriteLine("Stopped RabbitMQ. About to sleep for multiple recovery intervals...");
790+
Thread.Sleep(7000);
791+
}
792+
finally
793+
{
794+
StartRabbitMQ();
795+
}
796+
782797
Wait(shutdownLatch, TimeSpan.FromSeconds(30));
783798
Wait(recoveryLatch, TimeSpan.FromSeconds(30));
784799
Assert.True(_conn.IsOpen);
785-
786800
Assert.True(counter >= 1);
787801
}
788802

projects/Unit/TestHeartbeats.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
using System;
3333
using System.Collections.Generic;
34+
using System.IO;
3435
using System.Threading;
3536

3637
using Xunit;
@@ -58,14 +59,10 @@ public void TestThatHeartbeatWriterUsesConfigurableInterval()
5859
RunSingleConnectionTest(cf);
5960
}
6061

61-
[Fact]
62+
[SkippableFact]
6263
public void TestThatHeartbeatWriterWithTLSEnabled()
6364
{
64-
if (!LongRunningTestsEnabled())
65-
{
66-
Console.WriteLine("RABBITMQ_LONG_RUNNING_TESTS is not set, skipping test");
67-
return;
68-
}
65+
Skip.IfNot(LongRunningTestsEnabled());
6966

7067
var cf = new ConnectionFactory()
7168
{
@@ -75,15 +72,15 @@ public void TestThatHeartbeatWriterWithTLSEnabled()
7572
};
7673

7774
string sslDir = IntegrationFixture.CertificatesDirectory();
78-
if (null == sslDir)
79-
{
80-
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
81-
return;
82-
}
83-
cf.Ssl.ServerName = System.Net.Dns.GetHostName();
84-
Assert.NotNull(sslDir);
85-
cf.Ssl.CertPath = $"{sslDir}/client_key.p12";
86-
cf.Ssl.CertPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
75+
string certPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
76+
bool sslConfigured = Directory.Exists(sslDir) &&
77+
(false == string.IsNullOrEmpty(certPassphrase));
78+
Skip.IfNot(sslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");
79+
80+
string hostName = System.Net.Dns.GetHostName();
81+
cf.Ssl.ServerName = hostName;
82+
cf.Ssl.CertPath = $"{sslDir}/client_{hostName}_key.p12";
83+
cf.Ssl.CertPassphrase = certPassphrase;
8784
cf.Ssl.Enabled = true;
8885

8986
RunSingleConnectionTest(cf);

projects/Unit/TestSsl.cs

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,43 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.IO;
3334
using System.Net.Security;
35+
using System.Reflection;
3436
using System.Security.Authentication;
3537

3638
using Xunit;
39+
using Xunit.Abstractions;
3740

3841
namespace RabbitMQ.Client.Unit
3942
{
40-
4143
public class TestSsl
4244
{
43-
private void SendReceive(ConnectionFactory cf)
44-
{
45-
using (IConnection conn = cf.CreateConnection())
46-
{
47-
IModel ch = conn.CreateModel();
45+
private readonly ITestOutputHelper _output;
46+
private readonly string _testDisplayName;
47+
private readonly string _sslDir;
48+
private readonly string _certPassphrase;
49+
private readonly bool _sslConfigured;
4850

49-
ch.ExchangeDeclare("Exchange_TestSslEndPoint", ExchangeType.Direct);
50-
string qName = ch.QueueDeclare();
51-
ch.QueueBind(qName, "Exchange_TestSslEndPoint", "Key_TestSslEndpoint", null);
52-
53-
string message = "Hello C# SSL Client World";
54-
byte[] msgBytes = System.Text.Encoding.UTF8.GetBytes(message);
55-
ch.BasicPublish("Exchange_TestSslEndPoint", "Key_TestSslEndpoint", msgBytes);
51+
public TestSsl(ITestOutputHelper output)
52+
{
53+
_output = output;
54+
var type = _output.GetType();
55+
var testMember = type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic);
56+
var test = (ITest)testMember.GetValue(output);
57+
_testDisplayName = test.DisplayName;
5658

57-
bool autoAck = false;
58-
BasicGetResult result = ch.BasicGet(qName, autoAck);
59-
byte[] body = result.Body.ToArray();
60-
string resultMessage = System.Text.Encoding.UTF8.GetString(body);
59+
_sslDir = IntegrationFixture.CertificatesDirectory();
60+
_certPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
6161

62-
Assert.Equal(message, resultMessage);
63-
}
62+
_sslConfigured = Directory.Exists(_sslDir) &&
63+
(false == string.IsNullOrEmpty(_certPassphrase));
6464
}
6565

66-
[Fact]
66+
[SkippableFact]
6767
public void TestServerVerifiedIgnoringNameMismatch()
6868
{
69-
string sslDir = IntegrationFixture.CertificatesDirectory();
70-
if (null == sslDir)
71-
{
72-
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
73-
return;
74-
}
69+
Skip.IfNot(_sslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");
7570

7671
ConnectionFactory cf = new ConnectionFactory { Port = 5671 };
7772
cf.Ssl.ServerName = "*";
@@ -80,51 +75,36 @@ public void TestServerVerifiedIgnoringNameMismatch()
8075
SendReceive(cf);
8176
}
8277

83-
[Fact]
78+
[SkippableFact]
8479
public void TestServerVerified()
8580
{
86-
string sslDir = IntegrationFixture.CertificatesDirectory();
87-
if (null == sslDir)
88-
{
89-
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
90-
return;
91-
}
81+
Skip.IfNot(_sslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");
9282

9383
ConnectionFactory cf = new ConnectionFactory { Port = 5671 };
9484
cf.Ssl.ServerName = System.Net.Dns.GetHostName();
9585
cf.Ssl.Enabled = true;
9686
SendReceive(cf);
9787
}
9888

99-
[Fact]
89+
[SkippableFact]
10090
public void TestClientAndServerVerified()
10191
{
102-
string sslDir = IntegrationFixture.CertificatesDirectory();
103-
if (null == sslDir)
104-
{
105-
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
106-
return;
107-
}
92+
Skip.IfNot(_sslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");
10893

94+
string hostName = System.Net.Dns.GetHostName();
10995
ConnectionFactory cf = new ConnectionFactory { Port = 5671 };
110-
cf.Ssl.ServerName = System.Net.Dns.GetHostName();
111-
Assert.NotNull(sslDir);
112-
cf.Ssl.CertPath = $"{sslDir}/client_key.p12";
113-
cf.Ssl.CertPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
96+
cf.Ssl.ServerName = hostName;
97+
cf.Ssl.CertPath = $"{_sslDir}/client_{hostName}_key.p12";
98+
cf.Ssl.CertPassphrase = _certPassphrase;
11499
cf.Ssl.Enabled = true;
115100
SendReceive(cf);
116101
}
117102

118103
// rabbitmq/rabbitmq-dotnet-client#46, also #44 and #45
119-
[Fact]
104+
[SkippableFact]
120105
public void TestNoClientCertificate()
121106
{
122-
string sslDir = IntegrationFixture.CertificatesDirectory();
123-
if (null == sslDir)
124-
{
125-
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
126-
return;
127-
}
107+
Skip.IfNot(_sslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");
128108

129109
ConnectionFactory cf = new ConnectionFactory
130110
{
@@ -143,5 +123,29 @@ public void TestNoClientCertificate()
143123

144124
SendReceive(cf);
145125
}
126+
127+
private void SendReceive(ConnectionFactory cf)
128+
{
129+
using (IConnection conn = cf.CreateConnection($"{_testDisplayName}:{Guid.NewGuid()}"))
130+
{
131+
using (IModel ch = conn.CreateModel())
132+
{
133+
ch.ExchangeDeclare("Exchange_TestSslEndPoint", ExchangeType.Direct);
134+
string qName = ch.QueueDeclare();
135+
ch.QueueBind(qName, "Exchange_TestSslEndPoint", "Key_TestSslEndpoint", null);
136+
137+
string message = "Hello C# SSL Client World";
138+
byte[] msgBytes = System.Text.Encoding.UTF8.GetBytes(message);
139+
ch.BasicPublish("Exchange_TestSslEndPoint", "Key_TestSslEndpoint", msgBytes);
140+
141+
bool autoAck = false;
142+
BasicGetResult result = ch.BasicGet(qName, autoAck);
143+
byte[] body = result.Body.ToArray();
144+
string resultMessage = System.Text.Encoding.UTF8.GetString(body);
145+
146+
Assert.Equal(message, resultMessage);
147+
}
148+
}
149+
}
146150
}
147151
}

projects/Unit/Unit.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
</PackageReference>
2424
<PackageReference Include="Verify.Xunit" Version="11.18.2" />
25+
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
2526
</ItemGroup>
2627

2728
</Project>

0 commit comments

Comments
 (0)