如何为Visual Studio云测试的每个核心代理使用不同的.csv? [英] How to use different .csv for each core agent for Visual Studio Cloud Testing?

查看:390
本文介绍了如何为Visual Studio云测试的每个核心代理使用不同的.csv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Visual Studio Cloud测试执行简单的REST API负载测试: https://www.visualstudio.com/en-us/docs/test/performance-testing/getting-started/getting-started-with-performance - 测试

I'm trying to execute simple REST API load test with Visual Studio Cloud Test: https://www.visualstudio.com/en-us/docs/test/performance-testing/getting-started/getting-started-with-performance-testing

请求包含授权令牌,我使用预先生成的.csv数据源来提供它们。以下是说明: https://msdn.microsoft.com/library/ms243142.aspx

The request contains authorization token and I use pre-generated .csv data source to supply them. Here is the description: https://msdn.microsoft.com/library/ms243142.aspx

从本地计算机运行测试一切正常,但当我从云开始测试时,97%的测试失败。

When run the test from local machine everything works just fine, but when I start the test from cloud 97% of tests are failing.

因为我的服务有并发检查 - 一个令牌可以用来只做一个请求。似乎测试是从20个代理机器在云中运行,并且他们都使用相同的.csv数据源。

Because my service has concurrency check - one token can be used to make only one request. An it seems the test is running from 20 agent machines in cloud and all of them use the same .csv data source.

我想知道是否有一种方式,我可以传播每个云代理的不同数据源?

I wonder if there is a way where I can spread the different data sources per cloud agent?

推荐答案

根据您的注释,数据源访问方法 unique 不能用于VSTS CLOUD负载测试。

As per your comment, the data source access method of unique cannot be used with a VSTS CLOUD load test.

一种可能:您生成的令牌包括代理号码如果是,那么您可以使用包含基于以下代码的插件:

One possibility: Can the tokens you generate include the agent number (AgentID) ? If yes then you might use a plugin containing code based on:

string tokenFromCSV = e.WebTest.Context["DataSource1.file#csv.token"].ToString();
string agentId = e.WebTest.Context["AgentId"].ToString();
if(agentId.Length==1) agentId = "0" + agentId;
string tokenToUse = tokenFromCSV + agentId;
e.WebTest.Context["tokenToUse"] = tokenToUse;

然后,在当前使用CSV文件中的令牌的地方,使用新写入的上下文参数 tokenToUse 。还有很多其他方法可以将agent-id合并到令牌值中。

Then in the places that currently use the token from the CSV file, use the newly written context parameter tokenToUse. There are many other ways that the agent-id could be merged into the token value.

另一种可能性。如果从不超过20(或一些其他不太大数量)代理使用,则生成包含20列令牌值的CSV。列名称包含代理程序编号,然后让每个代理仅使用其列中的值。这可能需要一个插件来访问正确的列并将值存储到上下文参数中。

Another possibility. If there are never more than 20 (or some other not-too-large number of) agents used then generate a CSV containing 20 columns of token values. Have the column names contain the agent number and then let each agent only use the values from its column. This would probably need a plugin to access the correct column and store the value into a context parameter.

另一种可能性。如果CSV中的行数可以是测试中虚拟用户数的几倍。我想到的是至少10倍,但比例越大越好。将CSV访问方法设置为 Random 。然后,测试应该主要使用令牌,一次只能被一个测试使用。将有一些双重用途,因此测试失败,但您的客户可能会接受该级别的失败。

Another possibility. If the number of lines in the CSV can be several times bigger than the number of virtual users in the test. I am thinking of at least 10 times as many, but the bigger the ratio the better. The set the CSV access method to Random. The tests should then mostly run with tokens only being used by one test at a time. There will be some dual uses and hence test failures but your customer might accept that level of failures.

这篇关于如何为Visual Studio云测试的每个核心代理使用不同的.csv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆