Tag: 压力testing

Nodejs / Express API简单的Mocha / Chaitesting

我正在尝试为我的API构build一个testing集,这个testing集是用nodejs / express和mocha / chai开发的。 基本上,索引返回一个简单的string,我知道它的工作原理,因为我可以在我的浏览器上看到: router.get('/', function(req, res, next) { res.send('Hello World from Eclipse'); }); 然后我按照这个教程来构build这个testing: var supertest = require("supertest"); var should = require("should"); // This agent refers to PORT where program is runninng. var server = supertest.agent("http://localhost:5000"); // UNIT test begin describe("SAMPLE unit test",function(){ // #1 should return home page it("should return home […]

Node.js sinon在并行执行中桩存函数导致失败的testing

我有两个testing用例testing相同的function只是采取两个不同的执行path,所以说明: MyClass.prototype.functionBeingTested = function() { if (this.check1()) { this.isCheck1Called = true; } else if (this.check2()) { this.isCheck1Called = false; } else { … } }; 我的2个testing用例如下: it('should take check1() execution path', function() { var myClass= new MyClass({}, {}, {}); var check1Stub sinon.stub(MyClass.prototype, 'check1'); check1Stub.returns(true); myClass.functionBeingTested(); myClass.isCheck1Called.should.equal(true); }); it('should take check2() execution path', function() { var […]

如何将外部库附加到量angular器configuration文件?

这是图书馆: //library.js var exports = module.exports = {}; exports.login = function(user_login, user_password) { var input; input = element(by.model('loginInfo.login')); input.sendKeys(user_login); expect(input.getAttribute('value')).toBe(user_login); input = element(by.model('loginInfo.password')); input.sendKeys(user_password); expect(input.getAttribute('value')).toBe(user_password); browser.sleep(1000); browser.driver.actions().sendKeys(protractor.Key.ENTER).perform(); browser.sleep(1000); }; 这是我的configuration文件: //config.js var lib = require("./library.js"); exports.config = { directConnect: true, onPrepare: function() { browser.driver.manage().window().maximize(); }, // Capabilities to be passed to the webdriver instance. capabilities: […]

如何提高负载下的ArangoDB性能(多个并发查询)?

我们使用ArangoDB和PostgreSQL来存储几乎相同的数据。 PostgreSQL用于执行关系数据库可以很好地执行的一般types的查询。 selectArangoDB来执行graphics遍历等查询,find最短path等。 目前,我们有一个在PostgreSQL中有160000条logging的表,在ArangoDB中有一个与文档数量相同的集合。 我们正在使用的API将被多个用户同时使用,所以我首先要检查的是ArangoDB和PostgreSQL在负载下如何执行。 我创build了一个简单的负载testing,作为一个工作负载执行一个简单的select查询与filter既ArangoDB和PostgreSQL。 查询使用按date过滤字段select前N个logging/文档。 当我运行负载testing时,对PostgreSQL的所有查询都在0.5秒内执行,我将用户数量从10增加到100,并且完全不影响执行时间。 对于ArangoDB来说,同样的查询需要花费大约2秒钟的时间,然而,响应时间与并发用户的数量成正比。 有30个并发用户,等待60秒后,所有查询都会超时。 我试图debuggingarangojs连接器,发现这一点: var maxTasks = typeof agent.maxSockets === 'number' ? agent.maxSockets * 2 : Infinity; 和这个: Connection.agentDefaults = { maxSockets: 3, keepAlive: true, keepAliveMsecs: 1000 }; 这意味着默认的arangojs行为是同时向ArangoDB发送不超过6个并发查询,这导致所有其余查询在Node.js端排队。 我试图增加数量,但它没有帮助,现在看起来像所有的查询排队在ArandoDB一侧。 现在,如果我运行加载并尝试使用ArangoDB Web Interface执行一些查询,则查询将提交不可预测的时间量(取决于当前用户的数量),然后返回结果并显示它已被执行在大约4秒内这是不正确的。 对我来说,看起来像ArangoDB一次只能执行一个查询,而所有其他查询排队… 我错过了什么吗? 有没有什么设置来调整ArangoDB并提高它在负载下的性能? 更新: 我们使用ArangoDB 3.0,并将其作为Docker容器(来自官方图片)与1.5 GB的RAM一起运行。 样本文件(我们有大约16000个): { "type": "start", "from_date": "2016-07-28T10:22:16.000Z", "to_date": "9999-06-19T18:40:00.000Z", […]

在CentOS 7上的Spectron无头testing不起作用

环境 运行 Vagrant 1.8.4的Mac OSX 10.11.5 运行 Cent OS 7 节点v6.4.0 Npm v3.10.3 电子预制^ 1.2.0 电子包装^ 7.6.0 Spectron v3.3.0 运行testing无头,与Xvfb Xvfb :99 -screen 0 1024x768x24 +extension RANDR & export DISPLAY=':99.0' build立 我git cloned 电子快速启动回购。 然后通过electron-packager . MyApp –platform=linux –arch=x64 –prunebuild立它electron-packager . MyApp –platform=linux –arch=x64 –prune electron-packager . MyApp –platform=linux –arch=x64 –prune (脚本在package.json中) 然后运行test: node test_app.js […]

Sinon stubbing函数作为parameter passing

我有以下的示例类: function Example() {…} Example.prototype.someFunc1() {…} Example.prototype.someFunc2() {…} Example.prototype.func(func) {var res = func(); …} 我通常调用Example#func() ,如下所示: var example = new Example(); example.func(example.someFunc1) // or like this, depending on what I want example.func(example.someFunc2) 现在我在我的testing中存根Example#someFunc1()如下: var example = new Example(); sinon.stub(example, 'someFunc1').returns(…); exmaple.func(example.someFunc1); 问题是Example#someFunc1()没有被这种方式存根并被正常调用。 在这种情况下我能做些什么?

build立在TFS上想从Node.jstesting项目复制一个可执行文件

我使用Node.js工具为一个量angular器testing环境创build了一个Node.js项目来testing团队基础服务器上的一个Web应用程序。 在本地我可以创buildtesting项目并使用debugging器运行它。 但是,TFS上的构build不起作用。 日志: "<PATH>\TestProject.Web.Protractor.Tests.njsproj" (13) on node 2 (default targets). 13>PrepareForBuild: Creating directory "obj\Debug\". CoreCompile: Creating directory "bin". Copying file from "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Node.js Tools\Microsoft.NodejsTools.WebRole.dll" to "bin\Microsoft.NodejsTools.WebRole.dll". _CopyWebApplicationLegacy: Copying Web Application Project Files for TestProject.Web.Protractor.Tests Creating directory "<PATH>\bin\_PublishedWebsites\TestProject.Web.Protractor.Tests\bin". 13>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets(136,5): error MSB3030: Could not copy the file "obj\Debug\TestProject.Web.Protractor.Tests.exe" because it was not found.

NemoJs vs NightWatchJS? 的优点和缺点

我对这两个框架都非常陌生。 看起来像nightwatch有更好的文件和广泛的API相比,尼莫? 相互使用的主要优点是什么?

使用mocha / chai来确保REST API提供一个文件?

我想validation一个调用我的REST API的端点之一是提供一个文件,但我不知道如何去做,我没有看到任何这方面的例子? 我看过文档 ,但是这对我没有多大帮助。 服务器端代码本质上是(在Express中): handleRetrieveContent(req, res, next) { const filepaht = '…'; res.sendFile(filepath) } 和testing案例: it('Should get a file', (done) => { chai.request(url) .get('/api/exercise/1?token=' + token) .end(function(err, res) { if (err) { done(err); } res.should.have.status(200); // Not sure what the test here should be? res.should.be.json; // TODO get access to saved file and do […]

如何设置不同testing级别的testing代码覆盖率?

我使用nyc来生成代码覆盖率报告。 我用我的testing不同的水平。 我如何合并来自不同级别的报告? 有我的package.json的一部分 "scripts": { "test": "npm run test:unit && npm run test:component", "test:component": "nyc mocha ./test/component", "test:unit": "nyc mocha ./test/unit" }, "nyc": { "extension": [ ".ts" ], "cache": true, "reporter": [ "lcov", "text-summary" ] }