Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
6de5908a
Commit
6de5908a
authored
Jul 06, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More test fixes
parent
64289d42
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
32 deletions
+54
-32
PubSub.cs
StackExchange.Redis.Tests/Booksleeve/PubSub.cs
+5
-3
Cluster.cs
StackExchange.Redis.Tests/Cluster.cs
+7
-5
Failover.cs
StackExchange.Redis.Tests/Failover.cs
+1
-1
Attributes.cs
StackExchange.Redis.Tests/Helpers/Attributes.cs
+10
-0
Keys.cs
StackExchange.Redis.Tests/Keys.cs
+3
-2
Lex.cs
StackExchange.Redis.Tests/Lex.cs
+2
-2
MassiveOps.cs
StackExchange.Redis.Tests/MassiveOps.cs
+1
-1
Profiling.cs
StackExchange.Redis.Tests/Profiling.cs
+20
-14
Scans.cs
StackExchange.Redis.Tests/Scans.cs
+4
-3
Sets.cs
StackExchange.Redis.Tests/Sets.cs
+1
-1
No files found.
StackExchange.Redis.Tests/Booksleeve/PubSub.cs
View file @
6de5908a
...
...
@@ -24,7 +24,7 @@ public void TestPublishWithNoSubscribers()
}
}
[
Fact
]
[
Fact
LongRunning
]
public
void
TestMassivePublishWithWithoutFlush_Local
()
{
using
(
var
muxer
=
GetUnsecuredConnection
(
waitForOpen
:
true
))
...
...
@@ -73,7 +73,9 @@ private void TestMassivePublish(ISubscriber conn, string channel, string caption
Output
.
WriteLine
(
"{2}: {0}ms (F+F) vs {1}ms (async)"
,
withFAF
.
ElapsedMilliseconds
,
withAsync
.
ElapsedMilliseconds
,
caption
);
Assert
.
True
(
withFAF
.
ElapsedMilliseconds
<
withAsync
.
ElapsedMilliseconds
,
caption
);
// We've made async so far, this test isn't really valid anymore
// So let's check they're at least within a few seconds.
Assert
.
True
(
withFAF
.
ElapsedMilliseconds
<
withAsync
.
ElapsedMilliseconds
+
3000
,
caption
);
}
[
FactLongRunning
]
...
...
@@ -397,7 +399,7 @@ public void Issue38()
internal
static
void
AllowReasonableTimeToPublishAndProcess
()
{
Thread
.
Sleep
(
5
0
);
Thread
.
Sleep
(
10
0
);
}
[
Fact
]
...
...
StackExchange.Redis.Tests/Cluster.cs
View file @
6de5908a
...
...
@@ -432,7 +432,7 @@ public void Keys(string pattern, int pageSize)
public
void
HashSlots
(
string
key
,
int
slot
)
{
using
(
var
muxer
=
Create
(
connectTimeout
:
500
,
pause
:
false
))
using
(
var
muxer
=
Create
(
connectTimeout
:
500
0
,
pause
:
false
))
{
Assert
.
Equal
(
slot
,
muxer
.
HashSlot
(
key
));
}
...
...
@@ -595,18 +595,20 @@ public void SimpleProfiling()
using
(
var
conn
=
Create
())
{
var
profiler
=
new
TestProfiler
();
var
key
=
Me
();
var
db
=
conn
.
GetDatabase
();
db
.
KeyDelete
(
key
);
conn
.
RegisterProfiler
(
profiler
);
conn
.
BeginProfiling
(
profiler
.
MyContext
);
var
db
=
conn
.
GetDatabase
();
db
.
StringSet
(
"hello"
,
"world"
);
var
val
=
db
.
StringGet
(
"hello"
);
db
.
StringSet
(
key
,
"world"
);
var
val
=
db
.
StringGet
(
key
);
Assert
.
Equal
(
"world"
,
val
);
var
msgs
=
conn
.
FinishProfiling
(
profiler
.
MyContext
);
Assert
.
Equal
(
2
,
msgs
.
Count
());
Assert
.
Contains
(
msgs
,
m
=>
m
.
Command
==
"GET"
);
Assert
.
Contains
(
msgs
,
m
=>
m
.
Command
==
"SET"
);
Assert
.
Equal
(
2
,
msgs
.
Count
());
}
}
...
...
StackExchange.Redis.Tests/Failover.cs
View file @
6de5908a
...
...
@@ -62,7 +62,7 @@ public async Task ConfigVerifyReceiveConfigChangeBroadcast()
long
count
=
sender
.
PublishReconfigure
();
GetServer
(
receiver
).
Ping
();
GetServer
(
receiver
).
Ping
();
await
Task
.
Delay
(
10
).
ConfigureAwait
(
false
);
await
Task
.
Delay
(
10
0
).
ConfigureAwait
(
false
);
Assert
.
True
(
count
==
-
1
||
count
>=
2
,
"subscribers"
);
Assert
.
True
(
Interlocked
.
CompareExchange
(
ref
total
,
0
,
0
)
>=
1
,
"total (1st)"
);
...
...
StackExchange.Redis.Tests/Helpers/Attributes.cs
View file @
6de5908a
...
...
@@ -46,6 +46,16 @@ public override string Skip
[
XunitTestCaseDiscoverer
(
"StackExchange.Redis.Tests.TheoryDiscoverer"
,
"StackExchange.Redis.Tests"
)]
public
class
TheoryAttribute
:
Xunit
.
TheoryAttribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
class
TheoryLongRunningAttribute
:
Xunit
.
TheoryAttribute
{
public
override
string
Skip
{
get
=>
TestConfig
.
Current
.
RunLongRunning
?
base
.
Skip
:
"Config.RunLongRunning is false - skipping long test."
;
set
=>
base
.
Skip
=
value
;
}
}
public
class
FactDiscoverer
:
Xunit
.
Sdk
.
FactDiscoverer
{
public
FactDiscoverer
(
IMessageSink
diagnosticMessageSink
)
:
base
(
diagnosticMessageSink
)
{
}
...
...
StackExchange.Redis.Tests/Keys.cs
View file @
6de5908a
...
...
@@ -33,8 +33,9 @@ public void FlushFetchRandomKey()
{
using
(
var
conn
=
Create
(
allowAdmin
:
true
))
{
var
db
=
conn
.
GetDatabase
(
14
);
conn
.
GetServer
(
TestConfig
.
Current
.
MasterServerAndPort
).
FlushDatabase
(
14
);
const
int
dbId
=
63
;
var
db
=
conn
.
GetDatabase
(
dbId
);
conn
.
GetServer
(
TestConfig
.
Current
.
MasterServerAndPort
).
FlushDatabase
(
dbId
);
string
anyKey
=
db
.
KeyRandom
();
Assert
.
Null
(
anyKey
);
...
...
StackExchange.Redis.Tests/Lex.cs
View file @
6de5908a
...
...
@@ -86,7 +86,7 @@ public void RemoveRangeByLex()
private
void
Equate
(
RedisValue
[]
actual
,
long
count
,
params
string
[]
expected
)
{
Assert
.
Equal
(
count
,
expected
.
Length
);
Assert
.
Equal
(
expected
.
Length
,
count
);
Assert
.
Equal
(
expected
.
Length
,
actual
.
Length
);
for
(
int
i
=
0
;
i
<
actual
.
Length
;
i
++)
{
...
...
@@ -94,4 +94,4 @@ private void Equate(RedisValue[] actual, long count, params string[] expected)
}
}
}
}
\ No newline at end of file
}
StackExchange.Redis.Tests/MassiveOps.cs
View file @
6de5908a
...
...
@@ -41,7 +41,7 @@ public async Task MassiveBulkOpsAsync(bool withContinuation)
}
}
[
Theory
]
[
Theory
LongRunning
]
[
InlineData
(
1
)]
[
InlineData
(
5
)]
[
InlineData
(
10
)]
...
...
StackExchange.Redis.Tests/Profiling.cs
View file @
6de5908a
...
...
@@ -25,14 +25,15 @@ public void Simple()
using
(
var
conn
=
Create
())
{
var
profiler
=
new
TestProfiler
();
var
key
=
Me
();
conn
.
RegisterProfiler
(
profiler
);
conn
.
BeginProfiling
(
profiler
.
MyContext
);
var
db
=
conn
.
GetDatabase
(
4
);
db
.
StringSet
(
"hello"
,
"world"
);
var
val
=
db
.
StringGet
(
"hello"
);
db
.
StringSet
(
key
,
"world"
);
var
val
=
db
.
StringGet
(
key
);
Assert
.
Equal
(
"world"
,
(
string
)
val
);
var
result
=
db
.
ScriptEvaluate
(
LuaScript
.
Prepare
(
"return redis.call('get', @key)"
),
new
{
key
=
(
RedisKey
)
"hello"
});
var
result
=
db
.
ScriptEvaluate
(
LuaScript
.
Prepare
(
"return redis.call('get', @key)"
),
new
{
key
=
(
RedisKey
)
key
});
Assert
.
Equal
(
"world"
,
result
.
AsString
());
var
cmds
=
conn
.
FinishProfiling
(
profiler
.
MyContext
);
...
...
@@ -76,6 +77,7 @@ public void ManyThreads()
using
(
var
conn
=
Create
())
{
var
profiler
=
new
TestProfiler
();
var
prefix
=
Me
();
conn
.
RegisterProfiler
(
profiler
);
conn
.
BeginProfiling
(
profiler
.
MyContext
);
...
...
@@ -92,7 +94,7 @@ public void ManyThreads()
for
(
var
j
=
0
;
j
<
1000
;
j
++)
{
var
task
=
db
.
StringSetAsync
(
""
+
j
,
""
+
j
);
var
task
=
db
.
StringSetAsync
(
prefix
+
j
,
""
+
j
);
threadTasks
.
Add
(
task
);
}
...
...
@@ -140,12 +142,13 @@ public object GetContext()
}
}
[
Fact
]
[
Fact
LongRunning
]
public
void
ManyContexts
()
{
using
(
var
conn
=
Create
())
{
var
profiler
=
new
TestProfiler2
();
var
prefix
=
Me
();
conn
.
RegisterProfiler
(
profiler
);
var
perThreadContexts
=
new
List
<
object
>();
...
...
@@ -173,8 +176,8 @@ public void ManyContexts()
for
(
var
j
=
0
;
j
<
1000
;
j
++)
{
allTasks
.
Add
(
db
.
StringGetAsync
(
"hello"
+
ix
));
allTasks
.
Add
(
db
.
StringSetAsync
(
"hello"
+
ix
,
"world"
+
ix
));
allTasks
.
Add
(
db
.
StringGetAsync
(
prefix
+
ix
));
allTasks
.
Add
(
db
.
StringSetAsync
(
prefix
+
ix
,
"world"
+
ix
));
}
Task
.
WaitAll
(
allTasks
.
ToArray
());
...
...
@@ -298,7 +301,7 @@ public void LeaksCollectedAndRePooled()
}
}
[
Fact
]
[
Fact
LongRunning
]
public
void
ReuseStorage
()
{
const
int
ThreadCount
=
16
;
...
...
@@ -309,6 +312,7 @@ public void ReuseStorage()
using
(
var
conn
=
Create
())
{
var
profiler
=
new
TestProfiler2
();
var
prefix
=
Me
();
conn
.
RegisterProfiler
(
profiler
);
var
perThreadContexts
=
new
List
<
object
>();
...
...
@@ -342,8 +346,8 @@ public void ReuseStorage()
for
(
var
j
=
0
;
j
<
1000
;
j
++)
{
allTasks
.
Add
(
db
.
StringGetAsync
(
"hello"
+
ix
));
allTasks
.
Add
(
db
.
StringSetAsync
(
"hello"
+
ix
,
"world"
+
ix
));
allTasks
.
Add
(
db
.
StringGetAsync
(
prefix
+
ix
));
allTasks
.
Add
(
db
.
StringSetAsync
(
prefix
+
ix
,
"world"
+
ix
));
}
Task
.
WaitAll
(
allTasks
.
ToArray
());
...
...
@@ -461,13 +465,14 @@ public object GetContext()
}
}
[
Fact
]
[
Fact
LongRunning
]
public
void
ProfilingMD_Ex1
()
{
using
(
var
c
=
Create
())
{
ConnectionMultiplexer
conn
=
c
;
var
profiler
=
new
ToyProfiler
();
var
prefix
=
Me
();
var
thisGroupContext
=
new
object
();
conn
.
RegisterProfiler
(
profiler
);
...
...
@@ -484,7 +489,7 @@ public void ProfilingMD_Ex1()
for
(
var
j
=
0
;
j
<
1000
;
j
++)
{
var
task
=
db
.
StringSetAsync
(
""
+
j
,
""
+
j
);
var
task
=
db
.
StringSetAsync
(
prefix
+
j
,
""
+
j
);
threadTasks
.
Add
(
task
);
}
...
...
@@ -507,13 +512,14 @@ public void ProfilingMD_Ex1()
}
}
[
Fact
]
[
Fact
LongRunning
]
public
void
ProfilingMD_Ex2
()
{
using
(
var
c
=
Create
())
{
ConnectionMultiplexer
conn
=
c
;
var
profiler
=
new
ToyProfiler
();
var
prefix
=
Me
();
conn
.
RegisterProfiler
(
profiler
);
...
...
@@ -533,7 +539,7 @@ public void ProfilingMD_Ex2()
for
(
var
j
=
0
;
j
<
1000
;
j
++)
{
var
task
=
db
.
StringSetAsync
(
""
+
j
,
""
+
j
);
var
task
=
db
.
StringSetAsync
(
prefix
+
j
,
""
+
j
);
threadTasks
.
Add
(
task
);
}
...
...
StackExchange.Redis.Tests/Scans.cs
View file @
6de5908a
...
...
@@ -96,12 +96,13 @@ public void ScanResume()
// only goes up to 3.*, so...
Skip
.
IfMissingFeature
(
conn
,
"Avoiding Redis on Windows"
,
x
=>
x
.
Version
>=
new
Version
(
4
,
0
));
var
db
=
conn
.
GetDatabase
(
DB
);
var
prefix
=
Me
();
var
server
=
GetServer
(
conn
);
server
.
FlushDatabase
(
DB
);
int
i
;
for
(
i
=
0
;
i
<
100
;
i
++)
{
db
.
StringSet
(
"ScanResume
:"
+
i
,
Guid
.
NewGuid
().
ToString
());
db
.
StringSet
(
prefix
+
"
:"
+
i
,
Guid
.
NewGuid
().
ToString
());
}
var
expected
=
new
HashSet
<
string
>();
...
...
@@ -109,7 +110,7 @@ public void ScanResume()
int
snapOffset
=
0
,
snapPageSize
=
0
;
i
=
0
;
var
seq
=
server
.
Keys
(
DB
,
"ScanResume
:*"
,
pageSize
:
15
);
var
seq
=
server
.
Keys
(
DB
,
prefix
+
"
:*"
,
pageSize
:
15
);
foreach
(
var
key
in
seq
)
{
if
(
i
==
57
)
...
...
@@ -131,7 +132,7 @@ public void ScanResume()
Assert
.
Equal
(
12
,
snapOffset
);
Assert
.
Equal
(
15
,
snapPageSize
);
seq
=
server
.
Keys
(
DB
,
"ScanResume
:*"
,
pageSize
:
15
,
cursor
:
snapCursor
,
pageOffset
:
snapOffset
);
seq
=
server
.
Keys
(
DB
,
prefix
+
"
:*"
,
pageSize
:
15
,
cursor
:
snapCursor
,
pageOffset
:
snapOffset
);
var
seqCur
=
(
IScanningCursor
)
seq
;
Assert
.
Equal
(
snapCursor
,
seqCur
.
Cursor
);
Assert
.
Equal
(
snapPageSize
,
seqCur
.
PageSize
);
...
...
StackExchange.Redis.Tests/Sets.cs
View file @
6de5908a
...
...
@@ -17,7 +17,7 @@ public void SScan()
{
var
server
=
GetAnyMaster
(
conn
);
RedisKey
key
=
"a"
;
RedisKey
key
=
Me
()
;
var
db
=
conn
.
GetDatabase
();
db
.
KeyDelete
(
key
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment