I am required to simulate a file transfer from a location on premise to a location on the cloud or let say any other location.
I have to transfer close to 11 K files at a rate of 3 file per second and if required increase the rate of file transfer to find at what rate the system breaks
This kind of loading and throttling is easy with Jmeter OS sampler but there are issues with the sampler in my case because I am first calling an exe which is kind of parametrized and prompts for a confirmation when executed.
With Jmeter OS sampler I am not able to handle the user input and I used the correct method tested with other command to suppress the prompt.
But I think because of the EXE I am not able to suppress the prompt with OS sampler
With OS sampler it was quite easy I just had to specify the command, parametrize the file name and generate the UUID on the go and just trigger the command.
I could also control the throughput with Jmeter and control the file transfer rate, but the approach with jmeter is out of question as it simply does not work and gets stuck waiting for user input!
Towards the end I decided an approach with PowerShell script which when executed works perfectly but I am not an expert and I have created a parametrized PowerShell script as below with some guidance
param(
[string]$fileName,
[string]$uuid
)
$myshell = New-Object -com "Wscript.Shell"
$myshell.sendKeys("y")
$myshell.sendKeys("{Enter}")
.\BlobFileUpload.exe .\$fileName "4f21-8c7e-45fe9b515a7f/$uuid" "routeid" "/$fileName" "inbox" <Azure Blob SAS url>
The way to execute this scrip is:- .\script-1.ps1 -uuid uuid1 -fileName file1 from the prompt
This code works perfectly but now I need help to pass the file name and UUID from a CSV file and a way to execute this code based on the loop count I specify and in multiple PowerShell window (for example 2 or 3 parallel execution but should pick unique file names and UUID from CSV)
Looking forward to suggestions or links to code snippets I can use to crack this one. Thanks
CodePudding user response:
It sounds like you want a poor man's template engine. I have written such a tool.
Here's what I mean:
Supposing you started with a template file that looks like this:
& .\script-1.ps1 -uuid $uuid -fileName $file
I'm not sure about the ampersand, but if that turns out to be unnecessary, just get rid of it.
Now suppose you had a csv file that looks like this:
uuid,file
uuid1,file1
uuid2,file2
uuid3,file3
You would use my template engine like this:
Expand-csv bloblist.csv bloblist.tmplt > bloblist.ps1
And you would produce the following:
& .\script-1.ps1 -uuid uuid1 -fileName file1
& .\script-1.ps1 -uuid uuid2 -fileName file2
& .\script-1.ps1 -uuid uuid3 -fileName file3
Now this isn't exactly what you were asking about, because this creates an expansion of the template for the entire csv file. But maybe you could write code that reads in the entire csv file and then lets the user select a subset to write out to a smaller csv file that could be used with Expand-csv
And finally, here is Expand-Csv itself:
<#
.NOTES
Script: Expand-Csv Rev: 3.2
By: DGC Date: 2-21-19
.SYNOPSIS
Generates multiple expansions of a template,
driven by data in a CSV file.
.DESCRIPTION
This function is a table driven template tool.
It generates output from a template and
a driver table. The template file contains plain
text and embedded variables. The driver table
(in a csv file) has one column for each variable,
and one row for each expansion to be generated.
#>
function Expand-csv {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)] [string] $driver,
[Parameter(Mandatory=$true)] [string] $template
)
Process {
Import-Csv $driver | % {
$_.psobject.properties | % {Set-variable -name $_.name -value $_.value}
Get-Content $template | % {$ExecutionContext.InvokeCommand.ExpandString($_)}
}
}
}
CodePudding user response:
Passing command line arguments and inputs is a feature of shell, JMeter has nothing to do about it.
I don't have powershell installed, in "normal"
In JMeter's OS Process Sampler you can achieve the same by using the following configuration:
If you want to parameterize the input with the values from the CSV file - go for
Looking here in powershell you can play the same trick but you won't need to invoke echo command.