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
2777240f
Commit
2777240f
authored
Aug 10, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
record failure logs even if none passed in
parent
6a340235
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
52 deletions
+65
-52
TestBase.cs
StackExchange.Redis.Tests/TestBase.cs
+65
-52
No files found.
StackExchange.Redis.Tests/TestBase.cs
View file @
2777240f
...
...
@@ -203,68 +203,81 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer)
string
configuration
=
null
,
[
CallerMemberName
]
string
caller
=
null
)
{
configuration
=
configuration
??
GetConfiguration
();
var
config
=
ConfigurationOptions
.
Parse
(
configuration
);
if
(
disabledCommands
!=
null
&&
disabledCommands
.
Length
!=
0
)
StringWriter
localLog
=
null
;
if
(
log
==
null
)
{
config
.
CommandMap
=
CommandMap
.
Create
(
new
HashSet
<
string
>(
disabledCommands
),
false
);
log
=
localLog
=
new
StringWriter
(
);
}
else
if
(
enabledCommands
!=
null
&&
enabledCommands
.
Length
!=
0
)
try
{
config
.
CommandMap
=
CommandMap
.
Create
(
new
HashSet
<
string
>(
enabledCommands
),
true
);
}
configuration
=
configuration
??
GetConfiguration
();
var
config
=
ConfigurationOptions
.
Parse
(
configuration
);
if
(
disabledCommands
!=
null
&&
disabledCommands
.
Length
!=
0
)
{
config
.
CommandMap
=
CommandMap
.
Create
(
new
HashSet
<
string
>(
disabledCommands
),
false
);
}
else
if
(
enabledCommands
!=
null
&&
enabledCommands
.
Length
!=
0
)
{
config
.
CommandMap
=
CommandMap
.
Create
(
new
HashSet
<
string
>(
enabledCommands
),
true
);
}
if
(
Debugger
.
IsAttached
)
{
syncTimeout
=
int
.
MaxValue
;
}
if
(
Debugger
.
IsAttached
)
{
syncTimeout
=
int
.
MaxValue
;
}
if
(
channelPrefix
!=
null
)
config
.
ChannelPrefix
=
channelPrefix
;
if
(
tieBreaker
!=
null
)
config
.
TieBreaker
=
tieBreaker
;
if
(
password
!=
null
)
config
.
Password
=
string
.
IsNullOrEmpty
(
password
)
?
null
:
password
;
if
(
clientName
!=
null
)
config
.
ClientName
=
clientName
;
else
if
(
caller
!=
null
)
config
.
ClientName
=
caller
;
if
(
syncTimeout
!=
null
)
config
.
SyncTimeout
=
syncTimeout
.
Value
;
if
(
allowAdmin
!=
null
)
config
.
AllowAdmin
=
allowAdmin
.
Value
;
if
(
keepAlive
!=
null
)
config
.
KeepAlive
=
keepAlive
.
Value
;
if
(
connectTimeout
!=
null
)
config
.
ConnectTimeout
=
connectTimeout
.
Value
;
if
(
proxy
!=
null
)
config
.
Proxy
=
proxy
.
Value
;
var
watch
=
Stopwatch
.
StartNew
();
var
task
=
ConnectionMultiplexer
.
ConnectAsync
(
config
,
log
);
if
(!
task
.
Wait
(
config
.
ConnectTimeout
>=
(
int
.
MaxValue
/
2
)
?
int
.
MaxValue
:
config
.
ConnectTimeout
*
2
))
{
task
.
ContinueWith
(
x
=>
if
(
channelPrefix
!=
null
)
config
.
ChannelPrefix
=
channelPrefix
;
if
(
tieBreaker
!=
null
)
config
.
TieBreaker
=
tieBreaker
;
if
(
password
!=
null
)
config
.
Password
=
string
.
IsNullOrEmpty
(
password
)
?
null
:
password
;
if
(
clientName
!=
null
)
config
.
ClientName
=
clientName
;
else
if
(
caller
!=
null
)
config
.
ClientName
=
caller
;
if
(
syncTimeout
!=
null
)
config
.
SyncTimeout
=
syncTimeout
.
Value
;
if
(
allowAdmin
!=
null
)
config
.
AllowAdmin
=
allowAdmin
.
Value
;
if
(
keepAlive
!=
null
)
config
.
KeepAlive
=
keepAlive
.
Value
;
if
(
connectTimeout
!=
null
)
config
.
ConnectTimeout
=
connectTimeout
.
Value
;
if
(
proxy
!=
null
)
config
.
Proxy
=
proxy
.
Value
;
var
watch
=
Stopwatch
.
StartNew
();
var
task
=
ConnectionMultiplexer
.
ConnectAsync
(
config
,
log
);
if
(!
task
.
Wait
(
config
.
ConnectTimeout
>=
(
int
.
MaxValue
/
2
)
?
int
.
MaxValue
:
config
.
ConnectTimeout
*
2
))
{
t
ry
t
ask
.
ContinueWith
(
x
=>
{
GC
.
KeepAlive
(
x
.
Exception
);
}
catch
{
}
},
TaskContinuationOptions
.
OnlyOnFaulted
);
throw
new
TimeoutException
(
"Connect timeout"
);
}
watch
.
Stop
();
if
(
Output
==
null
)
{
Assert
.
True
(
false
,
"Failure: Be sure to call the TestBase constuctor like this: BasicOpsTests(ITestOutputHelper output) : base(output) { }"
);
try
{
GC
.
KeepAlive
(
x
.
Exception
);
}
catch
{
}
},
TaskContinuationOptions
.
OnlyOnFaulted
);
throw
new
TimeoutException
(
"Connect timeout"
);
}
watch
.
Stop
();
if
(
Output
==
null
)
{
Assert
.
True
(
false
,
"Failure: Be sure to call the TestBase constuctor like this: BasicOpsTests(ITestOutputHelper output) : base(output) { }"
);
}
Log
(
"Connect took: "
+
watch
.
ElapsedMilliseconds
+
"ms"
);
var
muxer
=
task
.
Result
;
if
(
checkConnect
&&
(
muxer
==
null
||
!
muxer
.
IsConnected
))
{
// If fail is true, we throw.
Assert
.
False
(
fail
,
failMessage
+
"Server is not available"
);
Skip
.
Inconclusive
(
failMessage
+
"Server is not available"
);
}
muxer
.
InternalError
+=
OnInternalError
;
muxer
.
ConnectionFailed
+=
OnConnectionFailed
;
muxer
.
MessageFaulted
+=
(
msg
,
ex
,
origin
)
=>
Writer
?.
WriteLine
(
$"Faulted from '
{
origin
}
': '
{
msg
}
' - '
{(
ex
==
null
?
"(null)"
:
ex
.
Message
)}
'"
);
muxer
.
Connecting
+=
(
e
,
t
)
=>
Writer
.
WriteLine
(
$"Connecting to
{
Format
.
ToString
(
e
)}
as
{
t
}
"
);
muxer
.
TransactionLog
+=
msg
=>
{
lock
(
Writer
)
{
Writer
.
WriteLine
(
"tran: "
+
msg
);
}
};
muxer
.
Resurrecting
+=
(
e
,
t
)
=>
Writer
.
WriteLine
(
$"Resurrecting
{
Format
.
ToString
(
e
)}
as
{
t
}
"
);
muxer
.
Closing
+=
complete
=>
Writer
.
WriteLine
(
complete
?
"Closed"
:
"Closing..."
);
return
muxer
;
}
Log
(
"Connect took: "
+
watch
.
ElapsedMilliseconds
+
"ms"
);
var
muxer
=
task
.
Result
;
if
(
checkConnect
&&
(
muxer
==
null
||
!
muxer
.
IsConnected
))
catch
{
// If fail is true, we throw.
Assert
.
False
(
fail
,
failMessage
+
"Server is not available"
);
Skip
.
Inconclusive
(
failMessage
+
"Server is not available"
);
if
(
localLog
!=
null
)
Output
?.
WriteLine
(
localLog
.
ToString
());
throw
;
}
muxer
.
InternalError
+=
OnInternalError
;
muxer
.
ConnectionFailed
+=
OnConnectionFailed
;
muxer
.
MessageFaulted
+=
(
msg
,
ex
,
origin
)
=>
Writer
?.
WriteLine
(
$"Faulted from '
{
origin
}
': '
{
msg
}
' - '
{(
ex
==
null
?
"(null)"
:
ex
.
Message
)}
'"
);
muxer
.
Connecting
+=
(
e
,
t
)
=>
Writer
.
WriteLine
(
$"Connecting to
{
Format
.
ToString
(
e
)}
as
{
t
}
"
);
muxer
.
TransactionLog
+=
msg
=>
{
lock
(
Writer
)
{
Writer
.
WriteLine
(
"tran: "
+
msg
);
}
};
muxer
.
Resurrecting
+=
(
e
,
t
)
=>
Writer
.
WriteLine
(
$"Resurrecting
{
Format
.
ToString
(
e
)}
as
{
t
}
"
);
muxer
.
Closing
+=
complete
=>
Writer
.
WriteLine
(
complete
?
"Closed"
:
"Closing..."
);
return
muxer
;
}
public
static
string
Me
([
CallerFilePath
]
string
filePath
=
null
,
[
CallerMemberName
]
string
caller
=
null
)
=>
...
...
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