forked from bekimd-ms/AzureStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestloop.ps1
More file actions
78 lines (64 loc) · 2.06 KB
/
testloop.ps1
File metadata and controls
78 lines (64 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Param(
[string]$location = "",
[string]$dns = "",
[string]$sub = "",
[string]$user = "",
[string]$pwd = "",
[string]$maxvm=2,
[string]$vmcount=4,
[string]$vnet = "",
[string]$vnetrg = "",
[string]$sleeptime = 10
)
$commandprefix = "./tools/logindeployvm.ps1 -location " + $location + " -dns " + $dns + " -sub " + $sub + `
" -user " + $user + " -pwd " + $pwd + " -vnetrg " + $vnetrg + " -vnet " + $vnet
Write-Host "Command " $commandprefix
$chars = [char[]] ([char]'0'..[char]'9' + [char]'a'..[char]'z')
$chars = $chars * 3
$sizes = @("xxl") * 2
$sizes = $sizes + (@("xl") * 4 )
$sizes = $sizes + (@("l") * 8 )
$sizes = $sizes + (@("m") * 16 )
$sizes = $sizes + (@("s") * 32 )
$sizes = $sizes + (@("xs") * 38 )
$sizes = $sizes | sort {get-random }
function GetCommand( $size )
{
switch( $size )
{
"xxl" { "-vmsize Standard_D4 -disknum 4 -disksize 1023" }
"xl" { "-vmsize Standard_D3 -disknum 2 -disksize 1023" }
"l" { "-vmsize Standard_D2 -disknum 1 -disksize 1023" }
"m" { "-vmsize Standard_D1 -disknum 1 -disksize 511" }
"s" { "-vmsize Standard_D1 -disknum 1 -disksize 127" }
"xs" { "-vmsize Standard_D1 -disknum 0 -disksize 0" }
}
}
$nextvm = 0
$activevm = 0
while( $nextvm -lt $vmcount )
{
Write-Host "Active deployments ", $activevm
Write-Host "Next VM ", $nextvm
if( $activevm -lt $maxvm )
{
$size = $sizes[$nextvm]
$nextvm = $nextvm + 1
$rgname = " -rgname '" + $size + "vm" + (-join(Get-Random $chars -Count 8)) + "' "
$command = $commandprefix + $rgname + ( GetCommand $size )
Write-Host "Starting ", $size, ": ", $command
#$processes += @(Start-Process -PassThru PowerShell ./testcnt.ps1)
$processes += @(Start-Process -PassThru Powershell "$command")
}
$liveproc = 0
Write-Host "Checking processes..."
foreach( $process in $processes )
{
if( -not $process.HasExited )
{
$liveproc = $liveproc + 1
}
}
$activevm = $liveproc
start-sleep -s $sleeptime
}