Toad World® Forums

BMF Job Post route doesn't "check" agents??


#1

When running the REST route to add a job it doesn’t “check” the agents for usage with the job if I add them to the user_agent key. Using the post route for the job to add agents it will correctly check the keys.

This works:

$agentHash = @{
classname= “CUserAgent”
host= “10.108.4.150”
username= “administrator”
password= “ssdrive01”
session_cred= 0
version= “”
os= “Microsoft Windows 10 Pro”
processor= “Intel® Xeon® CPU E5-2630 v3 @ 2.40GHz”
no_core= 0
no_cpus= 1
physical_memory= 12884430848.0
virtual_memory= 0.0
disk_size= 33494659072.0
disk_free_size= 5140746240.0
number_of_agent= 5
max_virtual_user= 0
checked= 1
flags= 0
address_width= 0
}

Invoke-RestMethod -Method Post -Uri "localhost:30110/…/agents" -Body ($agentHash | ConvertTo-Json -Depth 12 -Compress)

But adding the same agent information to the user_agent key within the job post method does not.

Invoke-RestMethod -Method Post -Uri ""localhost:30110/…/jobs" -ContentType ‘application/json’ -Body ($baseJobJSON | ConvertTo-Json -Depth 12 -Compress)

Not sure what i’m doing wrong as the other route works fine. Thanks for any assistance on this.


#2

Hi can you please post your body $baseJobJSON, so can check what’s happen here.


#3

I have since changed my code to use the individual agent add as it correctly does the checked and selects that agent for the job. Prior to that i was adding the above agent JSON to the agent_list.

Powershell code I was trying to use (latest i’m using now i’m just using the agent add route):


param(

[Parameter(Mandatory=$true)]

[array]$agentAddresses,

[Parameter(Mandatory=$true)]

[array]$sqlServerAddresses,

[int]$numberOfAgents = 5,

[int]$jobsToRun = $sqlServerAddresses.count,

[int]$agentMachinesPerSQLServer = 2,

[string]$baseJobJSONPath = “\configs\benchmarkfactory\BMFJobJSON.json”,

[string]$restServer = 'http://localhost:30110/api’

)

$ErrorActionPreference = ‘stop’

#Append the script path to the base json config path TODO figure out why it won’t take it as a param?

$baseJobJSONPath = $PSScriptRoot + $baseJobJSONPath

variable initialization

$agentCounter = 0

$agentHash = @{

classname= “CUserAgent”

host= “10.108.1.241”

username= “ssdrive”

session_cred= 0

version= “”

os= “Microsoft Windows 10 Pro”

processor= “Intel® Xeon® CPU E5-2630 v3 @ 2.40GHz”

no_core= 0

no_cpus= 4

physical_memory= 6441979904.0

virtual_memory= 0.0

disk_size= 135838822400.0

disk_free_size= 113495097344.0

number_of_agent= 5

max_virtual_user= 0

checked= 1

flags= 0

address_width= 0

}

$connectionHash = @{

connectiontype= “SQLServerODBC”

name= “MSSQL_10.108.3.176_ODBC”

username= “sa”

datasourcename= “10.108.3.176_ODBC”

infinitetimeout= $false

timeout= 60

reconnectoption= @{

enabled= $false

numberofretry= 3

retryinterval= 10

}

customproperties= @()

serverproperties= @()

}

load the base REST request content for creating the job(s)

$baseJobJSON = get-content $baseJobJSONPath | convertfrom-json

check if the user DSNs exist

$DSNs = Get-OdbcDsn

foreach($sqlServerAddress in $sqlServerAddresses)

{

if(!($DSNs.name.contains("$($sqlServerAddress)_ODBC")))

{

Add-OdbcDsn -Name “$($sqlServerAddress)_ODBC” -DsnType User -DriverName ‘SQL Server’ -SetPropertyValue “Server=$sqlServerAddress”

Set-OdbcDsn -name “$($sqlServerAddress)_ODBC” -DsnType User -DriverName ‘SQL Server’ -SetPropertyValue ‘Database=BMF_1’

}

}

build the REST objects and add them to the job to configure it for the given database/agents

for($i =0;$i -lt $sqlServerAddresses.Count; $i++)

{

create the agent list with the first one being the BMF host?? TODO Not sure how to remove/configure without it yet.

$userAgentArray = @(

@{

classname= “CUserAgent”

host= “$env:COMPUTERNAME”

username= “”

session_cred= 1

version= “”

os= “Microsoft Windows10”

processor= “Intel® Xeon® CPU E5620 @ 2.40GHz - 2 CPU(s)”

no_core= 0

no_cpus= 0

physical_memory= 8586817536.0

virtual_memory= 0.0

disk_size= 135180320768.0

disk_free_size= 61427679232.0

number_of_agent= 1

max_virtual_user= 0

checked= 0

flags= 0

address_width= 0

}

)

Agents – Create the amount that is specified per SQL instance for the job

for($j=0;$j -lt $agentMachinesPerSQLServer; $j++)

{

$tempAgent = $agentHash.Clone()

$tempAgent.number_of_agent = $numberOfAgents

$tempAgent.host = $agentAddresses[$agentCounter]

$userAgentArray += $tempAgent

$agentCounter++

}

set the base job agents to the new list

$baseJobJSON.user_agent = $userAgentArray

Database connection setup

$tempConnection = $connectionHash.Clone()

$tempConnection.name = “MSSQL_$($sqlServerAddresses[$i])_ODBC”

$tempConnection.datasourcename = “$($sqlServerAddresses[$i])_ODBC”

$baseJobJSON.connection = $tempConnection

$baseJobJSON.name = “TPC-C_BMF_JOB_$i”

submit the job

Invoke-RestMethod -Method Post -Uri “$restServer/jobs” -ContentType ‘application/json’ -Body ($baseJobJSON | ConvertTo-Json -Depth 12 -Compress)

}

Here’s the basejobJSON file:

    {
"classname": "CJob",
"name": "TPC-C Job 1",
"comment": "",
"connectionname": "MSSQL_10.108.3.176_ODBC",
"emailoperator": 0,
"operatoraddress": "",
"emailpager": 0,
"pageraddress": "",
"sendnet": 0,
"netsendname": "",
"realtimereportinterval": 5,
"realtimereportcounters": "",
"expanded": 1,
"stoponerror": 1,
"globalvariables": [
],
"tests": [
{
"classname": "CBenchmarkObjectsTest",
"benchmarkid": 10,
"create_objects": 1,
"always_delete_before_create": 0,
"benchmark_properties": {
"classname": "CBenchmarkProperties",
"benchmark_id": 10,
"string_attribute1": "",
"string_attribute2": "",
"string_attribute3": "",
"string_attribute4": "",
"int_attribute1": 0,
"int_attribute2": 0,
"int_attribute3": 0,
"int_attribute4": 0,
"scale": 1500.0,
"current_scale": 0.0,
"loaded_max_scale": 0.0,
"max_users": 5,
"datasetsize": "112.19",
"datasizetype": "GB",
"enable_partition": 1,
"create_use_backups": 0,
"default_scale": 1.0,
"enable_creationsql_mappings": 0,
"creationsql_mappings": [
],
"replication_options": {
"classname": "CRepBenchmarkProperties",
"table_number": 10,
"min_columnnumber": 10,
"max_columnnumber": 20,
"column_distribution": 2,
"columninfos": [
{
"classname": "ColumnInfo",
"weight": 1,
"isnull": 1,
"datatype": {
"classname": "CCharType",
"maxlength": 4000,
"length": 255,
"name": "VARCHAR2",
"size": 1,
"datatype": 2
}
},
{
"classname": "ColumnInfo",
"weight": 1,
"isnull": 1,
"datatype": {
"classname": "CNumberType",
"maxprecision": 0,
"minscale": 0,
"maxscale": 0,
"precision": 38,
"scale": 0,
"name": "INTEGER",
"size": 22,
"datatype": 3
}
},
{
"classname": "ColumnInfo",
"weight": 1,
"isnull": 1,
"datatype": {
"classname": "CNumberType",
"maxprecision": 126,
"minscale": 0,
"maxscale": 0,
"precision": 53,
"scale": 0,
"name": "FLOAT",
"size": 22,
"datatype": 5
}
},
{
"classname": "ColumnInfo",
"weight": 1,
"isnull": 1,
"datatype": {
"classname": "CNumberType",
"maxprecision": 38,
"minscale": -84,
"maxscale": 127,
"precision": 5,
"scale": 2,
"name": "NUMBER",
"size": 22,
"datatype": 4
}
},
{
"classname": "ColumnInfo",
"weight": 1,
"isnull": 1,
"datatype": {
"classname": "CDbType",
"name": "TIMESTAMP",
"size": 11,
"datatype": 7
}
}
]
},
"last_load_failed": 0,
"last_backup_option": 0
},
"run_on_agents": 1,
"virtualusers_for_table": 200,
"parallel_index_create": 1,
"delete_after_run": 0,
"reload_from_backup": 0,
"refresh_using_inserts": 0,
"name": "Create Objects for TPC-C",
"testid": -1,
"guid": "{728F120F-4F6D-4E94-879E-0E1C64E4FFEB}",
"options": 4096,
"enable_latency_scaling": 0,
"latency_scaling_factor": 1,
"commitnumber": 0,
"expanded": 1,
"instructions": [
],
"performcheckpoints": 0,
"performcheckpointsatstart": 0,
"numberofcheckpoints": 2,
"baselinerunid": -1,
"workloadid": -104,
"workloadinfor": {
"classname": "CTestOptionData"
},
"statisreportnames": "",
"resultlogname": ""
},
{
"classname": "CMixTest",
"name": "TPC-C Transaction Mix",
"testid": 2,
"guid": "{D48CB95A-8003-4339-8C91-4174ED5631FA}",
"options": 5120,
"enable_latency_scaling": 0,
"latency_scaling_factor": 1,
"commitnumber": 0,
"expanded": 1,
"instructions": [
{
"classname": "CXact",
"name": "New Order Transaction",
"guid": "{D9830886-7D17-479B-8FD9-5AF9CAA073F0}",
"testtypeid": -1,
"moduletypeid": -1,
"latency": {
"classname": "CLatency",
"think_time_enabled": 1,
"interarrival_rate_enabled": 0,
"keying_time_enabled": 1,
"think_time": {
"classname": "CLatencyModel",
"think_time_type": 4,
"absolute": 0,
"uniform_minimum": 0,
"uniform_maximum": 0,
"negative_exp_mean": 3000,
"normal_mean": 0,
"poisson_mean": 0
},
"keying_time": {
"classname": "CLatencyModel",
"think_time_type": 1,
"absolute": 4500,
"uniform_minimum": 0,
"uniform_maximum": 0,
"negative_exp_mean": 0,
"normal_mean": 0,
"poisson_mean": 0
},
"interarrival_time": {
"classname": "CLatencyModel",
"think_time_type": 1,
"absolute": 1000,
"uniform_minimum": 1000,
"uniform_maximum": 2000,
"negative_exp_mean": 2000,
"normal_mean": 2000,
"poisson_mean": 2000
}
},
"weight": 45,
"iterations": 1,
"xacts": [
],
"xacttype": 5,
"basexactresponsetime": 0.0,
"run_order": 0,
"userids": "",
"benchmarkid": 10,
"xid": 801,
"description": "",
"benchmark_properties": {
"classname": "CBenchmarkProperties",
"benchmark_id": 10,
"string_attribute1": "",
"string_attribute2": "",
"string_attribute3": "",
"string_attribute4": "",
"int_attribute1": 0,
"int_attribute2": 0,
"int_attribute3": 0,
"int_attribute4": 0,
"scale": 1500.0,
"current_scale": 0.0,
"loaded_max_scale": 0.0,
"max_users": 5,
"datasetsize": "112.19",
"datasizetype": "GB",
"enable_partition": 1,
"create_use_backups": 0,
"default_scale": 1.0,
"enable_creationsql_mappings": 0,
"creationsql_mappings": [
],
"replication_options": {
"classname": "CRepBenchmarkProperties",
"table_number": 10,
"min_columnnumber": 10,

#4

Hi jhieb,

in your powershell script you have this line

set the base job agents to the new list

$baseJobJSON.user_agent = $userAgentArray

if you comment this line then all agents configured in your json file will be set correctly. this is because the assign will change the element’s order in user_agent collections. the classname element should be the first element for a user agent, but when you assign a new collection, the order was changed. $userAgentArray is dictionary,


#5

Whoops posted some semi older code. UserAgentArray is a list of dictionaries. If the classname element has to be first why would it not fail when i use the REST route to add agents? I can give what you described a try I can comment out the user agent array but the issue i’d run into is I have to run this test in a validation environment. I build up multiple new agent machines (which is just a new IP address for a vmware agent image we spin up) for every product that we have to run through the validation automation. I can’t have a hard coded JSON for automating all my environment setup.

User agent array should just read as this: $userAgentArray = @()


#6

I have since moved to the below powershell code that works successfully for dynamically adding agents to a job and setting them as “checked” equals true so that the job launches correctly as it has enough agents for the user load (10 agents, 5 on each VM with a user load of 15000 for two seperate jobs executing at once). Just wondering if you guys have a bug in the job submission or if this is good enough for now. I have some issues with pulling results for multiple jobs that i’ll post in a separate discussion as it’s unrelated to this issue. Thanks for the quick responses.

param(
[Parameter(Mandatory=$true)]
[array]$agentAddresses,
[Parameter(Mandatory=$true)]
[array]$sqlServerAddresses,
[int]$numberOfAgents = 5,
[int]$jobsToRun = $sqlServerAddresses.count,
[int]$agentMachinesPerSQLServer = 2,
[string]$baseJobJSONPath = “\configs\benchmarkfactory\BMFJobJSON.json”,
[string]$restServer = 'http://localhost:30110/api’,
[bool]$deleteJobsConnections = $true
)

$ErrorActionPreference = ‘stop’

#Append the script path to the base json config path TODO figure out why it won’t take it as a param?
$baseJobJSONPath = $PSScriptRoot + $baseJobJSONPath

variable initialization

$agentCounter = 0

$agentHash = @{
classname= “CUserAgent”
host= “10.108.4.195”
username= “administrator”
password= “ssdrive01”
session_cred= 0
version= “”
os= “Microsoft Windows 10 Pro”
processor= “Intel® Xeon® CPU E5-2630 v3 @ 2.40GHz”
no_core= 0
no_cpus= 1
physical_memory= 12884430848.0
virtual_memory= 0.0
disk_size= 33494659072.0
disk_free_size= 5140746240.0
number_of_agent= 5
max_virtual_user= 0
checked= 1
flags= 0
address_width= 0
}

$connectionHash = @{
connectiontype= “SQLServerODBC”
name= “MSSQL_10.108.3.176_ODBC”
username= “sa”
password= “Ssdrive01”
datasourcename= “10.108.3.176_ODBC”
infinitetimeout= $false
timeout= 60
reconnectoption= @{
enabled= $false
numberofretry= 3
retryinterval= 10
}
customproperties= @()
serverproperties= @()
}

load the base REST request content for creating the job(s)

$baseJobJSON = get-content $baseJobJSONPath | convertfrom-json

check if the user DSNs exist

$DSNs = Get-OdbcDsn
foreach($sqlServerAddress in $sqlServerAddresses)
{
if(!($DSNs.name.contains("$($sqlServerAddress)_ODBC")))
{
Add-OdbcDsn -Name “$($sqlServerAddress)_ODBC” -DsnType User -DriverName ‘SQL Server’ -SetPropertyValue “Server=$sqlServerAddress”
Set-OdbcDsn -name “$($sqlServerAddress)_ODBC” -DsnType User -DriverName ‘SQL Server’ -SetPropertyValue ‘Database=BMF_1’
}
}

$existingConnections = Invoke-RestMethod -Method Get -Uri “$restServer/connections”

build the REST objects and add them to the job to configure it for the given database/agents

for($i =0;$i -lt $sqlServerAddresses.Count; $i++)
{

Database connection setup

$tempConnection = $connectionHash.Clone()
$tempConnection.name = “MSSQL_$($sqlServerAddresses[$i])_ODBC”
$tempConnection.datasourcename = “$($sqlServerAddresses[$i])ODBC"
$baseJobJSON.connection = $tempConnection
$baseJobJSON.name = "TPC-C_BMF_JOB
$i”

Try setting the agent log file names to empty??

$baseJobJSON.agentlogfilenames = “”
$baseJobJSON.user_agent = @()

submit the job

Invoke-RestMethod -Method Post -Uri “$restServer/jobs” -ContentType ‘application/json’ -Body ($baseJobJSON | ConvertTo-Json -Depth 12 -Compress)

Agents – Create the amount that is specified per SQL instance for the job – Use the agent PUT method instead for adding new agents

for($j=0;$j -lt $agentMachinesPerSQLServer; $j++)
{
$tempAgent = $agentHash.Clone()

$tempAgent.number_of_agent = $numberOfAgents
$tempAgent.host = $agentAddresses[$agentCounter]
Invoke-RestMethod -Method Post -Uri “$restServer/jobs/TPC-C_BMF_JOB_$i/agents” -Body ($tempAgent | ConvertTo-Json -Depth 12 -Compress)

increment the counter so we keep track of which agents we have used so far

$agentCounter++
}
}

start the tests

$jobUpdateHash = @{
status = 2
}

for($i =0;$i -lt $sqlServerAddresses.Count; $i++)
{
Invoke-RestMethod -Method Put -Uri “$restServer/jobs/TPC-C_BMF_JOB_$i” -Body ($jobUpdateHash | ConvertTo-Json -Depth 12 -Compress)
}

TODO need to link a job name(s) to run(s) in order to wait

TODO use the given job(s) to pull the summary data with the below route(s)

$testRunSummary = Invoke-RestMethod -Method Get -Uri “$restServer/testruns//UserloadResults”

TODO need to figure out how to pull the time series (transaction data?) for storage/reporting

delete the jobs off if we chose it

if($deleteJobsConnections)
{

delete each job

for($i=0; $i -lt $jobsToDelete; $i++)
{
Invoke-RestMethod -Method Delete -Uri “$restServer/jobs/TPC-C_BMF_JOB_$i”
}

delete each sql server connection

foreach($connection in $sqlServerAddresses)
{
Invoke-RestMethod -Method Delete -Uri “$restServer/connections/MSSQL_$($connection)_ODBC”
}
}


#7

It is an issue and will make changes in future release.