This repository was archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 870
/
Copy pathRedisClientConfigTests.cs
105 lines (94 loc) · 3.13 KB
/
RedisClientConfigTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Linq;
using NUnit.Framework;
using ServiceStack.Text;
namespace ServiceStack.Redis.Tests
{
[TestFixture]
public class RedisClientConfigTests
: RedisClientTestsBase
{
[Ignore("Hurts MSOpenTech Redis Server")]
[Test]
public void Can_Set_and_Get_Config()
{
var orig = Redis.GetConfig("maxmemory");
var newMaxMemory = (long.Parse(orig) + 1).ToString();
Redis.SetConfig("maxmemory", newMaxMemory);
var current = Redis.GetConfig("maxmemory");
Assert.That(current, Is.EqualTo(newMaxMemory));
}
[Test]
public void Can_Rewrite_Redis_Config()
{
try
{
Redis.SaveConfig();
}
catch (RedisResponseException ex)
{
if (ex.Message.StartsWith("Rewriting config file: Permission denied")
|| ex.Message.StartsWith("The server is running without a config file"))
return;
throw;
}
}
[Test]
public void Can_Rewrite_Info_Stats()
{
Redis.ResetInfoStats();
}
[Test]
public void Can_set_and_Get_Client_Name()
{
var clientName = "CLIENT-" + Environment.TickCount;
Redis.SetClient(clientName);
var client = Redis.GetClient();
Assert.That(client, Is.EqualTo(clientName));
}
[Test]
public void Can_GetClientsInfo()
{
var clientList = Redis.GetClientsInfo();
clientList.PrintDump();
}
[Test]
public void Can_Kill_Client()
{
var clientList = Redis.GetClientsInfo();
var firstAddr = clientList.First()["addr"];
Redis.KillClient(firstAddr);
}
[Test]
public void Can_Kill_Clients()
{
Redis.KillClients(fromAddress: "192.168.0.1:6379");
Redis.KillClients(withId: "1");
Redis.KillClients(ofType: RedisClientType.Normal);
Redis.KillClients(ofType: RedisClientType.PubSub);
Redis.KillClients(ofType: RedisClientType.Slave);
Redis.KillClients(skipMe: true);
Redis.KillClients(fromAddress: "192.168.0.1:6379", withId: "1", ofType: RedisClientType.Normal);
Redis.KillClients(skipMe: false);
}
[Test]
public void Can_get_Role_Info()
{
var result = Redis.Role();
result.PrintDump();
Assert.That(result.Children[0].Text, Is.EqualTo("master"));
Assert.That(Redis.GetServerRole(), Is.EqualTo(RedisServerRole.Master));
//needs redis-server v3.0
//var replica = new RedisClient("10.0.0.9:6380");
//result = replica.Role();
//result.PrintDump();
}
[Test]
public void Can_PauseAllClients()
{
//needs redis-server v3.0
//var replica = new RedisClient("10.0.0.9:6380");
//replica.PauseAllClients(TimeSpan.FromSeconds(2));
}
}
}