如何在多个用户之间拆分CSV文件& JMeter中用于分布式测试的辅助机器

7fyelxc5  于 2023-06-27  发布在  其他
关注(0)|答案(1)|浏览(86)

如何在多个用户之间拆分CSV文件&在JMeter中为分布式测试从机器。我的CSV文件有10,000行测试数据,我们希望在400个用户之间共享它,包括主机和8个从机。
如何才能实现以上几点

nxagd54h

nxagd54h1#

根据您使用的操作系统:
对于Windows,您可以使用followingPowershell脚本:

# variable used to store the path of the source CSV file
$sourceCSV = <path of source CSV> ;

# variable used to advance the number of the row from which the export starts
$startrow = 0 ;

# counter used in names of resulting CSV files
$counter = 1 ;

# setting the while loop to continue as long as the value of the $startrow variable is smaller than the number of rows in your source CSV file
while ($startrow -lt <total number of rows in source CSV>)
{

# import of however many rows you want the resulting CSV to contain starting from the $startrow position and export of the imported content to a new file
Import-CSV $sourceCSV | select-object -skip $startrow -first <number of rows in resulting CSV> | Export-CSV "<resulting CSV filepath>$($counter).csv" -NoClobber;

# advancing the number of the row from which the export starts
$startrow += <number of rows in resulting CSV> ;

# incrementing the $counter variable
$counter++ ;

}

对于Unix和衍生版本,您可以使用split命令

split -l 1250 file.csv splitted

或者,你可以选择i.e. HTTP Simple Table Server,在这种情况下,您将不必拆分文件,并且您将能够将其加载到一台机器上,并通过HTTP提供给从属设备。HTTP Simple Table Server可以使用JMeter Plugins Manager安装

相关问题