docker - PACT.Net 无法分配请求的地址
问题描述
我目前正在尝试在 docker 容器中运行我的 pact.net 示例测试,但是我收到以下错误:
Starting test execution, please wait...
pact-consumer-tests | [xUnit.net 00:00:19.9436627]
pact_consumer.tests.AddConsumerTest.Add_customer [FAIL]
pact-consumer-tests | Failed
pact_consumer.tests.AddConsumerTest.Add_customer
pact-consumer-tests | Error Message:
pact-consumer-tests | System.AggregateException : One or more errors
occurred. (One or more errors occurred. (Cannot assign requested
address)) (The following constructor parameters did not have matching
fixture data: ConsumerApiPact data)
pact-consumer-tests | ---- System.AggregateException : One or more
errors occurred. (Cannot assign requested address)
pact-consumer-tests | -------- System.Net.Http.HttpRequestException :
Cannot assign requested address
pact-consumer-tests | ------------ System.Net.Sockets.SocketException
: Cannot assign requested address
pact-consumer-tests | ---- The following constructor parameters did
not have matching fixture data: ConsumerApiPact data
pact-consumer-tests | Stack Trace:
pact-consumer-tests |
pact-consumer-tests | ----- Inner Stack Trace #1
(System.AggregateException) -----
pact-consumer-tests | at
PactNet.Mocks.MockHttpService.Host.RubyHttpHost.Start() in
C:\projects\pact-
net\PactNet\Mocks\MockHttpService\Host\RubyHttpHost.cs:line 65
pact-consumer-tests | at PactNet.PactBuilder.MockService(Int32
port, JsonSerializerSettings jsonSerializerSettings, Boolean enableSsl,
IPAddress host) in C:\projects\pact-net\PactNet\PactBuilder.cs:line 82
pact-consumer-tests | at
pact_consumer.tests.context.ConsumerApiPact..ctor() in /app/pact-
consumer.tests/context/ConsumerApiPact.cs:line 27
pact-consumer-tests | ----- Inner Stack Trace -----
pact-consumer-tests | at
System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,
CancellationToken cancellationToken)
....
无论我发送到 Host IPAddress.Any AND IpAddress.Loopback 的框架中,但我似乎仍然遇到这个问题?
我错过了什么吗?它在没有其他服务运行的 docker 容器中运行..
我可以在 OSX 上运行它dotnet test
,一切都很好。
提前谢谢了
理查德
解决方案
System.Net.Sockets.SocketException : Cannot assign requested address
绝对看起来系统无法绑定到端口 - 您确定主机上的端口可用(不仅仅是 Docker 容器)?
推荐阅读
- c# - 没有使用'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' asp.net core 3.1找到构造函数
- python - Python正则表达式查找多行
- java - Spring Bean中的ScheduledExecutorService,在几次执行后不起作用
- sencha-test - 清除 ST.future.Component 的预填充数据的方法
- reactjs - Nextjs 中的路由器
- spring - 处理器出错时如何停止Spring批处理作业
- python - 在 Python 中给出不同 p 值的比例与偶然卡方检验
- javascript - JavaScript 下拉框问题 - 数组映射不起作用
- python - 正则表达式模式在剥离结束标点符号的同时标记句子?
- java - Java - 从不同目录中的另一个包导入类