Skip to content

Commit 67d23ca

Browse files
committed
Tests host:port cleanup
There were several mismatches here...this should help avoid future ones.
1 parent 72b1cba commit 67d23ca

File tree

14 files changed

+734
-729
lines changed

14 files changed

+734
-729
lines changed

StackExchange.Redis.Tests/AsyncTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class AsyncTests : TestBase
88
{
99
public AsyncTests(ITestOutputHelper output) : base (output) { }
1010

11-
protected override string GetConfiguration() => TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort;
11+
protected override string GetConfiguration() => TestConfig.Current.MasterServerAndPort;
1212

1313
#if DEBUG // IRedisServerDebug and AllowConnect are only available if DEBUG is defined
1414
[Fact]

StackExchange.Redis.Tests/ConnectionShutdown.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace StackExchange.Redis.Tests
77
{
88
public class ConnectionShutdown : TestBase
99
{
10-
protected override string GetConfiguration() => TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort;
10+
protected override string GetConfiguration() => TestConfig.Current.MasterServerAndPort;
1111
public ConnectionShutdown(ITestOutputHelper output) : base (output) { }
1212

1313
[Fact(Skip="Unfriendly")]
@@ -53,4 +53,4 @@ public void ShutdownRaisesConnectionFailedAndRestore()
5353
}
5454
}
5555
}
56-
}
56+
}

StackExchange.Redis.Tests/Helpers/TestConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ public class Config
4242

4343
public string MasterServer { get; set; } = "127.0.0.1";
4444
public int MasterPort { get; set; } = 6379;
45+
public string MasterServerAndPort => MasterServer + ":" + MasterPort.ToString();
4546

4647
public string SlaveServer { get; set; } = "127.0.0.1";
4748
public int SlavePort { get; set; } = 6380;
49+
public string SlaveServerAndPort => SlaveServer + ":" + SlavePort.ToString();
4850

4951
public string SecureServer { get; set; } = "127.0.0.1";
5052
public int SecurePort { get; set; } = 6381;
5153
public string SecurePassword { get; set; } = "changeme";
54+
public string SecureServerAndPort => SecureServer + ":" + SecurePort.ToString();
5255

5356
public string IPv4Server { get; set; } = "127.0.0.1";
5457
public int IPv4Port { get; set; } = 6379;

StackExchange.Redis.Tests/Issues/DefaultDatabase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void ConfigurationOptions_UnspecifiedDefaultDb()
2828
var log = new StringWriter();
2929
try
3030
{
31-
using (var conn = ConnectionMultiplexer.Connect($"{TestConfig.Current.MasterServer}:{TestConfig.Current.MasterPort}", log)) {
31+
using (var conn = ConnectionMultiplexer.Connect(TestConfig.Current.MasterServerAndPort, log)) {
3232
var db = conn.GetDatabase();
3333
Assert.Equal(0, db.Database);
3434
}
@@ -45,7 +45,7 @@ public void ConfigurationOptions_SpecifiedDefaultDb()
4545
var log = new StringWriter();
4646
try
4747
{
48-
using (var conn = ConnectionMultiplexer.Connect($"{TestConfig.Current.MasterServer}:{TestConfig.Current.MasterPort},defaultDatabase=3", log)) {
48+
using (var conn = ConnectionMultiplexer.Connect($"{TestConfig.Current.MasterServerAndPort},defaultDatabase=3", log)) {
4949
var db = conn.GetDatabase();
5050
Assert.Equal(3, db.Database);
5151
}
Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
using System;
2-
using System.Linq;
3-
using Xunit;
4-
using Xunit.Abstractions;
5-
6-
namespace StackExchange.Redis.Tests.Issues
7-
{
8-
public class Issue182 : TestBase
9-
{
10-
protected override string GetConfiguration() => $"{TestConfig.Current.MasterServer}:{TestConfig.Current.MasterPort},responseTimeout=10000";
11-
12-
public Issue182(ITestOutputHelper output) : base (output) { }
13-
14-
[FactLongRunning]
15-
public void SetMembers()
16-
{
17-
using (var conn = Create())
18-
{
19-
conn.ConnectionFailed += (s, a) =>
20-
{
21-
Output.WriteLine(a.FailureType.ToString());
22-
Output.WriteLine(a.Exception.Message);
23-
Output.WriteLine(a.Exception.StackTrace);
24-
};
25-
var db = conn.GetDatabase();
26-
27-
var key = Me();
28-
const int count = (int)5e6;
29-
30-
db.KeyDeleteAsync(key).Wait();
31-
foreach (var _ in Enumerable.Range(0, count))
32-
db.SetAdd(key, Guid.NewGuid().ToByteArray(), CommandFlags.FireAndForget);
33-
34-
Assert.Equal(count, db.SetLengthAsync(key).Result); // SCARD for set
35-
36-
var task = db.SetMembersAsync(key);
37-
task.Wait();
38-
Assert.Equal(count, task.Result.Length); // SMEMBERS result length
39-
}
40-
}
41-
42-
[FactLongRunning]
43-
public void SetUnion()
44-
{
45-
using (var conn = Create())
46-
{
47-
var db = conn.GetDatabase();
48-
49-
var key1 = Me() + ":1";
50-
var key2 = Me() + ":2";
51-
var dstkey = Me() + ":dst";
52-
53-
db.KeyDeleteAsync(key1).Wait();
54-
db.KeyDeleteAsync(key2).Wait();
55-
db.KeyDeleteAsync(dstkey).Wait();
56-
57-
const int count = (int)5e6;
58-
foreach (var _ in Enumerable.Range(0, count))
59-
{
60-
db.SetAdd(key1, Guid.NewGuid().ToByteArray(), CommandFlags.FireAndForget);
61-
db.SetAdd(key2, Guid.NewGuid().ToByteArray(), CommandFlags.FireAndForget);
62-
}
63-
Assert.Equal(count, db.SetLengthAsync(key1).Result); // SCARD for set 1
64-
Assert.Equal(count, db.SetLengthAsync(key2).Result); // SCARD for set 2
65-
66-
db.SetCombineAndStoreAsync(SetOperation.Union, dstkey, key1, key2).Wait();
67-
var dstLen = db.SetLength(dstkey);
68-
Assert.Equal(count * 2, dstLen); // SCARD for destination set
69-
}
70-
}
71-
}
72-
}
1+
using System;
2+
using System.Linq;
3+
using Xunit;
4+
using Xunit.Abstractions;
5+
6+
namespace StackExchange.Redis.Tests.Issues
7+
{
8+
public class Issue182 : TestBase
9+
{
10+
protected override string GetConfiguration() => $"{TestConfig.Current.MasterServerAndPort},responseTimeout=10000";
11+
12+
public Issue182(ITestOutputHelper output) : base (output) { }
13+
14+
[FactLongRunning]
15+
public void SetMembers()
16+
{
17+
using (var conn = Create())
18+
{
19+
conn.ConnectionFailed += (s, a) =>
20+
{
21+
Output.WriteLine(a.FailureType.ToString());
22+
Output.WriteLine(a.Exception.Message);
23+
Output.WriteLine(a.Exception.StackTrace);
24+
};
25+
var db = conn.GetDatabase();
26+
27+
var key = Me();
28+
const int count = (int)5e6;
29+
30+
db.KeyDeleteAsync(key).Wait();
31+
foreach (var _ in Enumerable.Range(0, count))
32+
db.SetAdd(key, Guid.NewGuid().ToByteArray(), CommandFlags.FireAndForget);
33+
34+
Assert.Equal(count, db.SetLengthAsync(key).Result); // SCARD for set
35+
36+
var task = db.SetMembersAsync(key);
37+
task.Wait();
38+
Assert.Equal(count, task.Result.Length); // SMEMBERS result length
39+
}
40+
}
41+
42+
[FactLongRunning]
43+
public void SetUnion()
44+
{
45+
using (var conn = Create())
46+
{
47+
var db = conn.GetDatabase();
48+
49+
var key1 = Me() + ":1";
50+
var key2 = Me() + ":2";
51+
var dstkey = Me() + ":dst";
52+
53+
db.KeyDeleteAsync(key1).Wait();
54+
db.KeyDeleteAsync(key2).Wait();
55+
db.KeyDeleteAsync(dstkey).Wait();
56+
57+
const int count = (int)5e6;
58+
foreach (var _ in Enumerable.Range(0, count))
59+
{
60+
db.SetAdd(key1, Guid.NewGuid().ToByteArray(), CommandFlags.FireAndForget);
61+
db.SetAdd(key2, Guid.NewGuid().ToByteArray(), CommandFlags.FireAndForget);
62+
}
63+
Assert.Equal(count, db.SetLengthAsync(key1).Result); // SCARD for set 1
64+
Assert.Equal(count, db.SetLengthAsync(key2).Result); // SCARD for set 2
65+
66+
db.SetCombineAndStoreAsync(SetOperation.Union, dstkey, key1, key2).Wait();
67+
var dstLen = db.SetLength(dstkey);
68+
Assert.Equal(count * 2, dstLen); // SCARD for destination set
69+
}
70+
}
71+
}
72+
}

StackExchange.Redis.Tests/Issues/Issue791.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void DefaultValue_IsTrue()
2929
[Fact]
3030
public void PreserveAsyncOrder_SetConnectionMultiplexerProperty()
3131
{
32-
var multiplexer = ConnectionMultiplexer.Connect(TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort + ",preserveAsyncOrder=false");
32+
var multiplexer = ConnectionMultiplexer.Connect(TestConfig.Current.MasterServerAndPort + ",preserveAsyncOrder=false");
3333
Assert.False(multiplexer.PreserveAsyncOrder);
3434
}
3535
}

StackExchange.Redis.Tests/Issues/SO25567566.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace StackExchange.Redis.Tests.Issues
77
{
88
public class SO25567566 : TestBase
99
{
10-
protected override string GetConfiguration() => $"{TestConfig.Current.MasterServer}:{TestConfig.Current.MasterPort}";
10+
protected override string GetConfiguration() => TestConfig.Current.MasterServerAndPort;
1111
public SO25567566(ITestOutputHelper output) : base(output) { }
1212

1313
[FactLongRunning]
@@ -70,4 +70,4 @@ private async Task<string> DoStuff(ConnectionMultiplexer conn)
7070
}
7171
}
7272
}
73-
}
73+
}

StackExchange.Redis.Tests/Keys.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void RandomKey()
3434
using (var conn = Create(allowAdmin: true))
3535
{
3636
var db = conn.GetDatabase();
37-
conn.GetServer(TestConfig.Current.MasterServer, TestConfig.Current.MasterPort).FlushDatabase();
37+
conn.GetServer(TestConfig.Current.MasterServerAndPort).FlushDatabase();
3838
string anyKey = db.KeyRandom();
3939

4040
Assert.Null(anyKey);

StackExchange.Redis.Tests/Locking.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace StackExchange.Redis.Tests
99
{
1010
public class Locking : TestBase
1111
{
12-
protected override string GetConfiguration() => TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort;
12+
protected override string GetConfiguration() => TestConfig.Current.MasterServerAndPort;
1313
public Locking(ITestOutputHelper output) : base (output) { }
1414

1515
public enum TestMode

StackExchange.Redis.Tests/MultiMaster.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace StackExchange.Redis.Tests
1212
public class MultiMaster : TestBase
1313
{
1414
protected override string GetConfiguration() =>
15-
TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort + "," + TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort + ",password=" + TestConfig.Current.SecurePassword;
15+
TestConfig.Current.MasterServerAndPort + "," + TestConfig.Current.SecureServerAndPort + ",password=" + TestConfig.Current.SecurePassword;
1616

1717
public MultiMaster(ITestOutputHelper output) : base (output) { }
1818

@@ -39,8 +39,8 @@ public async Task DeslaveGoesToPrimary()
3939
ConfigurationOptions config = GetMasterSlaveConfig();
4040
using (var conn = ConnectionMultiplexer.Connect(config))
4141
{
42-
var primary = conn.GetServer(TestConfig.Current.MasterServer, TestConfig.Current.MasterPort);
43-
var secondary = conn.GetServer(TestConfig.Current.SlaveServer, TestConfig.Current.SlavePort);
42+
var primary = conn.GetServer(TestConfig.Current.MasterServerAndPort);
43+
var secondary = conn.GetServer(TestConfig.Current.SlaveServerAndPort);
4444

4545
primary.Ping();
4646
secondary.Ping();
@@ -58,7 +58,7 @@ public async Task DeslaveGoesToPrimary()
5858
conn.Configure(writer);
5959
string log = writer.ToString();
6060

61-
Assert.True(log.Contains("tie-break is unanimous at " + TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort), "unanimous");
61+
Assert.True(log.Contains("tie-break is unanimous at " + TestConfig.Current.MasterServerAndPort), "unanimous");
6262
}
6363
// k, so we know everyone loves 6379; is that what we get?
6464

@@ -89,8 +89,8 @@ public async Task DeslaveGoesToPrimary()
8989
// server topology changes from failures to recognize those changes
9090
using (var conn2 = ConnectionMultiplexer.Connect(config))
9191
{
92-
var primary2 = conn.GetServer(TestConfig.Current.MasterServer, TestConfig.Current.MasterPort);
93-
var secondary2 = conn.GetServer(TestConfig.Current.SlaveServer, TestConfig.Current.SlavePort);
92+
var primary2 = conn.GetServer(TestConfig.Current.MasterServerAndPort);
93+
var secondary2 = conn.GetServer(TestConfig.Current.SlaveServerAndPort);
9494

9595
Writer.WriteLine($"Check: {primary2.EndPoint}: {primary2.ServerType}, Mode: {(primary2.IsSlave ? "Slave" : "Master")}");
9696
Writer.WriteLine($"Check: {secondary2.EndPoint}: {secondary2.ServerType}, Mode: {(secondary2.IsSlave ? "Slave" : "Master")}");
@@ -143,15 +143,15 @@ public void TestMultiNoTieBreak()
143143

144144
public static IEnumerable<object[]> GetConnections()
145145
{
146-
yield return new object[] { TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort };
147-
yield return new object[] { TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort };
148-
yield return new object[] { TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort, null };
149-
yield return new object[] { TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort, null };
150-
151-
yield return new object[] { null, TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort };
152-
yield return new object[] { TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort, null, TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort };
153-
yield return new object[] { null, TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort, TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort };
154-
yield return new object[] { TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort, null, TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort };
146+
yield return new object[] { TestConfig.Current.MasterServerAndPort, TestConfig.Current.MasterServerAndPort, TestConfig.Current.MasterServerAndPort };
147+
yield return new object[] { TestConfig.Current.SecureServerAndPort, TestConfig.Current.SecureServerAndPort, TestConfig.Current.SecureServerAndPort };
148+
yield return new object[] { TestConfig.Current.SecureServerAndPort, TestConfig.Current.MasterServerAndPort, null };
149+
yield return new object[] { TestConfig.Current.MasterServerAndPort, TestConfig.Current.SecureServerAndPort, null };
150+
151+
yield return new object[] { null, TestConfig.Current.MasterServerAndPort, TestConfig.Current.MasterServerAndPort };
152+
yield return new object[] { TestConfig.Current.MasterServerAndPort, null, TestConfig.Current.MasterServerAndPort };
153+
yield return new object[] { null, TestConfig.Current.SecureServerAndPort, TestConfig.Current.SecureServerAndPort };
154+
yield return new object[] { TestConfig.Current.SecureServerAndPort, null, TestConfig.Current.SecureServerAndPort };
155155
yield return new object[] { null, null, null };
156156
}
157157

@@ -160,11 +160,11 @@ public void TestMultiWithTiebreak(string a, string b, string elected)
160160
{
161161
const string TieBreak = "__tie__";
162162
// set the tie-breakers to the expected state
163-
using (var aConn = ConnectionMultiplexer.Connect(TestConfig.Current.MasterServer + ":" + TestConfig.Current.MasterPort))
163+
using (var aConn = ConnectionMultiplexer.Connect(TestConfig.Current.MasterServerAndPort))
164164
{
165165
aConn.GetDatabase().StringSet(TieBreak, a);
166166
}
167-
using (var aConn = ConnectionMultiplexer.Connect(TestConfig.Current.MasterServer + ":" + TestConfig.Current.SecurePort + ",password=" + TestConfig.Current.SecurePassword))
167+
using (var aConn = ConnectionMultiplexer.Connect(TestConfig.Current.SecureServerAndPort + ",password=" + TestConfig.Current.SecurePassword))
168168
{
169169
aConn.GetDatabase().StringSet(TieBreak, b);
170170
}

0 commit comments

Comments
 (0)