我们有一个目前正在开发的项目,我们使用Azure DocumentDb作为数据存储库.它一直很好,我真的很喜欢它如何工作以及它如何实现快速开发,但最近我们的集成测试已经开始失败.
每次测试运行时,我们的集成测试都会在数据库中创建和拆除集合.我想知道它的这个过程是否以某种方式"破坏"了数据库.
我已经将我们的项目剥离到了它的骨架并在这里检查了它:https://github.com/DamianStanger/DocumentDbDemo
当我运行测试时,我收到以下错误:
System.AggregateException : One or more errors occurred.
----> Microsoft.Azure.Documents.DocumentClientException : Message: {"Errors":["Resource with specified id or name already exists"]}
ActivityId: e273b9d6-b571-43d3-9802-c7d7c819a3f0, Request URI: /apps/c9c8f510-0ca7-4702-aa6c-9c596d797367/services/507e2a70-c787-437c-9587-0ff4341bc265/partitions/ae4ca317-e883-4419-84f9-c8d053ffc73d/replicas/131159218637566393p
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at DocumentDbDemo.Data.AggregateRepository.CreateCollectionIfNotExists() in K:\_code\VisualStudio\DocumentDbPerfTests\DocumentDbDemo.Data\AggregateRepository.cs:line 32
at DocumentDbDemo.Data.AggregateRepository..ctor(ConfigFactory configFactory) in K:\_code\VisualStudio\DocumentDbPerfTests\DocumentDbDemo.Data\AggregateRepository.cs:line 19
at DocumentDbDemo.Data.Tests.AggregateRepositoryTests.ShouldReturnNullIfNotFound() in K:\_code\VisualStudio\DocumentDbPerfTests\DocumentDbDemo.Data.Tests\AggregateRepositoryTests.cs:line 24
--DocumentClientException
Run Code Online (Sandbox Code Playgroud)
由AggregateRepository.cs_client.ReadDocumentCollectionAsync内的调用失败引起的.我不明白.代码中的异常是首先检查集合是否存在(它确实存在),然后如果不存在则会创建它.显然,创建将失败,因为集合存在!
第二种类型的失败是:
System.AggregateException : One or more errors occurred.
----> Microsoft.Azure.Documents.DocumentClientException : Message: {"Errors":["Owner resource does not exist"]} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用我的accessKey和secretKey使用curl向我在AWS中的es集群发布请求。我已经通过邮递员成功完成了此操作(详细信息请参见此处),您可以在其中指定 AWS 凭证,但我想使用curl 来完成此操作。邮递员可以为您自动生成您的卷曲请求,但我得到的只是错误。
这是生成的curl请求和响应
curl -X GET \
https://search-00000000000001.eu-west-1.es.amazonaws.com/_cat/indices \
-H 'Authorization: AWS4-HMAC-SHA256 Credential=11111111111111111111/20181119/eu-west-1/es/aws4_request, SignedHeaders=cache-control;content-type;host;postman-token;x-amz-date, Signature=11111111116401882398f46011f14fdb9d55e012a4fb912706d67c1111111111' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: search-00000000000001.eu-west-1.es.amazonaws.com' \
-H 'Postman-Token: 00000000-0000-4001-8006-9291e208a000' \
-H 'X-Amz-Date: 20181119T220000Z' \
-H 'cache-control: no-cache'
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}%
Run Code Online (Sandbox Code Playgroud)
为了保护无辜者,身份证已被更改。
我已经检查了我所有的密钥和区域,就像我说的,这可以通过邮递员进行。是否可以通过curl 使用我的密钥访问此AWS 服务?
我一直在使用mongo 3.2.9安装进行一些实时数据调查.主要的关键是找出文档中缺少数据的记录的一些细节.但我正在运行的查询是在robomongo和指南针中超时.
我有一个包含超过300万条记录的集合(foo).我正在搜索没有barId的所有记录,这是我在mongo上发出的查询:
db.foo.find({barId:{$exists:true}}).explain(true)
Run Code Online (Sandbox Code Playgroud)
从mongo shell这是执行计划(它在robomongo或指南针中超时)
MongoDB Enterprise > db.foo.find({barId:{$exists:true}}).explain(true)
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "myDatabase01.foo",
"indexFilterSet" : false,
"parsedQuery" : {
"barId" : {
"$exists" : true
}
},
"winningPlan" : {
"stage" : "FETCH",
"filter" : {
"barId" : {
"$exists" : true
}
},
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"barId" : 1
},
"indexName" : "barId_1",
"isMultiKey" : false,
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" …Run Code Online (Sandbox Code Playgroud) 我最近在Windows 8机器上使用autoHotKey并喜欢它.但我希望能够按下大写锁定并将键盘转换为vim命令模式,以便在任何程序中轻松移动光标,插入和删除.
更新(感谢@MCL到目前为止的帮助)
我试图使用以下脚本,但它不会根据状态更改行为
state := GetKeyState("Capslock", "T")
if state
j::Send,{Left}
l::Send,{Right}
i::Send,{Up}
k::Send,{Down}
return
Run Code Online (Sandbox Code Playgroud) 问题
如果当前正在测试的方法是通过传入消息(进入处理程序)之外的其他方法启动的,那么如何测试事件的发布。NServiceBus.Testing 的问题(据我所知)是它非常适合测试处理程序,从而导致消息/事件被发送/发布。
背景:
我们有许多遗留系统,在持续努力转向正确的 SOA 实施的过程中,我们需要与一些遗留数据库作业集成。这些作业每 15 分钟对数据库执行一次操作,我们希望在发生某些条件时挂钩并发布事件。
我们有一个在 NsbHost 内运行的 Windows 服务,但不包含任何处理程序。相反,我们使用 Quartz 创建一个每分钟运行一次的内部 cron 作业,轮询数据库以查找与指定模式匹配的记录,并在更新数据库之前发布一个事件,表明我们已经处理了该记录。这就是我们整合新旧系统的方式。
显然,这不是一个理想的情况,但考虑到我们正处于 SOA 实施的过渡阶段,它和我们现在一样好。
详细信息和代码:
我们正在发布的事件界面如下所示
public interface IPremiumAdjustmentFinalised
{
string PolicyNumber { get; set; }
decimal Amount { get; set; }
DateTime FinalisedOn { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
实际发布事件的代码是
Bus.Publish<IPremiumAdjustmentFinalised>(e =>
{
e.Amount = AdjustmentAmount;
e.PolicyNumber = PolicyNumber;
e.FinalisedOn = LastModifiedOn;
});
Run Code Online (Sandbox Code Playgroud)
这一切都工作正常,我们可以测试使用最小起订量进行的调用,如下所示:
eventPublisher.MethodToTest();
bus.Verify(x => x.Publish(It.IsAny<Action<IPremiumAdjustmentFinalised>>()), Times.Once);
Run Code Online (Sandbox Code Playgroud)
其中bus是插入到构造函数中的新Mock。
但我想测试 IPremiumAdjustmentFinalized 中的值。我发现这真的很困难,我认为主要是因为它是一个接口而不是一个具体的类。
我们尝试使用 NServiceBus.Testing 来尝试检查生成的事件,但无济于事。
有谁知道如何在给定场景中测试事件中的值?
我有一个 azure 订阅,其中有超过 200 个 appServices,其中大约一半有连续的,总是在附加的 webJobs 上,有些也有插槽,也有 webJobs。
有没有办法列出订阅中的所有 web 作业?我最初尝试使用 powershell 来执行此操作,但它变得相当复杂,并且想知道是否有人知道实现上述目标的简单方法。
似乎 Get-AzureRmWebApp 应该能够提供帮助,但我找不到列出驻留在 webapp 中的作业的方法。
powershell azure azure-resource-manager azure-web-app-service
我正在尝试使用批量插入 api 进行弹性搜索。我想插入带有自动生成 ID 的文档,但无论我尝试什么,我都会收到错误。
以下是一些示例:
http://localhost:9200/_bulk
{"create": {"_index": "test", "_type": "_doc"} }
{"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}
Run Code Online (Sandbox Code Playgroud)
put 和 post 都会给出错误:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud)
如果我删除 _type _doc 我会收到以下错误:
{
"error": { …Run Code Online (Sandbox Code Playgroud) 当使用ng serve --open --live-reload我的开发机器上的Angular应用程序提供服务,并使用WebStorm更改文件时,WebStorm尝试保存时出现错误“无法保存文件”。
当我在Sublime中编辑文件时,没有任何问题,因此看起来文件没有被锁定ng serve。
开发设置
??? @angular/cli@1.4.9
? ??? @ngtools/webpack@1.7.4
??? @ngtools/webpack@1.7.4ng serve --open --live-reloadwindows node.js webstorm windows-subsystem-for-linux angular
azure ×2
c# ×2
windows ×2
.net ×1
angular ×1
autohotkey ×1
curl ×1
mongodb ×1
moq ×1
node.js ×1
nservicebus ×1
powershell ×1
unit-testing ×1
vim ×1
webstorm ×1