Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
3bbde1ff
R
runtime
项目概览
dotNET Platform
/
runtime
11 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3bbde1ff
编写于
6月 16, 2021
作者:
M
Miha Zupan
提交者:
GitHub
6月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't use a remote server in SendAsync_HttpTracingEnabled_Succeeds (#54240)
上级
00024ea6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
33 deletion
+15
-33
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
...System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
+15
-33
未找到文件。
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
浏览文件 @
3bbde1ff
...
@@ -17,8 +17,6 @@
...
@@ -17,8 +17,6 @@
namespace
System.Net.Http.Functional.Tests
namespace
System.Net.Http.Functional.Tests
{
{
using
Configuration
=
System
.
Net
.
Test
.
Common
.
Configuration
;
public
abstract
class
DiagnosticsTest
:
HttpClientHandlerTestBase
public
abstract
class
DiagnosticsTest
:
HttpClientHandlerTestBase
{
{
private
const
string
EnableActivityPropagationEnvironmentVariableSettingName
=
"DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION"
;
private
const
string
EnableActivityPropagationEnvironmentVariableSettingName
=
"DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION"
;
...
@@ -163,14 +161,17 @@ public void SendAsync_ExpectedDiagnosticSourceNoLogging()
...
@@ -163,14 +161,17 @@ public void SendAsync_ExpectedDiagnosticSourceNoLogging()
},
UseVersion
.
ToString
(),
TestAsync
.
ToString
()).
Dispose
();
},
UseVersion
.
ToString
(),
TestAsync
.
ToString
()).
Dispose
();
}
}
[
ActiveIssue
(
"https://github.com/dotnet/runtime/issues/1477"
,
TestPlatforms
.
AnyUnix
)]
[
OuterLoop
(
"Uses external servers"
)]
[
ConditionalTheory
(
typeof
(
RemoteExecutor
),
nameof
(
RemoteExecutor
.
IsSupported
))]
[
ConditionalTheory
(
typeof
(
RemoteExecutor
),
nameof
(
RemoteExecutor
.
IsSupported
))]
[
InlineData
(
false
)]
[
InlineData
(
false
)]
[
InlineData
(
true
)]
[
InlineData
(
true
)]
public
void
SendAsync_HttpTracingEnabled_Succeeds
(
bool
useSsl
)
public
void
SendAsync_HttpTracingEnabled_Succeeds
(
bool
useSsl
)
{
{
RemoteExecutor
.
Invoke
(
async
(
useVersion
,
useSslString
)
=>
if
(
useSsl
&&
UseVersion
==
HttpVersion
.
Version20
&&
!
PlatformDetection
.
SupportsAlpn
)
{
return
;
}
RemoteExecutor
.
Invoke
(
async
(
useVersion
,
useSsl
,
testAsync
)
=>
{
{
using
(
var
listener
=
new
TestEventListener
(
"Private.InternalDiagnostics.System.Net.Http"
,
EventLevel
.
Verbose
))
using
(
var
listener
=
new
TestEventListener
(
"Private.InternalDiagnostics.System.Net.Http"
,
EventLevel
.
Verbose
))
{
{
...
@@ -178,28 +179,10 @@ public void SendAsync_HttpTracingEnabled_Succeeds(bool useSsl)
...
@@ -178,28 +179,10 @@ public void SendAsync_HttpTracingEnabled_Succeeds(bool useSsl)
await
listener
.
RunWithCallbackAsync
(
events
.
Enqueue
,
async
()
=>
await
listener
.
RunWithCallbackAsync
(
events
.
Enqueue
,
async
()
=>
{
{
// Exercise various code paths to get coverage of tracing
// Exercise various code paths to get coverage of tracing
using
(
HttpClient
client
=
CreateHttpClient
(
useVersion
))
await
GetFactoryForVersion
(
useVersion
).
CreateClientAndServerAsync
(
{
async
uri
=>
await
GetAsync
(
useVersion
,
testAsync
,
uri
),
// Do a get to a loopback server
async
server
=>
await
server
.
HandleRequestAsync
(),
await
LoopbackServer
.
CreateServerAsync
(
async
(
server
,
url
)
=>
options
:
new
GenericLoopbackOptions
{
UseSsl
=
bool
.
Parse
(
useSsl
)
});
{
await
TestHelper
.
WhenAllCompletedOrAnyFailed
(
server
.
AcceptConnectionSendResponseAndCloseAsync
(),
client
.
GetAsync
(
url
));
});
// Do a post to a remote server
byte
[]
expectedData
=
Enumerable
.
Range
(
0
,
20000
).
Select
(
i
=>
unchecked
((
byte
)
i
)).
ToArray
();
Uri
remoteServer
=
bool
.
Parse
(
useSslString
)
?
Configuration
.
Http
.
SecureRemoteEchoServer
:
Configuration
.
Http
.
RemoteEchoServer
;
var
content
=
new
ByteArrayContent
(
expectedData
);
content
.
Headers
.
ContentMD5
=
TestHelper
.
ComputeMD5Hash
(
expectedData
);
using
(
HttpResponseMessage
response
=
await
client
.
PostAsync
(
remoteServer
,
content
))
{
Assert
.
Equal
(
HttpStatusCode
.
OK
,
response
.
StatusCode
);
}
}
});
});
// We don't validate receiving specific events, but rather that we do at least
// We don't validate receiving specific events, but rather that we do at least
...
@@ -209,7 +192,7 @@ public void SendAsync_HttpTracingEnabled_Succeeds(bool useSsl)
...
@@ -209,7 +192,7 @@ public void SendAsync_HttpTracingEnabled_Succeeds(bool useSsl)
ev
=>
ev
.
EventId
==
0
);
// make sure there are no event source error messages
ev
=>
ev
.
EventId
==
0
);
// make sure there are no event source error messages
Assert
.
InRange
(
events
.
Count
,
1
,
int
.
MaxValue
);
Assert
.
InRange
(
events
.
Count
,
1
,
int
.
MaxValue
);
}
}
},
UseVersion
.
ToString
(),
useSsl
.
ToString
()).
Dispose
();
},
UseVersion
.
ToString
(),
useSsl
.
ToString
()
,
TestAsync
.
ToString
()
).
Dispose
();
}
}
[
ConditionalFact
(
typeof
(
RemoteExecutor
),
nameof
(
RemoteExecutor
.
IsSupported
))]
[
ConditionalFact
(
typeof
(
RemoteExecutor
),
nameof
(
RemoteExecutor
.
IsSupported
))]
...
@@ -979,11 +962,10 @@ private static void AssertHeadersAreInjected(HttpRequestData request, Activity p
...
@@ -979,11 +962,10 @@ private static void AssertHeadersAreInjected(HttpRequestData request, Activity p
private
static
async
Task
<(
HttpRequestMessage
,
HttpResponseMessage
)>
GetAsync
(
string
useVersion
,
string
testAsync
,
Uri
uri
,
CancellationToken
cancellationToken
=
default
)
private
static
async
Task
<(
HttpRequestMessage
,
HttpResponseMessage
)>
GetAsync
(
string
useVersion
,
string
testAsync
,
Uri
uri
,
CancellationToken
cancellationToken
=
default
)
{
{
using
HttpClient
client
=
CreateHttpClient
(
useVersion
);
HttpClientHandler
handler
=
CreateHttpClientHandler
(
useVersion
);
var
request
=
new
HttpRequestMessage
(
HttpMethod
.
Get
,
uri
)
handler
.
ServerCertificateCustomValidationCallback
=
TestHelper
.
AllowAllCertificates
;
{
using
var
client
=
new
HttpClient
(
handler
);
Version
=
Version
.
Parse
(
useVersion
)
var
request
=
CreateRequest
(
HttpMethod
.
Get
,
uri
,
Version
.
Parse
(
useVersion
),
exactVersion
:
true
);
};
return
(
request
,
await
client
.
SendAsync
(
bool
.
Parse
(
testAsync
),
request
,
cancellationToken
));
return
(
request
,
await
client
.
SendAsync
(
bool
.
Parse
(
testAsync
),
request
,
cancellationToken
));
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录